Exemplo n.º 1
0
        private void InitialSetup(string tableName, bool useHttps, int viewId, bool convertXStoreTableMode, int numberOfBlobs)
        {
            this.configurationInfos = this.GetRTableConfigurationLocationInfo(numberOfBlobs);

            this.configurationService = new ReplicatedTableConfigurationServiceV2(this.configurationInfos, this.connectionStringMap, useHttps);

            this.UploadRTableConfigToBlob(viewId, convertXStoreTableMode, numberOfBlobs);

            this.configurationWrapper = new ReplicatedTableConfigurationV2Wrapper(tableName, this.configurationService);
            this.configurationWrapper.SetLockTimeout(TimeSpan.FromSeconds(TestLockTimeoutInSeconds));
        }
Exemplo n.º 2
0
 public IChainTable GetChainTable(string tableId)
 {
     if (tableId.StartsWith("__RTable_"))
     {
         var name = tableId.Substring(9);
         ReplicatedTableConfigurationService rtableConfig = new ReplicatedTableConfigurationService(rTabConfLocs, true);
         ReplicatedTable rTable = new ReplicatedTable(name, rtableConfig);
         return(new RTableAdapter(rTable));
     }
     else
     {
         return(new ATableAdapter(client.GetTableReference(tableId)));
     }
 }
Exemplo n.º 3
0
        public DefaultChainTableService(string configFile)
        {
            this.configFileName = configFile;
            StreamReader fs   = System.IO.File.OpenText(configFileName);
            string       line = fs.ReadLine();

            rTabConfLocs  = new List <ConfigurationStoreLocationInfo>();
            rTabDataChain = new List <ReplicaInfo>();

            bool first = true;

            while (!fs.EndOfStream)
            {
                line = fs.ReadLine();
                string[] tokens      = line.Split();
                string   accountName = tokens[0];
                string   accountKey  = tokens[1];

                string connStr = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", accountName, accountKey);
                if (first)
                {
                    first  = false;
                    csa    = CloudStorageAccount.Parse(connStr);
                    client = csa.CreateCloudTableClient();
                    rTabConfLocs.Add(new ConfigurationStoreLocationInfo()
                    {
                        StorageAccountName = accountName,
                        StorageAccountKey  = accountKey,
                        BlobPath           = Constants.RTableConfigurationBlobLocationContainerName + "/myRTableConfig1"
                    });
                }

                rTabDataChain.Add(new ReplicaInfo()
                {
                    StorageAccountName = accountName,
                    StorageAccountKey  = accountKey
                });
            }

            ReplicatedTableConfigurationService rtableConfig = new ReplicatedTableConfigurationService(rTabConfLocs, true);

            rtableConfig.UpdateConfiguration(rTabDataChain, 0);

            fs.Close();
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            ConfigurationAgentArguments parsedArguments = new ConfigurationAgentArguments();

            List <ConfigurationStoreLocationInfo> configLocationInfo = new List <ConfigurationStoreLocationInfo>();
            List <ReplicaInfo> replicaChain = new List <ReplicaInfo>();
            Dictionary <string, SecureString> connectionStringMap = new Dictionary <string, SecureString>();

            if (Parser.ParseArgumentsWithUsage(args, parsedArguments))
            {
                Console.WriteLine("The storage accounts for configuration store are:");

                for (int i = 0; i < parsedArguments.configStoreAccountName.Length; i++)
                {
                    Console.WriteLine("Account Name: {0}, Account Key: {1}", parsedArguments.configStoreAccountName[i], parsedArguments.configStoreAccountKey[i]);
                    configLocationInfo.Add(new ConfigurationStoreLocationInfo()
                    {
                        StorageAccountName = parsedArguments.configStoreAccountName[i],
                        StorageAccountKey  = parsedArguments.configStoreAccountKey[i],
                        BlobPath           = Constants.RTableConfigurationBlobLocationContainerName + "/" + parsedArguments.configLocation
                    });
                }

                Console.WriteLine("The Replica Chain is:");
                for (int i = 0; i < parsedArguments.replicaChainAccountName.Length; i++)
                {
                    if (i != parsedArguments.replicaChainAccountName.Length - 1)
                    {
                        Console.Write("{0} -> ", parsedArguments.replicaChainAccountName[i]);
                    }
                    else
                    {
                        Console.WriteLine("{0}", parsedArguments.replicaChainAccountName[i]);
                    }

                    replicaChain.Add(new ReplicaInfo()
                    {
                        StorageAccountName = parsedArguments.replicaChainAccountName[i]
                    });

                    // connection strings (use short format)
                    string connectionString = string.Format(Constants.ShortConnectioStringTemplate,
                                                            "http",
                                                            parsedArguments.replicaChainAccountName[i],
                                                            parsedArguments.replicaChainAccountKey[i]);

                    connectionStringMap.Add(
                        parsedArguments.replicaChainAccountName[i],
                        SecureStringHelper.ToSecureString(connectionString));
                }

                Console.WriteLine("The head index in read view is : {0}", parsedArguments.readViewHeadIndex);

                if (parsedArguments.readViewHeadIndex == 0)
                {
                    Console.WriteLine("The read and write views are identical.");
                }
                else
                {
                    Console.WriteLine("The read and write views are different.");
                }
            }

            Console.WriteLine("Updating the configuration store...");

            ReplicatedTableConfigurationService agent = new ReplicatedTableConfigurationService(configLocationInfo, connectionStringMap, false);

            agent.UpdateConfiguration(replicaChain, parsedArguments.readViewHeadIndex, parsedArguments.convertXStoreTableMode);

            Console.WriteLine("Done updating the configuration store");

            Console.WriteLine("New Read View is:");
            View readView = agent.GetReadView();

            for (int i = 0; i < readView.Chain.Count; i++)
            {
                Console.WriteLine("{0} -> ", readView.GetReplicaInfo(i));
            }

            Console.WriteLine("New Write View is:");
            View writeView = agent.GetWriteView();

            for (int i = 0; i < writeView.Chain.Count; i++)
            {
                Console.Write("{0} -> ", writeView.GetReplicaInfo(i));
            }
        }
Exemplo n.º 5
0
 public DefaultChainTableService(ReplicatedTableConfigurationService rtableConfigV2)
 {
     this.rtableConfigV2 = rtableConfigV2;
 }