コード例 #1
0
        // Token: 0x0600049B RID: 1179 RVA: 0x00018C94 File Offset: 0x00016E94
        internal static MountStatus GetStoreDatabaseMountStatus(AmServerName serverName, Guid mdbGuid)
        {
            Exception   ex        = null;
            MountStatus result    = MountStatus.Unknown;
            MdbStatus   mdbStatus = AmStoreHelper.GetMdbStatus(serverName, mdbGuid, out ex);

            if (ex == null)
            {
                if (mdbStatus != null)
                {
                    if ((mdbStatus.Status & MdbStatusFlags.Online) == MdbStatusFlags.Online)
                    {
                        result = MountStatus.Mounted;
                    }
                    else
                    {
                        result = MountStatus.Dismounted;
                    }
                }
                else
                {
                    result = MountStatus.Dismounted;
                }
            }
            else if (AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex))
            {
                result = MountStatus.Dismounted;
            }
            return(result);
        }
コード例 #2
0
        // Token: 0x06000496 RID: 1174 RVA: 0x00018950 File Offset: 0x00016B50
        internal static Exception Dismount(Guid mdbGuid, UnmountFlags flags)
        {
            Exception result = null;

            if ((flags & UnmountFlags.SkipCacheFlush) == UnmountFlags.SkipCacheFlush)
            {
                result = AmStoreHelper.DismountWithKillOnTimeout(mdbGuid, flags, true);
            }
            else
            {
                try
                {
                    AmStoreHelper.RemoteDismount(null, mdbGuid, flags, true);
                }
                catch (MapiRetryableException ex)
                {
                    result = ex;
                }
                catch (MapiPermanentException ex2)
                {
                    result = ex2;
                }
            }
            return(result);
        }
        // Token: 0x060002DA RID: 730 RVA: 0x0000FFC0 File Offset: 0x0000E1C0
        protected override void RunInternal()
        {
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                this.CheckIfOperationIsAllowedOnCurrentRole();
                AmDbStateInfo amDbStateInfo = AmSystemManager.Instance.Config.DbState.Read(base.Database.Guid);
                if (!amDbStateInfo.IsAdminDismounted)
                {
                    AmTrace.Debug("AmDbDismountAdminDismountedOperation skipped since database is not marked as admin dismounted anymore", new object[0]);
                    return;
                }
                MountStatus storeDatabaseMountStatus = AmStoreHelper.GetStoreDatabaseMountStatus(null, base.Database.Guid);
                if (storeDatabaseMountStatus == MountStatus.Mounted)
                {
                    AmDbAction amDbAction = base.PrepareDbAction(this.ActionCode);
                    ReplayCrimsonEvents.DismountingAdminDismountRequestedDatabase.Log <string, Guid, AmServerName>(base.Database.Name, base.Database.Guid, amDbStateInfo.ActiveServer);
                    amDbAction.Dismount(UnmountFlags.None);
                    return;
                }
                AmTrace.Debug("AmDbDismountAdminDismountedOperation skipped since database is not mounted (db={0}, mountStatus={1})", new object[]
                {
                    base.Database.Name,
                    storeDatabaseMountStatus
                });
            });

            base.LastException = lastException;
        }
コード例 #4
0
 // Token: 0x060004A4 RID: 1188 RVA: 0x0001907C File Offset: 0x0001727C
 internal static void DismountAll(string hint)
 {
     AmTrace.Debug("AmStoreHelper.DismountAll( {0} ): Started dismounting all mounted databases.", new object[]
     {
         hint
     });
     lock (AmStoreHelper.ForceDismountLocker)
     {
         MdbStatus[] array  = null;
         DateTime    utcNow = DateTime.UtcNow;
         if (!AmStoreHelper.GetAllDatabaseStatuses(null, false, out array))
         {
             AmTrace.Error("AmStoreHelper.DismountAll( {0} ): GetAllDatabaseStatuses() failed. Now attempting to kill store to quickly get dismounted databases.", new object[]
             {
                 hint
             });
             AmStoreServiceMonitor.KillStoreIfRunningBefore(utcNow, "DismountAll");
         }
         else if (array != null && array.Length > 0)
         {
             DismountDatabasesInParallel dismountDatabasesInParallel = new DismountDatabasesInParallel(array);
             dismountDatabasesInParallel.Execute(RegistryParameters.AmDismountOrKillTimeoutInSec * 1000, hint);
         }
         else
         {
             AmTrace.Debug("Dismount all skipped since there are no mounted databases", new object[0]);
         }
     }
 }
