Exemplo n.º 1
0
        // Token: 0x0600054F RID: 1359 RVA: 0x0001B024 File Offset: 0x00019224
        private void Run(AmSystemFailoverOnReplayDownTracker failoverTracker)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (!config.IsPAM)
            {
                ReplayCrimsonEvents.FailoverOnReplDownSkipped.Log <AmServerName, string, string>(this.serverName, "RoleNotPAM", "TimerCallback");
                return;
            }
            if (AmHelper.IsReplayRunning(this.serverName))
            {
                ReplayCrimsonEvents.FailoverOnReplDownSkipped.Log <AmServerName, string, string>(this.serverName, "ReplRunning", "TimerCallback");
                return;
            }
            AmThrottledActionTracker <FailoverData> .ThrottlingShapshot throttlingSnapshot = failoverTracker.GetThrottlingSnapshot(this.serverName);
            if (throttlingSnapshot.IsActionCalledTooSoonPerNode || throttlingSnapshot.IsActionCalledTooSoonAcrossDag || throttlingSnapshot.IsMaxActionsPerNodeExceeded || throttlingSnapshot.IsMaxActionsAcrossDagExceeded)
            {
                throttlingSnapshot.LogResults(ReplayCrimsonEvents.FailoverOnReplDownThrottlingFailed, TimeSpan.FromMinutes(15.0));
                return;
            }
            failoverTracker.AddFailoverEntry(this.serverName);
            throttlingSnapshot.LogResults(ReplayCrimsonEvents.FailoverOnReplDownThrottlingSucceeded, TimeSpan.Zero);
            AmEvtSystemFailoverOnReplayDown amEvtSystemFailoverOnReplayDown = new AmEvtSystemFailoverOnReplayDown(this.serverName);

            amEvtSystemFailoverOnReplayDown.Notify();
        }
Exemplo n.º 2
0
        internal static void RemoveEntryFromClusdb(string serverName, string actionName)
        {
            using (IClusterDB clusterDB = ClusterDB.Open())
            {
                string keyName = AmThrottledActionTracker <TData> .ConstructRegKeyName(serverName);

                clusterDB.DeleteValue(keyName, actionName);
            }
        }
Exemplo n.º 3
0
        private void InitializeFromClusdbInternal()
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsPAM)
            {
                AmDagConfig dagConfig = config.DagConfig;
                using (IClusterDB clusterDB = ClusterDB.Open())
                {
                    foreach (AmServerName amServerName in dagConfig.MemberServers)
                    {
                        string keyName = AmThrottledActionTracker <TData> .ConstructRegKeyName(amServerName.NetbiosName);

                        string[] value = clusterDB.GetValue <string[]>(keyName, this.ActionName, null);
                        if (value != null && value.Length > 0)
                        {
                            LinkedList <TData> linkedList = new LinkedList <TData>();
                            foreach (string text in value)
                            {
                                int num = text.IndexOf('=');
                                if (num != -1)
                                {
                                    string s       = text.Substring(0, num);
                                    string dataStr = null;
                                    if (num < text.Length - 1)
                                    {
                                        dataStr = text.Substring(num + 1);
                                    }
                                    ExDateTime actionTime = ExDateTime.Parse(s);
                                    TData      value2     = Activator.CreateInstance <TData>();
                                    value2.Initialize(actionTime, dataStr);
                                    linkedList.AddFirst(value2);
                                }
                            }
                            this.actionHistory[amServerName] = linkedList;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void Persist(AmServerName node)
        {
            LinkedList <TData> linkedList;

            if (this.actionHistory.TryGetValue(node, out linkedList) && linkedList != null && linkedList.Count > 0)
            {
                using (IClusterDB clusterDB = ClusterDB.Open())
                {
                    List <string> list = new List <string>();
                    foreach (TData tdata in linkedList)
                    {
                        string arg     = tdata.Time.UniversalTime.ToString("o");
                        string dataStr = tdata.DataStr;
                        string item    = string.Format("{0}{1}{2}", arg, '=', dataStr);
                        list.Add(item);
                    }
                    string[] propetyValue = list.ToArray();
                    string   keyName      = AmThrottledActionTracker <TData> .ConstructRegKeyName(node.NetbiosName);

                    clusterDB.SetValue <string[]>(keyName, this.ActionName, propetyValue);
                }
            }
        }
Exemplo n.º 5
0
        internal AmThrottledActionTracker <TData> .ThrottlingShapshot GetThrottlingSnapshot(AmServerName server, TimeSpan minDurationBetweenActionsPerNode, TimeSpan maxCheckDurationPerNode, int maxAllowedActionsPerNode, TimeSpan minDurationBetweenActionsAcrossDag, TimeSpan maxCheckDurationAcrossDag, int maxAllowedActionsAcrossDag)
        {
            AmThrottledActionTracker <TData> .ThrottlingShapshot throttlingShapshot = new AmThrottledActionTracker <TData> .ThrottlingShapshot(server, minDurationBetweenActionsPerNode, maxCheckDurationPerNode, maxAllowedActionsPerNode, minDurationBetweenActionsAcrossDag, maxCheckDurationAcrossDag, maxAllowedActionsAcrossDag);

            ExDateTime now = ExDateTime.Now;

            throttlingShapshot.CalculationBaseTime = now;
            lock (this.locker)
            {
                throttlingShapshot.MostRecentActionDataForNode   = this.GetMostRecentActionData(server);
                throttlingShapshot.MostRecentActionDataAcrossDag = this.GetMostRecentActionDataAcrossDag();
                throttlingShapshot.ActionsCountPerNode           = this.GetActionsCountForTimeSpan(server, maxCheckDurationPerNode, now);
                throttlingShapshot.ActionsCountAcrossDag         = this.GetActionsForTimeSpanAcrossDag(maxCheckDurationAcrossDag, now);
            }
            throttlingShapshot.IsActionCalledTooSoonPerNode = false;
            if (minDurationBetweenActionsPerNode > TimeSpan.Zero)
            {
                throttlingShapshot.IsActionCalledTooSoonPerNode = this.IsActionCalledTooSoon(throttlingShapshot.MostRecentActionDataForNode, minDurationBetweenActionsPerNode, now);
            }
            throttlingShapshot.IsActionCalledTooSoonAcrossDag = false;
            if (minDurationBetweenActionsAcrossDag > TimeSpan.Zero)
            {
                throttlingShapshot.IsActionCalledTooSoonAcrossDag = this.IsActionCalledTooSoon(throttlingShapshot.MostRecentActionDataAcrossDag, minDurationBetweenActionsAcrossDag, now);
            }
            throttlingShapshot.IsMaxActionsPerNodeExceeded = false;
            if (maxAllowedActionsPerNode > 0 && throttlingShapshot.ActionsCountPerNode >= maxAllowedActionsPerNode)
            {
                throttlingShapshot.IsMaxActionsPerNodeExceeded = true;
            }
            throttlingShapshot.IsMaxActionsAcrossDagExceeded = false;
            if (maxAllowedActionsAcrossDag > 0 && throttlingShapshot.ActionsCountAcrossDag >= maxAllowedActionsAcrossDag)
            {
                throttlingShapshot.IsMaxActionsAcrossDagExceeded = true;
            }
            return(throttlingShapshot);
        }
 internal static void RemoveFailoverEntryFromClusterDatabase(string serverName)
 {
     AmThrottledActionTracker <FailoverData> .RemoveEntryFromClusdb(serverName, "ServerLevelFailover");
 }