Ejemplo n.º 1
0
        private bool RunChecks(AmServerName sourceServer, AmServerName targetServer, RpcDatabaseCopyStatus2 status, AmBcsChecks amBcsChecks, out AmBcsChecks completedChecks, ref LocalizedString error)
        {
            bool flag = this.HasNotBeenTried(targetServer, ref error);

            completedChecks = AmBcsChecks.None;
            if (flag)
            {
                if (this.m_bcsContext.ActionCode.IsMountOrRemountOperation && AmServerName.IsEqual(sourceServer, targetServer))
                {
                    AmTrace.Debug("BCS: Target server '{0}' is skipping validation checks to allow mount to take place for database '{1}'.", new object[]
                    {
                        targetServer.NetbiosName,
                        this.m_bcsContext.GetDatabaseNameOrGuid()
                    });
                    flag = true;
                }
                else
                {
                    AmBcsCopyValidation amBcsCopyValidation = new AmBcsCopyValidation(this.m_bcsContext.DatabaseGuid, this.m_bcsContext.GetDatabaseNameOrGuid(), amBcsChecks, sourceServer, targetServer, status, this.m_bcsContext.ErrorLogger, this.m_bcsContext.SkipValidationChecks, this.m_bcsContext.ComponentStateWrapper);
                    flag            = amBcsCopyValidation.RunChecks(ref error);
                    completedChecks = amBcsCopyValidation.CompletedChecks;
                }
            }
            else
            {
                AmTrace.Debug("BCS: Target server '{0}' has already been tried for database '{1}'.", new object[]
                {
                    targetServer.NetbiosName,
                    this.m_bcsContext.GetDatabaseNameOrGuid()
                });
            }
            return(flag);
        }
Ejemplo n.º 2
0
 private void UpdateAdProperties(bool isOperationSuccess, AmServerName initialActiveServer)
 {
     if (!AmServerName.IsNullOrEmpty(base.State.ActiveServer))
     {
         bool isForceUpdate = !AmServerName.IsEqual(initialActiveServer, base.State.ActiveServer);
         if (isOperationSuccess || isForceUpdate)
         {
             base.DbTrace.Debug("Issuing async SetDatabaseLegacyDnAndOwningServer", new object[0]);
             ThreadPool.QueueUserWorkItem(delegate(object param0)
             {
                 Exception ex = SharedHelper.RunADOperationEx(delegate(object param0, EventArgs param1)
                 {
                     SharedDependencies.WritableADHelper.SetDatabaseLegacyDnAndOwningServer(this.DatabaseGuid, initialActiveServer, this.State.ActiveServer, isForceUpdate);
                 });
                 if (ex != null)
                 {
                     this.DbTrace.Error("SetDatabaseLegacyDnAndOwningServer failed: {0}", new object[]
                     {
                         ex
                     });
                 }
             });
             return;
         }
     }
     else
     {
         AmTrace.Error("Skipped updating ad properties for database {0} since active server is empty", new object[]
         {
             base.DatabaseName
         });
     }
 }
        // Token: 0x0600008D RID: 141 RVA: 0x00004904 File Offset: 0x00002B04
        private bool IsActiveOnServer(IADDatabase db, AmServerName movingFromServer, out LocalizedString skipReason)
        {
            bool          result        = false;
            AmDbStateInfo amDbStateInfo = this.m_amConfig.DbState.Read(db.Guid);

            if (amDbStateInfo.IsEntryExist)
            {
                if (AmServerName.IsEqual(movingFromServer, amDbStateInfo.ActiveServer))
                {
                    result     = true;
                    skipReason = LocalizedString.Empty;
                }
                else
                {
                    AmTrace.Info("IsActiveOnServer: Excluding database {0} from moving since it is not active on {1} (active={2})", new object[]
                    {
                        db.Name,
                        movingFromServer,
                        amDbStateInfo.ActiveServer
                    });
                    skipReason = ReplayStrings.DbMoveSkippedBecauseNotActive(db.Name, movingFromServer.NetbiosName, amDbStateInfo.ActiveServer.NetbiosName);
                }
            }
            else
            {
                AmTrace.Error("IsActiveOnServer: Failed to find db state info from clusdb (db={0})", new object[]
                {
                    db.Name
                });
                skipReason = ReplayStrings.DbMoveSkippedBecauseNotFoundInClusDb(db.Name);
            }
            return(result);
        }
