コード例 #1
0
        // Token: 0x060002EB RID: 747 RVA: 0x000109F0 File Offset: 0x0000EBF0
        private bool AttemptMountOnServer(AmServerName serverToMount, AmServerName sourceServer, MountFlags storeMountFlags, AmMountFlags amMountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmBcsSkipFlags skipValidationChecks, bool tryOtherHealthyServers, ref int natSkippedServersCount, ref AmAcllReturnStatus acllStatus, out Exception lastException)
        {
            bool flag = true;
            bool fLossyMountEnabled    = false;
            bool isSuccess             = false;
            bool isAcllSuccess         = false;
            bool isMasterServerChanged = false;

            lastException = null;
            bool isSuccess2;

            try
            {
                acllStatus = new AmAcllReturnStatus();
                AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
                if (!base.ActionCode.IsAdminOperation && base.Config.IsIgnoreServerDebugOptionEnabled(serverToMount))
                {
                    ReplayCrimsonEvents.OperationNotPerformedDueToDebugOption.Log <string, string, string>(serverToMount.Fqdn, AmDebugOptions.IgnoreServerFromAutomaticActions.ToString(), "Mount database");
                    throw new AmDbOperationException("Mount not applicable for a server when debug options are enabled");
                }
                bool flag2 = this.IsAcllRequired(serverToMount, sourceServer);
                if (dbNodeAttemptTable.IsOkayForAction(base.Database, serverToMount, base.ActionCode))
                {
                    if (!flag2)
                    {
                        acllStatus.NoLoss       = true;
                        acllStatus.MountAllowed = true;
                    }
                    else
                    {
                        Stopwatch stopwatch = new Stopwatch();
                        stopwatch.Start();
                        try
                        {
                            ReplayCrimsonEvents.AcllInitiated.LogGeneric(base.PrepareSubactionArgs(new object[]
                            {
                                serverToMount,
                                sourceServer
                            }));
                            AmAcllReturnStatus tempAcllStatus = null;
                            lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                            {
                                this.RunAttemptCopyLastLogsOnServer(serverToMount, sourceServer, mountDialoverride, skipValidationChecks, 1, 15000, 15000, 15000, out fLossyMountEnabled, ref tempAcllStatus);
                                isAcllSuccess = true;
                            });
                            acllStatus = tempAcllStatus;
                        }
                        finally
                        {
                            stopwatch.Stop();
                            if (isAcllSuccess)
                            {
                                ReplayCrimsonEvents.AcllSuccess2.LogGeneric(base.PrepareSubactionArgs(new object[]
                                {
                                    serverToMount,
                                    fLossyMountEnabled,
                                    stopwatch.Elapsed
                                }));
                            }
                            else
                            {
                                ReplayCrimsonEvents.AcllFailed.LogGeneric(base.PrepareSubactionArgs(new object[]
                                {
                                    serverToMount,
                                    stopwatch.Elapsed,
                                    (lastException != null) ? lastException.Message : ReplayStrings.UnknownError
                                }));
                            }
                        }
                        if (lastException == null)
                        {
                            if (base.State.IsAdminDismounted && !base.ActionCode.IsAdminMountOperation)
                            {
                                AmTrace.Debug("Skipping mount for database '{0}' on server '{1}' since it was admin dismounted.", new object[]
                                {
                                    base.DatabaseName,
                                    serverToMount
                                });
                                if (this.UpdateMaster(serverToMount, true))
                                {
                                    this.SendReplicaNotifications();
                                    isMasterServerChanged = true;
                                }
                                isSuccess = true;
                                flag      = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    if (!flag)
                    {
                        goto IL_45C;
                    }
                    isSuccess     = false;
                    lastException = null;
                    Stopwatch stopwatch2 = new Stopwatch();
                    stopwatch2.Start();
                    try
                    {
                        ReplayCrimsonEvents.DirectMountInitiated.LogGeneric(base.PrepareSubactionArgs(new object[]
                        {
                            serverToMount,
                            storeMountFlags,
                            fLossyMountEnabled,
                            amMountFlags
                        }));
                        lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                        {
                            TimeSpan mountTimeout = this.DetermineMountTimeout(skipValidationChecks);
                            this.RunMountDatabaseDirect(serverToMount, storeMountFlags, amMountFlags, fLossyMountEnabled, mountTimeout, ref isMasterServerChanged);
                            isSuccess = true;
                        });
                        goto IL_45C;
                    }
                    finally
                    {
                        stopwatch2.Stop();
                        if (isSuccess)
                        {
                            ReplayCrimsonEvents.DirectMountSuccess.LogGeneric(base.PrepareSubactionArgs(new object[]
                            {
                                serverToMount,
                                stopwatch2.Elapsed
                            }));
                        }
                        else
                        {
                            string text = (lastException != null) ? lastException.Message : ReplayStrings.UnknownError;
                            ReplayCrimsonEvents.DirectMountFailed.LogGeneric(base.PrepareSubactionArgs(new object[]
                            {
                                serverToMount,
                                stopwatch2.Elapsed,
                                text
                            }));
                        }
                    }
                }
                natSkippedServersCount++;
                AmTrace.Debug("Mount for database '{0}' skipped server '{1}' since a recent mount operation on this node failed.", new object[]
                {
                    base.DatabaseName,
                    serverToMount
                });
                lastException = new AmDbOperationAttempedTooSoonException(base.DatabaseName);
                ReplayCrimsonEvents.MountServerSkipped.LogGeneric(base.PrepareSubactionArgs(new object[]
                {
                    serverToMount,
                    lastException.Message
                }));
                isSuccess = false;
IL_45C:
                isSuccess2 = isSuccess;
            }
            finally
            {
                if (!isMasterServerChanged)
                {
                    AmTrace.Error("The active server for database '{0}' has not been changed, so we need to rollback the database state tracker information.", new object[]
                    {
                        base.DatabaseName
                    });
                    AmDatabaseStateTracker databaseStateTracker = AmSystemManager.Instance.DatabaseStateTracker;
                    if (databaseStateTracker != null)
                    {
                        databaseStateTracker.UpdateActive(base.DatabaseGuid, sourceServer);
                    }
                }
            }
            return(isSuccess2);
        }
コード例 #2
0
 // Token: 0x06000805 RID: 2053 RVA: 0x00026F9A File Offset: 0x0002519A
 internal void Leaving(string format, params object[] args)
 {
     AmTrace.Leaving(this.PrefixDatabase(format), args);
 }
コード例 #3
0
        // Token: 0x06000495 RID: 1173 RVA: 0x00018778 File Offset: 0x00016978
        internal static void Mount(Guid mdbGuid, MountFlags flags)
        {
            bool flag = false;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(null))
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                bool isCheckDbStatus = true;
                bool flag2           = false;
                for (;;)
                {
                    ReplayCrimsonEvents.MountStoreRpcInitiated.Log <Guid, MountFlags>(mdbGuid, flags);
                    Exception ex = null;
                    try
                    {
                        try
                        {
                            newStoreControllerInstance.MountDatabase(Guid.Empty, mdbGuid, (int)flags);
                            AmTrace.Info("rpcAdmin.MountDatabase({0}) successful.", new object[]
                            {
                                mdbGuid
                            });
                            isCheckDbStatus = false;
                            flag2           = true;
                            break;
                        }
                        catch (MapiExceptionMountInProgress mapiExceptionMountInProgress)
                        {
                            ex = mapiExceptionMountInProgress;
                            AmTrace.Error("rpcAdmin.MountDatabase({0}) encountered {1}.", new object[]
                            {
                                mdbGuid,
                                mapiExceptionMountInProgress.Message
                            });
                            if (!flag)
                            {
                                ReplayCrimsonEvents.MountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, mapiExceptionMountInProgress.Message);
                                flag = true;
                            }
                            if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                            {
                                throw;
                            }
                            if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                            {
                                AmTrace.Debug("shutdown requested - hence not retrying mount for database {0}", new object[]
                                {
                                    mdbGuid
                                });
                                throw;
                            }
                        }
                        catch (MapiPermanentException ex2)
                        {
                            ex = ex2;
                            throw;
                        }
                        catch (MapiRetryableException ex3)
                        {
                            ex = ex3;
                            throw;
                        }
                        continue;
                    }
                    finally
                    {
                        if (flag2)
                        {
                            ReplayCrimsonEvents.MountStoreRpcSucceeded.Log <Guid>(mdbGuid);
                        }
                        else if (ex == null || !(ex is MapiExceptionMountInProgress))
                        {
                            ReplayCrimsonEvents.MountStoreRpcFailed.Log <Guid, string, Exception>(mdbGuid, (ex != null) ? ex.Message : null, ex);
                        }
                        AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, flag2, isCheckDbStatus);
                    }
                    break;
                }
            }
        }
コード例 #4
0
        internal void SleepIfRequired(string subKeyName, string propertyName)
        {
            if (!this.IsEnabled)
            {
                return;
            }
            string text = "Software\\Microsoft\\Exchange\\ActiveManager\\FaultInject";

            if (!string.IsNullOrEmpty(subKeyName))
            {
                text = text + "\\" + subKeyName;
            }
            int num  = 0;
            int num2 = 0;

            while (!this.IsTempDisabled)
            {
                bool flag = this.ReadProperty <int>(text, propertyName, out num2, 0);
                if (!flag && !string.IsNullOrEmpty(subKeyName))
                {
                    flag = this.ReadProperty <int>("Software\\Microsoft\\Exchange\\ActiveManager\\FaultInject", propertyName, out num2, 0);
                }
                if (!flag || num >= num2)
                {
                    break;
                }
                if (num % 30 == 0)
                {
                    if (num == 0)
                    {
                        AmTrace.Debug("Sleep induced at:", new object[0]);
                        AmTrace.Debug(new StackTrace(true).ToString(), new object[0]);
                        AmTrace.Debug("Starting to sleeping for {0}\\{1}: (elasped={2}, max={3})", new object[]
                        {
                            subKeyName,
                            propertyName,
                            num,
                            num2
                        });
                    }
                    else
                    {
                        AmTrace.Debug("Sleeping for {0}\\{1}: (elasped={2}, max={3})", new object[]
                        {
                            subKeyName,
                            propertyName,
                            num,
                            num2
                        });
                    }
                }
                Thread.Sleep(1000);
                num++;
            }
            if (num > 0)
            {
                AmTrace.Debug("Finished sleeping for {0}\\{1}: (elasped={2}, max={3})", new object[]
                {
                    subKeyName,
                    propertyName,
                    num,
                    num2
                });
            }
        }
コード例 #5
0
 internal AmPamMonitor(TimeSpan checkPeriod) : base(checkPeriod, checkPeriod, "AmPamMonitor")
 {
     AmTrace.Entering("Constructor of AmPamMonitor", new object[0]);
     this.checkPeriod = checkPeriod;
 }
