// Token: 0x060002F8 RID: 760 RVA: 0x00011878 File Offset: 0x0000FA78
        protected override void RemountInternal(MountFlags mountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer)
        {
            AmDbOperationDetailedStatus amDbOperationDetailedStatus = new AmDbOperationDetailedStatus(base.Database);

            this.DismountInternal(UnmountFlags.SkipCacheFlush);
            this.MountInternal(mountFlags, AmMountFlags.None, mountDialoverride, ref amDbOperationDetailedStatus);
        }
예제 #2
0
        // Token: 0x060001AF RID: 431 RVA: 0x0000AA50 File Offset: 0x00008C50
        internal void RemountDatabase(Guid mdbGuid, MountFlags mountFlags, DatabaseMountDialOverride mountDialOverride, AmServerName fromServer, AmDbActionCode actionCode)
        {
            AmTrace.Debug("RemountDatabase ({0},{1},{2},{3},{4}) called", new object[]
            {
                mdbGuid,
                mountFlags,
                mountDialOverride,
                fromServer,
                actionCode
            });
            ActiveManagerCore.ValidatePamOrStandalone("RemountDatabase");
            IADDatabase iaddatabase = this.AdLookup.DatabaseLookup.FindAdObjectByGuidEx(mdbGuid, AdObjectLookupFlags.ReadThrough);

            if (iaddatabase == null)
            {
                throw new AmDatabaseNotFoundException(mdbGuid);
            }
            AmDbRemountOperation amDbRemountOperation = new AmDbRemountOperation(iaddatabase, actionCode);

            amDbRemountOperation.Flags             = mountFlags;
            amDbRemountOperation.MountDialOverride = mountDialOverride;
            amDbRemountOperation.FromServer        = fromServer;
            amDbRemountOperation.Enqueue();
            AmDbCompletionReason amDbCompletionReason = amDbRemountOperation.Wait();

            AmTrace.Debug("RemountDatabase({0}) completed (reason={1})", new object[]
            {
                mdbGuid,
                amDbCompletionReason
            });
        }
예제 #3
0
        protected override void RemountInternal(MountFlags mountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer)
        {
            Exception exception = null;

            base.AttemptDismount(base.State.ActiveServer, UnmountFlags.SkipCacheFlush, true, out exception);
            int num = 0;
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
            AmAcllReturnStatus   amAcllReturnStatus = null;

            this.AttemptMountOnServer(base.State.ActiveServer, base.State.ActiveServer, mountFlags, AmMountFlags.None, UnmountFlags.SkipCacheFlush, mountDialoverride, AmBcsSkipFlags.None, false, ref num, ref amAcllReturnStatus, out exception);
            base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
            {
                amAcllReturnStatus
            });
            AmHelper.ThrowDbActionWrapperExceptionIfNecessary(exception);
        }
예제 #4
0
 protected abstract void MoveInternal(MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, string componentName, ref AmDbOperationDetailedStatus moveStatus);
예제 #5
0
 protected abstract void MountInternal(MountFlags storeFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialoverride, ref AmDbOperationDetailedStatus mountStatus);
예제 #6
0
        // Token: 0x060006EB RID: 1771 RVA: 0x00020E40 File Offset: 0x0001F040
        public AmBestCopySelection(Guid dbGuid, IADDatabase database, AmDbActionCode actionCode, AmMultiNodeCopyStatusFetcher statusFetcher, AmServerName sourceServerName, AmConfig amConfig, DatabaseMountDialOverride mountDialOverride, AmBcsSkipFlags skipValidationChecks, AmDbAction.PrepareSubactionArgsDelegate prepareSubaction, string componentName)
        {
            this.m_amConfig          = amConfig;
            this.m_statusFetcher     = statusFetcher;
            this.m_mountDialOverride = mountDialOverride;
            IAmBcsErrorLogger errorLogger = new AmBcsServerFailureLogger(dbGuid, database.Name, true);

            this.m_bcsContext                      = new AmBcsContext(dbGuid, sourceServerName, errorLogger);
            this.m_bcsContext.Database             = database;
            this.m_bcsContext.ActionCode           = actionCode;
            this.m_bcsContext.SkipValidationChecks = skipValidationChecks;
            this.m_bcsContext.InitiatingComponent  = componentName;
            this.m_bcsContext.PrepareSubaction     = prepareSubaction;
            this.m_perfTracker                     = new BcsPerformanceTracker(prepareSubaction);
        }
 // Token: 0x060002F7 RID: 759 RVA: 0x00011869 File Offset: 0x0000FA69
 protected override void MoveInternal(MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, string componentName, ref AmDbOperationDetailedStatus moveStatus)
 {
     throw new AmDbMoveOperationNotSupportedStandaloneException(base.DatabaseName);
 }
