private void CollectStatusForServer(string serverName, TimeSpan waitDuration)
        {
            InstanceStatusInfo statusInfo = null;
            Exception          ex         = null;
            string             label      = string.Format("GetStatus({0})", serverName);

            if (!this.groupConfig.Settings.IsUseHttpTransportForInstanceCommunication)
            {
                ex = Utils.RunOperation(this.groupConfig.Identity, label, delegate
                {
                    DxStoreInstanceClient client = this.instanceClientFactory.GetClient(serverName);
                    statusInfo = client.GetStatus(null);
                }, this.EventLogger, LogOptions.LogException | this.groupConfig.Settings.AdditionalLogOptions, true, null, new TimeSpan?(this.groupConfig.Settings.PeriodicExceptionLoggingDuration), null, null, null);
            }
            else
            {
                try
                {
                    string memberNetworkAddress           = this.groupConfig.GetMemberNetworkAddress(serverName);
                    Task <InstanceStatusInfo> statusAsync = HttpClient.GetStatusAsync(memberNetworkAddress, serverName, this.groupConfig.Name, this.self);
                    statusAsync.Wait(waitDuration);
                    statusInfo = statusAsync.Result;
                }
                catch (Exception ex2)
                {
                    ex = ex2;
                    this.EventLogger.Log(DxEventSeverity.Error, 0, "http send for GetStatusAsync failed: {0}", new object[]
                    {
                        ex2.ToString()
                    });
                }
            }
            this.UpdateStatus(serverName, statusInfo, ex);
        }
        // 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));
        }
        // 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);
            }
        }
Esempio n. 4
0
        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);
                }
            }
        }
Esempio n. 5
0
        private void NotifyInitiator(int instanceNumber, DxStoreCommand command, Exception exception)
        {
            DxStoreInstanceClient client = this.instance.InstanceClientFactory.GetClient(command.Initiator);

            client.NotifyInitiator(command.CommandId, this.self, instanceNumber, exception == null, (exception != null) ? exception.Message : "<none>", null);
        }