コード例 #6
0
        // Token: 0x0600005D RID: 93 RVA: 0x00002EBC File Offset: 0x000010BC
        protected Dictionary <Guid, DatabaseInfo> GenerateDatabaseInfoMap()
        {
            Dictionary <Guid, DatabaseInfo> dictionary = new Dictionary <Guid, DatabaseInfo>();
            List <AmServerName>             servers    = this.GetServers();
            IADConfig adconfig = Dependencies.ADConfig;

            foreach (AmServerName amServerName in servers)
            {
                IADServer server = adconfig.GetServer(amServerName);
                if (server == null)
                {
                    AmTrace.Debug("Startup mount could not find server named {0} in AD", new object[]
                    {
                        amServerName
                    });
                }
                else
                {
                    IEnumerable <IADDatabase> databasesOnServer = adconfig.GetDatabasesOnServer(server);
                    if (databasesOnServer != null)
                    {
                        using (IEnumerator <IADDatabase> enumerator2 = databasesOnServer.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                IADDatabase  iaddatabase = enumerator2.Current;
                                DatabaseInfo databaseInfo;
                                if (!dictionary.TryGetValue(iaddatabase.Guid, out databaseInfo))
                                {
                                    AmDbStateInfo amDbStateInfo = this.m_amConfig.DbState.Read(iaddatabase.Guid);
                                    if (amDbStateInfo == null)
                                    {
                                        AmTrace.Error("Skipping database {0} since AmDbStateInfo is null", new object[]
                                        {
                                            iaddatabase.Name
                                        });
                                        continue;
                                    }
                                    if (this.IsSelectOnlyActives && !AmServerName.IsNullOrEmpty(amDbStateInfo.ActiveServer) && !amDbStateInfo.ActiveServer.Equals(amServerName))
                                    {
                                        AmTrace.Debug("Skipping database {0} since it is not active on {1}.", new object[]
                                        {
                                            iaddatabase.Name,
                                            amServerName
                                        });
                                        continue;
                                    }
                                    if (iaddatabase.Servers == null || iaddatabase.Servers.Length == 0 || iaddatabase.DatabaseCopies == null || iaddatabase.DatabaseCopies.Length == 0)
                                    {
                                        AmTrace.Error("Skipping database {0} since no copies were found.", new object[]
                                        {
                                            iaddatabase.Name
                                        });
                                        ReplayCrimsonEvents.AmBatchMounterIgnoresInvalidDatabase.LogPeriodic <Guid, string>(iaddatabase.Guid, TimeSpan.FromMinutes(30.0), iaddatabase.Guid, iaddatabase.Name);
                                        continue;
                                    }
                                    databaseInfo = new DatabaseInfo(iaddatabase, amDbStateInfo);
                                    dictionary[iaddatabase.Guid] = databaseInfo;
                                }
                                databaseInfo.StoreStatus[amServerName] = null;
                            }
                            continue;
                        }
                    }
                    AmTrace.Debug("Skipping server {0} for automounting since it does not have any database copies", new object[]
                    {
                        amServerName
                    });
                }
            }
            return(dictionary);
        }
コード例 #7
0
        internal static bool AttemptServerSwitchoverOnShutdown()
        {
            AmTrace.Entering("ActiveManagerCore.AttemptServerSwitchoverOnShutdown", new object[0]);
            ExDateTime utcNow = ExDateTime.UtcNow;

            ReplayEventLogConstants.Tuple_PreShutdownStart.LogEvent(null, new object[0]);
            Exception ex     = null;
            bool      result = false;

            try
            {
                AmConfig config = AmSystemManager.Instance.Config;
                if (config.IsPamOrSam)
                {
                    string fqdn = config.DagConfig.CurrentPAM.Fqdn;
                    AmTrace.Debug("{0} Trying to mount all the databases on other servers", new object[]
                    {
                        ExDateTime.Now
                    });
                    AmRpcClientHelper.ServerSwitchOver(fqdn, AmServerName.LocalComputerName.Fqdn);
                    if (config.IsPAM)
                    {
                        AmTrace.Debug("{0} Trying to move PAM off this node", new object[]
                        {
                            ExDateTime.Now
                        });
                        using (IAmCluster amCluster = ClusterFactory.Instance.Open())
                        {
                            using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup())
                            {
                                TimeSpan ts       = ExDateTime.UtcNow.Subtract(utcNow);
                                TimeSpan timeSpan = TimeSpan.FromSeconds(115.0).Subtract(ts);
                                if (!(timeSpan <= TimeSpan.Zero))
                                {
                                    if (amClusterGroup.MoveGroupToReplayEnabledNode((string targetNode) => AmHelper.IsReplayRunning(targetNode), "Network Name", timeSpan, out fqdn))
                                    {
                                        ReplayEventLogConstants.Tuple_SuccMovePAM.LogEvent(null, new object[]
                                        {
                                            Environment.MachineName,
                                            fqdn
                                        });
                                        AmTrace.Debug("{0} Moved PAM to another node", new object[]
                                        {
                                            ExDateTime.Now
                                        });
                                        goto IL_197;
                                    }
                                }
                                ReplayEventLogConstants.Tuple_FailedMovePAM.LogEvent(null, new object[]
                                {
                                    Environment.MachineName
                                });
                                IL_197 :;
                            }
                        }
                    }
                    result = true;
                    ReplayEventLogConstants.Tuple_PreShutdownOK.LogEvent(null, new object[0]);
                }
            }
            catch (ClusterException ex2)
            {
                ex = ex2;
            }
            catch (AmRpcException ex3)
            {
                ex = ex3;
            }
            catch (AmServerTransientException ex4)
            {
                ex = ex4;
            }
            catch (AmServerException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    ReplayEventLogConstants.Tuple_PreShutdownFailed.LogEvent(null, new object[]
                    {
                        ex.Message
                    });
                }
                AmTrace.Leaving("ActiveManagerCore.AttemptServerSwitchoverOnShutdown", new object[0]);
            }
            return(result);
        }
コード例 #8
0
        private void CopyWorker(RegistryManipulator source, RegistryManipulator destination)
        {
            string text  = null;
            string text2 = null;
            bool   flag  = true;
            bool   flag2 = true;

            this.m_isCopying = true;
            try
            {
                Queue <string> queue  = new Queue <string>();
                Queue <string> queue2 = new Queue <string>();
                List <string>  list   = new List <string>();
                List <string>  list2  = new List <string>();
                queue.Enqueue(string.Empty);
                queue2.Enqueue(string.Empty);
                while (this.m_isValid)
                {
                    if (flag)
                    {
                        list.Clear();
                        if (queue.Count > 0)
                        {
                            text = queue.Dequeue();
                            flag = false;
                            foreach (string text3 in source.GetSubKeyNames(text))
                            {
                                string item = text3;
                                if (text.CompareTo(string.Empty) != 0)
                                {
                                    item = text + "\\" + text3;
                                }
                                queue.Enqueue(item);
                            }
                        }
                        else
                        {
                            text = null;
                        }
                    }
                    if (flag2)
                    {
                        list2.Clear();
                        if (queue2.Count > 0)
                        {
                            text2 = queue2.Dequeue();
                            foreach (string text4 in destination.GetSubKeyNames(text2))
                            {
                                string item2 = text4;
                                if (text2.CompareTo(string.Empty) != 0)
                                {
                                    item2 = text2 + "\\" + text4;
                                }
                                queue2.Enqueue(item2);
                            }
                        }
                        else
                        {
                            text2 = null;
                        }
                    }
                    int num;
                    if (text == null)
                    {
                        num = 1;
                    }
                    else if (text2 == null)
                    {
                        num = -1;
                    }
                    else
                    {
                        num = string.Compare(text, text2, StringComparison.OrdinalIgnoreCase);
                    }
                    if (num == 0)
                    {
                        foreach (string item3 in source.GetValueNames(text))
                        {
                            list.Add(item3);
                        }
                        list.Sort();
                        foreach (string item4 in destination.GetValueNames(text2))
                        {
                            list2.Add(item4);
                        }
                        list2.Sort();
                        int num2 = 0;
                        int num3 = 0;
                        while (num3 < list.Count || num2 < list2.Count)
                        {
                            int num4;
                            if (num3 >= list.Count)
                            {
                                num4 = 1;
                            }
                            else if (num2 >= list2.Count)
                            {
                                num4 = -1;
                            }
                            else
                            {
                                num4 = string.Compare(list[num3], list2[num2]);
                            }
                            if (num4 == 0)
                            {
                                RegistryValue value  = source.GetValue(text, list[num3]);
                                RegistryValue value2 = destination.GetValue(text2, list2[num2]);
                                if (value != null && !value.Equals(value2))
                                {
                                    destination.SetValue(text, value);
                                }
                                else if (value == null)
                                {
                                    destination.DeleteValue(text2, list2[num2]);
                                }
                                num3++;
                                num2++;
                            }
                            else if (num4 < 0)
                            {
                                RegistryValue value3 = source.GetValue(text, list[num3]);
                                if (value3 != null)
                                {
                                    destination.SetValue(text, value3);
                                }
                                num3++;
                            }
                            else
                            {
                                destination.DeleteValue(text2, list2[num2]);
                                num2++;
                            }
                        }
                        flag  = true;
                        flag2 = true;
                    }
                    else if (num < 0 && text != null)
                    {
                        destination.CreateKey(text);
                        flag2 = false;
                        text2 = text;
                    }
                    else
                    {
                        if (text2 == null)
                        {
                            return;
                        }
                        destination.DeleteKey(text2);
                        flag2 = true;
                    }
                }
                AmTrace.Warning("Skipping a copy notification since the database has changed master. Source root: {0}", new object[]
                {
                    source.Root
                });
            }
            finally
            {
                this.m_isCopying = false;
            }
        }