Ejemplo n.º 4
0
        // Token: 0x06000316 RID: 790 RVA: 0x00011DC0 File Offset: 0x0000FFC0
        internal void UpdateActiveServerAndIncrementFailoverSequenceNumber(AmServerName activeServer)
        {
            long ticks = DateTime.UtcNow.Ticks;
            bool flag  = false;

            if (!this.IsEntryExist || !AmServerName.IsEqual(this.ActiveServer, activeServer))
            {
                flag = true;
            }
            this.ActiveServer = activeServer;
            if (flag)
            {
                if (!this.IsEntryExist || this.FailoverSequenceNumber == 0L)
                {
                    this.FailoverSequenceNumber = ticks;
                    return;
                }
                if (this.FailoverSequenceNumber < ticks)
                {
                    this.FailoverSequenceNumber = ticks;
                    return;
                }
                this.FailoverSequenceNumber += 1L;
                ReplayCrimsonEvents.DatabaseFailoverSequenceNumberNotBasedOnTime.LogPeriodic <Guid, long>(this.DatabaseGuid, TimeSpan.FromMinutes(30.0), this.DatabaseGuid, this.FailoverSequenceNumber);
            }
        }
Ejemplo n.º 5
0
 private int IsServerActive(AmServerName server)
 {
     if (!AmServerName.IsEqual(server, this.m_bcsContext.SourceServerName))
     {
         return(0);
     }
     return(1);
 }