예제 #8
0
        // Token: 0x060001AA RID: 426 RVA: 0x0000A74C File Offset: 0x0000894C
        internal List <AmDatabaseMoveResult> ServerMoveAllDatabases(AmServerName sourceServer, AmServerName targetServer, MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialOverride, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, AmDbActionCode actionCode, string moveComment, string componentName)
        {
            AmTrace.Debug("ServerMoveAllDatabases() called: sourceServer='{0}', targetServer='{1}', mountFlags='{2}', dismountFlags='{3}', mountDialOverride='{4}', tryOtherHealthyServers='{5}', skipValidationChecks='{6}', actionCode='{7}', MoveComment='{8}' Component='{9}'", new object[]
            {
                sourceServer,
                targetServer,
                mountFlags,
                dismountFlags,
                mountDialOverride,
                tryOtherHealthyServers,
                skipValidationChecks,
                actionCode,
                moveComment,
                componentName
            });
            ActiveManagerCore.ValidatePamOrStandalone("ServerMoveAllDatabases");
            ThirdPartyManager.PreventOperationWhenTPREnabled("ServerMoveAllDatabases");
            AmDbMoveArguments amDbMoveArguments = new AmDbMoveArguments(actionCode);

            amDbMoveArguments.SourceServer           = sourceServer;
            amDbMoveArguments.TargetServer           = targetServer;
            amDbMoveArguments.MountFlags             = mountFlags;
            amDbMoveArguments.DismountFlags          = dismountFlags;
            amDbMoveArguments.MountDialOverride      = mountDialOverride;
            amDbMoveArguments.TryOtherHealthyServers = tryOtherHealthyServers;
            amDbMoveArguments.SkipValidationChecks   = skipValidationChecks;
            amDbMoveArguments.MoveComment            = moveComment;
            amDbMoveArguments.ComponentName          = componentName;
            if (string.IsNullOrEmpty(sourceServer.Fqdn))
            {
                return(MoveBackToServer.Move(amDbMoveArguments));
            }
            AmEvtMoveAllDatabasesBase amEvtMoveAllDatabasesBase;

            if (actionCode.IsAutomaticManagedAvailabilityFailover)
            {
                amEvtMoveAllDatabasesBase = new AmEvtMoveAllDatabasesOnComponentRequest(sourceServer);
            }
            else
            {
                amEvtMoveAllDatabasesBase = new AmEvtMoveAllDatabasesOnAdminRequest(sourceServer);
            }
            amEvtMoveAllDatabasesBase.MoveArgs = amDbMoveArguments;
            amEvtMoveAllDatabasesBase.Notify();
            amEvtMoveAllDatabasesBase.WaitForSwitchoverComplete();
            AmTrace.Debug("ServerMoveAllDatabases({0}) completed", new object[]
            {
                sourceServer
            });
            return(amEvtMoveAllDatabasesBase.GetMoveResultsForOperationsRun());
        }