コード例 #9
0
 private void MonitorClusterEvents()
 {
     while (!this.m_fShutdown)
     {
         AmClusterEventInfo amClusterEventInfo;
         bool flag = this.m_cen.WaitForEvent(out amClusterEventInfo, this.DefaultClusterEventNotifierTimeout);
         if (this.m_fShutdown)
         {
             AmClusterEventManager.Tracer.TraceDebug((long)this.GetHashCode(), "MonitorClusterEvents: Detected shutdown flag is set. Exiting from cluster notification monitoring");
             return;
         }
         if (flag)
         {
             if (amClusterEventInfo.IsNotifyHandleClosed)
             {
                 AmClusterEventManager.Tracer.TraceDebug((long)this.GetHashCode(), "Cluster notification handle closed. Exiting cluster event monitoring");
                 return;
             }
             if (amClusterEventInfo.IsNodeStateChanged)
             {
                 AmServerName nodeName = new AmServerName(amClusterEventInfo.ObjectName);
                 if (!string.IsNullOrEmpty(amClusterEventInfo.ObjectName))
                 {
                     Exception   ex;
                     AmNodeState nodeState = this.Cluster.GetNodeState(nodeName, out ex);
                     if (ex != null)
                     {
                         AmClusterEventManager.Tracer.TraceError <Exception>(0L, "MonitorClusterEvents fails to get node state: {0}", ex);
                     }
                     AmEvtNodeStateChanged amEvtNodeStateChanged = new AmEvtNodeStateChanged(nodeName, nodeState);
                     amEvtNodeStateChanged.Notify();
                     if (ex != null)
                     {
                         throw ex;
                     }
                 }
                 else
                 {
                     AmTrace.Error("Node state change detected but node name is invalid", new object[0]);
                 }
             }
             if (amClusterEventInfo.IsGroupStateChanged)
             {
                 AmSystemManager.Instance.ConfigManager.TriggerRefresh(false);
             }
             if (amClusterEventInfo.IsClusterStateChanged)
             {
                 AmEvtClusterStateChanged amEvtClusterStateChanged = new AmEvtClusterStateChanged();
                 amEvtClusterStateChanged.Notify();
                 AmSystemManager.Instance.ConfigManager.TriggerRefresh(true);
                 return;
             }
             if (amClusterEventInfo.IsNodeAdded)
             {
                 AmEvtNodeAdded amEvtNodeAdded = new AmEvtNodeAdded(new AmServerName(amClusterEventInfo.ObjectName));
                 amEvtNodeAdded.Notify();
             }
             if (amClusterEventInfo.IsNodeRemoved)
             {
                 AmEvtNodeRemoved amEvtNodeRemoved = new AmEvtNodeRemoved(new AmServerName(amClusterEventInfo.ObjectName));
                 amEvtNodeRemoved.Notify();
                 AmServerNameCache.Instance.RemoveEntry(amClusterEventInfo.ObjectName);
             }
             AmSystemManager.Instance.NetworkMonitor.ProcessEvent(amClusterEventInfo);
         }
     }
 }
コード例 #10
0
ファイル: AmHelper.cs プロジェクト: YHZX2013/exchange_diff
        private static DateTime GetBootTimeWithWmi(ManagementClass mgmtClass, AmServerName machineName)
        {
            DateTime  dateTime = ExDateTime.Now.UniversalTime;
            Exception ex       = null;

            try
            {
                using (ManagementObjectCollection instances = mgmtClass.GetInstances())
                {
                    if (instances != null)
                    {
                        using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = instances.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                ManagementBaseObject managementBaseObject = enumerator.Current;
                                ManagementObject     managementObject     = (ManagementObject)managementBaseObject;
                                using (managementObject)
                                {
                                    string dmtfDate = (string)managementObject["LastBootupTime"];
                                    dateTime = ManagementDateTimeConverter.ToDateTime(dmtfDate).ToUniversalTime();
                                    AmTrace.Debug("GetBootTimeWithWmi: WMI says that the boot time for {0} is {1}.", new object[]
                                    {
                                        machineName,
                                        dateTime
                                    });
                                }
                            }
                            goto IL_102;
                        }
                    }
                    AmTrace.Error("GetBootTimeWithWmi: WMI could not query the boot time on server {0}: No instances found for management path {1}.", new object[]
                    {
                        machineName,
                        mgmtClass.ClassPath.Path
                    });
                    ReplayEventLogConstants.Tuple_GetBootTimeWithWmiFailure.LogEvent(string.Empty, new object[]
                    {
                        machineName,
                        ReplayStrings.NoInstancesFoundForManagementPath(mgmtClass.ClassPath.Path)
                    });
                    IL_102 :;
                }
            }
            catch (COMException ex2)
            {
                ex = ex2;
            }
            catch (UnauthorizedAccessException ex3)
            {
                ex = ex3;
            }
            catch (ManagementException ex4)
            {
                ex = ex4;
            }
            catch (OutOfMemoryException ex5)
            {
                ex = ex5;
            }
            if (ex != null)
            {
                AmTrace.Error("GetBootTimeWithWmi: WMI could not query the boot time on server {0}: {1}", new object[]
                {
                    machineName,
                    ex
                });
                ReplayEventLogConstants.Tuple_GetBootTimeWithWmiFailure.LogEvent(string.Empty, new object[]
                {
                    machineName,
                    ex.Message
                });
            }
            return(dateTime);
        }
コード例 #11
0
        internal bool Lock(Guid dbGuid, AmDbLockReason lockReason)
        {
            bool flag = false;
            int  num  = 0;
            int  currentManagedThreadId = Environment.CurrentManagedThreadId;

            AmTrace.Debug("Trying to acquire lock for db={0} requester={1} reason={2}", new object[]
            {
                dbGuid,
                currentManagedThreadId,
                lockReason
            });
            do
            {
                lock (this.m_locker)
                {
                    AmDbLock.LockData lockData = null;
                    if (this.m_lockTable.TryGetValue(dbGuid, out lockData))
                    {
                        AmTrace.Debug("lock already held for db={0} heldby={1} current={2} reason={3}", new object[]
                        {
                            dbGuid,
                            lockData.ThreadId,
                            currentManagedThreadId,
                            lockData.Reason
                        });
                        if (lockData.ThreadId == currentManagedThreadId)
                        {
                            lockData.RefCount++;
                            flag = true;
                            AmTrace.Debug("same thread has requested lock db={0} heldby={1} refcount={2}", new object[]
                            {
                                dbGuid,
                                lockData.ThreadId,
                                lockData.RefCount
                            });
                        }
                    }
                    else
                    {
                        lockData = new AmDbLock.LockData(currentManagedThreadId, lockReason);
                        this.m_lockTable[dbGuid] = lockData;
                        flag = true;
                        AmTrace.Debug("lock created for db={0} owner={1} reason={2}", new object[]
                        {
                            dbGuid,
                            lockData.ThreadId,
                            lockData.Reason
                        });
                    }
                }
                if (flag)
                {
                    break;
                }
                AmTrace.Debug("sleeping to get the lock again for db={0} requester={1} reason={2} sleptSoFar={3}", new object[]
                {
                    dbGuid,
                    currentManagedThreadId,
                    lockReason,
                    num
                });
                Thread.Sleep(500);
                num += 500;
                AmDbLock.WarnIfSleepingForEver(dbGuid, num, lockReason);
            }while (!this.IsExiting);
            if (this.IsExiting && flag)
            {
                this.Release(dbGuid, lockReason);
                flag = false;
            }
            AmTrace.Debug("Got lock!! db={0} requester={1}", new object[]
            {
                dbGuid,
                currentManagedThreadId
            });
            return(flag);
        }
コード例 #12
0
 // Token: 0x0600047C RID: 1148 RVA: 0x00018057 File Offset: 0x00016257
 protected override void OnStart()
 {
     AmTrace.Debug("AmSearchServiceMonitor: service start detected.", new object[0]);
     this.IsServiceRunning = true;
 }
コード例 #13
0
 // Token: 0x0600047B RID: 1147 RVA: 0x0001803E File Offset: 0x0001623E
 protected override void OnStop()
 {
     AmTrace.Debug("AmSearchServiceMonitor: service stop detected.", new object[0]);
     this.IsServiceRunning = false;
 }
コード例 #14
0
        // Token: 0x060002E5 RID: 741 RVA: 0x000101D0 File Offset: 0x0000E3D0
        protected override void MountInternal(MountFlags storeMountFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialOverride, ref AmDbOperationDetailedStatus mountStatus)
        {
            Exception ex = null;
            int       natSkippedServersCount = 0;
            int       num  = 0;
            bool      flag = true;

            if (ThirdPartyManager.IsThirdPartyReplicationEnabled)
            {
                flag = false;
            }
            if (base.ActionCode.IsAdminOperation)
            {
                if (base.State.IsActiveServerValid)
                {
                    flag = false;
                }
                else
                {
                    AmTrace.Debug("Mount issued for the first time on this database. We will try all the available servers. (db={0})", new object[]
                    {
                        base.DatabaseName
                    });
                }
            }
            AmServerName amServerName = base.State.ActiveServer;

            if (AmServerName.IsNullOrEmpty(amServerName))
            {
                amServerName = new AmServerName(base.Database.Server.Name);
            }
            AmBcsSkipFlags skipValidationChecks = AmBcsSkipFlags.SkipAll;

            if (flag)
            {
                skipValidationChecks = AmBcsSkipFlags.None;
            }
            IBestCopySelector    bestCopySelector   = this.ConstructBestCopySelector(flag, skipValidationChecks, null, amServerName, amServerName, mountDialOverride, null);
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;

            if (base.ActionCode.IsAdminOperation)
            {
                dbNodeAttemptTable.ClearFailedTime(base.DatabaseGuid);
            }
            AmServerName       sourceServer       = amServerName;
            AmAcllReturnStatus amAcllReturnStatus = null;
            AmServerName       amServerName2      = bestCopySelector.FindNextBestCopy();

            while (amServerName2 != null)
            {
                num++;
                base.DbTrace.Debug("Attempting mount on server {0}", new object[]
                {
                    amServerName2
                });
                this.AttemptMountOnServer(amServerName2, sourceServer, storeMountFlags, amMountFlags, UnmountFlags.SkipCacheFlush, mountDialOverride, AmBcsSkipFlags.None, flag, ref natSkippedServersCount, ref amAcllReturnStatus, out ex);
                base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
                {
                    amAcllReturnStatus
                });
                sourceServer = base.State.ActiveServer;
                if (ex == null)
                {
                    break;
                }
                bestCopySelector.ErrorLogger.ReportServerFailure(amServerName2, "CopyHasBeenTriedCheck", ex.Message);
                if (ex is AmRoleChangedWhileOperationIsInProgressException || ex is AmMountTimeoutException)
                {
                    break;
                }
                amServerName2 = bestCopySelector.FindNextBestCopy();
                base.CurrentAttemptNumber++;
            }
            this.CheckActionResultsAndUpdateAdProperties(amServerName, null, bestCopySelector, ex, num, natSkippedServersCount);
        }
