Ejemplo n.º 1
0
        /// <summary>
        /// Create the contents of the RTable configuration, and upload it to the appropriate container and blob.
        /// </summary>
        private void UploadRTableConfigToBlob(int viewId, bool convertXStoreTableMode, int numberOfBlobs)
        {
            string blobName = this.configurationInfos.FirstOrDefault().BlobPath;
            int    index    = blobName.IndexOf("/");

            blobName = blobName.Substring(index + 1); // +1 to acording for "/"

            Console.WriteLine("Uploading RTable config ...");

            for (int blobIndex = 0; blobIndex < numberOfBlobs; blobIndex++)
            {
                string          connectionString;
                CloudBlobClient cloudBloblClient = this.GenerateCloudBlobClient(
                    this.rtableTestConfiguration.StorageInformation.AccountNames[blobIndex],
                    this.rtableTestConfiguration.StorageInformation.AccountKeys[blobIndex],
                    this.rtableTestConfiguration.StorageInformation.DomainName,
                    out connectionString);

                CloudBlobContainer container = cloudBloblClient.GetContainerReference(this.rtableTestConfiguration.RTableInformation.ContainerName);
                container.CreateIfNotExists();

                CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);

                ReplicatedTableConfigurationStore configuration = this.GetRTableConfiguration(viewId, convertXStoreTableMode);

                string jsonConfigText = JsonStore <ReplicatedTableConfigurationStore> .Serialize(configuration);

                blockBlob.UploadText(jsonConfigText);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Modify the contents of the RTable configuration blob to use the updated viewId
        /// </summary>
        /// <param name="updatedViewId"></param>
        /// <param name="convertXStoreTableMode"></param>
        /// <param name="readViewHeadIndex"></param>
        private void ModifyConfigurationBlob(long updatedViewId, bool convertXStoreTableMode, int readViewHeadIndex, List <int> blobIndexes)
        {
            try
            {
                foreach (var blobIndex in blobIndexes)
                {
                    Console.WriteLine("ModifyConfigurationBlob#{0} ...", blobIndex);

                    string blobName = this.configurationInfos[blobIndex].BlobPath;
                    int    index    = blobName.IndexOf("/");
                    blobName = blobName.Substring(index + 1); // +1 to acording for "/"

                    Console.WriteLine("Configuration blobname = {0}", blobName);

                    string          connectionString;
                    CloudBlobClient cloudBloblClient = this.GenerateCloudBlobClient(
                        this.rtableTestConfiguration.StorageInformation.AccountNames[blobIndex],
                        this.rtableTestConfiguration.StorageInformation.AccountKeys[blobIndex],
                        this.rtableTestConfiguration.StorageInformation.DomainName,
                        out connectionString);

                    CloudBlobContainer container =
                        cloudBloblClient.GetContainerReference(
                            this.rtableTestConfiguration.RTableInformation.ContainerName);
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);

                    string currentConfigText = blockBlob.DownloadText();
                    Console.WriteLine("currentConfigText = {0}", currentConfigText);

                    ReplicatedTableConfigurationStore configuration = this.GetRTableConfiguration(updatedViewId,
                                                                                                  convertXStoreTableMode, readViewHeadIndex);

                    string updatedConfigText = JsonStore <ReplicatedTableConfigurationStore> .Serialize(configuration);

                    Console.WriteLine("updatedConfigText = {0}", updatedConfigText);

                    blockBlob.UploadText(updatedConfigText);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ModifyConfigurationBlob() encountered exception {0}", ex.ToString());
                throw;
            }
        }