// Token: 0x060003DB RID: 987 RVA: 0x00014DA0 File Offset: 0x00012FA0
        protected override Exception RunServerRpc(AmServerName node, out object result)
        {
            Exception exception = null;

            result = null;
            AmRole?role = null;

            try
            {
                InvokeWithTimeout.Invoke(delegate()
                {
                    string errorMessage = null;
                    exception           = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        role = new AmRole?(Dependencies.AmRpcClientWrapper.GetActiveManagerRole(node.Fqdn, out errorMessage));
                    });
                }, this.timeout);
            }
            catch (TimeoutException exception)
            {
                TimeoutException exception2;
                exception = exception2;
            }
            if (role != null)
            {
                Interlocked.Increment(ref this.successCount);
                result = role;
            }
            return(exception);
        }
        // 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;
        }
        // Token: 0x060004B2 RID: 1202 RVA: 0x00019670 File Offset: 0x00017870
        private void DismountCompletionCallback(IAsyncResult ar)
        {
            DismountDatabasesInParallel.AsyncDismountState state = (DismountDatabasesInParallel.AsyncDismountState)ar.AsyncState;
            Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                state.DismountFunction.EndInvoke(ar);
            });

            if (ex == null)
            {
                AmTrace.Debug("DismountDatabasesInParallel: Finished dismount for DB {0}.", new object[]
                {
                    state.MdbGuid
                });
            }
            else
            {
                AmTrace.Debug("DismountDatabasesInParallel: Dismount for DB {0} failed with {1}.", new object[]
                {
                    state.MdbGuid,
                    ex.Message
                });
            }
            lock (this.m_locker)
            {
                this.m_completedCount++;
                if (this.m_completedCount == this.m_totalRequests && this.m_completedEvent != null)
                {
                    this.m_completedEvent.Set();
                }
            }
        }
Esempio n. 4
0
        // Token: 0x0600054E RID: 1358 RVA: 0x0001AF88 File Offset: 0x00019188
        protected override void TimerCallbackInternal()
        {
            bool      flag = true;
            Exception ex   = null;
            AmSystemFailoverOnReplayDownTracker failoverTracker = AmSystemManager.Instance.SystemFailoverOnReplayDownTracker;

            if (failoverTracker != null)
            {
                try
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        this.Run(failoverTracker);
                    });
                    flag = false;
                }
                finally
                {
                    failoverTracker.RemoveTimer(this.serverName);
                    if (flag || ex != null)
                    {
                        ReplayCrimsonEvents.FailoverOnReplDownFailedToInitiate.Log <AmServerName, string>(this.serverName, (ex != null) ? ex.Message : "<Unhandled exception>");
                    }
                }
            }
        }
        public static void HandleRequest(RpcGenericRequestInfo requestInfo, ref RpcGenericReplyInfo replyInfo)
        {
            RpcGenericReplyInfo tmpReplyInfo = null;

            RpcKillServiceImpl.Request req = null;
            RpcKillServiceImpl.Reply   rep = new RpcKillServiceImpl.Reply();
            Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                req = ActiveManagerGenericRpcHelper.ValidateAndGetAttachedRequest <RpcKillServiceImpl.Request>(requestInfo, 1, 0);
                ReplayCrimsonEvents.ReceivedRequestToKillService.Log <string, string, RpcKillServiceImpl.Request>(req.ServiceName, req.OriginatingServerName, req);
                lock (RpcKillServiceImpl.locker)
                {
                    RpcKillServiceImpl.HandleRequestInternal(req, rep);
                }
                tmpReplyInfo = ActiveManagerGenericRpcHelper.PrepareServerReply(requestInfo, rep, 1, 0);
            });

            if (tmpReplyInfo != null)
            {
                replyInfo = tmpReplyInfo;
            }
            if (ex != null)
            {
                throw new AmServerException(ex.Message, ex);
            }
        }
Esempio n. 6
0
        // Token: 0x0600079D RID: 1949 RVA: 0x00024D10 File Offset: 0x00022F10
        public static void HandleRequest(RpcGenericRequestInfo requestInfo, ref RpcGenericReplyInfo replyInfo)
        {
            RpcGenericReplyInfo tmpReplyInfo = null;

            RpcUpdateLastLogImpl.Request req = null;
            RpcUpdateLastLogImpl.Reply   rep = new RpcUpdateLastLogImpl.Reply();
            Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                req = ActiveManagerGenericRpcHelper.ValidateAndGetAttachedRequest <RpcUpdateLastLogImpl.Request>(requestInfo, 1, 0);
                ExDateTime exDateTime = ExDateTime.MinValue;
                AmCachedLastLogUpdater pamCachedLastLogUpdater = AmSystemManager.Instance.PamCachedLastLogUpdater;
                if (pamCachedLastLogUpdater != null)
                {
                    exDateTime = pamCachedLastLogUpdater.AddEntries(req.ServerName, req.InitiatedTimeUtc, req.LastLogEntries);
                }
                rep.LastSuccessfulUpdateTimeUtc = exDateTime.UniversalTime;
                tmpReplyInfo = ActiveManagerGenericRpcHelper.PrepareServerReply(requestInfo, rep, 1, 0);
            });

            if (tmpReplyInfo != null)
            {
                replyInfo = tmpReplyInfo;
            }
            if (ex != null)
            {
                throw new AmServerException(ex.Message, ex);
            }
        }
        // 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);
        }
        // Token: 0x060003FB RID: 1019 RVA: 0x00015764 File Offset: 0x00013964
        private void PerformVerification()
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsSAM)
            {
                AmServerName pam          = config.DagConfig.CurrentPAM;
                AmRole       role         = AmRole.Unknown;
                string       errorMessage = null;
                Exception    ex           = null;
                bool         flag         = false;
                if (this.IsServerDisabled(AmServerName.LocalComputerName))
                {
                    AmTrace.Debug("PamMonitor.PerformVerification found local server marked ActivationDisabled", new object[0]);
                    return;
                }
                IADServer server = Dependencies.ADConfig.GetServer(pam);
                if (server == null)
                {
                    AmTrace.Error("PamMonitor.PerformVerification found pam on {0} but no server data in ADConfig", new object[]
                    {
                        pam.Fqdn
                    });
                    return;
                }
                if (this.IsServerDisabled(server))
                {
                    AmTrace.Debug("PamMonitor.PerformVerification found PAM server marked ActivationDisabled", new object[0]);
                    flag = true;
                }
                if (!flag)
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        role = Dependencies.AmRpcClientWrapper.GetActiveManagerRole(pam.Fqdn, out errorMessage);
                    });
                }
                if (flag || role != AmRole.PAM)
                {
                    string text = string.Empty;
                    int    num  = RegistryParameters.PamMonitorRecoveryDurationInSec;
                    if (flag)
                    {
                        errorMessage = "PAM has been marked ActivationDisabled";
                        num          = 5;
                    }
                    else if (ex != null)
                    {
                        text = ex.Message;
                    }
                    ReplayCrimsonEvents.PamMonitorServerNotInPamRole.Log <AmServerName, AmRole, string, string>(pam, role, errorMessage, text);
                    this.pamServerInVerificationPhase = pam;
                    this.phase = AmPamMonitor.PamMonitorPhase.Recovery;
                    TimeSpan timeSpan = TimeSpan.FromSeconds((double)num);
                    base.ChangeTimer(timeSpan, timeSpan);
                }
            }
        }
Esempio n. 9
0
        protected override void RunInternal()
        {
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                AmDbAction.DismountIfMismounted(base.Database, this.ActionCode, this.MismountedNodes);
            });

            base.LastException = lastException;
        }
        protected override void RunInternal()
        {
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                AmDbAction amDbAction = base.PrepareDbAction(this.ActionCode);
                amDbAction.Remount(this.Flags, this.MountDialOverride, this.FromServer);
            });

            base.LastException = lastException;
        }
        // Token: 0x060002E0 RID: 736 RVA: 0x00010040 File Offset: 0x0000E240
        protected override void RunInternal()
        {
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                this.CheckIfOperationIsAllowedOnCurrentRole();
                AmDbAction.SyncDatabaseOwningServerAndLegacyDn(base.Database, this.ActionCode);
            });

            base.LastException = lastException;
        }
Esempio n. 12
0
        // Token: 0x06000628 RID: 1576 RVA: 0x0001E7A4 File Offset: 0x0001C9A4
        internal void DeleteFromPersistentStoreBestEffort()
        {
            Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                this.DeleteFromPersistentStore();
            });

            if (ex != null)
            {
                ReplayCrimsonEvents.TransientFailoverSuppressionPersistentStoreFailure.Log <string, AmServerName, string>("Delete", this.ServerName, ex.Message);
            }
        }