コード例 #15
0
        private void MonitorRegistry()
        {
            int      num      = 0;
            int      num2     = RegistryParameters.RegistryMonitorPollingIntervalInSec / 5;
            AmConfig amConfig = null;

            Dictionary <Guid, RegistryReplicator> .KeyCollection.Enumerator enumerator = this.replicators.Keys.GetEnumerator();
            try
            {
                bool flag = false;
                RegistryReplicator registryReplicator = null;
                RealRegistry       realRegistry       = null;
                ClusterRegistry    clusterRegistry    = null;
                List <Guid>        list  = new List <Guid>();
                List <WaitHandle>  list2 = new List <WaitHandle>();
                while (!this.stopEvent.WaitOne(5000, false))
                {
                    amConfig = AmSystemManager.Instance.Config;
                    while (!this.stopEvent.WaitOne(0, false) && amConfig.IsPamOrSam)
                    {
                        AmClusterHandle handle = amConfig.DagConfig.Cluster.Handle;
                        if (flag)
                        {
                            enumerator.Dispose();
                            enumerator = this.replicators.Keys.GetEnumerator();
                        }
                        int num3 = 0;
                        list2.Clear();
                        list.Clear();
                        while (num3 < 64 && enumerator.MoveNext())
                        {
                            if (this.replicators[enumerator.Current].IsValid)
                            {
                                list2.Add(this.replicators[enumerator.Current].KeyChanged);
                                list.Add(enumerator.Current);
                                num3++;
                            }
                        }
                        flag = (num3 < 64);
                        if (list2.Count <= 0)
                        {
                            goto IL_205;
                        }
                        int num4 = WaitHandle.WaitAny(list2.ToArray(), 5000, false);
                        if (num4 >= 0 && num4 < list2.Count)
                        {
                            Guid key = list[num4];
                            if (this.replicators[key].IsCopyEnabled)
                            {
                                lock (this.workQueue)
                                {
                                    this.workQueue.Enqueue(this.replicators[key]);
                                    this.replicators[key].KeyChanged.Reset();
                                }
                                try
                                {
                                    DiagnosticsNativeMethods.ErrorCode errorCode = DiagnosticsNativeMethods.RegNotifyChangeKeyValue((SafeRegistryHandle)this.replicators[key].Handle, true, DiagnosticsNativeMethods.RegistryNotifications.ChangeName | DiagnosticsNativeMethods.RegistryNotifications.ChangeAttributes | DiagnosticsNativeMethods.RegistryNotifications.LastSet, this.replicators[key].KeyChanged.SafeWaitHandle, true);
                                    if (errorCode != DiagnosticsNativeMethods.ErrorCode.Success)
                                    {
                                        throw new AmRegistryException("RegNotifyChangeKeyValue", new Win32Exception((int)errorCode));
                                    }
                                    goto IL_21B;
                                }
                                catch (AmRegistryException ex)
                                {
                                    AmTrace.Warning("Registering for registry key change notifications failed. Inner Exception: {0}", new object[]
                                    {
                                        ex
                                    });
                                    goto IL_21B;
                                }
                                goto IL_205;
                            }
                        }
IL_21B:
                        if (num == 0 || this.dbMountedEvent.WaitOne(0, false))
                        {
                            num2 = RegistryParameters.RegistryMonitorPollingIntervalInSec / 5;
                            foreach (KeyValuePair <Guid, RegistryReplicator> keyValuePair in this.replicators)
                            {
                                keyValuePair.Value.SetMarkedForRemoval();
                            }
                            IADDatabase[] databasesToMonitor = this.GetDatabasesToMonitor();
                            if (databasesToMonitor != null)
                            {
                                foreach (IADDatabase iaddatabase in databasesToMonitor)
                                {
                                    if (this.replicators.ContainsKey(iaddatabase.Guid))
                                    {
                                        this.replicators[iaddatabase.Guid].ResetMarkedForRemoval();
                                    }
                                    else
                                    {
                                        Exception ex2 = null;
                                        try
                                        {
                                            if (!flag)
                                            {
                                                enumerator.Dispose();
                                                flag = true;
                                            }
                                            string             text             = iaddatabase.IsPublicFolderDatabase ? RegistryMonitor.publicString : RegistryMonitor.privateString;
                                            string             text2            = string.Format(RegistryMonitor.localRegistryPathFormat, Environment.MachineName, iaddatabase.Guid, text);
                                            string             root             = string.Format(RegistryMonitor.clusterRegistryPathFormat, iaddatabase.Guid, text);
                                            ManualResetEvent   manualResetEvent = new ManualResetEvent(false);
                                            SafeRegistryHandle safeRegistryHandle;
                                            DiagnosticsNativeMethods.ErrorCode errorCode = DiagnosticsNativeMethods.RegOpenKeyEx(SafeRegistryHandle.LocalMachine, text2, 0, 131097, out safeRegistryHandle);
                                            if (DiagnosticsNativeMethods.ErrorCode.FileNotFound == errorCode)
                                            {
                                                RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(text2);
                                                if (registryKey != null)
                                                {
                                                    registryKey.Close();
                                                    errorCode = DiagnosticsNativeMethods.RegOpenKeyEx(SafeRegistryHandle.LocalMachine, text2, 0, 131097, out safeRegistryHandle);
                                                }
                                            }
                                            if (errorCode != DiagnosticsNativeMethods.ErrorCode.Success)
                                            {
                                                throw new AmRegistryException("RegOpenKeyEx", new Win32Exception((int)errorCode));
                                            }
                                            realRegistry       = new RealRegistry(text2, safeRegistryHandle);
                                            clusterRegistry    = new ClusterRegistry(root, amConfig.DagConfig.Cluster.Handle);
                                            registryReplicator = new RegistryReplicator(realRegistry, clusterRegistry, manualResetEvent);
                                            realRegistry       = null;
                                            clusterRegistry    = null;
                                            if (registryReplicator.IsInitialReplication)
                                            {
                                                registryReplicator.Copy(handle);
                                                registryReplicator.SetInitialReplication();
                                            }
                                            else
                                            {
                                                registryReplicator.InverseCopy();
                                            }
                                            errorCode = DiagnosticsNativeMethods.RegNotifyChangeKeyValue(safeRegistryHandle, true, DiagnosticsNativeMethods.RegistryNotifications.ChangeName | DiagnosticsNativeMethods.RegistryNotifications.ChangeAttributes | DiagnosticsNativeMethods.RegistryNotifications.LastSet, manualResetEvent.SafeWaitHandle, true);
                                            if (errorCode != DiagnosticsNativeMethods.ErrorCode.Success)
                                            {
                                                throw new AmRegistryException("RegNotifyChangeKeyValue", new Win32Exception((int)errorCode));
                                            }
                                            this.replicators.Add(iaddatabase.Guid, registryReplicator);
                                            registryReplicator = null;
                                        }
                                        catch (AmRegistryException ex3)
                                        {
                                            ex2 = ex3;
                                            AmTrace.Warning("Failed to add database to monitor: {0}. Exception: {1}", new object[]
                                            {
                                                iaddatabase.Name,
                                                ex3
                                            });
                                        }
                                        catch (ClusterException ex4)
                                        {
                                            ex2 = ex4;
                                            AmTrace.Warning("Failed to add database to monitor: {0}. Exception: {1}", new object[]
                                            {
                                                iaddatabase.Name,
                                                ex4
                                            });
                                        }
                                        finally
                                        {
                                            if (ex2 != null)
                                            {
                                                ReplayEventLogConstants.Tuple_RegistryReplicatorException.LogEvent(null, new object[]
                                                {
                                                    ex2
                                                });
                                            }
                                            if (registryReplicator != null)
                                            {
                                                registryReplicator.Dispose();
                                                registryReplicator = null;
                                            }
                                            if (realRegistry != null)
                                            {
                                                realRegistry.Dispose();
                                                realRegistry = null;
                                            }
                                            if (clusterRegistry != null)
                                            {
                                                clusterRegistry.Dispose();
                                                clusterRegistry = null;
                                            }
                                        }
                                    }
                                }
                            }
                            list.Clear();
                            foreach (KeyValuePair <Guid, RegistryReplicator> keyValuePair2 in this.replicators)
                            {
                                if (keyValuePair2.Value.IsMarkedForRemoval)
                                {
                                    list.Add(keyValuePair2.Key);
                                }
                            }
                            lock (this.workQueue)
                            {
                                foreach (Guid key2 in list)
                                {
                                    registryReplicator = this.replicators[key2];
                                    registryReplicator.SetInvalid();
                                    if (!registryReplicator.IsCopying)
                                    {
                                        if (!flag)
                                        {
                                            flag = true;
                                        }
                                        this.replicators.Remove(key2);
                                        registryReplicator.Dispose();
                                    }
                                }
                            }
                            registryReplicator = null;
                        }
                        num      = (num + 1) % num2;
                        amConfig = AmSystemManager.Instance.Config;
                        continue;
IL_205:
                        if (!this.stopEvent.WaitOne(5000, false))
                        {
                            goto IL_21B;
                        }
                        break;
                    }
                }
                foreach (KeyValuePair <Guid, RegistryReplicator> keyValuePair3 in this.replicators)
                {
                    if (!keyValuePair3.Value.IsCopying)
                    {
                        keyValuePair3.Value.SetInvalid();
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
コード例 #16
0
        public AmServerName FindNextBestCopy()
        {
            AmServerName    amServerName = null;
            LocalizedString error        = LocalizedString.Empty;
            bool            flag         = false;
            AmBcsChecks     amBcsChecks  = AmBcsChecks.None;

            if (!this.m_fInitialized)
            {
                this.m_bcsWatch.Start();
                try
                {
                    if (this.m_bcsContext.ShouldLogSubactionEvent)
                    {
                        ReplayCrimsonEvents.BcsInitiated.LogGeneric(this.m_bcsContext.PrepareSubaction(new object[]
                        {
                            this.BestCopySelectionType,
                            false
                        }));
                    }
                    bool fDbNeverMounted = false;
                    this.m_perfTracker.RunTimedOperation(BcsOperation.HasDatabaseBeenMounted, delegate
                    {
                        fDbNeverMounted = !AmBestCopySelectionHelper.HasDatabaseBeenMounted(this.m_bcsContext.DatabaseGuid, this.m_amConfig);
                        this.m_bcsContext.DatabaseNeverMounted = fDbNeverMounted;
                    });
                    AmBcsServerValidation serverValidator = new AmBcsServerValidation(this.m_targetServerName, this.m_bcsContext.SourceServerName, this.m_bcsContext.Database, this.m_amConfig, this.m_bcsContext.ErrorLogger, null);
                    AmBcsServerChecks     serverChecks    = AmBcsServerValidation.GetServerValidationChecks(this.m_bcsContext.ActionCode, true);
                    bool serverChecksPassed = false;
                    this.m_perfTracker.RunTimedOperation(BcsOperation.DetermineServersToContact, delegate
                    {
                        serverChecksPassed = serverValidator.RunChecks(serverChecks, ref error);
                    });
                    if (!serverChecksPassed)
                    {
                        goto IL_39C;
                    }
                    if (!fDbNeverMounted && !this.m_bcsContext.ActionCode.IsMountOrRemountOperation)
                    {
                        List <AmServerName> serversToContact = new List <AmServerName>(2);
                        serversToContact.Add(this.m_targetServerName);
                        if (!AmServerName.IsEqual(this.m_bcsContext.SourceServerName, this.m_targetServerName) && (this.m_bcsContext.SkipValidationChecks & AmBcsSkipFlags.SkipActiveCopyChecks) == AmBcsSkipFlags.None)
                        {
                            serversToContact.Add(this.m_bcsContext.SourceServerName);
                        }
                        this.m_perfTracker.RunTimedOperation(BcsOperation.GetCopyStatusRpc, delegate
                        {
                            this.ConstructBcsStatusTable(serversToContact);
                        });
                        AmBcsServerFailureLogger amBcsServerFailureLogger = this.m_bcsContext.ErrorLogger as AmBcsServerFailureLogger;
                        string concatenatedErrorString = amBcsServerFailureLogger.GetConcatenatedErrorString();
                        if (concatenatedErrorString != null)
                        {
                            error = new LocalizedString(concatenatedErrorString);
                            goto IL_39C;
                        }
                    }
                    this.m_fInitialized = true;
                }
                finally
                {
                    this.m_bcsWatch.Stop();
                    this.m_perfTracker.RecordDuration(BcsOperation.BcsOverall, this.m_bcsWatch.Elapsed);
                    this.m_perfTracker.LogEvent();
                }
            }
            if (this.TargetHasBeenTried(ref error))
            {
                this.m_bcsContext.ErrorLogger.ReportServerFailure(this.m_targetServerName, "CopyHasBeenTriedCheck", error, false);
            }
            else
            {
                if (this.m_bcsContext.ActionCode.IsMountOrRemountOperation)
                {
                    amBcsChecks = AmBcsChecks.None;
                    AmTrace.Debug("BCS: FindNextBestCopy: Skipping validation checks for Database '{0}' on server '{1}'.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid(),
                        this.m_targetServerName
                    });
                }
                else if (this.m_bcsContext.DatabaseNeverMounted)
                {
                    amBcsChecks = AmBcsChecks.IsPassiveCopy;
                    AmTrace.Debug("BCS: FindNextBestCopy: Database '{0}' has never been mounted. Running non-status related checks.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid()
                    });
                }
                else
                {
                    if (!this.CheckActiveForMove(ref error))
                    {
                        goto IL_39C;
                    }
                    amBcsChecks = (AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.MaxActivesUnderPreferredLimit);
                }
                RpcDatabaseCopyStatus2 copyStatus = null;
                this.m_bcsContext.StatusTable.TryGetValue(this.m_targetServerName, out copyStatus);
                AmBcsCopyValidation amBcsCopyValidation = new AmBcsCopyValidation(this.m_bcsContext.DatabaseGuid, this.m_bcsContext.GetDatabaseNameOrGuid(), amBcsChecks, this.m_bcsContext.SourceServerName, this.m_targetServerName, copyStatus, this.m_bcsContext.ErrorLogger, this.m_bcsContext.SkipValidationChecks, this.m_bcsContext.ComponentStateWrapper);
                flag        = amBcsCopyValidation.RunChecks(ref error);
                amBcsChecks = amBcsCopyValidation.CompletedChecks;
            }
IL_39C:
            if (flag)
            {
                AmTrace.Info("BCS: FindNextBestCopy: DatabaseCopy: '{0}\\{1}' passed validation checks.", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    this.m_targetServerName.NetbiosName
                });
                amServerName = this.m_targetServerName;
                this.m_serverAlreadyTried = this.m_targetServerName;
                ReplayCrimsonEvents.BcsDbMoveChecksPassed.Log <string, Guid, AmServerName, AmBcsChecks>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, amServerName, amBcsChecks);
            }
            else
            {
                AmTrace.Error("BCS: FindNextBestCopy: DatabaseCopy: '{0}\\{1}'. Checks returned error: {2}", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    this.m_targetServerName.NetbiosName,
                    error
                });
                AmBcsServerFailureLogger amBcsServerFailureLogger2 = this.m_bcsContext.ErrorLogger as AmBcsServerFailureLogger;
                string concatenatedErrorString2 = amBcsServerFailureLogger2.GetConcatenatedErrorString();
                this.m_lastException = new AmBcsSingleCopyValidationException(concatenatedErrorString2);
                ReplayCrimsonEvents.BcsDbMoveChecksFailed.Log <string, Guid, AmServerName, AmBcsChecks, LocalizedString>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, this.m_targetServerName, amBcsChecks, error);
            }
            return(amServerName);
        }