コード例 #5
0
        // Token: 0x06000493 RID: 1171 RVA: 0x00018740 File Offset: 0x00016940
        internal static void Dismount(Guid mdbGuid)
        {
            Exception ex = AmStoreHelper.Dismount(mdbGuid, UnmountFlags.SkipCacheFlush);

            if (ex != null)
            {
                throw ex;
            }
        }
コード例 #6
0
        protected override bool IsServiceReady()
        {
            bool flag = AmStoreHelper.IsStoreRunning(AmServerName.LocalComputerName);

            AmTrace.Debug("AmStoreHelper.IsStoreRunning() returned {0}", new object[]
            {
                flag
            });
            return(flag);
        }
コード例 #7
0
        // Token: 0x0600049A RID: 1178 RVA: 0x00018C68 File Offset: 0x00016E68
        internal static bool IsMounted(AmServerName serverName, Guid mdbGuid)
        {
            bool      result = false;
            Exception ex;
            MdbStatus mdbStatus = AmStoreHelper.GetMdbStatus(serverName, mdbGuid, out ex);

            if (mdbStatus != null && (mdbStatus.Status & MdbStatusFlags.Online) == MdbStatusFlags.Online)
            {
                result = true;
            }
            return(result);
        }
コード例 #8
0
 protected override void TimerCallbackInternal()
 {
     if (this.IsRequested)
     {
         if (this.m_configManager.CurrentConfig.IsUnknown)
         {
             AmStoreHelper.DismountAll("TransientFailoverSuppression");
         }
         else
         {
             ReplayCrimsonEvents.DelayedSelfDismountAllSkipped.Log <AmRole>(this.m_configManager.CurrentConfig.Role);
         }
         this.IsRequested = false;
     }
 }
コード例 #9
0
        protected void DismountCommon(UnmountFlags flags)
        {
            AmServerName serverToDismount  = this.State.ActiveServer;
            Exception    dismountException = null;
            bool         isSuccess         = false;
            Exception    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                this.ReportStatus(AmDbActionStatus.StoreDismountInitiated);
                isSuccess = this.AttemptDismount(this.State.ActiveServer, flags, false, out dismountException);
                if (this.ActionCode.IsAdminDismountOperation)
                {
                    MountStatus storeDatabaseMountStatus = AmStoreHelper.GetStoreDatabaseMountStatus(serverToDismount, this.DatabaseGuid);
                    if (storeDatabaseMountStatus == MountStatus.Dismounted)
                    {
                        this.WriteStateAdminDismounted();
                        dismountException = null;
                        return;
                    }
                    if (storeDatabaseMountStatus == MountStatus.Mounted)
                    {
                        if (dismountException == null)
                        {
                            dismountException = new AmDismountSucceededButStillMountedException(serverToDismount.Fqdn, this.Database.Name);
                        }
                        this.WriteStateDismountFinished(true, MountStatus.Mounted, true);
                        return;
                    }
                    if (dismountException == null)
                    {
                        dismountException = new AmFailedToDetermineDatabaseMountStatusException(serverToDismount.Fqdn, this.Database.Name);
                    }
                    this.WriteStateDismountFinished(true, MountStatus.Dismounted, true);
                }
            });

            if (dismountException != null)
            {
                ex = dismountException;
            }
            if (ex != null)
            {
                this.ReportStatus(AmDbActionStatus.StoreDismountFailed);
                AmHelper.ThrowDbActionWrapperExceptionIfNecessary(ex);
                return;
            }
            this.ReportStatus(AmDbActionStatus.StoreDismountSuccessful);
        }