Ejemplo n.º 6
0
        private string GetAllNodesStillInList(AmServerName nodeToExclude)
        {
            string result = string.Empty;

            lock (this.locker)
            {
                if (this.nodeActionMap.Count > 0)
                {
                    result = this.GetNodeInfoListAsString(from nodeInfo in this.nodeActionMap.Values
                                                          where !AmServerName.IsEqual(nodeInfo.Name, nodeToExclude)
                                                          select nodeInfo);
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        private bool UpdateMaster(AmServerName newMasterServer, bool isMountSkipped)
        {
            bool         flag         = false;
            AmServerName activeServer = base.State.ActiveServer;

            if (!AmServerName.IsEqual(activeServer, newMasterServer))
            {
                AmTrace.Debug("Active server changed. (previous={0}, current={1})", new object[]
                {
                    activeServer,
                    newMasterServer
                });
                flag = true;
            }
            base.ReportStatus(AmDbActionStatus.UpdateMasterServerInitiated);
            bool flag2 = isMountSkipped ? base.WriteStateMountSkipped(newMasterServer) : base.WriteStateMountStart(newMasterServer);

            if (flag2)
            {
                AmDatabaseStateTracker databaseStateTracker = AmSystemManager.Instance.DatabaseStateTracker;
                if (databaseStateTracker != null)
                {
                    databaseStateTracker.UpdateActive(base.DatabaseGuid, newMasterServer);
                }
            }
            if (flag)
            {
                if (!activeServer.IsEmpty)
                {
                    ReplayCrimsonEvents.ActiveServerChanged.LogGeneric(base.PrepareSubactionArgs(new object[]
                    {
                        activeServer,
                        newMasterServer
                    }));
                }
                else
                {
                    ReplayCrimsonEvents.ActiveServerChanged.LogGeneric(base.PrepareSubactionArgs(new object[]
                    {
                        "<none>",
                        newMasterServer
                    }));
                }
            }
            base.ReportStatus(AmDbActionStatus.UpdateMasterServerFinished);
            return(flag);
        }
Ejemplo n.º 8
0
        private AmServerName RunPhaseN(AmBcsChecks checks)
        {
            bool         flag         = false;
            AmServerName result       = null;
            AmServerName amServerName = null;

            if (this.m_bcsContext.ActionCode.Reason == AmDbActionReason.ActivationDisabled)
            {
                checks |= AmBcsChecks.ActivationEnabled;
            }
            if (this.m_bcsContext.ActionCode.IsMountOrRemountOperation || this.m_bcsContext.ActionCode.IsAdminMoveOperation)
            {
                amServerName = this.m_bcsContext.SourceServerName;
                if (this.m_bcsContext.IsSourceServerAllowedForMount)
                {
                    flag = this.RunChecksWrapper(checks, out result, amServerName, null);
                }
                else
                {
                    AmTrace.Debug("BCS: RunPhaseN: Ignoring source server {0} since determine servers did not allow it.", new object[]
                    {
                        amServerName
                    });
                }
            }
            if (!flag)
            {
                foreach (KeyValuePair <AmServerName, RpcDatabaseCopyStatus2> keyValuePair in this.m_sortedStatusCollection)
                {
                    if (!AmServerName.IsEqual(amServerName, keyValuePair.Key))
                    {
                        flag = this.RunChecksWrapper(checks, out result, keyValuePair.Key, keyValuePair.Value);
                        if (flag)
                        {
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        // Token: 0x06000136 RID: 310 RVA: 0x00007620 File Offset: 0x00005820
        internal static AmConfigChangedFlags CheckForChanges(AmConfig left, AmConfig right)
        {
            AmConfigChangedFlags amConfigChangedFlags = AmConfigChangedFlags.None;

            if (left.Role != right.Role)
            {
                amConfigChangedFlags |= AmConfigChangedFlags.Role;
            }
            if (!object.ReferenceEquals(left.DbState, right.DbState))
            {
                amConfigChangedFlags |= AmConfigChangedFlags.DbState;
            }
            if (!SharedHelper.StringIEquals(left.LastError, right.LastError))
            {
                amConfigChangedFlags |= AmConfigChangedFlags.LastError;
            }
            if ((left.DagConfig == null && right.DagConfig != null) || (left.DagConfig != null && right.DagConfig == null))
            {
                amConfigChangedFlags |= AmConfigChangedFlags.DagConfig;
            }
            if (left.DagConfig != null && right.DagConfig != null)
            {
                if (!left.DagConfig.Id.Equals(right.DagConfig.Id))
                {
                    amConfigChangedFlags |= AmConfigChangedFlags.DagId;
                }
                if (!AmServerName.IsArrayEquals(left.DagConfig.MemberServers, right.DagConfig.MemberServers))
                {
                    amConfigChangedFlags |= AmConfigChangedFlags.MemberServers;
                }
                if (!AmServerName.IsEqual(left.DagConfig.CurrentPAM, right.DagConfig.CurrentPAM))
                {
                    amConfigChangedFlags |= AmConfigChangedFlags.CurrentPAM;
                }
                if (!object.ReferenceEquals(left.DagConfig.Cluster, right.DagConfig.Cluster))
                {
                    amConfigChangedFlags |= AmConfigChangedFlags.Cluster;
                }
            }
            return(amConfigChangedFlags);
        }
Ejemplo n.º 10
0
        // Token: 0x0600068C RID: 1676 RVA: 0x0001FD2C File Offset: 0x0001DF2C
        private bool IsPassiveCopy(ref LocalizedString error)
        {
            RpcDatabaseCopyStatus2 copyStatus = this.CopyStatus;
            bool flag = AmServerName.IsEqual(this.SourceServer, this.TargetServer);

            if (!flag && copyStatus != null && (copyStatus.CopyStatus == CopyStatusEnum.Mounted || copyStatus.CopyStatus == CopyStatusEnum.Mounting || copyStatus.CopyStatus == CopyStatusEnum.Dismounted || copyStatus.CopyStatus == CopyStatusEnum.Dismounting))
            {
                AmTrace.Error("IsPassiveCopy: Copy status for DB '{0}' has active copy status, but fActive is false! CopyStatus = '{1}'. Changing fActive to 'true'.", new object[]
                {
                    this.DbName,
                    copyStatus.CopyStatus
                });
                flag = true;
            }
            if (flag)
            {
                error = ReplayStrings.AmBcsDatabaseCopyHostedOnTarget(this.DbName, this.TargetServer.NetbiosName);
                this.ReportCopyStatusFailure(AmBcsChecks.IsPassiveCopy, error);
            }
            return(!flag);
        }
Ejemplo n.º 11
0
 private void CheckIfMoveApplicableForDatabase(AmServerName activeServer, AmServerName moveFromServer, AmDbActionCode actionCode)
 {
     if (base.Database.ReplicationType != ReplicationType.Remote)
     {
         AmTrace.Debug("Move ignored for database {0} since it is not replicated.", new object[]
         {
             base.DatabaseName
         });
         throw new AmDbMoveOperationNotSupportedException(base.DatabaseName);
     }
     if (!AmServerName.IsNullOrEmpty(moveFromServer))
     {
         if (!AmServerName.IsEqual(activeServer, moveFromServer))
         {
             AmTrace.Diagnostic("Move ignored for database {0} since the master server is different from the server that originally initiated the failover. (master={1}, movedInitiatedFrom={2})", new object[]
             {
                 base.DatabaseName,
                 activeServer,
                 moveFromServer
             });
             throw new AmDbMoveOperationNoLongerApplicableException(base.DatabaseName, moveFromServer.NetbiosName, activeServer.NetbiosName);
         }
         if (actionCode.Reason == AmDbActionReason.TimeoutFailure)
         {
             bool flag = AmStoreHelper.IsMounted(moveFromServer, base.DatabaseGuid);
             if (flag)
             {
                 throw new AmDbMoveOperationOnTimeoutFailureCancelled(base.DatabaseName, moveFromServer.NetbiosName);
             }
         }
     }
     if (base.Config.DagConfig.MemberServers.Length < 2)
     {
         AmTrace.Diagnostic("Move ignored for database {0} since according to active manager there is just one server in the DAG)", new object[]
         {
             base.DatabaseName
         });
         throw new AmDbMoveOperationNotSupportedException(base.DatabaseName);
     }
 }
Ejemplo n.º 12
0
        internal static void DismountIfMismounted(IADDatabase db, AmDbActionCode actionCode, List <AmServerName> mismountedNodes)
        {
            AmConfig config = AmSystemManager.Instance.Config;

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

            if (amDbStateInfo.IsEntryExist)
            {
                using (List <AmServerName> .Enumerator enumerator = mismountedNodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AmServerName amServerName = enumerator.Current;
                        if (!AmServerName.IsEqual(amServerName, amDbStateInfo.ActiveServer))
                        {
                            ReplayCrimsonEvents.DismountingMismountedDatabase.Log <string, Guid, AmServerName>(db.Name, db.Guid, amServerName);
                            AmStoreHelper.RemoteDismount(amServerName, db.Guid, UnmountFlags.SkipCacheFlush, false);
                        }
                        else
                        {
                            AmTrace.Warning("Ignoring force dismount for {0} since it is the current active {1}", new object[]
                            {
                                db.Name,
                                amServerName
                            });
                        }
                    }
                    return;
                }
            }
            AmTrace.Warning("DismountIfMismounted skipped since the database {0} was never mounted", new object[]
            {
                db.Name
            });
        }
Ejemplo n.º 13
0
        private bool IsAcllRequired(AmServerName serverToMount, AmServerName sourceServer)
        {
            if (base.Config.DagConfig.IsThirdPartyReplEnabled)
            {
                return(false);
            }
            bool result = true;

            if (base.Database.ReplicationType != ReplicationType.Remote)
            {
                AmTrace.Debug("Skipping ACLL for database '{0}' on server '{1}' since it is not replicated.", new object[]
                {
                    base.DatabaseName,
                    serverToMount
                });
                result = false;
            }
            else if (!base.State.IsMountSucceededAtleastOnce)
            {
                AmTrace.Debug("Skipping ACLL for database '{0}' on server '{1}' since it has never been successfully mounted.", new object[]
                {
                    base.DatabaseName,
                    serverToMount
                });
                result = false;
            }
            else if (AmServerName.IsEqual(serverToMount, sourceServer))
            {
                AmTrace.Debug("Skipping ACLL for database '{0}' on server '{1}' since it is already the source server.", new object[]
                {
                    base.DatabaseName,
                    serverToMount
                });
                result = false;
            }
            return(result);
        }
Ejemplo n.º 14
0
 internal bool IsActiveOnServerAndReplicated(AmServerName serverName)
 {
     return(this.Database.ReplicationType == ReplicationType.Remote && AmServerName.IsEqual(this.ActiveServer, serverName));
 }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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;
            }
        }
Ejemplo n.º 17
0
        internal static void SyncClusterDatabaseState(IADDatabase db, AmDbActionCode actionCode)
        {
            AmConfig config = AmSystemManager.Instance.Config;

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

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

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

            if (mountStatus != mountStatus2 || !AmServerName.IsEqual(amDbStateInfo.LastMountedServer, amDbStateInfo.ActiveServer))
            {
                if (mountStatus != mountStatus2)
                {
                    AmTrace.Debug("Mounted state reported by STORE is different from persistent state. (Database:{0}, PersistentState: {1}, StoreIsReporting: {2})", new object[]
                    {
                        db.Name,
                        mountStatus2,
                        mountStatus
                    });
                }
                else
                {
                    AmTrace.Debug("State is in transit. (Database:{0}, LastMountedServer: {1},ActiveServer: {2})", new object[]
                    {
                        db.Name,
                        amDbStateInfo.LastMountedServer,
                        amDbStateInfo.ActiveServer
                    });
                }
                AmDbAction.WriteStateSyncMountStatus(config, amDbStateInfo, db.Guid, amServerName, mountStatus);
                ReplayCrimsonEvents.DatabaseMountStatusSynchronized.Log <string, Guid, MountStatus, MountStatus, AmServerName>(db.Name, db.Guid, mountStatus2, mountStatus, amServerName);
                return;
            }
            AmTrace.Debug("Ignored persistent state sync for {0} since nothing is out of sync", new object[]
            {
                db.Name
            });
        }
Ejemplo n.º 18
0
 internal void Analyze()
 {
     this.OwningServer = new AmServerName(this.Database.Server.Name);
     this.ActiveServer = this.StateInfo.ActiveServer;
     if (AmServerName.IsNullOrEmpty(this.ActiveServer))
     {
         this.ActiveServer = this.OwningServer;
     }
     if (!AmServerName.IsEqual(this.ActiveServer, this.OwningServer))
     {
         this.IsAdPropertiesOutOfSync = true;
     }
     if (this.Database.Servers.Length > 1 && AmBestCopySelectionHelper.IsActivationDisabled(this.ActiveServer))
     {
         this.IsActiveOnDisabledServer = true;
     }
     this.MisMountedServerList = new List <AmServerName>();
     foreach (AmServerName amServerName in this.StoreStatus.Keys)
     {
         if ((this.StoreStatus[amServerName] & MdbStatusFlags.Online) == MdbStatusFlags.Online)
         {
             if (AmServerName.IsEqual(amServerName, this.ActiveServer))
             {
                 this.IsMountedOnActive = true;
             }
             else
             {
                 this.MisMountedServerList.Add(amServerName);
             }
         }
         else if ((this.StoreStatus[amServerName] & MdbStatusFlags.MountInProgress) == MdbStatusFlags.MountInProgress && AmServerName.IsEqual(amServerName, this.ActiveServer))
         {
             this.IsMountedOnActive = true;
         }
     }
     this.IsMismounted = (this.MisMountedServerList != null && this.MisMountedServerList.Count > 0);
     this.IsMountedButAdminRequestedDismount = false;
     if (this.IsMountedOnActive)
     {
         if (this.StateInfo.IsAdminDismounted)
         {
             this.IsMountedButAdminRequestedDismount = true;
         }
         if (!this.StateInfo.IsMounted)
         {
             this.IsClusterDatabaseOutOfSync = true;
         }
     }
     else if (this.StateInfo.IsMounted)
     {
         this.IsClusterDatabaseOutOfSync = true;
     }
     this.IsPeriodicMountRequired = true;
     if (!this.IsMountedOnActive)
     {
         bool flag = AmSystemManager.Instance.StoreStateMarker.IsStoreGracefullyStoppedOn(this.ActiveServer);
         if (!this.Database.MountAtStartup || this.StateInfo.IsAdminDismounted || !this.StateInfo.IsMountAttemptedAtleastOnce || flag)
         {
             this.IsPeriodicMountRequired = false;
             ReplayCrimsonEvents.PeriodicCheckerSkippedMount.LogPeriodic <string, Guid, AmServerName, bool, bool, bool, bool>(this.Database.Guid, TimeSpan.FromMinutes(30.0), this.Database.Name, this.Database.Guid, this.ActiveServer, this.Database.MountAtStartup, this.StateInfo.IsAdminDismounted, this.StateInfo.IsMountAttemptedAtleastOnce, flag);
         }
     }
     else
     {
         this.IsPeriodicMountRequired = false;
     }
     if (this.StateInfo.IsMountSucceededAtleastOnce && !AmServerName.IsEqual(this.StateInfo.LastMountedServer, this.StateInfo.ActiveServer))
     {
         this.IsClusterDatabaseOutOfSync = true;
     }
 }
Ejemplo n.º 19
0
        // Token: 0x060003FD RID: 1021 RVA: 0x0001596C File Offset: 0x00013B6C
        private void PerformRecoveryInternal()
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsSAM)
            {
                AmServerName currentPAM = config.DagConfig.CurrentPAM;
                if (!AmServerName.IsEqual(this.pamServerInVerificationPhase, currentPAM))
                {
                    ReplayCrimsonEvents.PamMonitorMoveSkippedSinceServerChanged.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, currentPAM);
                    return;
                }
                List <AmServerName>    list = config.DagConfig.MemberServers.ToList <AmServerName>();
                AmMultiNodeRoleFetcher amMultiNodeRoleFetcher = new AmMultiNodeRoleFetcher(list, TimeSpan.FromSeconds((double)RegistryParameters.PamMonitorRoleCheckTimeoutInSec), false);
                amMultiNodeRoleFetcher.Run();
                Dictionary <AmServerName, AmRole> roleMap = amMultiNodeRoleFetcher.RoleMap;
                string text = string.Join("\n", (from kvp in roleMap
                                                 select string.Format("[{0}] => {1}", kvp.Key, kvp.Value)).ToArray <string>());
                ReplayCrimsonEvents.PamMonitorServerRolesView.Log <string>(text);
                int count = list.Count;
                int num   = roleMap.Count((KeyValuePair <AmServerName, AmRole> kvp) => kvp.Value == AmRole.SAM);
                int num2  = count / 2 + 1;
                if (num < num2)
                {
                    ReplayCrimsonEvents.PamMonitorMoveCancelledSinceMinimumRequiredNotMet.Log <int, int, int>(count, num, num2);
                    return;
                }
                List <AmServerName> list2 = new List <AmServerName>(roleMap.Count);
                List <AmServerName> list3 = new List <AmServerName>(roleMap.Count);
                foreach (KeyValuePair <AmServerName, AmRole> keyValuePair in roleMap)
                {
                    if (!this.IsServerDisabled(keyValuePair.Key))
                    {
                        if (keyValuePair.Value == AmRole.PAM)
                        {
                            ReplayCrimsonEvents.PamMonitorMoveSkippedDueToValidResponseFromPAM.Log <AmServerName>(keyValuePair.Key);
                            return;
                        }
                        if (keyValuePair.Value == AmRole.SAM)
                        {
                            if (keyValuePair.Key.CompareTo(currentPAM) > 0)
                            {
                                list2.Add(keyValuePair.Key);
                            }
                            else
                            {
                                list3.Add(keyValuePair.Key);
                            }
                        }
                    }
                }
                list2.Sort();
                list3.Sort();
                AmServerName[] array = new AmServerName[list2.Count + list3.Count];
                list2.CopyTo(array);
                list3.CopyTo(array, list2.Count);
                bool flag = false;
                foreach (AmServerName amServerName in array)
                {
                    if (flag)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(5.0));
                        currentPAM = config.DagConfig.CurrentPAM;
                        if (!AmServerName.IsEqual(this.pamServerInVerificationPhase, currentPAM))
                        {
                            ReplayCrimsonEvents.PamMonitorMoveSkippedSinceServerChanged.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, currentPAM);
                            return;
                        }
                    }
                    try
                    {
                        ReplayCrimsonEvents.PamMonitorBeginsToMovePAM.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, amServerName);
                        AmClusterGroup.MoveClusterGroupWithTimeout(AmServerName.LocalComputerName, amServerName, TimeSpan.FromSeconds((double)RegistryParameters.PamMonitorMoveClusterGroupTimeout));
                        ReplayCrimsonEvents.PamMonitorSuccessfulyMovedPAM.Log <AmServerName, AmServerName>(this.pamServerInVerificationPhase, amServerName);
                        return;
                    }
                    catch (ClusterException ex)
                    {
                        flag = true;
                        AmTrace.Error("PAM election failed for {0} : {1}", new object[]
                        {
                            amServerName,
                            ex
                        });
                        ReplayCrimsonEvents.PamMonitorEncounteredException.Log <string, string>(ex.Message, "MoveClusterGroup");
                    }
                }
                ReplayCrimsonEvents.PamMonitorCouldNotFindValidServerToMovePAM.Log();
            }
        }
