// Token: 0x060003BF RID: 959 RVA: 0x00014544 File Offset: 0x00012744
        private static Dictionary <AmServerName, AmMdbStatusServerInfo> GetMultiNodeServerInfo(AmConfig cfg, List <AmServerName> serversList)
        {
            Dictionary <AmServerName, AmMdbStatusServerInfo> dictionary = new Dictionary <AmServerName, AmMdbStatusServerInfo>();

            foreach (AmServerName amServerName in serversList)
            {
                if (!cfg.IsUnknown)
                {
                    if (cfg.IsDebugOptionsEnabled() && cfg.IsIgnoreServerDebugOptionEnabled(amServerName))
                    {
                        AmTrace.Warning("Server {0} is ignored from batch mounter operation since debug option {1} is enabled", new object[]
                        {
                            amServerName.NetbiosName,
                            AmDebugOptions.IgnoreServerFromAutomaticActions.ToString()
                        });
                    }
                    else if (cfg.IsStandalone || cfg.DagConfig.IsNodePubliclyUp(amServerName))
                    {
                        dictionary[amServerName] = new AmMdbStatusServerInfo(amServerName, true, TimeSpan.FromSeconds((double)RegistryParameters.MdbStatusFetcherServerUpTimeoutInSec));
                    }
                    else if (RegistryParameters.TransientFailoverSuppressionDelayInSec > 0)
                    {
                        dictionary[amServerName] = new AmMdbStatusServerInfo(amServerName, false, TimeSpan.FromSeconds((double)RegistryParameters.MdbStatusFetcherServerDownTimeoutInSec));
                    }
                }
            }
            return(dictionary);
        }
        // Token: 0x060003C7 RID: 967 RVA: 0x0001482C File Offset: 0x00012A2C
        protected override Exception RunServerRpc(AmServerName node, out object result)
        {
            Exception result2        = null;
            Exception storeException = null;

            MdbStatus[] mdbStatuses = null;
            result = null;
            AmMdbStatusServerInfo amMdbStatusServerInfo = this.ServerInfoMap[node];
            bool flag = false;

            try
            {
                InvokeWithTimeout.Invoke(delegate()
                {
                    storeException = this.RunServerRpcInternal(node, out mdbStatuses);
                }, amMdbStatusServerInfo.TimeOut);
            }
            catch (TimeoutException ex)
            {
                result2 = ex;
                flag    = true;
            }
            if (!flag)
            {
                result2 = storeException;
                amMdbStatusServerInfo.IsStoreRunning  = true;
                amMdbStatusServerInfo.IsReplayRunning = AmHelper.IsReplayRunning(node);
                result = mdbStatuses;
            }
            return(result2);
        }
        // Token: 0x0600005E RID: 94 RVA: 0x00003118 File Offset: 0x00001318
        private bool ShouldConsiderMdbStatus(AmMdbStatusServerInfo serverInfo, MdbStatus[] mdbStatuses)
        {
            bool flag = false;

            if (mdbStatuses != null)
            {
                if (RegistryParameters.IsTransientFailoverSuppressionEnabled)
                {
                    if (serverInfo.IsNodeUp)
                    {
                        flag = true;
                    }
                    else if (serverInfo.IsReplayRunning)
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = serverInfo.IsNodeUp;
                }
            }
            AmTrace.Info("ShouldConsiderMdbStatus: ServerName: {0}, IsConsider: {1}, IsStoreRunning: {2}, MountedDbCount: {3}, IsNodeUp: {4}, IsReplayRunning: {5}, IsTimedout: {6}", new object[]
            {
                serverInfo.ServerName,
                flag,
                serverInfo.IsStoreRunning,
                (mdbStatuses != null) ? mdbStatuses.Length : -1,
                serverInfo.IsNodeUp,
                serverInfo.IsReplayRunning,
                serverInfo.TimeOut
            });
            return(flag);
        }
 // Token: 0x0600005F RID: 95 RVA: 0x000031C0 File Offset: 0x000013C0
 protected void MergeDatabaseInfoWithMdbStatus(Dictionary <Guid, DatabaseInfo> dbMap, Dictionary <AmServerName, MdbStatus[]> mdbFullStatusMap, Dictionary <AmServerName, AmMdbStatusServerInfo> serverInfoMap)
 {
     if (mdbFullStatusMap == null)
     {
         AmTrace.Warning("MergeDatabaseInfoWithMdbStatus: mdbFullStatusMap was null.", new object[0]);
         return;
     }
     foreach (AmServerName amServerName in mdbFullStatusMap.Keys)
     {
         MdbStatus[]           array = mdbFullStatusMap[amServerName];
         AmMdbStatusServerInfo amMdbStatusServerInfo = serverInfoMap[amServerName];
         if (array == null)
         {
             AmListMdbStatusMonitor.Instance.RecordFailure(amServerName);
         }
         else
         {
             AmListMdbStatusMonitor.Instance.RecordSuccess(amServerName);
         }
         if (this.ShouldConsiderMdbStatus(amMdbStatusServerInfo, array))
         {
             if (!amMdbStatusServerInfo.IsNodeUp && array.Length > 0)
             {
                 base.AddDelayedFailoverEntryAsync(amServerName, this.m_reasonCode);
             }
             foreach (MdbStatus mdbStatus in array)
             {
                 DatabaseInfo databaseInfo = null;
                 dbMap.TryGetValue(mdbStatus.MdbGuid, out databaseInfo);
                 if (databaseInfo != null)
                 {
                     databaseInfo.StoreStatus[amServerName] = new MdbStatusFlags?(mdbStatus.Status);
                     string text = string.Format("{0}{1}{2}", mdbStatus.MdbGuid, amServerName.NetbiosName, mdbStatus.Status);
                     ReplayCrimsonEvents.ObservedMdbStatus.LogPeriodic <string, Guid, string, string>(text, TimeSpan.FromMinutes(480.0), databaseInfo.Database.Name, mdbStatus.MdbGuid, amServerName.NetbiosName, string.Format("{0} (0x{0:X})", mdbStatus.Status));
                 }
                 else
                 {
                     AmTrace.Warning("{0} is reported from MdbStatus but not present in the dbmap - so ignoring", new object[]
                     {
                         mdbStatus.MdbGuid
                     });
                 }
             }
             foreach (DatabaseInfo databaseInfo2 in dbMap.Values)
             {
                 MdbStatusFlags?mdbStatusFlags;
                 if (databaseInfo2.StoreStatus.TryGetValue(amServerName, out mdbStatusFlags) && mdbStatusFlags == null)
                 {
                     databaseInfo2.StoreStatus[amServerName] = new MdbStatusFlags?(MdbStatusFlags.Offline);
                 }
             }
         }
     }
 }