Esempio n. 13
0
        internal static RpcKillServiceImpl.Reply SendKillRequest(string serverName, string serviceName, DateTime minTimeCheck, bool isForce, int timeoutInMSec)
        {
            Exception ex = null;

            RpcKillServiceImpl.Reply reply = null;
            bool isSucceded = false;
            bool flag       = true;

            try
            {
                ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                {
                    ReplayCrimsonEvents.SendingServiceKillRequest.Log <string, string>(serviceName, serverName);
                    RpcKillServiceImpl.Request attachedRequest = new RpcKillServiceImpl.Request(serviceName, minTimeCheck, false);
                    RpcGenericRequestInfo requestInfo          = ActiveManagerGenericRpcHelper.PrepareClientRequest(attachedRequest, 1, 1, 0);
                    reply      = ActiveManagerGenericRpcHelper.RunRpcAndGetReply <RpcKillServiceImpl.Reply>(requestInfo, serverName, timeoutInMSec);
                    isSucceded = reply.IsSucceeded;
                });
                flag = false;
            }
            finally
            {
                if (isSucceded)
                {
                    ReplayCrimsonEvents.ServiceKillRequestSucceeded.Log <string, string, string>(serviceName, serverName, reply.ToString());
                }
                else
                {
                    string text = "Unknown";
                    if (ex != null)
                    {
                        text = string.Format("Error: {0}", ex.Message);
                    }
                    else if (reply != null)
                    {
                        if (reply.IsThrottled)
                        {
                            text = "Throttled";
                        }
                        else if (reply.IsSkippedDueToTimeCheck)
                        {
                            text = "SkippedDueToTimeCheck";
                        }
                        else if (reply.IsSkippedDueToRegistryOverride)
                        {
                            text = "SkippedDueToRegistryOverride";
                        }
                    }
                    ReplayCrimsonEvents.ServiceKillRequestFailed.Log <string, string, bool, string, bool, string>(serviceName, serverName, reply != null && reply.IsThrottled, text, flag, (reply != null) ? reply.ToString() : "<null>");
                }
            }
            return(reply);
        }
        // Token: 0x060002A9 RID: 681 RVA: 0x0000F8DC File Offset: 0x0000DADC
        protected override void RunInternal()
        {
            AmDbOperationDetailedStatus mountStatus = null;
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                AmDbAction amDbAction = this.PrepareDbAction(this.ActionCode);
                amDbAction.Mount(this.StoreMountFlags, this.AmMountFlags, this.MountDialOverride, ref mountStatus);
            });

            base.DetailedStatus = mountStatus;
            base.LastException  = lastException;
        }
        // Token: 0x060002C2 RID: 706 RVA: 0x0000FCD8 File Offset: 0x0000DED8
        protected override void RunInternal()
        {
            AmDbOperationDetailedStatus moveStatus = null;
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                AmDbAction amDbAction = this.PrepareDbAction(this.Arguments.ActionCode);
                amDbAction.Move(this.Arguments.MountFlags, this.Arguments.DismountFlags, this.Arguments.MountDialOverride, this.Arguments.SourceServer, this.Arguments.TargetServer, this.Arguments.TryOtherHealthyServers, this.Arguments.SkipValidationChecks, this.Arguments.MoveComment, this.Arguments.ComponentName, ref moveStatus);
            });

            base.DetailedStatus = moveStatus;
            base.LastException  = lastException;
        }
Esempio n. 16
0
        // Token: 0x06000624 RID: 1572 RVA: 0x0001E57C File Offset: 0x0001C77C
        internal static AmFailoverEntry ReadFromPersistentStoreBestEffort(AmServerName serverName)
        {
            AmFailoverEntry entry = null;
            Exception       ex    = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                entry = AmFailoverEntry.ReadFromPersistentStore(serverName);
            });

            if (ex != null)
            {
                ReplayCrimsonEvents.TransientFailoverSuppressionPersistentStoreFailure.Log <string, AmServerName, string>("Read", serverName, ex.Message);
            }
            return(entry);
        }
Esempio n. 17
0
        internal void InitializeFromClusdb()
        {
            Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                lock (this.locker)
                {
                    this.InitializeFromClusdbInternal();
                }
            });

            if (ex != null)
            {
                ReplayCrimsonEvents.FailoverOnReplDownClusdbInitializeFailed.Log <string, int, string>(this.ActionName, this.MaxHistorySize, (ex != null) ? ex.Message : "<null>");
            }
        }