Ejemplo n.º 20
0
        // Token: 0x060000B5 RID: 181 RVA: 0x00005598 File Offset: 0x00003798
        private bool IsDatabaseActiveOnServer(Dictionary <Guid, AmDbStateInfo> dbStateInfoMap, Guid databaseGuid, AmServerName serverName)
        {
            AmDbStateInfo amDbStateInfo;

            return(dbStateInfoMap != null && dbStateInfoMap.TryGetValue(databaseGuid, out amDbStateInfo) && amDbStateInfo != null && amDbStateInfo.IsActiveServerValid && AmServerName.IsEqual(amDbStateInfo.ActiveServer, serverName));
        }
        // Token: 0x06000728 RID: 1832 RVA: 0x00022C0C File Offset: 0x00020E0C
        public AmServerName FindNextBestCopy()
        {
            AmServerName    amServerName = null;
            LocalizedString error        = LocalizedString.Empty;
            bool            flag         = false;
            AmBcsChecks     amBcsChecks  = AmBcsChecks.None;

            if (!this.m_fInitialized)
            {
                this.m_bcsWatch.Start();
                try
                {
                    if (this.m_bcsContext.ShouldLogSubactionEvent)
                    {
                        ReplayCrimsonEvents.BcsInitiated.LogGeneric(this.m_bcsContext.PrepareSubaction(new object[]
                        {
                            this.BestCopySelectionType,
                            false
                        }));
                    }
                    bool fDbNeverMounted = false;
                    this.m_perfTracker.RunTimedOperation(BcsOperation.HasDatabaseBeenMounted, delegate
                    {
                        fDbNeverMounted = !AmBestCopySelectionHelper.HasDatabaseBeenMounted(this.m_bcsContext.DatabaseGuid, this.m_amConfig);
                        this.m_bcsContext.DatabaseNeverMounted = fDbNeverMounted;
                    });
                    AmBcsServerValidation serverValidator = new AmBcsServerValidation(this.m_targetServerName, this.m_bcsContext.SourceServerName, this.m_bcsContext.Database, this.m_amConfig, this.m_bcsContext.ErrorLogger, null);
                    AmBcsServerChecks     serverChecks    = AmBcsServerValidation.GetServerValidationChecks(this.m_bcsContext.ActionCode, true);
                    bool serverChecksPassed = false;
                    this.m_perfTracker.RunTimedOperation(BcsOperation.DetermineServersToContact, delegate
                    {
                        serverChecksPassed = serverValidator.RunChecks(serverChecks, ref error);
                    });
                    if (!serverChecksPassed)
                    {
                        goto IL_39C;
                    }
                    if (!fDbNeverMounted && !this.m_bcsContext.ActionCode.IsMountOrRemountOperation)
                    {
                        List <AmServerName> serversToContact = new List <AmServerName>(2);
                        serversToContact.Add(this.m_targetServerName);
                        if (!AmServerName.IsEqual(this.m_bcsContext.SourceServerName, this.m_targetServerName) && (this.m_bcsContext.SkipValidationChecks & AmBcsSkipFlags.SkipActiveCopyChecks) == AmBcsSkipFlags.None)
                        {
                            serversToContact.Add(this.m_bcsContext.SourceServerName);
                        }
                        this.m_perfTracker.RunTimedOperation(BcsOperation.GetCopyStatusRpc, delegate
                        {
                            this.ConstructBcsStatusTable(serversToContact);
                        });
                        AmBcsServerFailureLogger amBcsServerFailureLogger = this.m_bcsContext.ErrorLogger as AmBcsServerFailureLogger;
                        string concatenatedErrorString = amBcsServerFailureLogger.GetConcatenatedErrorString();
                        if (concatenatedErrorString != null)
                        {
                            error = new LocalizedString(concatenatedErrorString);
                            goto IL_39C;
                        }
                    }
                    this.m_fInitialized = true;
                }
                finally
                {
                    this.m_bcsWatch.Stop();
                    this.m_perfTracker.RecordDuration(BcsOperation.BcsOverall, this.m_bcsWatch.Elapsed);
                    this.m_perfTracker.LogEvent();
                }
            }
            if (this.TargetHasBeenTried(ref error))
            {
                this.m_bcsContext.ErrorLogger.ReportServerFailure(this.m_targetServerName, "CopyHasBeenTriedCheck", error, false);
            }
            else
            {
                if (this.m_bcsContext.ActionCode.IsMountOrRemountOperation)
                {
                    amBcsChecks = AmBcsChecks.None;
                    AmTrace.Debug("BCS: FindNextBestCopy: Skipping validation checks for Database '{0}' on server '{1}'.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid(),
                        this.m_targetServerName
                    });
                }
                else if (this.m_bcsContext.DatabaseNeverMounted)
                {
                    amBcsChecks = AmBcsChecks.IsPassiveCopy;
                    AmTrace.Debug("BCS: FindNextBestCopy: Database '{0}' has never been mounted. Running non-status related checks.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid()
                    });
                }
                else
                {
                    if (!this.CheckActiveForMove(ref error))
                    {
                        goto IL_39C;
                    }
                    amBcsChecks = (AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.MaxActivesUnderPreferredLimit);
                }
                RpcDatabaseCopyStatus2 copyStatus = null;
                this.m_bcsContext.StatusTable.TryGetValue(this.m_targetServerName, out copyStatus);
                AmBcsCopyValidation amBcsCopyValidation = new AmBcsCopyValidation(this.m_bcsContext.DatabaseGuid, this.m_bcsContext.GetDatabaseNameOrGuid(), amBcsChecks, this.m_bcsContext.SourceServerName, this.m_targetServerName, copyStatus, this.m_bcsContext.ErrorLogger, this.m_bcsContext.SkipValidationChecks, this.m_bcsContext.ComponentStateWrapper);
                flag        = amBcsCopyValidation.RunChecks(ref error);
                amBcsChecks = amBcsCopyValidation.CompletedChecks;
            }