コード例 #10
0
 // Token: 0x060004A6 RID: 1190 RVA: 0x00019164 File Offset: 0x00017364
 internal static bool UpdateIsMountedCounter(Guid mdbGuid, string mdbName, bool isMounted, bool isCheckDbStatus)
 {
     if (string.IsNullOrEmpty(mdbName))
     {
         IADDatabase iaddatabase = Dependencies.ReplayAdObjectLookup.DatabaseLookup.FindAdObjectByGuid(mdbGuid);
         if (iaddatabase != null)
         {
             mdbName = iaddatabase.Name;
         }
     }
     if (!string.IsNullOrEmpty(mdbName))
     {
         bool flag = false;
         try
         {
             flag = AmStoreHelper.sm_perfCounterLock.Lock(mdbGuid, AmDbLockReason.UpdatePerfCounter);
             if (isCheckDbStatus)
             {
                 isMounted = AmStoreHelper.IsMounted(null, mdbGuid);
             }
             AmTrace.Debug("AmStoreHelper.UpdateIsMountedCounter: Database {0} ({1}) IsMounted is {2}", new object[]
             {
                 mdbGuid,
                 mdbName,
                 isMounted
             });
             ActiveManagerPerfmonInstance instance = ActiveManagerPerfmon.GetInstance(mdbName);
             if (instance != null)
             {
                 instance.IsMounted.RawValue = (isMounted ? 1L : 0L);
             }
             return(isMounted);
         }
         finally
         {
             if (flag)
             {
                 AmStoreHelper.sm_perfCounterLock.Release(mdbGuid, AmDbLockReason.UpdatePerfCounter);
             }
         }
     }
     AmTrace.Error("AmStoreHelper.UpdateIsMountedCounter: Perfmon update skipped for {0} since mdbName is null", new object[]
     {
         mdbGuid
     });
     return(isMounted);
 }
コード例 #11
0
        // Token: 0x060004A9 RID: 1193 RVA: 0x00019340 File Offset: 0x00017540
        private static Exception DismountWithKillOnTimeout(Guid mdbGuid, UnmountFlags flags, bool retryOnConflict)
        {
            AmTrace.Debug("DismountWithKillOnTimeout {0}", new object[]
            {
                mdbGuid
            });
            Exception result   = null;
            bool      flag     = false;
            DateTime  utcNow   = DateTime.UtcNow;
            TimeSpan  timeSpan = TimeSpan.FromSeconds((double)RegistryParameters.AmDismountOrKillTimeoutInSec);

            try
            {
                InvokeWithTimeout.Invoke(delegate()
                {
                    AmStoreHelper.RemoteDismount(null, mdbGuid, flags, retryOnConflict);
                }, timeSpan);
            }
            catch (TimeoutException)
            {
                flag = true;
            }
            catch (MapiPermanentException ex)
            {
                result = ex;
            }
            catch (MapiRetryableException ex2)
            {
                result = ex2;
            }
            if (flag)
            {
                AmTrace.Debug("Dismount {0} timedOut after {1}ms", new object[]
                {
                    mdbGuid,
                    timeSpan.TotalMilliseconds
                });
                ReplayCrimsonEvents.DismountFailedOnTimeout.Log <Guid, TimeSpan>(mdbGuid, timeSpan);
                result = AmStoreServiceMonitor.KillStoreIfRunningBefore(utcNow, "DismountWithKillOnTimeout");
            }
            return(result);
        }
コード例 #12
0
        // Token: 0x060001B3 RID: 435 RVA: 0x0000B1EC File Offset: 0x000093EC
        internal void DismountDatabaseDirect(Guid mdbGuid, UnmountFlags flags, AmDbActionCode actionCode)
        {
            AmTrace.Debug("DismountDatabaseDirect called. (Guid={0}, Flags={1}, ActionCode={2})", new object[]
            {
                mdbGuid,
                flags,
                actionCode
            });
            Exception ex = AmStoreHelper.Dismount(mdbGuid, flags);

            if (ex != null)
            {
                AmTrace.Error("DismountDatabaseDirect: Store dismount RPC for ({0}) threw exception: {1}", new object[]
                {
                    mdbGuid,
                    ex
                });
                throw ex;
            }
            AmTrace.Debug("DismountDatabaseDirect: Store dismount RPC for ({0}) completed.", new object[]
            {
                mdbGuid
            });
            AmTrace.Debug("DismountDatabaseDirect initiating UpdateReplicationContentIndexing() asynchronously for DB '{0}'.", new object[]
            {
                mdbGuid
            });
            ThreadPool.QueueUserWorkItem(delegate(object obj)
            {
                Exception ex2 = ReplicaInstance.UpdateReplicationContentIndexing();
                if (ex2 != null)
                {
                    AmTrace.Error("DismountDatabaseDirect background call of UpdateReplicationContentIndexing() failed for DB '{0}'. Exception: {1}", new object[]
                    {
                        (Guid)obj,
                        ex2
                    });
                }
            }, mdbGuid);
        }
