// 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);
        }
Beispiel #2
0
        private void RunMountDatabaseDirect(AmServerName serverToMount, MountFlags storeMountFlags, AmMountFlags amMountFlags, bool fLossyMountEnabled, TimeSpan mountTimeout, ref bool isMasterChanged)
        {
            bool flag  = false;
            bool flag2 = false;

            isMasterChanged = false;
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;
            AmServerName         activeServer       = base.State.ActiveServer;

            try
            {
                isMasterChanged = this.UpdateMaster(serverToMount, false);
                base.ReportStatus(AmDbActionStatus.StoreMountInitiated);
                if (fLossyMountEnabled)
                {
                    storeMountFlags |= MountFlags.AllowDatabasePatch;
                }
                ExTraceGlobals.FaultInjectionTracer.TraceTest(2229677373U);
                try
                {
                    InvokeWithTimeout.Invoke(delegate()
                    {
                        AmDbAction.MountDatabaseDirect(serverToMount, this.State.LastMountedServer, this.DatabaseGuid, storeMountFlags, amMountFlags, this.ActionCode);
                        ExTraceGlobals.FaultInjectionTracer.TraceTest(2441489725U);
                    }, mountTimeout);
                }
                catch (TimeoutException ex)
                {
                    base.DbTrace.Error("Mount timeout on {0}: {1}", new object[]
                    {
                        base.DatabaseName,
                        ex
                    });
                    AmMountTimeoutException ex2 = new AmMountTimeoutException(base.DatabaseName, serverToMount.NetbiosName, (int)mountTimeout.TotalSeconds, ex);
                    this.HandleMountTimeout(serverToMount, ex2);
                    throw ex2;
                }
                flag = true;
                dbNodeAttemptTable.ClearFailedTime(base.DatabaseGuid);
                try
                {
                    base.WriteStateMountSuccess();
                }
                catch (AmRoleChangedWhileOperationIsInProgressException ex3)
                {
                    base.DbTrace.Warning("Mount AmRoleChanged exception (error={0})", new object[]
                    {
                        ex3
                    });
                }
                base.ReportStatus(AmDbActionStatus.StoreMountSuccessful);
            }
            catch (TransientException ex4)
            {
                base.DbTrace.Error("Mount transient exception (error={0})", new object[]
                {
                    ex4
                });
                flag2 = true;
                throw;
            }
            catch (AmReplayServiceDownException ex5)
            {
                base.DbTrace.Error("Mount transient RPC exception (error={0})", new object[]
                {
                    ex5
                });
                flag2 = true;
                throw;
            }
            finally
            {
                if (flag)
                {
                    SharedDependencies.WritableADHelper.ResetAllowFileRestoreDsFlag(base.DatabaseGuid, activeServer, serverToMount);
                }
                else
                {
                    base.WriteStateMountFailed(true);
                    if (base.ActionCode.IsAutomaticFailureItem && !flag2)
                    {
                        dbNodeAttemptTable.MarkFailedTime(base.DatabaseGuid, serverToMount, base.ActionCode);
                    }
                    base.ReportStatus(AmDbActionStatus.StoreMountFailed);
                }
                if (isMasterChanged && AmSystemManager.Instance.Config.IsPAM)
                {
                    this.SendReplicaNotifications();
                }
            }
        }