Пример #1
0
        public static bool RemoveGroupStorage(IDxStoreEventLogger eventLogger, InstanceGroupConfig group)
        {
            bool flag;

            if (Directory.Exists(group.Settings.PaxosStorageDir))
            {
                flag = (Utils.RunOperation(group.Identity, "Removing Paxos directory", delegate
                {
                    Directory.Delete(group.Settings.PaxosStorageDir, true);
                }, eventLogger, LogOptions.LogException | LogOptions.LogStart | LogOptions.LogSuccess | LogOptions.LogPeriodic | group.Settings.AdditionalLogOptions, true, null, null, null, null, null) == null);
            }
            else
            {
                flag = true;
            }
            bool flag2;

            if (Directory.Exists(group.Settings.SnapshotStorageDir))
            {
                flag2 = (Utils.RunOperation(group.Identity, "Removing Snapshot directory", delegate
                {
                    Directory.Delete(group.Settings.SnapshotStorageDir, true);
                }, eventLogger, LogOptions.LogException | LogOptions.LogStart | LogOptions.LogSuccess | LogOptions.LogPeriodic | group.Settings.AdditionalLogOptions, true, null, null, null, null, null) == null);
            }
            else
            {
                flag2 = true;
            }
            return(flag && flag2);
        }
Пример #2
0
 public void RemoveGroupConfig(InstanceGroupConfig group)
 {
     this.EventLogger.Log(DxEventSeverity.Info, 0, "{0}: Removing group configuration", new object[]
     {
         group.Name
     });
     this.ConfigProvider.RemoveGroupConfig(group.Name);
 }
Пример #3
0
 public void RestartInstance(string groupName, bool isForce)
 {
     lock (this.locker)
     {
         InstanceGroupConfig groupConfig = this.ConfigProvider.GetGroupConfig(groupName, false);
         this.RestartInstanceInternal(groupConfig, isForce);
     }
 }
Пример #4
0
        public void Analyze(string self, InstanceGroupConfig groupConfig)
        {
            if (this.isAnalyzed)
            {
                return;
            }
            int num = this.TotalRequested / 2 + 1;

            this.IsMajoritySuccessfulyReplied = (this.TotalSuccessful >= num);
            IEnumerable <InstanceStatusInfo> source = from v in this.StatusMap.Values
                                                      where v != null
                                                      select v;
            IEnumerable <GroupStatusInfo.NodeInstancePair> enumerable = from s in source
                                                                        orderby s.LastInstanceExecuted descending
                                                                        select new GroupStatusInfo.NodeInstancePair
            {
                NodeName       = s.Self,
                InstanceNumber = s.LastInstanceExecuted
            };

            foreach (GroupStatusInfo.NodeInstancePair nodeInstancePair in enumerable)
            {
                if (this.HighestInstance == null)
                {
                    this.HighestInstance = nodeInstancePair;
                }
                if (Utils.IsEqual(nodeInstancePair.NodeName, self, StringComparison.OrdinalIgnoreCase))
                {
                    this.LocalInstance = nodeInstancePair;
                    break;
                }
            }
            PaxosBasicInfo[] array = (from s in source
                                      where s.PaxosInfo != null
                                      select s.PaxosInfo).ToArray <PaxosBasicInfo>();
            this.IsMajorityHavePaxosInitialized = (array.Length >= num);
            IEnumerable <Round <string> > source2 = from p in array
                                                    where !string.IsNullOrEmpty(p.LeaderHint.replica)
                                                    select p.LeaderHint;
            IOrderedEnumerable <IGrouping <string, Round <string> > > source3 = from s in source2
                                                                                group s by s.replica into g
                                                                                orderby g.Count <Round <string> >() descending
                                                                                select g;

            this.IsMajorityAgreeWithLeader = false;
            IGrouping <string, Round <string> > grouping = source3.FirstOrDefault <IGrouping <string, Round <string> > >();

            if (grouping != null)
            {
                this.LeaderHint = grouping.FirstOrDefault <Round <string> >();
                int num2 = grouping.Count <Round <string> >();
                if (num2 >= num)
                {
                    this.IsMajorityAgreeWithLeader = true;
                }
            }
            this.isAnalyzed = true;
        }