コード例 #13
0
 private void CheckIfMoveApplicableForDatabase(AmServerName activeServer, AmServerName moveFromServer, AmDbActionCode actionCode)
 {
     if (base.Database.ReplicationType != ReplicationType.Remote)
     {
         AmTrace.Debug("Move ignored for database {0} since it is not replicated.", new object[]
         {
             base.DatabaseName
         });
         throw new AmDbMoveOperationNotSupportedException(base.DatabaseName);
     }
     if (!AmServerName.IsNullOrEmpty(moveFromServer))
     {
         if (!AmServerName.IsEqual(activeServer, moveFromServer))
         {
             AmTrace.Diagnostic("Move ignored for database {0} since the master server is different from the server that originally initiated the failover. (master={1}, movedInitiatedFrom={2})", new object[]
             {
                 base.DatabaseName,
                 activeServer,
                 moveFromServer
             });
             throw new AmDbMoveOperationNoLongerApplicableException(base.DatabaseName, moveFromServer.NetbiosName, activeServer.NetbiosName);
         }
         if (actionCode.Reason == AmDbActionReason.TimeoutFailure)
         {
             bool flag = AmStoreHelper.IsMounted(moveFromServer, base.DatabaseGuid);
             if (flag)
             {
                 throw new AmDbMoveOperationOnTimeoutFailureCancelled(base.DatabaseName, moveFromServer.NetbiosName);
             }
         }
     }
     if (base.Config.DagConfig.MemberServers.Length < 2)
     {
         AmTrace.Diagnostic("Move ignored for database {0} since according to active manager there is just one server in the DAG)", new object[]
         {
             base.DatabaseName
         });
         throw new AmDbMoveOperationNotSupportedException(base.DatabaseName);
     }
 }
コード例 #14
0
        internal static void DismountIfMismounted(IADDatabase db, AmDbActionCode actionCode, List <AmServerName> mismountedNodes)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.Role == AmRole.Unknown)
            {
                throw new AmInvalidConfiguration(config.LastError);
            }
            AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid);

            if (amDbStateInfo.IsEntryExist)
            {
                using (List <AmServerName> .Enumerator enumerator = mismountedNodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AmServerName amServerName = enumerator.Current;
                        if (!AmServerName.IsEqual(amServerName, amDbStateInfo.ActiveServer))
                        {
                            ReplayCrimsonEvents.DismountingMismountedDatabase.Log <string, Guid, AmServerName>(db.Name, db.Guid, amServerName);
                            AmStoreHelper.RemoteDismount(amServerName, db.Guid, UnmountFlags.SkipCacheFlush, false);
                        }
                        else
                        {
                            AmTrace.Warning("Ignoring force dismount for {0} since it is the current active {1}", new object[]
                            {
                                db.Name,
                                amServerName
                            });
                        }
                    }
                    return;
                }
            }
            AmTrace.Warning("DismountIfMismounted skipped since the database {0} was never mounted", new object[]
            {
                db.Name
            });
        }
コード例 #15
0
        // Token: 0x060003C8 RID: 968 RVA: 0x000148E4 File Offset: 0x00012AE4
        private Exception RunServerRpcInternal(AmServerName node, out MdbStatus[] results)
        {
            results = null;
            Exception ex = null;

            MdbStatus[] array = null;
            if (!AmStoreHelper.GetAllDatabaseStatuses(node, this.m_isBasicInformation, out array))
            {
                Thread.Sleep(2000);
                if (!AmStoreHelper.GetAllDatabaseStatuses(node, this.m_isBasicInformation, out array, out ex))
                {
                    AmTrace.Error("Failed to get mounted database information from store on server {0}. Exception: {1}", new object[]
                    {
                        node,
                        ex
                    });
                    ReplayCrimsonEvents.ListMdbStatusFailed.LogPeriodic <string, string>(node.NetbiosName, TimeSpan.FromMinutes(15.0), node.NetbiosName, ex.ToString());
                    return(ex);
                }
            }
            results = array;
            return(ex);
        }