コード例 #17
0
        private void BackgroundCopy(object data)
        {
            int millisecondsTimeout = 5000;
            RegistryReplicator registryReplicator = null;
            bool flag = false;

            while (!this.stopEvent.WaitOne(millisecondsTimeout, false))
            {
                millisecondsTimeout = 5000;
                AmConfig config = AmSystemManager.Instance.Config;
                if (config.IsPamOrSam)
                {
                    AmClusterHandle handle = null;
                    if (flag)
                    {
                        handle = config.DagConfig.Cluster.Handle;
                        flag   = false;
                    }
                    while (this.workQueue.Count > 0 && !this.stopEvent.WaitOne(0, false))
                    {
                        lock (this.workQueue)
                        {
                            registryReplicator = this.workQueue.Dequeue();
                        }
                        Exception ex = null;
                        try
                        {
                            registryReplicator.Copy(handle);
                        }
                        catch (AmRegistryException ex2)
                        {
                            ex = ex2;
                            lock (this.workQueue)
                            {
                                this.workQueue.Enqueue(registryReplicator);
                            }
                        }
                        catch (ClusterException ex3)
                        {
                            ex = ex3;
                            AmTrace.Warning("Caught AmClusterApiException during registry replication: {0}", new object[]
                            {
                                ex3
                            });
                            lock (this.workQueue)
                            {
                                this.workQueue.Enqueue(registryReplicator);
                                millisecondsTimeout = 30000;
                                flag = true;
                                break;
                            }
                        }
                        finally
                        {
                            if (ex != null)
                            {
                                ReplayEventLogConstants.Tuple_RegistryReplicatorException.LogEvent(null, new object[]
                                {
                                    ex
                                });
                            }
                        }
                    }
                }
            }
        }
コード例 #18
0
        public AmServerName FindNextBestCopy()
        {
            AmServerName amServerName = null;
            AmBcsChecks  amBcsChecks  = AmBcsChecks.None;

            try
            {
                this.Initialize();
                List <AmBcsChecks> list = new List <AmBcsChecks>
                {
                    AmBcsChecks.ManagedAvailabilityAllHealthy,
                    AmBcsChecks.ManagedAvailabilityUptoNormalHealthy,
                    AmBcsChecks.ManagedAvailabilityAllBetterThanSource,
                    AmBcsChecks.ManagedAvailabilitySameAsSource
                };
                if (!this.m_bcsContext.ActionCode.IsAutomaticManagedAvailabilityFailover)
                {
                    list.Add(AmBcsChecks.None);
                }
                else
                {
                    amBcsChecks = AmBcsChecks.ManagedAvailabilityInitiatorBetterThanSource;
                }
                if (this.m_bcsContext.DatabaseNeverMounted)
                {
                    AmTrace.Debug("FindNextBestCopy: Database '{0}' has never been mounted. Running non-status related checks.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid()
                    });
                    if (amServerName == null)
                    {
                        amServerName = this.RunPhaseN(AmBcsChecks.IsPassiveCopy);
                    }
                }
                else
                {
                    if (this.m_bcsContext.ActionCode.IsAdminMoveOperation)
                    {
                        AmBcsChecks amBcsChecks2 = AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit;
                        AmBcsChecks amBcsChecks3 = AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit;
                        using (List <AmBcsChecks> .Enumerator enumerator = list.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                AmBcsChecks amBcsChecks4 = enumerator.Current;
                                AmBcsChecks amBcsChecks5 = amBcsChecks4 | amBcsChecks;
                                if (amServerName == null)
                                {
                                    AmBcsChecks amBcsChecks6 = amBcsChecks2 | amBcsChecks5;
                                    AmTrace.Debug("FindNextBestCopy: IsAdminMoveOperation='true', so first attempting '{0}' checks.", new object[]
                                    {
                                        amBcsChecks6
                                    });
                                    amServerName = this.RunPhaseN(amBcsChecks6);
                                }
                                if (amServerName == null)
                                {
                                    AmBcsChecks amBcsChecks7 = amBcsChecks3 | amBcsChecks5;
                                    AmTrace.Debug("FindNextBestCopy: IsAdminMoveOperation='true', so second attempting '{0}' checks.", new object[]
                                    {
                                        amBcsChecks7
                                    });
                                    amServerName = this.RunPhaseN(amBcsChecks7);
                                }
                                if (amServerName != null)
                                {
                                    break;
                                }
                            }
                            goto IL_2FA;
                        }
                    }
                    if (this.m_bcsContext.ActionCode.Reason == AmDbActionReason.CatalogFailureItem)
                    {
                        AmTrace.Debug("FindNextBestCopy: Catalog induced failover, so a healthy catalog must be found", new object[0]);
                        using (List <AmBcsChecks> .Enumerator enumerator2 = list.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                AmBcsChecks amBcsChecks8 = enumerator2.Current;
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks8);
                                }
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks8);
                                }
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks8);
                                }
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks8);
                                }
                                if (amServerName != null)
                                {
                                    break;
                                }
                            }
                            goto IL_2FA;
                        }
                    }
                    foreach (AmBcsChecks amBcsChecks9 in list)
                    {
                        AmBcsChecks amBcsChecks10 = amBcsChecks9 | amBcsChecks;
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.CopyQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null && amBcsChecks10 == AmBcsChecks.None)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName != null)
                        {
                            break;
                        }
                    }
                }
                IL_2FA :;
            }
            finally
            {
                if (!AmServerName.IsNullOrEmpty(amServerName))
                {
                    this.AddAttemptedServer(amServerName);
                }
            }
            if (this.m_attemptedServers == null || this.m_attemptedServers.Count == 0)
            {
                AmTrace.Error("FindNextBestCopy: Database '{0}' has no possible copies for activation.", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid()
                });
                if (this.Context.ErrorLogger.GetLastException() == null)
                {
                    Exception ex = new AmDbNotMountedNoViableServersException(this.m_bcsContext.GetDatabaseNameOrGuid());
                    this.m_lastException = new AmBcsSelectionException(ex.Message, ex);
                }
            }
            return(amServerName);
        }