예제 #9
0
        internal static void Move(IADDatabase database, string from, AmDbActionCode actionCode, DatabaseMountDialOverride mountDialOverride)
        {
            Exception            ex = null;
            AmDatabaseMoveResult amDatabaseMoveResult = null;

            DatabaseTasks.Trace("Database '{0}' moved from '{1}'", new object[]
            {
                database.Name,
                from
            });
            try
            {
                string text;
                AmRpcClientHelper.MoveDatabaseEx(database, 0, 16, (int)mountDialOverride, from, null, true, 0, actionCode, null, out text, ref amDatabaseMoveResult);
            }
            catch (AmServerException ex2)
            {
                DatabaseTasks.Trace("MoveDatabase() failed with {0}; Exception: {1}", new object[]
                {
                    amDatabaseMoveResult,
                    ex2
                });
                ex = ex2;
            }
            catch (AmServerTransientException ex3)
            {
                DatabaseTasks.Trace("MoveDatabase() failed with {0}; Exception: {1}", new object[]
                {
                    amDatabaseMoveResult,
                    ex3
                });
                ex = ex3;
            }
            if (ex != null)
            {
                throw new DatabaseFailoverFailedException(database.Name, ex.ToString(), ex);
            }
        }
예제 #10
0
        internal void Move(MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, string moveComment, string componentName, ref AmDbOperationDetailedStatus moveStatus)
        {
            moveStatus = new AmDbOperationDetailedStatus(this.Database);
            Exception    ex   = null;
            bool         flag = true;
            AmServerName initialSourceServer = null;
            Stopwatch    stopwatch           = new Stopwatch();

            stopwatch.Start();
            string initialActive = string.Empty;
            AmDbOperationDetailedStatus tempStatus = moveStatus;

            try
            {
                using (AmDatabaseOperationLock.Lock(this.DatabaseGuid, AmDbLockReason.Move, null))
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        initialActive = this.GetSafeActiveServer();
                        ReplayCrimsonEvents.ToplevelMoveInitiated.LogGeneric(this.PrepareStartupArgs(new object[]
                        {
                            mountFlags,
                            dismountFlags,
                            mountDialoverride,
                            AmServerName.IsNullOrEmpty(fromServer) ? initialActive : fromServer.Fqdn,
                            targetServer,
                            tryOtherHealthyServers,
                            skipValidationChecks,
                            moveComment,
                            componentName
                        }));
                        initialSourceServer = this.State.ActiveServer;
                        this.EnsureAutomaticActionIsAllowed();
                        this.ClearFailureAttemptIfAdminAction(this.DatabaseGuid);
                        this.MoveInternal(mountFlags, dismountFlags, mountDialoverride, fromServer, targetServer, tryOtherHealthyServers, skipValidationChecks, componentName, ref tempStatus);
                    });
                    this.WriteStateClearIfInProgressStatus(true);
                    flag = false;
                }
            }
            catch (AmDbLockConflictException ex2)
            {
                ex = ex2;
            }
            finally
            {
                stopwatch.Stop();
                moveStatus = tempStatus;
                if (flag || ex != null)
                {
                    string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError;
                    ReplayCrimsonEvents.ToplevelMoveFailed.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        initialActive,
                        stopwatch.Elapsed,
                        text,
                        moveComment
                    }));
                    if (AmServerName.IsNullOrEmpty(targetServer))
                    {
                        ReplayEventLogConstants.Tuple_AmDatabaseMoveUnspecifiedServerFailed.LogEvent(null, new object[]
                        {
                            this.DatabaseName,
                            initialSourceServer,
                            text,
                            moveComment
                        });
                    }
                    else
                    {
                        ReplayEventLogConstants.Tuple_AmDatabaseMoveFailed.LogEvent(null, new object[]
                        {
                            this.DatabaseName,
                            initialActive,
                            targetServer,
                            text,
                            moveComment
                        });
                    }
                }
                else
                {
                    ReplayCrimsonEvents.ToplevelMoveSuccess.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        initialActive,
                        stopwatch.Elapsed,
                        moveComment
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseMoved.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        initialActive,
                        moveStatus.FinalDbState.ActiveServer,
                        moveComment
                    });
                }
            }
            if (ex != null)
            {
                throw ex;
            }
        }
예제 #11
0
        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);
        }
예제 #12
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);
        }
예제 #13
0
 // Token: 0x06000841 RID: 2113 RVA: 0x00028264 File Offset: 0x00026464
 public void AttemptCopyLastLogsDirect(string serverToRpc, Guid dbGuid, DatabaseMountDialOverride mountDialOverride, int numRetries, int e00timeoutMs, int networkIOtimeoutMs, int networkConnecttimeoutMs, string sourceServer, int actionCode, int skipValidationChecks, bool mountPending, string uniqueOperationId, int subactionAttemptNumber, ref AmAcllReturnStatus acllStatus)
 {
     AmRpcClientHelper.AttemptCopyLastLogsDirect(serverToRpc, dbGuid, mountDialOverride, numRetries, e00timeoutMs, networkIOtimeoutMs, networkConnecttimeoutMs, sourceServer, actionCode, skipValidationChecks, mountPending, uniqueOperationId, subactionAttemptNumber, ref acllStatus);
 }
        // Token: 0x06001BA1 RID: 7073 RVA: 0x00075F7C File Offset: 0x0007417C
        public AttemptCopyLastLogs(IPerfmonCounters perfmonCounters, ReplayConfiguration configuration, FileChecker fileChecker, bool performDivergenceCheck, ISetGeneration setGeneration, ISetViable setViable, bool fSkipHealthChecks, DatabaseMountDialOverride mountDialOverride, AcllPerformanceTracker acllPerf, string uniqueOperationId, int subactionAttemptNumber)
        {
            this.m_uniqueOperationId      = uniqueOperationId;
            this.m_subactionAttemptNumber = subactionAttemptNumber;
            this.m_acllPerf = acllPerf;
            this.m_fPerformDivergenceCheck = performDivergenceCheck;
            this.m_fSkipHealthChecks       = fSkipHealthChecks;
            this.m_mountDialOverride       = mountDialOverride;
            this.m_perfmonCounters         = perfmonCounters;
            this.m_configuration           = configuration;
            string displayName = this.m_configuration.DisplayName;

            this.m_setBrokenForCopier    = new SimpleSetBroken(displayName);
            this.m_setBrokenForInspector = new SimpleSetBroken(displayName);
            this.m_setBrokenForReplayer  = new SimpleSetBroken(displayName);
            this.m_setBrokenForOther     = new SimpleSetBroken(displayName);
            this.m_setGeneration         = setGeneration;
            this.m_setViable             = setViable;
            this.m_state          = this.m_configuration.ReplayState;
            this.m_fileChecker    = fileChecker;
            this.m_fileState      = fileChecker.FileState;
            this.m_logCopier      = null;
            this.m_logInspector   = null;
            this.m_remoteConfig   = (this.m_configuration as RemoteReplayConfiguration);
            this.NumberOfLogsLost = -1L;
            DiagCore.RetailAssert(this.m_remoteConfig != null, "ACLL is only supported for HA replicated databases", new object[0]);
        }
        // Token: 0x06001BB1 RID: 7089 RVA: 0x00076118 File Offset: 0x00074318
        public static AmAcllReturnStatus AttemptCopyLastLogsOnceRcr(IPerfmonCounters perfmonCounters, ReplayConfiguration configuration, FileChecker fileChecker, ISetGeneration setGeneration, ISetViable setViable, LogCopier logCopier, LogInspector logInspector, LogReplayer logReplayer, bool performDivergenceCheck, bool fSkipHealthChecks, DatabaseMountDialOverride mountDialOverride, AcllPerformanceTracker acllPerf, string uniqueOperationId, int subactionAttemptNumber, bool mountPending)
        {
            AttemptCopyLastLogs attemptCopyLastLogs = new AttemptCopyLastLogs(perfmonCounters, configuration, fileChecker, performDivergenceCheck, setGeneration, setViable, fSkipHealthChecks, mountDialOverride, acllPerf, uniqueOperationId, subactionAttemptNumber);

            attemptCopyLastLogs.MakeAttempt(logCopier, logInspector, logReplayer);
            return(attemptCopyLastLogs.GetReturnStatus());
        }
예제 #16
0
 protected abstract void RemountInternal(MountFlags mountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer);