Пример #5
0
 public DxStoreInstance(InstanceGroupConfig groupConfig, IDxStoreEventLogger eventLogger)
 {
     this.Identity           = groupConfig.Identity;
     this.IdentityHash       = groupConfig.Identity.GetHashCode();
     this.EventLogger        = eventLogger;
     this.GroupConfig        = groupConfig;
     this.LocalProcessInfo   = new ProcessBasicInfo(true);
     this.StopEvent          = new ManualResetEvent(false);
     this.StopCompletedEvent = new ManualResetEvent(false);
     this.State = InstanceState.Initialized;
 }
        // Token: 0x06000EB2 RID: 3762 RVA: 0x0003ECC4 File Offset: 0x0003CEC4
        public InstanceClientFactory GetDefaultGroupInstanceClientFactory()
        {
            DistributedStoreEventLogger      eventLogger = new DistributedStoreEventLogger(false);
            DistributedStoreTopologyProvider distributedStoreTopologyProvider = new DistributedStoreTopologyProvider(eventLogger, null, false);
            InstanceGroupConfig groupConfig = distributedStoreTopologyProvider.GetGroupConfig(null, true);

            if (groupConfig != null)
            {
                return(new InstanceClientFactory(groupConfig, null));
            }
            return(null);
        }
Пример #7
0
 public void StartInstance(string groupName, bool isForce)
 {
     lock (this.locker)
     {
         if (this.GetInstanceContainer(groupName) == null)
         {
             InstanceGroupConfig groupConfig = this.ConfigProvider.GetGroupConfig(groupName, false);
             if (groupConfig == null)
             {
                 throw new DxStoreManagerGroupNotFoundException(groupName);
             }
             this.StartInstanceInternal(groupConfig, isForce);
         }
     }
 }
Пример #8
0
        public bool CheckStartProcessLimits(InstanceGroupConfig group, bool isForce)
        {
            DateTimeOffset now = DateTimeOffset.Now;

            DxStoreManager.InstanceStartStats instanceStartStats;
            if (!this.instanceStartMap.TryGetValue(group.Identity, out instanceStartStats))
            {
                instanceStartStats = new DxStoreManager.InstanceStartStats();
                this.ResetStartProcessLimit(instanceStartStats, now);
                this.instanceStartMap[group.Identity] = instanceStartStats;
            }
            else
            {
                TimeSpan t  = now - instanceStartStats.FirstStartRequestedTime;
                TimeSpan t2 = now - instanceStartStats.LastStartRequestedTime;
                if (t2 < group.Settings.InstanceStartSilenceDuration)
                {
                    if (instanceStartStats.TotalStartRequestsFromFirstReported > group.Settings.InstanceStartHoldupDurationMaxAllowedStarts)
                    {
                        if (t < group.Settings.InstanceStartHoldUpDuration)
                        {
                            this.EventLogger.LogPeriodic(group.Identity, TimeSpan.FromMinutes(10.0), DxEventSeverity.Warning, 0, "Instance start request exceeded maximum allowed ({3}). (FirstStartTime: {0}, LastStartTime: {1}, TotalRequests: {2}", new object[]
                            {
                                instanceStartStats.FirstStartRequestedTime,
                                instanceStartStats.LastStartRequestedTime,
                                instanceStartStats.TotalStartRequestsFromFirstReported,
                                isForce ? "but allowing due to force flag" : "start rejected"
                            });
                            if (!isForce)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            this.ResetStartProcessLimit(instanceStartStats, now);
                        }
                    }
                    instanceStartStats.LastStartRequestedTime = now;
                    instanceStartStats.TotalStartRequestsFromFirstReported++;
                }
                else
                {
                    this.ResetStartProcessLimit(instanceStartStats, now);
                }
            }
            return(true);
        }
Пример #9
0
        private void StartInstanceInternal(InstanceGroupConfig group, bool isForce = false)
        {
            DxStoreManager.Tracer.TraceDebug <string, string, bool>((long)this.Config.Identity.GetHashCode(), "{0}: Starting instance checker {1} (group.IsRestartRequested: {2})", this.Config.Identity, group.Identity, group.IsRestartRequested);
            if (group.IsRestartRequested)
            {
                this.ConfigProvider.SetRestartRequired(group.Name, false);
                group.IsRestartRequested = false;
            }
            else if (!this.CheckStartProcessLimits(group, isForce))
            {
                return;
            }
            DxStoreInstanceChecker dxStoreInstanceChecker = new DxStoreInstanceChecker(this, group);

            this.instanceMap[group.Name] = new Tuple <InstanceGroupConfig, DxStoreInstanceChecker>(group, dxStoreInstanceChecker);
            dxStoreInstanceChecker.Start();
        }