コード例 #19
0
 // Token: 0x06000062 RID: 98 RVA: 0x000034CC File Offset: 0x000016CC
 protected virtual void PopulateWithDatabaseOperations(Dictionary <Guid, DatabaseInfo> dbMap)
 {
     foreach (DatabaseInfo databaseInfo in dbMap.Values)
     {
         databaseInfo.Analyze();
         if (this.m_isDebugOptionEnabled && this.m_amConfig.IsIgnoreServerDebugOptionEnabled(databaseInfo.ActiveServer))
         {
             AmTrace.Warning("Batchmounter operation for database {0} is not performed since debug option {1} is set for server {2} which is the current active for the database", new object[]
             {
                 databaseInfo.Database.Name,
                 databaseInfo.ActiveServer.NetbiosName,
                 AmDebugOptions.IgnoreServerFromAutomaticActions.ToString()
             });
         }
         else
         {
             List <AmDbOperation> list     = new List <AmDbOperation>();
             IADDatabase          database = databaseInfo.Database;
             if (databaseInfo.IsMountedButAdminRequestedDismount)
             {
                 AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Admin, this.m_reasonCode, AmDbActionCategory.Dismount);
                 AmDbDismountAdminDismountedOperation item = new AmDbDismountAdminDismountedOperation(database, actionCode);
                 list.Add(item);
                 this.m_dismountRequests++;
             }
             else
             {
                 if (databaseInfo.IsMismounted)
                 {
                     AmDbActionCode actionCode2            = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.ForceDismount);
                     AmDbDismountMismountedOperation item2 = new AmDbDismountMismountedOperation(database, actionCode2, databaseInfo.MisMountedServerList);
                     list.Add(item2);
                     this.m_dismountRequests++;
                 }
                 if (databaseInfo.IsActiveOnDisabledServer && !this.AllCopiesAreDisfavored(database))
                 {
                     list.Add(this.BuildMoveForActivationDisabled(database));
                     this.m_moveRequests++;
                 }
                 if (!databaseInfo.IsMountedOnActive)
                 {
                     AmDbActionCode     actionCode3 = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.Mount);
                     AmDbMountOperation item3       = new AmDbMountOperation(database, actionCode3);
                     list.Add(item3);
                     this.m_mountRequests++;
                 }
                 if (databaseInfo.IsClusterDatabaseOutOfSync)
                 {
                     AmDbActionCode actionCode4             = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.SyncState);
                     AmDbClusterDatabaseSyncOperation item4 = new AmDbClusterDatabaseSyncOperation(database, actionCode4);
                     list.Add(item4);
                     this.m_clusDbSyncRequests++;
                 }
                 if (databaseInfo.IsAdPropertiesOutOfSync)
                 {
                     AmDbActionCode actionCode5        = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.SyncAd);
                     AmDbAdPropertySyncOperation item5 = new AmDbAdPropertySyncOperation(database, actionCode5);
                     list.Add(item5);
                     this.m_adSyncRequests++;
                 }
             }
             databaseInfo.OperationsQueued = list;
         }
     }
 }
コード例 #20
0
        protected override void TimerCallbackInternal()
        {
            List <Guid> list = null;

            lock (this.m_cacheLock)
            {
                if (this.m_allDatabasesCached == null || this.m_allDatabasesCached.Count == 0)
                {
                    ExTraceGlobals.AmConfigManagerTracer.TraceDebug(0L, "AmPerfCounterUpdater: No configurations have been discovered, so nothing to do! Exiting.");
                    return;
                }
                list = new List <Guid>(this.m_allDatabasesCached);
            }
            Exception ex = null;

            MdbStatus[] array = null;
            if (AmStoreHelper.GetAllDatabaseStatuses(null, false, out array, out ex))
            {
                Dictionary <Guid, string> dictionary = new Dictionary <Guid, string>(array.Length);
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] != null && (array[i].Status & MdbStatusFlags.Online) == MdbStatusFlags.Online)
                    {
                        try
                        {
                            dictionary.Add(array[i].MdbGuid, array[i].MdbName);
                        }
                        catch (ArgumentException)
                        {
                            ExTraceGlobals.AmConfigManagerTracer.TraceDebug <Guid, string>(0L, "AmPerfCounterUpdater: Database {0} ({1}) was returned more than once from GetAllDatabasesStatuses.", array[i].MdbGuid, array[i].MdbName);
                        }
                    }
                }
                AmStoreHelper.UpdateNumberOfDatabasesCounter(list.Count);
                foreach (Guid guid in list)
                {
                    string empty = string.Empty;
                    if (dictionary.TryGetValue(guid, out empty))
                    {
                        AmStoreHelper.UpdateIsMountedCounter(guid, empty, true, false);
                    }
                    else
                    {
                        AmStoreHelper.UpdateIsMountedCounter(guid, null, false, false);
                    }
                    IADDatabase database = Dependencies.ADConfig.GetDatabase(guid);
                    if (database != null)
                    {
                        MountStatus? mountStatus;
                        string       activeServerForDatabase = ReplicaInstance.GetActiveServerForDatabase(guid, database.Name, new AmServerName(database.Server.Name).Fqdn, out mountStatus);
                        AmServerName amServerName            = new AmServerName(activeServerForDatabase);
                        AmStoreHelper.UpdateCopyRoleIsActivePerfCounter(guid, empty, amServerName.IsLocalComputerName);
                    }
                    else
                    {
                        ExTraceGlobals.AmConfigManagerTracer.TraceError <Guid>(0L, "AmPerfCounterUpdater: Failed to get the database for guid {0}", guid);
                    }
                }
                return;
            }
            AmTrace.Error("AmPerfCounterUpdater: Failed to get mounted database information from store. Exception: {0}", new object[]
            {
                ex
            });
        }
コード例 #21
0
        internal void MountDatabaseDirect(Guid mdbGuid, MountFlags storeFlags, AmMountFlags amMountFlags, AmDbActionCode actionCode)
        {
            AmTrace.Debug("MountDatabaseDirect called. (Guid={0}, StoreFlags={1}, AmMountFlags={2} ActionCode={3})", new object[]
            {
                mdbGuid,
                storeFlags,
                amMountFlags,
                actionCode
            });
            AmConfig config = AmSystemManager.Instance.Config;

            if (!config.IsUnknown)
            {
                bool flag = false;
                LogStreamResetOnMount         logReset  = null;
                MountDirectPerformanceTracker mountPerf = new MountDirectPerformanceTracker(mdbGuid);
                ReplicaInstanceContext        replicaInstanceContext = null;
                try
                {
                    int         actualMountFlags = (int)storeFlags;
                    IADDatabase db = this.AdLookup.DatabaseLookup.FindAdObjectByGuidEx(mdbGuid, AdObjectLookupFlags.None);
                    if (db == null)
                    {
                        throw new AmDatabaseNotFoundException(mdbGuid);
                    }
                    if (AmSystemManager.Instance.IsSystemShutdownInProgress)
                    {
                        ReplayCrimsonEvents.MountRejectedSinceSystemShutdownInProgress.Log <string, Guid, ExDateTime?>(db.Name, mdbGuid, AmSystemManager.Instance.SystemShutdownStartTime);
                        throw new AmInvalidConfiguration(string.Empty);
                    }
                    ExTraceGlobals.FaultInjectionTracer.TraceTest(2198220093U);
                    mountPerf.RunTimedOperation(MountDatabaseDirectOperation.AmPreMountCallback, delegate
                    {
                        this.m_replicaInstanceManager.AmPreMountCallback(mdbGuid, ref actualMountFlags, amMountFlags, mountPerf, out logReset, out replicaInstanceContext);
                    });
                    mountPerf.RunTimedOperation(MountDatabaseDirectOperation.RegistryReplicatorCopy, delegate
                    {
                        this.m_registryMonitor.PreMountCopy(mdbGuid, db.IsPublicFolderDatabase);
                    });
                    if (replicaInstanceContext != null)
                    {
                        replicaInstanceContext.IsReplayDatabaseDismountPending = false;
                    }
                    ExTraceGlobals.FaultInjectionTracer.TraceTest(2166762813U);
                    try
                    {
                        mountPerf.RunTimedOperation(MountDatabaseDirectOperation.StoreMount, delegate
                        {
                            AmStoreHelper.Mount(mdbGuid, (MountFlags)actualMountFlags);
                        });
                    }
                    catch (MapiExceptionDismountInProgress mapiExceptionDismountInProgress)
                    {
                        AmTrace.Error("AmStoreHelper.Mount encountered exception {0}", new object[]
                        {
                            mapiExceptionDismountInProgress
                        });
                        mountPerf.IsDismountInProgress = true;
                        throw;
                    }
                    ((ReplicaInstanceManager)this.m_replicaInstanceManager).ClearLossyMountRecord(mdbGuid);
                    ((ReplicaInstanceManager)this.m_replicaInstanceManager).ClearLastAcllRunWithSkipHealthChecksRecord(mdbGuid);
                    AmTrace.Debug("MountDatabaseDirect initiating UpdateReplicationContentIndexing() asynchronously for DB '{0}'.", new object[]
                    {
                        mdbGuid
                    });
                    ThreadPool.QueueUserWorkItem(delegate(object obj)
                    {
                        Exception ex = ReplicaInstance.UpdateReplicationContentIndexing();
                        if (ex != null)
                        {
                            AmTrace.Error("MountDatabaseDirect background call of UpdateReplicationContentIndexing() failed for DB '{0}'. Exception: {1}", new object[]
                            {
                                (Guid)obj,
                                ex
                            });
                        }
                    }, mdbGuid);
                    this.DetermineWorkerProcessId(mdbGuid);
                    this.m_registryMonitor.PostMountCopy();
                    flag = true;
                    return;
                }
                finally
                {
                    if (replicaInstanceContext != null)
                    {
                        replicaInstanceContext.BestEffortDismountReplayDatabase();
                    }
                    if (logReset != null && logReset.ResetPending)
                    {
                        if (flag)
                        {
                            mountPerf.RunTimedOperation(MountDatabaseDirectOperation.ConfirmLogReset, delegate
                            {
                                logReset.ConfirmLogReset();
                            });
                            Dependencies.ConfigurationUpdater.NotifyChangedReplayConfiguration(mdbGuid, false, true, true, true, ReplayConfigChangeHints.AmPreMountCallbackLogStreamReset, -1);
                        }
                        else
                        {
                            logReset.CancelLogReset();
                        }
                    }
                    mountPerf.LogEvent();
                }
            }
            AmTrace.Error("MountDatabaseDirect: AmConfig is invalid!", new object[0]);
            throw new AmInvalidConfiguration(config.LastError);
        }
