Exemple #1
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));
            }
        }
 public ReplicatedTableConfigurationWrapper(ReplicatedTableConfigurationService service)
 {
     this._service = service;
 }
 public ReplicatedTableConfigurationWrapper(ReplicatedTableConfigurationService service)
 {
     this._service = service;
 }