예제 #17
0
        internal void Mount(MountFlags storeFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialoverride, ref AmDbOperationDetailedStatus mountStatus)
        {
            mountStatus = new AmDbOperationDetailedStatus(this.Database);
            Exception ex        = null;
            bool      flag      = true;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            AmDbOperationDetailedStatus tempStatus = mountStatus;

            try
            {
                using (AmDatabaseOperationLock.Lock(this.DatabaseGuid, AmDbLockReason.Mount, null))
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        ReplayCrimsonEvents.ToplevelMountInitiated.LogGeneric(this.PrepareStartupArgs(new object[]
                        {
                            storeFlags,
                            mountDialoverride
                        }));
                        this.EnsureAutomaticActionIsAllowed();
                        this.ClearFailureAttemptIfAdminAction(this.DatabaseGuid);
                        if (!this.State.IsEntryExist)
                        {
                            this.DbTrace.Info("Mounting database for the first time!", new object[0]);
                        }
                        this.MountInternal(storeFlags, amMountFlags, mountDialoverride, ref tempStatus);
                    });
                    mountStatus = tempStatus;
                    this.WriteStateClearIfInProgressStatus(true);
                    flag = false;
                }
            }
            catch (AmDbLockConflictException ex2)
            {
                ex = ex2;
            }
            finally
            {
                stopwatch.Stop();
                if (flag || ex != null)
                {
                    string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError;
                    ReplayCrimsonEvents.ToplevelMountFailed.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        stopwatch.Elapsed,
                        text
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseMountFailed.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        this.State.ActiveServer,
                        text
                    });
                }
                else
                {
                    ReplayCrimsonEvents.ToplevelMountSuccess.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        stopwatch.Elapsed
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseMounted.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        this.State.ActiveServer
                    });
                }
            }
            if (ex != null)
            {
                throw ex;
            }
        }
예제 #18
0
        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);
        }
예제 #19
0
        internal void Remount(MountFlags mountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer)
        {
            Exception    ex           = null;
            bool         flag         = true;
            AmServerName amServerName = null;
            Stopwatch    stopwatch    = new Stopwatch();

            stopwatch.Start();
            try
            {
                using (AmDatabaseOperationLock.Lock(this.DatabaseGuid, AmDbLockReason.Remount, null))
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        ReplayCrimsonEvents.ToplevelRemountInitiated.LogGeneric(this.PrepareStartupArgs(new object[]
                        {
                            mountFlags,
                            mountDialoverride,
                            fromServer
                        }));
                        if (!this.State.IsEntryExist)
                        {
                            this.DbTrace.Error("Database was never mounted. Remount is applicable only if it was mounted at least once", new object[0]);
                            throw new AmDatabaseNeverMountedException();
                        }
                        if (this.State.IsAdminDismounted)
                        {
                            this.DbTrace.Error("Skipping remount action since the database was admin dismounted", new object[0]);
                            throw new AmDbRemountSkippedSinceDatabaseWasAdminDismounted(this.DatabaseName);
                        }
                        if (!AmServerName.IsEqual(this.State.ActiveServer, fromServer))
                        {
                            this.DbTrace.Error("Skipping remount action since database master had changed", new object[0]);
                            throw new AmDbRemountSkippedSinceMasterChanged(this.DatabaseName, this.State.ActiveServer.Fqdn, fromServer.NetbiosName);
                        }
                        this.EnsureAutomaticActionIsAllowed();
                        this.RemountInternal(mountFlags, mountDialoverride, fromServer);
                    });
                    this.WriteStateClearIfInProgressStatus(true);
                    flag = false;
                }
            }
            catch (AmDbLockConflictException ex2)
            {
                ex = ex2;
            }
            finally
            {
                stopwatch.Stop();
                if (flag || ex != null)
                {
                    string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError;
                    ReplayCrimsonEvents.ToplevelRemountFailed.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        stopwatch.Elapsed,
                        text
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseMountFailed.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        amServerName,
                        text
                    });
                }
                else
                {
                    ReplayCrimsonEvents.ToplevelRemountSuccess.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        stopwatch.Elapsed
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseMounted.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        amServerName
                    });
                }
            }
            if (ex != null)
            {
                throw ex;
            }
        }
