Example #1
0
        public InstanceSnapshotInfo GetSnapshot(string keyName = null, bool isCompress = true)
        {
            keyName = this.NormalizeKeyName(keyName);
            ExTraceGlobals.StoreReadTracer.TraceDebug <string, string, bool>((long)this.identityHash, "{0}: Entering GetSnapshot - Key: {1} IsCompress: {2}", this.identity, keyName, isCompress);
            InstanceSnapshotInfo instanceSnapshotInfo = new InstanceSnapshotInfo
            {
                FullKeyName        = keyName,
                RetrievalStartTime = DateTimeOffset.Now
            };
            int      num;
            XElement xelementSnapshot = this.GetXElementSnapshot(keyName, out num);

            if (xelementSnapshot == null)
            {
                throw new DxStoreInstanceKeyNotFoundException(keyName);
            }
            instanceSnapshotInfo.Snapshot = xelementSnapshot.ToString();
            if (isCompress)
            {
                instanceSnapshotInfo.Compress();
            }
            instanceSnapshotInfo.LastInstanceExecuted = num;
            instanceSnapshotInfo.RetrievalFinishTime  = DateTimeOffset.Now;
            ExTraceGlobals.StoreReadTracer.TraceDebug <string, int, int>((long)this.identityHash, "{0}: [1] Exiting GetSnapshot (Length: {2})", this.identity, num, instanceSnapshotInfo.Snapshot.Length);
            return(instanceSnapshotInfo);
        }
        // Token: 0x06000EB3 RID: 3763 RVA: 0x0003ECF8 File Offset: 0x0003CEF8
        public XElement GetDxStoreSnapshot()
        {
            DxStoreInstanceClient localClient          = this.ClientFactory.LocalClient;
            InstanceSnapshotInfo  instanceSnapshotInfo = localClient.AcquireSnapshot("Public", true, null);

            instanceSnapshotInfo.Decompress();
            return(XElement.Parse(instanceSnapshotInfo.Snapshot));
        }
 public void ApplySnapshot(InstanceSnapshotInfo snapshotInfo, bool isTakeSnapshot = true)
 {
     lock (this.locker)
     {
         this.instance.LocalDataStore.ApplySnapshot(snapshotInfo, null);
         if (isTakeSnapshot)
         {
             this.SaveSnapshot(true);
         }
     }
 }
        public InstanceSnapshotInfo AcquireSnapshot(string fullKeyName, bool isCompress)
        {
            this.EnsureInstanceIsReady();
            bool isStale = !this.HealthChecker.IsStoreReady();
            InstanceSnapshotInfo snapshot = this.LocalDataStore.GetSnapshot(fullKeyName, isCompress);

            if (snapshot != null)
            {
                snapshot.IsStale = isStale;
            }
            return(snapshot);
        }
        // Token: 0x06000EB7 RID: 3767 RVA: 0x0003F048 File Offset: 0x0003D248
        public void CopyClusdbSnapshotToDxStore()
        {
            InstanceSnapshotInfo instanceSnapshotInfo = new InstanceSnapshotInfo();

            instanceSnapshotInfo.FullKeyName = "Public";
            instanceSnapshotInfo.Snapshot    = this.ClusdbSnapshot.ToString();
            instanceSnapshotInfo.Compress();
            using (InstanceClientFactory defaultGroupInstanceClientFactory = this.GetDefaultGroupInstanceClientFactory())
            {
                DxStoreInstanceClient localClient = defaultGroupInstanceClientFactory.LocalClient;
                localClient.ApplySnapshot(instanceSnapshotInfo, false, null);
            }
        }
