Пример #1
0
        public IComputeNode GetComputeNode()
        {
            IComputeNode compute_node = null;

            try
            {
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageAccount.ConnectionString"));
                CloudBlobClient     blobClient     = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer  container      = blobClient.GetContainerReference(AzureContainer);
                container.CreateIfNotExist();
                CloudBlob blob = container.GetBlobReference(BermudaConfig);
                string    data = blob.DownloadText();

                //deserialize
                compute_node = new ComputeNode().DeserializeComputeNode(data);
                if (compute_node.Catalogs.Values.Cast <ICatalog>().FirstOrDefault().CatalogMetadata.Tables.FirstOrDefault().Value.DataType == null)
                {
                    compute_node.Catalogs.Values.Cast <ICatalog>().FirstOrDefault().CatalogMetadata.Tables.FirstOrDefault().Value.DataType = typeof(UDPTestDataItems);
                }
                compute_node.Init(CurrentInstanceIndex, AllNodeEndpoints.Count());
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            return(compute_node);
        }
        public IComputeNode GetComputeNode()
        {
            IComputeNode compute_node = null;

            try
            {
                //amazon client
                using (var client = new AmazonS3Client())
                {
                    //download request
                    using (var response = client.GetObject(new GetObjectRequest()
                                                           .WithBucketName(AmazonBucket)
                                                           .WithKey(BermudaConfig)))
                    {
                        using (StreamReader reader = new StreamReader(response.ResponseStream))
                        {
                            //read the file
                            string data = reader.ReadToEnd();

                            //deserialize
                            compute_node = new ComputeNode().DeserializeComputeNode(data);
                            compute_node.Init(CurrentInstanceIndex, AllNodeEndpoints.Count());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            return(compute_node);
        }
        public IComputeNode GetComputeNode()
        {
            IComputeNode compute_node = null;

            try
            {
                //amazon client
                using (var client = new AmazonS3Client())
                {
                    //download request
                    using (var response = client.GetObject(new GetObjectRequest()
                                                           .WithBucketName(AmazonBucket)
                                                           .WithKey(BermudaConfig)))
                    {
                        using (StreamReader reader = new StreamReader(response.ResponseStream))
                        {
                            //read the file
                            string data = reader.ReadToEnd();

                            //deserialize
                            compute_node = new ComputeNode().DeserializeComputeNode(data);
                            if (compute_node.Catalogs.Values.Cast <ICatalog>().FirstOrDefault().CatalogMetadata.Tables.FirstOrDefault().Value.DataType == null)
                            {
                                compute_node.Catalogs.Values.Cast <ICatalog>().FirstOrDefault().CatalogMetadata.Tables.FirstOrDefault().Value.DataType = typeof(UDPTestDataItems);
                            }
                            compute_node.Init(CurrentInstanceIndex, AllNodeEndpoints.Count());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            return(compute_node);
        }