예제 #20
0
        private void RunAttemptCopyLastLogsOnServer(AmServerName serverToMount, AmServerName sourceServer, DatabaseMountDialOverride mountDialOverride, AmBcsSkipFlags skipValidationChecks, int numRetries, int e00timeoutMs, int networkIOtimeoutMs, int networkConnecttimeoutMs, out bool fLossyMountEnabled, ref AmAcllReturnStatus acllStatus)
        {
            acllStatus = null;
            bool flag = false;

            fLossyMountEnabled = false;
            try
            {
                base.ReportStatus(AmDbActionStatus.AcllInitiated);
                AmAcllArgs amAcllArgs = new AmAcllArgs();
                amAcllArgs.NumRetries              = numRetries;
                amAcllArgs.E00TimeoutMs            = e00timeoutMs;
                amAcllArgs.NetworkIOTimeoutMs      = networkIOtimeoutMs;
                amAcllArgs.NetworkConnectTimeoutMs = networkConnecttimeoutMs;
                amAcllArgs.SourceServer            = sourceServer;
                amAcllArgs.ActionCode              = base.ActionCode;
                amAcllArgs.MountDialOverride       = mountDialOverride;
                amAcllArgs.SkipValidationChecks    = skipValidationChecks;
                amAcllArgs.UniqueOperationId       = base.UniqueOperationId;
                amAcllArgs.SubactionAttemptNumber  = base.CurrentAttemptNumber;
                if (base.State.IsAdminDismounted && !base.ActionCode.IsAdminMountOperation)
                {
                    amAcllArgs.MountPending = false;
                }
                else
                {
                    amAcllArgs.MountPending = true;
                }
                AmDbAction.AttemptCopyLastLogsDirect(serverToMount, base.DatabaseGuid, amAcllArgs, ref acllStatus);
                fLossyMountEnabled = (!acllStatus.NoLoss && acllStatus.MountAllowed);
                flag = true;
                base.ReportStatus(AmDbActionStatus.AcllSuccessful);
            }
            finally
            {
                if (!flag)
                {
                    base.ReportStatus(AmDbActionStatus.AcllFailed);
                }
            }
        }
예제 #21
0
        // Token: 0x060001A8 RID: 424 RVA: 0x0000A59C File Offset: 0x0000879C
        internal void MoveDatabase(Guid mdbGuid, MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialOverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, AmDbActionCode actionCode, string moveComment, ref AmDatabaseMoveResult databaseMoveResult)
        {
            AmTrace.Debug("Task: MoveDatabase({0},{1},{2},{3},{4},{5},{6},{7},'{8}') called", new object[]
            {
                mdbGuid,
                mountFlags,
                dismountFlags,
                mountDialOverride,
                fromServer,
                targetServer,
                tryOtherHealthyServers,
                actionCode,
                moveComment
            });
            ActiveManagerCore.ValidatePamOrStandalone("MoveDatabase");
            ThirdPartyManager.PreventOperationWhenTPREnabled("MoveDatabase");
            IADDatabase iaddatabase = this.AdLookup.DatabaseLookup.FindAdObjectByGuidEx(mdbGuid, AdObjectLookupFlags.ReadThrough);

            if (iaddatabase == null)
            {
                throw new AmDatabaseNotFoundException(mdbGuid);
            }
            AmDbMoveOperation    amDbMoveOperation    = new AmDbMoveOperation(iaddatabase, actionCode);
            AmDbMoveArguments    arguments            = amDbMoveOperation.Arguments;
            AmDbCompletionReason amDbCompletionReason = AmDbCompletionReason.None;

            arguments.MountFlags             = mountFlags;
            arguments.DismountFlags          = dismountFlags;
            arguments.MountDialOverride      = mountDialOverride;
            arguments.SourceServer           = fromServer;
            arguments.TargetServer           = targetServer;
            arguments.TryOtherHealthyServers = tryOtherHealthyServers;
            arguments.SkipValidationChecks   = skipValidationChecks;
            arguments.MoveComment            = moveComment;
            amDbMoveOperation.Arguments      = arguments;
            amDbMoveOperation.Enqueue();
            try
            {
                amDbCompletionReason = amDbMoveOperation.Wait();
            }
            finally
            {
                if (amDbMoveOperation.DetailedStatus != null)
                {
                    databaseMoveResult = amDbMoveOperation.ConvertDetailedStatusToRpcMoveResult(amDbMoveOperation.DetailedStatus);
                }
            }
            AmTrace.Debug("MoveDatabase({0}) completed (reason={1})", new object[]
            {
                mdbGuid,
                amDbCompletionReason
            });
        }