Пример #10
0
        public void CheckGroup(InstanceGroupConfig group)
        {
            if (!group.IsConfigurationReady)
            {
                return;
            }
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;
            Tuple <InstanceGroupConfig, DxStoreInstanceChecker> instanceContainer = this.GetInstanceContainer(group.Name);

            if (instanceContainer == null)
            {
                flag = (group.IsAutomaticActionsAllowed && group.IsMembersContainSelf);
            }
            else if (!group.IsAutomaticActionsAllowed || !group.IsMembersContainSelf)
            {
                flag2 = true;
            }
            else
            {
                InstanceGroupConfig    item  = instanceContainer.Item1;
                DxStoreInstanceChecker item2 = instanceContainer.Item2;
                if (item2.IsRestartRequested || group.IsRestartRequested)
                {
                    flag3 = true;
                }
            }
            if (flag3)
            {
                this.RestartInstanceInternal(group, false);
            }
            else if (flag2)
            {
                this.StopInstanceInternal(group.Name, false);
            }
            else if (flag)
            {
                this.StartInstanceInternal(group, false);
            }
            if (!group.IsMembersContainSelf && !group.IsConfigurationManagedExternally && DxStoreInstance.RemoveGroupStorage(this.EventLogger, group))
            {
                this.RemoveGroupConfig(group);
            }
        }
Пример #11
0
 public void MonitorGroupsInternal(bool isForceRefreshCache)
 {
     this.isTriggerRefreshPostponed = false;
     this.RegisterServiceHostIfRequired();
     this.ConfigProvider.RefreshTopology(isForceRefreshCache);
     InstanceGroupConfig[] allGroupConfigs = this.ConfigProvider.GetAllGroupConfigs();
     this.RemoveStartProcessLimitForNonExistentGroups(allGroupConfigs);
     InstanceGroupConfig[] array = allGroupConfigs;
     for (int i = 0; i < array.Length; i++)
     {
         InstanceGroupConfig instanceGroupConfig = array[i];
         InstanceGroupConfig tmpGroup            = instanceGroupConfig;
         Utils.RunOperation(tmpGroup.Identity, "CheckGroup", delegate
         {
             this.CheckGroup(tmpGroup);
         }, this.EventLogger, LogOptions.LogPeriodic | LogOptions.LogExceptionFull | instanceGroupConfig.Settings.AdditionalLogOptions, true, null, null, null, null, null);
     }
     this.StopRemovedGroups(allGroupConfigs);
 }
Пример #12
0
        public InstanceGroupConfig GetInstanceConfig(string groupName, bool isForce = false)
        {
            InstanceGroupConfig result = null;

            lock (this.locker)
            {
                if (!isForce)
                {
                    Tuple <InstanceGroupConfig, DxStoreInstanceChecker> instanceContainer = this.GetInstanceContainer(groupName);
                    if (instanceContainer != null)
                    {
                        result = instanceContainer.Item1;
                    }
                }
                else
                {
                    result = this.ConfigProvider.GetGroupConfig(groupName, true);
                }
            }
            return(result);
        }
Пример #13
0
 private void RestartInstanceInternal(InstanceGroupConfig group, bool isForce = false)
 {
     DxStoreManager.Tracer.TraceDebug <string, string>((long)this.Config.Identity.GetHashCode(), "{0}: Restarting instance checker {1}", this.Config.Identity, group.Identity);
     this.StopInstanceInternal(group.Name, false);
     this.StartInstanceInternal(group, isForce);
 }
Пример #14
0
 public GroupMembersMesh(string identity, INodeEndPoints <ServiceEndpoint> nodeEndPoints, InstanceGroupConfig groupConfig)
 {
     this.groupConfig       = groupConfig;
     this.identity          = identity;
     this.nodeEndPoints     = nodeEndPoints;
     this.incoming          = Subject.Synchronize <Tuple <string, Message>, Tuple <string, Message> >(new Subject <Tuple <string, Message> >(), Scheduler.TaskPool);
     this.factoryByEndPoint = new ConcurrentDictionary <ServiceEndpoint, WCF.CachedChannelFactory <IDxStoreInstance> >();
     ObservableExtensions.Subscribe <Tuple <string, Message> >(this.incoming, delegate(Tuple <string, Message> item)
     {
         this.TraceMessage(false, item);
     });
 }
 public DxStoreInstanceChecker(DxStoreManager manager, InstanceGroupConfig config)
 {
     this.manager = manager;
     this.config  = config;
 }
Пример #16
0
 public void Initialize(string self, InstanceClientFactory instanceClientFactory, InstanceGroupConfig groupConfig, IDxStoreEventLogger eventLogger, double requiredSuccessPercent)
 {
     this.EventLogger            = eventLogger;
     this.self                   = self;
     this.instanceClientFactory  = instanceClientFactory;
     this.GroupStatusInfo        = new GroupStatusInfo();
     this.groupConfig            = groupConfig;
     this.completionEvent        = new ManualResetEvent(false);
     this.requiredSuccessPercent = requiredSuccessPercent;
 }
Пример #17
0
 public GroupStatusCollector(string self, InstanceClientFactory instanceClientFactory, InstanceGroupConfig groupConfig, IDxStoreEventLogger eventLogger, double requiredSuccessPercent)
 {
     this.Initialize(self, instanceClientFactory, groupConfig, eventLogger, requiredSuccessPercent);
 }