예제 #5
0
        protected void InitiateSystemFailoverIfReplayUnreachable(AmMultiNodeMdbStatusFetcher mdbStatusFetcher, Dictionary <Guid, DatabaseInfo> dbMap)
        {
            AmRole role = AmSystemManager.Instance.Config.Role;

            if (role != AmRole.PAM)
            {
                return;
            }
            if (!RegistryParameters.OnReplDownFailoverEnabled)
            {
                ReplayCrimsonEvents.FailoverOnReplDownDisabledInRegistry.LogPeriodic(Environment.MachineName, TimeSpan.FromHours(1.0));
                return;
            }
            AmSystemFailoverOnReplayDownTracker systemFailoverOnReplayDownTracker = AmSystemManager.Instance.SystemFailoverOnReplayDownTracker;

            if (systemFailoverOnReplayDownTracker == null)
            {
                ReplayCrimsonEvents.FailoverOnReplDownFailoverTrackerNotInitialized.LogPeriodic(Environment.MachineName, TimeSpan.FromHours(1.0));
                return;
            }
            foreach (KeyValuePair <AmServerName, AmMdbStatusServerInfo> keyValuePair in mdbStatusFetcher.ServerInfoMap)
            {
                AmServerName          key   = keyValuePair.Key;
                AmMdbStatusServerInfo value = keyValuePair.Value;
                if (value.IsReplayRunning)
                {
                    systemFailoverOnReplayDownTracker.MarkReplayUp(key);
                }
                else if (value.IsStoreRunning)
                {
                    systemFailoverOnReplayDownTracker.MarkReplayDown(key, false);
                    int activeDatabaseCountOnServer = this.GetActiveDatabaseCountOnServer(dbMap, key);
                    if (activeDatabaseCountOnServer > 0)
                    {
                        systemFailoverOnReplayDownTracker.ScheduleFailover(key);
                    }
                    else
                    {
                        ReplayCrimsonEvents.FailoverOnReplDownSkipped.LogPeriodic <AmServerName, string, string>(key, TimeSpan.FromDays(1.0), key, "NoActives", "Periodic");
                    }
                }
            }
        }
        // Token: 0x06000093 RID: 147 RVA: 0x00004B2C File Offset: 0x00002D2C
        protected override void RunInternal()
        {
            IADDatabase[] dbList = null;
            if (!this.m_isForce)
            {
                AmMultiNodeMdbStatusFetcher amMultiNodeMdbStatusFetcher = base.StartMdbStatusFetcher();
                IADDatabase[] databases = base.GetDatabases();
                amMultiNodeMdbStatusFetcher.WaitUntilStatusIsReady();
                Dictionary <AmServerName, MdbStatus[]> mdbStatusMap = amMultiNodeMdbStatusFetcher.MdbStatusMap;
                AmMdbStatusServerInfo amMdbStatusServerInfo         = amMultiNodeMdbStatusFetcher.ServerInfoMap[this.m_nodeName];
                MdbStatus[]           mdbStatuses = mdbStatusMap[this.m_nodeName];
                if (amMdbStatusServerInfo.IsReplayRunning)
                {
                    if (!this.skipIfReplayRunning)
                    {
                        if (RegistryParameters.TransientFailoverSuppressionDelayInSec > 0)
                        {
                            dbList = this.GetDatabasesToBeMoved(databases, mdbStatuses);
                            base.AddDelayedFailoverEntryAsync(this.m_nodeName, this.m_reasonCode);
                        }
                    }
                    else
                    {
                        ReplayCrimsonEvents.FailoverOnReplDownSkipped.Log <AmServerName, string, string>(this.m_nodeName, "ReplRunning", "MoveAll");
                    }
                }
                else
                {
                    dbList = databases;
                }
            }
            else
            {
                dbList = base.GetDatabases();
            }
            AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.Move);

            base.MoveDatabases(actionCode, dbList);
        }