예제 #22
0
 private IBestCopySelector ConstructBestCopySelector(bool tryOtherServers, AmBcsSkipFlags skipValidationChecks, AmMultiNodeCopyStatusFetcher statusFetcher, AmServerName initialFromServer, AmServerName targetServer, DatabaseMountDialOverride mountDialOverride, string componentName)
 {
     if (tryOtherServers)
     {
         return(new AmBestCopySelection(base.DatabaseGuid, base.Database, base.ActionCode, statusFetcher, initialFromServer, base.Config, mountDialOverride, skipValidationChecks, new AmDbAction.PrepareSubactionArgsDelegate(base.PrepareSubactionArgs), componentName));
     }
     return(new AmSingleCopySelection(base.DatabaseGuid, base.Database, base.ActionCode, initialFromServer, targetServer, base.Config, skipValidationChecks, new AmDbAction.PrepareSubactionArgsDelegate(base.PrepareSubactionArgs)));
 }
예제 #23
0
 // Token: 0x060006EA RID: 1770 RVA: 0x00020E1C File Offset: 0x0001F01C
 public AmBestCopySelection(Guid dbGuid, IADDatabase database, AmDbActionCode actionCode, AmMultiNodeCopyStatusFetcher statusFetcher, AmServerName sourceServerName, AmConfig amConfig, DatabaseMountDialOverride mountDialOverride, AmBcsSkipFlags skipValidationChecks, AmDbAction.PrepareSubactionArgsDelegate prepareSubaction) : this(dbGuid, database, actionCode, statusFetcher, sourceServerName, amConfig, mountDialOverride, skipValidationChecks, prepareSubaction, null)
 {
 }
        // Token: 0x060002F5 RID: 757 RVA: 0x00011688 File Offset: 0x0000F888
        protected override void MountInternal(MountFlags storeFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialoverride, ref AmDbOperationDetailedStatus mountStatus)
        {
            Exception    ex            = null;
            bool         isSuccess     = false;
            AmServerName activeServer  = base.State.ActiveServer;
            AmServerName serverToMount = AmServerName.LocalComputerName;
            Stopwatch    stopwatch     = new Stopwatch();

            stopwatch.Start();
            try
            {
                ReplayCrimsonEvents.DirectMountInitiated.LogGeneric(base.PrepareSubactionArgs(new object[]
                {
                    serverToMount,
                    storeFlags,
                    false,
                    amMountFlags
                }));
                ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                {
                    this.ReportStatus(AmDbActionStatus.StoreMountInitiated);
                    this.WriteStateMountStart(serverToMount);
                    AmDbAction.MountDatabaseDirect(serverToMount, this.State.LastMountedServer, this.DatabaseGuid, storeFlags, amMountFlags, this.ActionCode);
                    isSuccess = true;
                });
            }
            finally
            {
                stopwatch.Stop();
                if (isSuccess)
                {
                    base.DbTrace.Debug("Database is now mounted on {0}", new object[]
                    {
                        serverToMount
                    });
                    SharedDependencies.WritableADHelper.ResetAllowFileRestoreDsFlag(base.DatabaseGuid, activeServer, serverToMount);
                    ReplayCrimsonEvents.DirectMountSuccess.LogGeneric(base.PrepareSubactionArgs(new object[]
                    {
                        serverToMount,
                        stopwatch.Elapsed
                    }));
                    base.WriteStateMountSuccess();
                    base.ReportStatus(AmDbActionStatus.StoreMountSuccessful);
                }
                else
                {
                    string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError;
                    ReplayCrimsonEvents.DirectMountFailed.LogGeneric(base.PrepareSubactionArgs(new object[]
                    {
                        serverToMount,
                        stopwatch.Elapsed,
                        text
                    }));
                    base.WriteStateMountFailed(true);
                    base.ReportStatus(AmDbActionStatus.StoreMountFailed);
                }
            }
            AmHelper.ThrowDbActionWrapperExceptionIfNecessary(ex);
        }