コード例 #16
0
        internal bool AttemptDismount(AmServerName serverName, UnmountFlags flags, bool isIgnoreKnownExceptions, out Exception exception)
        {
            bool result = false;

            exception = null;
            bool isNodeup = true;

            if (this.Config.IsPamOrSam && !this.Config.DagConfig.IsNodePubliclyUp(serverName))
            {
                isNodeup = false;
            }
            TimeSpan bestEffortDismountTimeout = this.DetermineDismountTimeout(this.ActionCode, isNodeup);

            this.DbTrace.Debug("Attempting dismount (server={0}, flags={1}, actionCode={2}, dismountTimeout={3}ms, ignoreException={4})", new object[]
            {
                serverName,
                flags,
                this.ActionCode,
                bestEffortDismountTimeout.TotalMilliseconds,
                isIgnoreKnownExceptions
            });
            AmDbAction.DismountMode modeOfDismount = AmDbAction.DismountMode.None;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            bool        flag        = true;
            MountStatus mountStatus = this.State.MountStatus;

            try
            {
                ReplayCrimsonEvents.StoreDismountInitiated.LogGeneric(this.PrepareSubactionArgs(new object[]
                {
                    serverName,
                    flags,
                    bestEffortDismountTimeout
                }));
                if (AmServerName.IsEqual(this.State.ActiveServer, serverName))
                {
                    this.WriteStateDismounting(false);
                }
                ExTraceGlobals.FaultInjectionTracer.TraceTest(3152424253U);
                exception = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                {
                    InvokeWithTimeout.Invoke(delegate()
                    {
                        if (isNodeup && AmHelper.IsReplayRunning(serverName))
                        {
                            this.DbTrace.Debug("Attempting Dismount through active manager", new object[0]);
                            modeOfDismount = AmDbAction.DismountMode.ThroughReplayService;
                            AmDbAction.DismountDatabaseDirect(serverName, this.DatabaseGuid, flags, this.ActionCode);
                            return;
                        }
                        this.DbTrace.Debug("Attempting dismount by directly RPCing to store", new object[0]);
                        modeOfDismount = AmDbAction.DismountMode.DirectlyToStore;
                        AmStoreHelper.RemoteDismount(serverName, this.DatabaseGuid, flags, true);
                    }, bestEffortDismountTimeout);
                    this.DbTrace.Debug("Database is possibly dismounted at server {0}", new object[]
                    {
                        serverName
                    });
                });
                if (exception != null)
                {
                    this.DbTrace.Debug("Dismount failed with error: {0}", new object[]
                    {
                        exception
                    });
                }
                flag = false;
            }
            finally
            {
                stopwatch.Stop();
                string text = null;
                if (flag)
                {
                    text = ReplayStrings.UnknownError;
                }
                else if (exception != null)
                {
                    text = exception.Message;
                }
                if (string.IsNullOrEmpty(text))
                {
                    result = true;
                    ReplayCrimsonEvents.StoreDismountSuccess.LogGeneric(this.PrepareSubactionArgs(new object[]
                    {
                        serverName,
                        modeOfDismount,
                        stopwatch.Elapsed
                    }));
                    if (AmServerName.IsEqual(this.State.ActiveServer, serverName))
                    {
                        this.WriteStateDismountFinished(true, MountStatus.Dismounted, false);
                    }
                }
                else
                {
                    ReplayCrimsonEvents.StoreDismountFailed.LogGeneric(this.PrepareSubactionArgs(new object[]
                    {
                        serverName,
                        modeOfDismount,
                        stopwatch.Elapsed,
                        text
                    }));
                    if (AmServerName.IsEqual(this.State.ActiveServer, serverName))
                    {
                        this.WriteStateDismountFinished(true, mountStatus, false);
                    }
                }
            }
            return(result);
        }
コード例 #17
0
 // Token: 0x06000492 RID: 1170 RVA: 0x00018736 File Offset: 0x00016936
 internal static void Mount(Guid mdbGuid)
 {
     AmStoreHelper.Mount(mdbGuid, MountFlags.None);
 }