Example #6
0
        public void ApplySnapshot(InstanceSnapshotInfo snapshotInfo, int?instanceNumber)
        {
            if (snapshotInfo == null || string.IsNullOrEmpty(snapshotInfo.Snapshot))
            {
                ExTraceGlobals.StoreWriteTracer.TraceError <string, int>((long)this.identityHash, "{0}: [1] ApplySnapshot ignored since snapshot info is not valid", this.identity, instanceNumber ?? -1);
                return;
            }
            snapshotInfo.Decompress();
            XElement rootElement = XElement.Parse(snapshotInfo.Snapshot);
            int      num         = (instanceNumber != null) ? instanceNumber.Value : snapshotInfo.LastInstanceExecuted;

            this.ApplySnapshotFromXElement(snapshotInfo.FullKeyName, num, rootElement);
            ExTraceGlobals.StoreWriteTracer.TraceDebug <string, int>((long)this.identityHash, "{0}: [1] Exiting ApplySnapshot", this.identity, num);
        }
 public void ApplySnapshot(InstanceSnapshotInfo snapshot, bool isForce = false)
 {
     this.EventLogger.Log(isForce ? DxEventSeverity.Warning : DxEventSeverity.Info, 0, "{0}: Applying snapshot (isForce={1})", new object[]
     {
         this.Identity,
         isForce
     });
     if (isForce)
     {
         this.LocalDataStore.ApplySnapshot(snapshot, null);
         return;
     }
     this.EnsureInstanceIsReady();
     snapshot.Compress();
     DxStoreCommand.ApplySnapshot command = new DxStoreCommand.ApplySnapshot
     {
         SnapshotInfo = snapshot
     };
     this.StateMachine.ReplicateCommand(command, null);
 }
        private void WhenHealthCheckerSeeMajorityOfNodes(GroupStatusInfo gsi)
        {
            if (this.IsStartupCompleted)
            {
                return;
            }
            bool flag = false;

            try
            {
                object obj;
                Monitor.Enter(obj = this.instanceLock, ref flag);
                bool isWaitForNextRound = false;
                bool flag2 = gsi.Lag > this.GroupConfig.Settings.MaxAllowedLagToCatchup;
                DxStoreInstance.Tracer.TraceDebug((long)this.IdentityHash, "{0}: Instance start - Majority replied (LocalInstance# {1}, Lag: {2}, CatchupLimit: {3}", new object[]
                {
                    this.Identity,
                    (gsi.LocalInstance != null) ? gsi.LocalInstance.InstanceNumber : -1,
                    gsi.Lag,
                    this.GroupConfig.Settings.MaxAllowedLagToCatchup
                });
                if (flag2)
                {
                    isWaitForNextRound = true;
                }
                DxStoreInstanceClient client       = this.InstanceClientFactory.GetClient(gsi.HighestInstance.NodeName);
                InstanceSnapshotInfo  snapshotInfo = null;
                this.RunBestEffortOperation("GetSnapshot :" + gsi.HighestInstance.NodeName, delegate
                {
                    snapshotInfo = client.AcquireSnapshot(null, true, null);
                }, LogOptions.LogAll, null, null, null, null);
                if (snapshotInfo != null && snapshotInfo.LastInstanceExecuted > gsi.LocalInstance.InstanceNumber)
                {
                    this.RunBestEffortOperation("Apply local snapshot", delegate
                    {
                        this.SnapshotManager.ApplySnapshot(snapshotInfo, true);
                        isWaitForNextRound = false;
                    }, LogOptions.LogAll, null, null, null, null);
                }
                if (!isWaitForNextRound)
                {
                    this.majorityNotificationSubscription.Dispose();
                    this.majorityNotificationSubscription = null;
                    this.HealthChecker.ChangeTimerDuration(this.GroupConfig.Settings.GroupHealthCheckDuration);
                    Round <string>?leaderHint = null;
                    if (gsi.IsLeaderExist)
                    {
                        leaderHint = new Round <string>?(gsi.LeaderHint);
                    }
                    this.StateMachine = this.CreateStateMachine(leaderHint, null);
                    Task task = this.StartStateMachine();
                    task.ContinueWith(delegate(Task t)
                    {
                        this.EventLogger.Log(DxEventSeverity.Info, 0, "Successfully started state machine", new object[0]);
                        this.SnapshotManager.Start();
                        this.State = InstanceState.Running;
                        this.IsStartupCompleted = true;
                    });
                }
                else
                {
                    DxStoreInstance.Tracer.TraceWarning <string>((long)this.IdentityHash, "{0}: Instance start - waiting for the next round to start local instance", this.Identity);
                }
            }
            finally
            {
                if (flag)
                {
                    object obj;
                    Monitor.Exit(obj);
                }
            }
        }