IL_39C:
            if (flag)
            {
                AmTrace.Info("BCS: FindNextBestCopy: DatabaseCopy: '{0}\\{1}' passed validation checks.", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    this.m_targetServerName.NetbiosName
                });
                amServerName = this.m_targetServerName;
                this.m_serverAlreadyTried = this.m_targetServerName;
                ReplayCrimsonEvents.BcsDbMoveChecksPassed.Log <string, Guid, AmServerName, AmBcsChecks>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, amServerName, amBcsChecks);
            }
            else
            {
                AmTrace.Error("BCS: FindNextBestCopy: DatabaseCopy: '{0}\\{1}'. Checks returned error: {2}", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    this.m_targetServerName.NetbiosName,
                    error
                });
                AmBcsServerFailureLogger amBcsServerFailureLogger2 = this.m_bcsContext.ErrorLogger as AmBcsServerFailureLogger;
                string concatenatedErrorString2 = amBcsServerFailureLogger2.GetConcatenatedErrorString();
                this.m_lastException = new AmBcsSingleCopyValidationException(concatenatedErrorString2);
                ReplayCrimsonEvents.BcsDbMoveChecksFailed.Log <string, Guid, AmServerName, AmBcsChecks, LocalizedString>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, this.m_targetServerName, amBcsChecks, error);
            }
            return(amServerName);
        }
