Beispiel #1
0
        /// <summary>
        /// Setup:
        /// 1 - Upload config => [Head]->[Tail]
        /// 2 - Initialize Thread_1 with previous config which never expires (6000 sec.)
        /// 3 - Cut-off Tail and upload config => [Head]
        /// 4 - Initialize Thread_2 with new config which never expires (6000 sec.)
        /// </summary>
        void SetupStaleViewAndNewView(out ReplicatedTableConfigurationServiceV2 configServiceOne, out ReplicatedTableConfigurationServiceV2 configServiceTwo)
        {
            // Verify current View has 2 replicas ?
            View view = this.configurationWrapper.GetWriteView();

            Assert.IsTrue(view.Chain.Count == 2, "expects 2 replicas only!");

            int leaseDurationInSec = 6000;

            /*
             * 1 - Upload config [Head]->[Tail]
             */
            configServiceOne = new ReplicatedTableConfigurationServiceV2(this.configurationInfos, this.connectionStringMap, useHttps);
            UploadHeadTailView(view.Name, leaseDurationInSec, configServiceOne);

            /*
             * 2 - Cut-off the Tail, set a high LeaseDuration.
             *     The new config will be [Head]
             */
            configServiceTwo = new ReplicatedTableConfigurationServiceV2(this.configurationInfos, this.connectionStringMap, useHttps);
            CutOffTailInView(view.Name, leaseDurationInSec, configServiceTwo);

            /*
             * At this stage:
             *  - configServiceOne sees a stale View (LeaseDuration = 6000sec.)
             *  - configServiceTwo sees the latest View (LeaseDuration = 6000sec.)
             */
            long staleViewId  = configServiceOne.GetTableView(this.repTable.TableName).ViewId;
            long latestViewId = configServiceTwo.GetTableView(this.repTable.TableName).ViewId;

            Assert.AreNotEqual(staleViewId, latestViewId, "View should have changed !!!");
        }
        private void InsertHeadInView(string viewName, int leaseDuration, ReplicatedTableConfigurationServiceV2 configService)
        {
            // Download config using provided instance
            ReplicatedTableConfiguration    config;
            ReplicatedTableQuorumReadResult readStatus = configurationService.RetrieveConfiguration(out config);

            Assert.IsTrue(readStatus.Code == ReplicatedTableQuorumReadCode.Success);

            // Add the Head
            ReplicatedTableConfigurationStore viewConfg = config.GetView(viewName);

            viewConfg.ReplicaChain[0].Status = ReplicaStatus.WriteOnly;
            viewConfg.ViewId++;

            config.LeaseDuration = leaseDuration;

            // Upload config using provided instance
            configService.UpdateConfiguration(config);
        }
Beispiel #3
0
        private void EnableTailInView(string viewName, int leaseDuration, ReplicatedTableConfigurationServiceV2 configService)
        {
            // Download config using provided instance
            ReplicatedTableConfiguration    config;
            ReplicatedTableQuorumReadResult readStatus = configurationService.RetrieveConfiguration(out config);

            Assert.IsTrue(readStatus.Code == ReplicatedTableQuorumReadCode.Success);

            // Enable the Tail
            ReplicatedTableConfigurationStore viewConfg = config.GetView(viewName);

            Assert.IsTrue(viewConfg.ReplicaChain.Count == 2);
            Assert.IsTrue(viewConfg.ReadViewTailIndex == 0);

            viewConfg.ReplicaChain[1].Status = ReplicaStatus.ReadWrite;
            viewConfg.ViewId++;

            config.LeaseDuration = leaseDuration;

            // Upload config using provided instance
            configService.UpdateConfiguration(config);
        }
Beispiel #4
0
        private void UploadHeadTailView(string viewName, int leaseDuration, ReplicatedTableConfigurationServiceV2 configService)
        {
            // Download config using provided instance
            ReplicatedTableConfiguration    config;
            ReplicatedTableQuorumReadResult readStatus = configService.RetrieveConfiguration(out config);

            Assert.IsTrue(readStatus.Code == ReplicatedTableQuorumReadCode.Success);

            // [Head] -> [Tail]
            ReplicatedTableConfigurationStore viewConfg = config.GetView(viewName);

            Assert.IsTrue(viewConfg.GetCurrentReplicaChain().Count == 2);

            // Force Reads on Head replica
            viewConfg.ReadViewTailIndex = 0;
            viewConfg.ViewId++;

            config.LeaseDuration = leaseDuration;

            // Upload config using provided instance
            configService.UpdateConfiguration(config);
        }