Esempio n. 18
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);
        }
 // Token: 0x060003FC RID: 1020 RVA: 0x000158D4 File Offset: 0x00013AD4
 private void PerformRecovery()
 {
     try
     {
         Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
         {
             this.PerformRecoveryInternal();
         });
         if (ex != null)
         {
             ReplayCrimsonEvents.PamMonitorEncounteredException.Log <string, string>(ex.Message, "Recovery");
         }
     }
     finally
     {
         this.phase = AmPamMonitor.PamMonitorPhase.Verification;
         base.ChangeTimer(this.checkPeriod, this.checkPeriod);
     }
 }
        private static bool ReportStoreStatus(AmServerName serverToContact, AmSystemEventCode eventCode, AmServerName reportingServer)
        {
            Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                AmRpcClientHelper.ReportSystemEvent(serverToContact.Fqdn, (int)eventCode, reportingServer.Fqdn);
            });

            if (ex != null)
            {
                AmServiceMonitor.Tracer.TraceError(0L, "Failed to report status to PAM (pam={0}, eventCode={1}, reportingServer={2}): error={3}", new object[]
                {
                    serverToContact,
                    eventCode,
                    reportingServer,
                    ex.Message
                });
                return(false);
            }
            return(true);
        }
 // Token: 0x06000045 RID: 69 RVA: 0x00002878 File Offset: 0x00000A78
 internal void Run()
 {
     AmTrace.Entering("AmBatchOperationBase.Run()", new object[0]);
     if (RegistryParameters.AmDisableBatchOperations)
     {
         ReplayCrimsonEvents.BatchMounterOperationsDisabled.Log();
         AmTrace.Leaving("AmBatchOperationBase.Run(), BatchMounterOperationsDisabled", new object[0]);
         return;
     }
     lock (this.m_locker)
     {
         try
         {
             this.m_isDebugOptionEnabled = this.m_amConfig.IsDebugOptionsEnabled();
             this.LogStartupInternal();
             Exception ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
             {
                 this.RunInternal();
             });
             if (ex != null)
             {
                 AmTrace.Error("Batch mounter operation {0} got an exception {1}", new object[]
                 {
                     base.GetType().Name,
                     ex
                 });
                 ReplayCrimsonEvents.BatchMounterOperationFailed.Log <string>(ex.Message);
             }
         }
         finally
         {
             if (!this.m_derivedManagesAllDone && (this.m_opList == null || this.m_opList.Count == 0))
             {
                 this.MarkAllDone();
             }
         }
     }
     AmTrace.Leaving("AmBatchOperationBase.Run()", new object[0]);
 }
Esempio n. 22
0
        internal void NotifyServiceKillToOtherServers(string serviceName, ExDateTime timeInUtc)
        {
            AmLastKnownGoodConfig lastKnownGoodConfig = AmSystemManager.Instance.LastKnownGoodConfig;

            if (lastKnownGoodConfig != null && lastKnownGoodConfig.Role != AmRole.Unknown && lastKnownGoodConfig.Members != null)
            {
                timeInUtc.ToString("s");
                AmServerName[] members = lastKnownGoodConfig.Members;
                for (int i = 0; i < members.Length; i++)
                {
                    AmServerName serverName = members[i];
                    ThreadPool.QueueUserWorkItem(delegate(object param0)
                    {
                        AmServerName serverToRpc     = serverName;
                        AmServerName reportingServer = AmServerName.LocalComputerName;
                        AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                        {
                            AmRpcClientHelper.AmReportServiceKill(serverToRpc.NetbiosName, AmRpcClientHelper.RpcTimeoutShort, serviceName, reportingServer.NetbiosName, timeInUtc.ToString("u"));
                        });
                    });
                }
            }
        }
Esempio n. 23
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;
            }
        }
Esempio n. 24
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);
        }
Esempio n. 25
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;
            }
        }
Esempio n. 26
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;
            }
        }
Esempio n. 27
0
        internal void Dismount(UnmountFlags flags)
        {
            Exception ex        = null;
            bool      flag      = true;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                using (AmDatabaseOperationLock.Lock(this.DatabaseGuid, AmDbLockReason.Dismount, this.m_lockTimeout))
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        ReplayCrimsonEvents.ToplevelDismountInitiated.LogGeneric(this.PrepareStartupArgs(new object[]
                        {
                            flags
                        }));
                        if (!this.State.IsEntryExist)
                        {
                            throw new AmDatabaseNeverMountedException();
                        }
                        this.ClearFailureAttemptIfAdminAction(this.DatabaseGuid);
                        this.DismountInternal(flags);
                    });
                    this.WriteStateClearIfInProgressStatus(true);
                    flag = false;
                }
            }
            catch (AmDbLockConflictException ex2)
            {
                ex = ex2;
            }
            finally
            {
                stopwatch.Stop();
                AmSystemManager.Instance.TransientFailoverSuppressor.AdminRequestedForRemoval(this.State.ActiveServer, "Dismount-Database");
                if (flag || ex != null)
                {
                    string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError;
                    ReplayCrimsonEvents.ToplevelDismountFailed.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        stopwatch.Elapsed,
                        text
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseDismountFailed.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        this.State.ActiveServer,
                        text
                    });
                }
                else
                {
                    ReplayCrimsonEvents.ToplevelDismountSuccess.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        stopwatch.Elapsed
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseDismounted.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        this.State.ActiveServer
                    });
                }
            }
            if (ex != null)
            {
                throw ex;
            }
        }
Esempio n. 28
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);
        }