Ejemplo n.º 22
0
        public bool IsSourceMachineEqual(AmServerName sourceServer)
        {
            AmServerName src = new AmServerName(this.SourceMachine);

            return(AmServerName.IsEqual(src, sourceServer));
        }
Ejemplo n.º 23
0
        // Token: 0x06000498 RID: 1176 RVA: 0x000189B0 File Offset: 0x00016BB0
        internal static void RemoteDismount(AmServerName serverName, Guid mdbGuid, UnmountFlags flags, bool retryOnConflict)
        {
            bool      isCheckDbStatus = true;
            bool      isMounted       = true;
            Exception ex = null;

            try
            {
                AmTrace.Debug("RemoteDismount() starting for DB {0} on server {1}. UnmountFlags = {2}, retryOnConflict = {3}", new object[]
                {
                    mdbGuid,
                    serverName,
                    flags,
                    retryOnConflict
                });
                ReplayCrimsonEvents.DismountStoreRpcInitiated.Log <AmServerName, Guid, UnmountFlags, bool>(serverName, mdbGuid, flags, retryOnConflict);
                using (IStoreMountDismount storeMountDismountInstance = Dependencies.GetStoreMountDismountInstance(AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn))
                {
                    if (!retryOnConflict)
                    {
                        storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                        isCheckDbStatus = false;
                        isMounted       = false;
                        AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                        {
                            mdbGuid
                        });
                    }
                    else
                    {
                        bool      flag      = false;
                        Stopwatch stopwatch = new Stopwatch();
                        stopwatch.Start();
                        for (;;)
                        {
                            try
                            {
                                storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                                isCheckDbStatus = false;
                                isMounted       = false;
                                AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                                {
                                    mdbGuid
                                });
                            }
                            catch (MapiRetryableException ex2)
                            {
                                AmTrace.Error("rpcAdmin.UnmountDatabase({0}) encountered {1}.", new object[]
                                {
                                    mdbGuid,
                                    ex2.Message
                                });
                                if (!(ex2 is MapiExceptionDismountInProgress))
                                {
                                    throw;
                                }
                                if (!flag)
                                {
                                    ReplayCrimsonEvents.DismountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, ex2.Message);
                                    flag = true;
                                }
                                if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                                {
                                    throw;
                                }
                                if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                                {
                                    AmTrace.Debug("shutdown requested - hence not retrying dismount for database {0}", new object[]
                                    {
                                        mdbGuid
                                    });
                                    throw;
                                }
                                continue;
                            }
                            break;
                        }
                    }
                }
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex3.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex3))
                {
                    throw;
                }
            }
            catch (MapiRetryableException ex4)
            {
                ex = ex4;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex4.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex4))
                {
                    throw;
                }
            }
            finally
            {
                ReplayCrimsonEvents.DismountStoreRpcFinished.Log <AmServerName, Guid, string>(serverName, mdbGuid, (ex != null) ? ex.Message : "<none>");
                if (AmServerName.IsNullOrEmpty(serverName) || AmServerName.IsEqual(AmServerName.LocalComputerName, serverName))
                {
                    AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, isMounted, isCheckDbStatus);
                }
            }
        }