コード例 #22
0
        // Token: 0x0600045A RID: 1114 RVA: 0x00016E6C File Offset: 0x0001506C
        public static bool TryStart(ActiveManagerCore amInstance)
        {
            bool fRpcServerStarted;

            lock (AmRpcServer.m_locker)
            {
                if (!AmRpcServer.m_fRpcServerStarted)
                {
                    AmTrace.Debug("Starting Active Manager Rpc", new object[0]);
                    AmRpcServer.m_amInstance = amInstance;
                    try
                    {
                        FileSecurity activeManagerRpcSecurity = Microsoft.Exchange.Cluster.Replay.ObjectSecurity.ActiveManagerRpcSecurity;
                        if (activeManagerRpcSecurity != null)
                        {
                            AmRpcServer.m_rpcServer = (AmRpcServer)RpcServerBase.RegisterServer(typeof(AmRpcServer), activeManagerRpcSecurity, 1, false, (uint)RegistryParameters.MaximumRpcThreadCount);
                            if (AmRpcServer.m_rpcServer != null)
                            {
                                AmTrace.Debug("Active Manager Rpc server successfully started.", new object[0]);
                                AmRpcServer.m_fRpcServerStarted = true;
                            }
                        }
                        if (AmRpcServer.m_rpcServer == null)
                        {
                            AmTrace.Error("Active Manager Rpc server failed to start!", new object[0]);
                            ReplayEventLogConstants.Tuple_AmRpcServerFailedToStart.LogEvent(null, new object[0]);
                        }
                        goto IL_1BF;
                    }
                    catch (RpcException ex)
                    {
                        AmTrace.Error("RPC Error occurred while trying to register the Active Manager RPC Server. Exception: {0}", new object[]
                        {
                            ex.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToRegister.LogEvent(null, new object[]
                        {
                            ex.Message
                        });
                        goto IL_1BF;
                    }
                    catch (ADTransientException ex2)
                    {
                        AmTrace.Error("Transient exception occurred while retrieving the ActiveManagerRpcSecurity object. Exception: {0}", new object[]
                        {
                            ex2.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToFindExchangeServersUsg.LogEvent(null, new object[]
                        {
                            ex2.Message
                        });
                        goto IL_1BF;
                    }
                    catch (ADExternalException ex3)
                    {
                        AmTrace.Error("Start(): Permanent exception occurred while retrieving the ActiveManagerRpcSecurity object. Exception: {0}", new object[]
                        {
                            ex3.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToFindExchangeServersUsg.LogEvent(null, new object[]
                        {
                            ex3.Message
                        });
                        goto IL_1BF;
                    }
                    catch (ADOperationException ex4)
                    {
                        AmTrace.Error("Start(): Permanent exception occurred while retrieving the ActiveManagerRpcSecurity object. Exception: {0}", new object[]
                        {
                            ex4.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToFindExchangeServersUsg.LogEvent(null, new object[]
                        {
                            ex4.Message
                        });
                        goto IL_1BF;
                    }
                }
                AmTrace.Debug("Active Manager RPC server already started.", new object[0]);
IL_1BF:
                fRpcServerStarted = AmRpcServer.m_fRpcServerStarted;
            }
            return(fRpcServerStarted);
        }
コード例 #23
0
        private void PerformRecoveryInternal()
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsSAM)
            {
                AmServerName currentPAM = config.DagConfig.CurrentPAM;
                if (!AmServerName.IsEqual(this.pamServerInVerificationPhase, currentPAM))
                {
                    ReplayCrimsonEvents.PamMonitorMoveSkippedSinceServerChanged.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, currentPAM);
                    return;
                }
                List <AmServerName>    list = config.DagConfig.MemberServers.ToList <AmServerName>();
                AmMultiNodeRoleFetcher amMultiNodeRoleFetcher = new AmMultiNodeRoleFetcher(list, TimeSpan.FromSeconds((double)RegistryParameters.PamMonitorRoleCheckTimeoutInSec), false);
                amMultiNodeRoleFetcher.Run();
                Dictionary <AmServerName, AmRole> roleMap = amMultiNodeRoleFetcher.RoleMap;
                string text = string.Join("\n", (from kvp in roleMap
                                                 select string.Format("[{0}] => {1}", kvp.Key, kvp.Value)).ToArray <string>());
                ReplayCrimsonEvents.PamMonitorServerRolesView.Log <string>(text);
                int count = list.Count;
                int num   = roleMap.Count((KeyValuePair <AmServerName, AmRole> kvp) => kvp.Value == AmRole.SAM);
                int num2  = count / 2 + 1;
                if (num < num2)
                {
                    ReplayCrimsonEvents.PamMonitorMoveCancelledSinceMinimumRequiredNotMet.Log <int, int, int>(count, num, num2);
                    return;
                }
                List <AmServerName> list2 = new List <AmServerName>(roleMap.Count);
                List <AmServerName> list3 = new List <AmServerName>(roleMap.Count);
                foreach (KeyValuePair <AmServerName, AmRole> keyValuePair in roleMap)
                {
                    if (!this.IsServerDisabled(keyValuePair.Key))
                    {
                        if (keyValuePair.Value == AmRole.PAM)
                        {
                            ReplayCrimsonEvents.PamMonitorMoveSkippedDueToValidResponseFromPAM.Log <AmServerName>(keyValuePair.Key);
                            return;
                        }
                        if (keyValuePair.Value == AmRole.SAM)
                        {
                            if (keyValuePair.Key.CompareTo(currentPAM) > 0)
                            {
                                list2.Add(keyValuePair.Key);
                            }
                            else
                            {
                                list3.Add(keyValuePair.Key);
                            }
                        }
                    }
                }
                list2.Sort();
                list3.Sort();
                AmServerName[] array = new AmServerName[list2.Count + list3.Count];
                list2.CopyTo(array);
                list3.CopyTo(array, list2.Count);
                bool flag = false;
                foreach (AmServerName amServerName in array)
                {
                    if (flag)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(5.0));
                        currentPAM = config.DagConfig.CurrentPAM;
                        if (!AmServerName.IsEqual(this.pamServerInVerificationPhase, currentPAM))
                        {
                            ReplayCrimsonEvents.PamMonitorMoveSkippedSinceServerChanged.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, currentPAM);
                            return;
                        }
                    }
                    try
                    {
                        ReplayCrimsonEvents.PamMonitorBeginsToMovePAM.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, amServerName);
                        AmClusterGroup.MoveClusterGroupWithTimeout(AmServerName.LocalComputerName, amServerName, TimeSpan.FromSeconds((double)RegistryParameters.PamMonitorMoveClusterGroupTimeout));
                        ReplayCrimsonEvents.PamMonitorSuccessfulyMovedPAM.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, amServerName);
                        return;
                    }
                    catch (ClusterException ex)
                    {
                        flag = true;
                        AmTrace.Error("PAM election failed for {0} : {1}", new object[]
                        {
                            amServerName,
                            ex
                        });
                        ReplayCrimsonEvents.PamMonitorEncounteredException.Log <string, string>(ex.Message, "MoveClusterGroup");
                    }
                }
                ReplayCrimsonEvents.PamMonitorCouldNotFindValidServerToMovePAM.Log();
            }
        }
コード例 #24
0
 private void WaitForStart()
 {
     this.m_serviceProcessId = -1;
     AmServiceMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "WaitForStart({0}) called", this.ServiceName);
     while (!this.m_fShutdown)
     {
         try
         {
             if (this.CheckServiceStatus(ServiceControllerStatus.Running) && this.IsServiceReady())
             {
                 Exception ex;
                 using (Process serviceProcess = ServiceOperations.GetServiceProcess(this.ServiceName, out ex))
                 {
                     if (serviceProcess != null)
                     {
                         Exception ex2 = null;
                         try
                         {
                             this.m_serviceProcessId        = serviceProcess.Id;
                             this.m_serviceProcessStartTime = serviceProcess.StartTime;
                             break;
                         }
                         catch (Win32Exception ex3)
                         {
                             ex2 = ex3;
                         }
                         catch (InvalidOperationException ex4)
                         {
                             ex2 = ex4;
                         }
                         if (ex2 != null)
                         {
                             AmTrace.Error("Service status for {0} is Running, but unable to read the process object details. Ex = {1}", new object[]
                             {
                                 this.ServiceName,
                                 ex2
                             });
                             this.m_serviceProcessId = -1;
                         }
                     }
                     else
                     {
                         AmTrace.Error("Service status for {0} is Running, but unable to get the process object", new object[]
                         {
                             this.ServiceName
                         });
                     }
                 }
             }
             if (this.m_shutdownEvent.WaitOne(5000, false))
             {
                 break;
             }
             this.OnWaitingForStart();
         }
         catch (Win32Exception e)
         {
             if (!this.HandleKnownException(e))
             {
                 throw;
             }
         }
         catch (InvalidOperationException e2)
         {
             if (!this.HandleKnownException(e2))
             {
                 throw;
             }
         }
     }
 }
コード例 #25
0
 // Token: 0x06000803 RID: 2051 RVA: 0x00026F7C File Offset: 0x0002517C
 internal void Error(string format, params object[] args)
 {
     AmTrace.Error(this.PrefixDatabase(format), args);
 }
コード例 #26
0
        // Token: 0x060004DB RID: 1243 RVA: 0x0001A0D0 File Offset: 0x000182D0
        internal static Exception TryCrashingStoreGracefully()
        {
            Exception       ex                   = null;
            Process         storeProcess         = null;
            EventWaitHandle crashControlAckEvent = null;

            try
            {
                ReplayCrimsonEvents.InitiatingGracefulStoreCrash.Log();
                storeProcess = ServiceOperations.GetServiceProcess("MSExchangeIS", out ex);
                if (ex == null)
                {
                    ex = ServiceOperations.RunOperation(delegate(object param0, EventArgs param1)
                    {
                        if (!RegistryParameters.KillStoreInsteadOfWatsonOnTimeout)
                        {
                            crashControlAckEvent = new EventWaitHandle(false, EventResetMode.ManualReset, "Global\\17B584B2-A9E0-45CF-87CB-7774112D6CB9");
                            ThreadPool.QueueUserWorkItem(delegate(object param0)
                            {
                                Exception ex2 = ServiceOperations.ControlService("MSExchangeIS", 130);
                                if (ex2 != null)
                                {
                                    AmTrace.Debug("ControlService() failed with {0}", new object[]
                                    {
                                        ex2.Message
                                    });
                                }
                            });
                        }
                        else
                        {
                            AmTrace.Diagnostic("Killing store instead of taking a Watson dump due to registry override.", new object[0]);
                        }
                        if (crashControlAckEvent != null)
                        {
                            if (crashControlAckEvent.WaitOne(RegistryParameters.StoreCrashControlCodeAckTimeoutInMSec))
                            {
                                AmStoreServiceMonitor.ReportKillStarted();
                                Stopwatch stopwatch = new Stopwatch();
                                stopwatch.Start();
                                if (!storeProcess.WaitForExit(RegistryParameters.StoreWatsonDumpTimeoutInMSec))
                                {
                                    AmTrace.Diagnostic("Store process did not finish taking dump in {0} msecs", new object[]
                                    {
                                        RegistryParameters.StoreWatsonDumpTimeoutInMSec
                                    });
                                }
                                else
                                {
                                    AmTrace.Diagnostic("Store process finished taking dump in {0} msecs", new object[]
                                    {
                                        stopwatch.Elapsed.TotalMilliseconds
                                    });
                                }
                            }
                            else
                            {
                                AmTrace.Diagnostic("Store failed to acknowledge that it received the crash control code in {0} msecs.", new object[]
                                {
                                    RegistryParameters.StoreCrashControlCodeAckTimeoutInMSec
                                });
                                AmStoreServiceMonitor.ReportKillStarted();
                            }
                        }
                        else
                        {
                            AmStoreServiceMonitor.ReportKillStarted();
                        }
                        if (!storeProcess.HasExited)
                        {
                            if (crashControlAckEvent != null)
                            {
                                AmTrace.Diagnostic("Store process is still running even after the graceful attempt. Force killing it.", new object[0]);
                            }
                            storeProcess.Kill();
                            TimeSpan timeSpan = TimeSpan.FromMilliseconds((double)RegistryParameters.StoreKillBugcheckTimeoutInMSec);
                            if (!storeProcess.WaitForExit(RegistryParameters.StoreKillBugcheckTimeoutInMSec))
                            {
                                ExDateTime storeKillBugcheckDisabledTime = RegistryParameters.StoreKillBugcheckDisabledTime;
                                string text = string.Format("Store process is still running {0} secs after attempt to force kill it.", timeSpan.TotalSeconds);
                                if (storeKillBugcheckDisabledTime > ExDateTime.UtcNow)
                                {
                                    AmTrace.Debug("Store bugcheck has been disabled by regkey '{0}' until '{1}'.", new object[]
                                    {
                                        "StoreKillBugcheckDisabledTime",
                                        storeKillBugcheckDisabledTime
                                    });
                                    ReplayCrimsonEvents.StoreBugCheckDisabledUntilTime.LogPeriodic <string, string, ExDateTime>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, text, "StoreKillBugcheckDisabledTime", storeKillBugcheckDisabledTime);
                                    return;
                                }
                                AmTrace.Debug("Attempting to bugcheck the system. Reason: {0}", new object[]
                                {
                                    text
                                });
                                BugcheckHelper.TriggerBugcheckIfRequired(DateTime.UtcNow, text);
                                return;
                            }
                            else
                            {
                                AmTrace.Diagnostic("Store process has been forcefully killed.", new object[0]);
                            }
                        }
                    });
                }
            }
            finally
            {
                ReplayCrimsonEvents.FinishedGracefulStoreCrash.Log <string>((ex != null) ? ex.Message : "<none>");
                if (crashControlAckEvent != null)
                {
                    crashControlAckEvent.Close();
                }
                if (storeProcess != null)
                {
                    storeProcess.Dispose();
                }
            }
            return(ex);
        }