コード例 #18
0
        internal static void SyncClusterDatabaseState(IADDatabase db, AmDbActionCode actionCode)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsUnknown)
            {
                AmTrace.Error("SyncClusterDatabaseState: Invalid configuration (db={0})", new object[]
                {
                    db
                });
                throw new AmInvalidConfiguration(config.LastError);
            }
            AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid);
            AmServerName  amServerName;

            if (amDbStateInfo.IsActiveServerValid)
            {
                amServerName = amDbStateInfo.ActiveServer;
            }
            else
            {
                amServerName = new AmServerName(db.Server.Name);
            }
            MountStatus mountStatus = MountStatus.Dismounted;

            if ((config.IsStandalone || (config.IsPamOrSam && config.DagConfig.IsNodePubliclyUp(amServerName))) && AmStoreHelper.IsMounted(amServerName, db.Guid))
            {
                mountStatus = MountStatus.Mounted;
                AmSystemManager.Instance.DbNodeAttemptTable.ClearFailedTime(db.Guid);
            }
            MountStatus mountStatus2 = amDbStateInfo.MountStatus;

            if (mountStatus != mountStatus2 || !AmServerName.IsEqual(amDbStateInfo.LastMountedServer, amDbStateInfo.ActiveServer))
            {
                if (mountStatus != mountStatus2)
                {
                    AmTrace.Debug("Mounted state reported by STORE is different from persistent state. (Database:{0}, PersistentState: {1}, StoreIsReporting: {2})", new object[]
                    {
                        db.Name,
                        mountStatus2,
                        mountStatus
                    });
                }
                else
                {
                    AmTrace.Debug("State is in transit. (Database:{0}, LastMountedServer: {1},ActiveServer: {2})", new object[]
                    {
                        db.Name,
                        amDbStateInfo.LastMountedServer,
                        amDbStateInfo.ActiveServer
                    });
                }
                AmDbAction.WriteStateSyncMountStatus(config, amDbStateInfo, db.Guid, amServerName, mountStatus);
                ReplayCrimsonEvents.DatabaseMountStatusSynchronized.Log <string, Guid, MountStatus, MountStatus, AmServerName>(db.Name, db.Guid, mountStatus2, mountStatus, amServerName);
                return;
            }
            AmTrace.Debug("Ignored persistent state sync for {0} since nothing is out of sync", new object[]
            {
                db.Name
            });
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        // Token: 0x0600049C RID: 1180 RVA: 0x00018CD8 File Offset: 0x00016ED8
        internal static MdbStatus GetMdbStatus(string serverFqdn, Guid mdbGuid)
        {
            Exception ex;

            return(AmStoreHelper.GetMdbStatus(new AmServerName(serverFqdn), mdbGuid, out ex));
        }
コード例 #21
0
 // Token: 0x0600049D RID: 1181 RVA: 0x00018CF4 File Offset: 0x00016EF4
 internal static MdbStatus GetMdbStatus(AmServerName serverName, Guid mdbGuid, out Exception exception)
 {
     return(AmStoreHelper.GetMdbStatus(serverName, mdbGuid, null, null, out exception));
 }
コード例 #22
0
 // Token: 0x06000497 RID: 1175 RVA: 0x000189A4 File Offset: 0x00016BA4
 internal static void RemoteDismount(AmServerName serverName, Guid mdbGuid)
 {
     AmStoreHelper.RemoteDismount(serverName, mdbGuid, UnmountFlags.SkipCacheFlush, true);
 }
コード例 #23
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);
                }
            }
        }
コード例 #24
0
 // Token: 0x060004A2 RID: 1186 RVA: 0x00018F9C File Offset: 0x0001719C
 internal static bool GetAllDatabaseStatuses(AmServerName serverName, bool isBasicInformation, out MdbStatus[] mdbStatuses, out Exception exception)
 {
     return(AmStoreHelper.GetAllDatabaseStatuses(serverName, isBasicInformation, null, null, out mdbStatuses, out exception));
 }
コード例 #25
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;
                }
            }
        }
コード例 #26
0
        // Token: 0x060001B1 RID: 433 RVA: 0x0000AD64 File Offset: 0x00008F64
        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);
        }
コード例 #27
0
 // Token: 0x06000499 RID: 1177 RVA: 0x00018C5C File Offset: 0x00016E5C
 internal static bool IsMountedLocally(Guid mdbGuid)
 {
     return(AmStoreHelper.IsMounted(null, mdbGuid));
 }
コード例 #28
0
 // Token: 0x060004A5 RID: 1189 RVA: 0x00019144 File Offset: 0x00017344
 private static bool UpdateIsMountedCounterNoDatabaseCache(Guid mdbGuid, string mdbName, bool isMounted, bool isCheckDbStatus)
 {
     Dependencies.ReplayAdObjectLookup.DatabaseLookup.FindAdObjectByGuidEx(mdbGuid, AdObjectLookupFlags.ReadThrough);
     return(AmStoreHelper.UpdateIsMountedCounter(mdbGuid, mdbName, isMounted, isCheckDbStatus));
 }
コード例 #29
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
            });
        }