Ejemplo n.º 24
0
        // Token: 0x060007AD RID: 1965 RVA: 0x00025064 File Offset: 0x00023264
        private static bool IsAlreadyOnTarget(IADDatabase db, AmServerName targetServer, AmConfig amConfig)
        {
            AmDbStateInfo amDbStateInfo = amConfig.DbState.Read(db.Guid);

            return(amDbStateInfo != null && AmServerName.IsEqual(amDbStateInfo.ActiveServer, targetServer));
        }
Ejemplo n.º 25
0
        public static ReplayConfiguration GetReplayConfiguration(IADDatabaseAvailabilityGroup dag, IADDatabase mdb, IADServer hostServer, ActiveManager activeManager, out bool fSource, out Exception ex)
        {
            ReplayConfiguration result = null;

            fSource = false;
            ex      = null;
            try
            {
                DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(mdb.Guid, GetServerForDatabaseFlags.BasicQuery);
                if (string.IsNullOrEmpty(serverForDatabase.ServerFqdn))
                {
                    ReplayConfiguration.Tracer.TraceDebug <string>(0L, "GetReplayConfiguration({0}) Performing a BasicQuery was insufficient. Calling again with AD access.", mdb.Name);
                    serverForDatabase = activeManager.GetServerForDatabase(mdb.Guid);
                }
                else
                {
                    ReplayConfiguration.Tracer.TraceDebug <string>(0L, "GetReplayConfiguration({0}) Performing a BasicQuery was sufficient. AD calls were avoided!", mdb.Name);
                }
                AmServerName amServerName  = new AmServerName(serverForDatabase.ServerFqdn);
                AmServerName amServerName2 = new AmServerName(hostServer.Fqdn);
                ReplayConfiguration.Tracer.TraceDebug <string, string, string>(0L, "GetReplayConfiguration({0}): GSFD returned active server of: {1}, hostServerFqdn is: {2}", mdb.Name, amServerName.Fqdn, amServerName2.Fqdn);
                if (AmServerName.IsEqual(amServerName, amServerName2))
                {
                    fSource = true;
                }
                if (fSource)
                {
                    if (mdb.ReplicationType == ReplicationType.None)
                    {
                        result = new SingleCopyReplayConfiguration(dag, mdb, hostServer, LockType.ReplayService);
                    }
                    else
                    {
                        result = RemoteReplayConfiguration.ServiceGetReplayConfig(dag, mdb, hostServer, serverForDatabase.ServerFqdn, ReplayConfigType.RemoteCopySource);
                    }
                }
                else
                {
                    if (mdb.ReplicationType != ReplicationType.Remote)
                    {
                        throw new ReplayConfigNotFoundException(mdb.Name, hostServer.Name);
                    }
                    result = RemoteReplayConfiguration.ServiceGetReplayConfig(dag, mdb, hostServer, serverForDatabase.ServerFqdn, ReplayConfigType.RemoteCopyTarget);
                }
            }
            catch (DatabaseNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ServerForDatabaseNotFoundException ex3)
            {
                ex = ex3;
            }
            catch (ObjectNotFoundException ex4)
            {
                ex = ex4;
            }
            catch (TransientException ex5)
            {
                ex = ex5;
            }
            return(result);
        }