コード例 #27
0
        // Token: 0x06000498 RID: 1176 RVA: 0x000189B0 File Offset: 0x00016BB0
        internal static void RemoteDismount(AmServerName serverName, Guid mdbGuid, UnmountFlags flags, bool retryOnConflict)
        {
            bool      isCheckDbStatus = true;
            bool      isMounted       = true;
            Exception ex = null;

            try
            {
                AmTrace.Debug("RemoteDismount() starting for DB {0} on server {1}. UnmountFlags = {2}, retryOnConflict = {3}", new object[]
                {
                    mdbGuid,
                    serverName,
                    flags,
                    retryOnConflict
                });
                ReplayCrimsonEvents.DismountStoreRpcInitiated.Log <AmServerName, Guid, UnmountFlags, bool>(serverName, mdbGuid, flags, retryOnConflict);
                using (IStoreMountDismount storeMountDismountInstance = Dependencies.GetStoreMountDismountInstance(AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn))
                {
                    if (!retryOnConflict)
                    {
                        storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                        isCheckDbStatus = false;
                        isMounted       = false;
                        AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                        {
                            mdbGuid
                        });
                    }
                    else
                    {
                        bool      flag      = false;
                        Stopwatch stopwatch = new Stopwatch();
                        stopwatch.Start();
                        for (;;)
                        {
                            try
                            {
                                storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                                isCheckDbStatus = false;
                                isMounted       = false;
                                AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                                {
                                    mdbGuid
                                });
                            }
                            catch (MapiRetryableException ex2)
                            {
                                AmTrace.Error("rpcAdmin.UnmountDatabase({0}) encountered {1}.", new object[]
                                {
                                    mdbGuid,
                                    ex2.Message
                                });
                                if (!(ex2 is MapiExceptionDismountInProgress))
                                {
                                    throw;
                                }
                                if (!flag)
                                {
                                    ReplayCrimsonEvents.DismountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, ex2.Message);
                                    flag = true;
                                }
                                if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                                {
                                    throw;
                                }
                                if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                                {
                                    AmTrace.Debug("shutdown requested - hence not retrying dismount for database {0}", new object[]
                                    {
                                        mdbGuid
                                    });
                                    throw;
                                }
                                continue;
                            }
                            break;
                        }
                    }
                }
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex3.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex3))
                {
                    throw;
                }
            }
            catch (MapiRetryableException ex4)
            {
                ex = ex4;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex4.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex4))
                {
                    throw;
                }
            }
            finally
            {
                ReplayCrimsonEvents.DismountStoreRpcFinished.Log <AmServerName, Guid, string>(serverName, mdbGuid, (ex != null) ? ex.Message : "<none>");
                if (AmServerName.IsNullOrEmpty(serverName) || AmServerName.IsEqual(AmServerName.LocalComputerName, serverName))
                {
                    AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, isMounted, isCheckDbStatus);
                }
            }
        }
コード例 #28
0
        private IADDatabase[] GetDatabasesToMonitor()
        {
            List <IADDatabase> list = new List <IADDatabase>();

            try
            {
                IADServer localServer = this.adConfig.GetLocalServer();
                if (localServer != null)
                {
                    IEnumerable <IADDatabase> databasesOnServer = this.adConfig.GetDatabasesOnServer(localServer);
                    if (databasesOnServer == null)
                    {
                        goto IL_CF;
                    }
                    using (IEnumerator <IADDatabase> enumerator = databasesOnServer.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            IADDatabase iaddatabase = enumerator.Current;
                            try
                            {
                                string name;
                                ActiveManagerCore.GetDatabaseMountStatus(iaddatabase.Guid, out name);
                                if (string.IsNullOrEmpty(name))
                                {
                                    name = iaddatabase.Server.Name;
                                }
                                if (Cluster.StringIEquals(name, localServer.Name))
                                {
                                    list.Add(iaddatabase);
                                }
                            }
                            catch (AmGetFqdnFailedNotFoundException ex)
                            {
                                AmTrace.Error("RegistryMonitor.GetDatabasesToMonitor ignoring db {0} due to {1}", new object[]
                                {
                                    iaddatabase.Guid,
                                    ex
                                });
                            }
                        }
                        goto IL_CF;
                    }
                }
                AmTrace.Warning("FindLocalServer() failed.", new object[0]);
                IL_CF :;
            }
            catch (AmCommonTransientException ex2)
            {
                AmTrace.Warning("GetDatabasesToMonitor() failed with {0}", new object[]
                {
                    ex2
                });
            }
            catch (ADTransientException ex3)
            {
                AmTrace.Warning("GetDatabasesToMonitor() failed with {0}", new object[]
                {
                    ex3
                });
            }
            catch (ADExternalException ex4)
            {
                AmTrace.Warning("GetDatabasesToMonitor() failed with {0}", new object[]
                {
                    ex4
                });
            }
            catch (ADOperationException ex5)
            {
                AmTrace.Warning("GetDatabasesToMonitor() failed with {0}", new object[]
                {
                    ex5
                });
            }
            catch (ClusterException ex6)
            {
                AmTrace.Warning("GetDatabasesToMonitor() failed with {0}", new object[]
                {
                    ex6
                });
            }
            return(list.ToArray());
        }
コード例 #29
0
 protected override void OnStart()
 {
     AmTrace.Debug("Cluster service start detected. Notifying config manager to refresh configuration", new object[0]);
     AmSystemManager.Instance.ConfigManager.TriggerRefresh(true);
 }
コード例 #30
0
        // Token: 0x060002E7 RID: 743 RVA: 0x000103F8 File Offset: 0x0000E5F8
        protected override void MoveInternal(MountFlags storeMountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, string componentName, ref AmDbOperationDetailedStatus moveStatus)
        {
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
            IBestCopySelector    bestCopySelector   = null;
            Exception            ex = null;
            bool flag = false;
            int  num  = 0;
            int  natSkippedServersCount = 0;

            if (!base.State.IsEntryExist)
            {
                base.DbTrace.Error("Database was never mounted. Move is applicable only if it was mounted at least once", new object[0]);
                throw new AmDatabaseNeverMountedException();
            }
            if (base.State.IsAdminDismounted)
            {
                AmTrace.Diagnostic("Moving a dismounted database {0}. The database will be moved, but won't be mounted", new object[]
                {
                    base.DatabaseName
                });
            }
            moveStatus.InitialDbState = base.State.Copy();
            AmServerName       activeServer       = base.State.ActiveServer;
            AmAcllReturnStatus amAcllReturnStatus = null;
            bool flag2 = true;

            try
            {
                this.CheckIfMoveApplicableForDatabase(base.State.ActiveServer, fromServer, base.ActionCode);
                bestCopySelector = this.ConstructBestCopySelector(tryOtherHealthyServers, skipValidationChecks, null, activeServer, targetServer, mountDialoverride, componentName);
                if (base.ActionCode.IsAutomaticShutdownSwitchover)
                {
                    base.AttemptDismount(base.State.ActiveServer, dismountFlags, true, out ex);
                    flag = true;
                }
                AmServerName amServerName = bestCopySelector.FindNextBestCopy();
                while (amServerName != null)
                {
                    num++;
                    if (!flag)
                    {
                        base.AttemptDismount(activeServer, dismountFlags, true, out ex);
                        flag = true;
                    }
                    AmMountFlags amMountFlags = AmMountFlags.None;
                    if (BitMasker.IsOn((int)skipValidationChecks, 4))
                    {
                        amMountFlags = AmMountFlags.MoveWithSkipHealth;
                    }
                    this.AttemptMountOnServer(amServerName, base.State.ActiveServer, storeMountFlags, amMountFlags, dismountFlags, mountDialoverride, skipValidationChecks, tryOtherHealthyServers, ref natSkippedServersCount, ref amAcllReturnStatus, out ex);
                    base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
                    {
                        amAcllReturnStatus
                    });
                    moveStatus.AddSubstatus(new AmDbOperationSubStatus(amServerName, amAcllReturnStatus, ex));
                    if (ex == null)
                    {
                        flag2 = false;
                        break;
                    }
                    bestCopySelector.ErrorLogger.ReportServerFailure(amServerName, "CopyHasBeenTriedCheck", ex.Message);
                    if (ex is AmRoleChangedWhileOperationIsInProgressException)
                    {
                        flag2 = false;
                        break;
                    }
                    if (ex is AmMountTimeoutException)
                    {
                        flag2 = false;
                        break;
                    }
                    amServerName = bestCopySelector.FindNextBestCopy();
                    base.CurrentAttemptNumber++;
                }
            }
            finally
            {
                moveStatus.FinalDbState = base.State.Copy();
            }
            if (flag2)
            {
                MountStatus storeDatabaseMountStatus = AmStoreHelper.GetStoreDatabaseMountStatus(base.State.ActiveServer, base.Database.Guid);
                if (storeDatabaseMountStatus != base.State.MountStatus)
                {
                    ReplayCrimsonEvents.MismatchErrorAfterMove.Log <string, Guid, AmServerName, MountStatus, MountStatus>(base.Database.Name, base.Database.Guid, base.State.ActiveServer, base.State.MountStatus, storeDatabaseMountStatus);
                    if (storeDatabaseMountStatus == MountStatus.Dismounted)
                    {
                        base.State.MountStatus = MountStatus.Dismounted;
                        base.WriteState();
                    }
                }
            }
            this.CheckActionResultsAndUpdateAdProperties(activeServer, targetServer, bestCopySelector, ex, num, natSkippedServersCount);
        }