// 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;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }