Beispiel #1
0
        /// <summary>
        /// Helper function to return the RTableConfig
        /// Note that even if 3 (say) accounts are specified in the xml,
        /// the test codes can specify that only accounts #0 and #2 are used to construct the RTable.
        /// </summary>
        /// <param name="viewId"></param>
        /// <param name="convertXStoreTableMode"></param>
        /// <param name="readViewHeadIndex"></param>
        /// <returns></returns>
        private ReplicatedTableConfiguration GetRTableConfiguration(long viewId, bool convertXStoreTableMode, int readViewHeadIndex = 0)
        {
            if (viewId <= 0)
            {
                throw new Exception(string.Format("GetRTableConfigText() was called with invalid viewId {0}", viewId));
            }

            // 1 - Create a default view
            var viewConfig = new ReplicatedTableConfigurationStore
            {
                ViewId            = viewId,
                ReadViewHeadIndex = readViewHeadIndex,
            };

            int numberOfStorageAccounts = this.rtableTestConfiguration.StorageInformation.AccountNames.Count();

            for (int i = 0; i < this.actualStorageAccountsUsed.Count; i++)
            {
                int index = this.actualStorageAccountsUsed[i];
                if (index < 0 || index > numberOfStorageAccounts)
                {
                    throw new Exception(string.Format("this.actualStorageAccountsUsed[{0}] = {1} is out of range.", i, index));
                }

                ReplicaInfo replica = new ReplicaInfo
                {
                    StorageAccountName = this.rtableTestConfiguration.StorageInformation.AccountNames[index],
                    Status             = ReplicaStatus.ReadWrite,
                };

                if (readViewHeadIndex != 0 && i < readViewHeadIndex)
                {
                    replica.Status = ReplicaStatus.WriteOnly;
                }

                viewConfig.ReplicaChain.Add(replica);
            }

            // 2 - Create a default table config. that references the "DefaultView"
            var tableConfig = new ReplicatedTableConfiguredTable
            {
                TableName       = DefaultTableConfigName,
                ViewName        = DefaultViewName,
                ConvertToRTable = convertXStoreTableMode,
                UseAsDefault    = true,
            };

            // 3 - Create the final RTable configuration
            ReplicatedTableConfiguration configuration = new ReplicatedTableConfiguration();

            configuration.SetView(DefaultViewName, viewConfig);
            configuration.SetTable(tableConfig);

            return(configuration);
        }
Beispiel #2
0
        protected void UpdateConfiguration(List <ReplicaInfo> replicaChain, int readViewHeadIndex, bool convertXStoreTableMode = false, long viewId = 0)
        {
            for (int i = 0; i < replicaChain.Count; i++)
            {
                replicaChain[i].Status = ReplicaStatus.ReadWrite;

                if (readViewHeadIndex != 0 && i < readViewHeadIndex)
                {
                    replicaChain[i].Status = ReplicaStatus.WriteOnly;
                }
            }

            // - view config
            var viewConfig = new ReplicatedTableConfigurationStore
            {
                ViewId            = viewId,
                ReadViewHeadIndex = readViewHeadIndex,
                ReplicaChain      = replicaChain,
            };

            // - table config
            var tableConfig = new ReplicatedTableConfiguredTable
            {
                TableName       = DefaultTableConfigName,
                ViewName        = DefaultViewName,
                ConvertToRTable = convertXStoreTableMode,
                UseAsDefault    = true,
            };

            // - Update RTable configuration
            ReplicatedTableConfiguration configuration = new ReplicatedTableConfiguration();

            configuration.SetView(DefaultViewName, viewConfig);
            configuration.SetTable(tableConfig);

            this.configurationService.UpdateConfiguration(configuration, false);
        }