private List <AmServerName> DetermineServersToContact() { Guid guid = this.Database.Guid; IADDatabase db = this.Database; IADDatabaseCopy[] databaseCopies = AmBestCopySelectionHelper.GetDatabaseCopies(guid, ref db); if (db != null) { this.Database = db; } AmConfig amConfig = AmSystemManager.Instance.Config; if (amConfig.IsUnknown) { AmTrace.Error("AmMultiNodeRpcNotifier: DB {0}: Invalid AM configuration", new object[] { db.Name }); throw new AmInvalidConfiguration(amConfig.LastError ?? string.Empty); } IAmBcsErrorLogger errorLogger = new AmBcsSingleCopyFailureLogger(); AmBcsServerChecks checksToRun = AmBcsServerChecks.ClusterNodeUp; if (this.ActionCode.IsAutomaticOperation) { checksToRun |= AmBcsServerChecks.DebugOptionDisabled; } IEnumerable <AmServerName> source = from dbCopy in databaseCopies where this.ValidateServer(new AmServerName(dbCopy.HostServerName), db, amConfig, checksToRun, errorLogger) select new AmServerName(dbCopy.HostServerName); return(source.ToList <AmServerName>()); }
public static bool HasDatabaseBeenMounted(Guid dbGuid, AmConfig amConfig) { AmServerName amServerName; AmServerName amServerName2; return(AmBestCopySelectionHelper.HasDatabaseBeenMounted(dbGuid, amConfig, out amServerName, out amServerName2)); }
public static bool IsActivationDisabled(AmServerName srv) { Exception ex; IADServer miniServer = AmBestCopySelectionHelper.GetMiniServer(srv, out ex); return(AmBestCopySelectionHelper.IsActivationDisabled(miniServer)); }
// Token: 0x060006F0 RID: 1776 RVA: 0x00020F6C File Offset: 0x0001F16C private void InitializeBestCopySelector() { this.m_bcsWatch.Start(); try { bool flag = this.m_statusFetcher == null; if (this.m_bcsContext.ShouldLogSubactionEvent) { ReplayCrimsonEvents.BcsInitiated.LogGeneric(this.m_bcsContext.PrepareSubaction(new object[] { this.BestCopySelectionType, flag })); } 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; }); Dictionary <AmServerName, RpcHealthStateInfo[]> stateInfoMap = null; this.m_bcsContext.StatusTable = this.ConstructBcsStatusTable(fDbNeverMounted, flag, out stateInfoMap); this.m_bcsContext.ComponentStateWrapper = new ComponentStateWrapper(this.m_bcsContext.Database.Name, this.m_bcsContext.InitiatingComponent, this.m_bcsContext.SourceServerName, this.m_bcsContext.ActionCode, stateInfoMap); this.m_bcsContext.SortCopiesByActivationPreference = this.ShouldDatabaseCopiesBeSortedByPreference(); this.m_bestCopySelector = new AmBestCopySelector(this.m_bcsContext); } finally { this.m_bcsWatch.Stop(); this.m_perfTracker.RecordDuration(BcsOperation.BcsOverall, this.m_bcsWatch.Elapsed); this.m_perfTracker.LogEvent(); } }
// Token: 0x06000694 RID: 1684 RVA: 0x00020039 File Offset: 0x0001E239 private bool IsActivationEnabled(ref LocalizedString error) { if (AmBestCopySelectionHelper.IsActivationDisabled(this.TargetServer)) { error = ReplayStrings.AmBcsTargetServerActivationDisabled(this.TargetServer.Fqdn); this.ReportCopyStatusFailure(AmBcsChecks.ActivationEnabled, error); return(false); } return(true); }
// Token: 0x0600081E RID: 2078 RVA: 0x000276B4 File Offset: 0x000258B4 internal static ServerVersion GetServerVersion(AmServerName serverName) { Exception ex; IADServer miniServer = AmBestCopySelectionHelper.GetMiniServer(serverName, out ex); if (miniServer == null) { throw ex; } return(miniServer.AdminDisplayVersion); }
// Token: 0x06000699 RID: 1689 RVA: 0x00020394 File Offset: 0x0001E594 internal bool UpdateActiveIfMaxActivesNotExceededPreferredLimit(ref LocalizedString error) { int?num; if (!AmBestCopySelectionHelper.UpdateActiveIfMaxActivesNotExceeded(this.DbGuid, this.TargetServer, (IADServer server) => server.MaximumPreferredActiveDatabases, out num)) { error = ReplayStrings.AmBcsTargetServerPreferredMaxActivesReached(this.TargetServer.Fqdn, (num != null) ? num.Value.ToString() : "<null>"); this.ReportCopyStatusFailure(AmBcsChecks.MaxActivesUnderPreferredLimit, error); return(false); } return(true); }
// Token: 0x06000697 RID: 1687 RVA: 0x00020294 File Offset: 0x0001E494 internal bool IsMaxActivesUnderPreferredLimit(ref LocalizedString error) { int?num; if (!AmBestCopySelectionHelper.IsMaxActivesUnderPreferredLimit(this.TargetServer, out num)) { error = ReplayStrings.AmBcsTargetServerPreferredMaxActivesReached(this.TargetServer.Fqdn, (num != null) ? num.Value.ToString() : "<null>"); this.ReportCopyStatusFailure(AmBcsChecks.MaxActivesUnderPreferredLimit, error); return(false); } return(true); }
protected virtual Dictionary <AmServerName, int> BuildActivationPreferenceCache(Guid dbGuid, ref IADDatabase database) { IADDatabaseCopy[] databaseCopies = AmBestCopySelectionHelper.GetDatabaseCopies(dbGuid, ref database); Dictionary <AmServerName, int> dictionary = new Dictionary <AmServerName, int>(databaseCopies.Length); foreach (IADDatabaseCopy iaddatabaseCopy in databaseCopies) { AmServerName key = new AmServerName(iaddatabaseCopy.HostServerName); dictionary[key] = iaddatabaseCopy.ActivationPreference; } return(dictionary); }
// Token: 0x060006D7 RID: 1751 RVA: 0x00020C1C File Offset: 0x0001EE1C private bool IsAutoActivationAllowed(ref LocalizedString error) { if (this.ServerToCheck.Equals(this.SourceServer)) { AmTrace.Debug("AmBcsServerValidation: Skipping 'IsAutoActivationAllowed' check since source == target. TargetServer: {0}", new object[] { this.ServerToCheck }); return(true); } Exception ex; IADServer miniServer = AmBestCopySelectionHelper.GetMiniServer(this.ServerToCheck, out ex); if (miniServer == null) { AmTrace.Error("AmBcsServerValidation: Rejecting server '{0}' for DB '{1}' because target MiniServer could not be read.", new object[] { this.ServerToCheck, this.Database.Name }); error = ReplayStrings.AmBcsTargetServerADError(this.ServerToCheck.Fqdn, ex.ToString()); this.ReportServerBlocked(AmBcsServerChecks.AutoActivationAllowed, error); return(false); } IADServer miniServer2 = AmBestCopySelectionHelper.GetMiniServer(this.SourceServer, out ex); if (miniServer2 == null) { AmTrace.Error("AmBcsServerValidation: Rejecting server '{0}' for DB '{1}' because source MiniServer '{2}' could not be read.", new object[] { this.ServerToCheck, this.Database.Name, this.SourceServer }); error = ReplayStrings.AmBcsSourceServerADError(this.SourceServer.Fqdn, ex.ToString()); this.ReportServerBlocked(AmBcsServerChecks.AutoActivationAllowed, error); return(false); } if (!AmBestCopySelectionHelper.IsAutoActivationAllowed(miniServer2, miniServer, out error)) { this.ReportServerBlocked(AmBcsServerChecks.AutoActivationAllowed, error); return(false); } return(true); }
// Token: 0x060006F3 RID: 1779 RVA: 0x00021310 File Offset: 0x0001F510 private void PopulateDatabaseCopiesIfNecessary() { if (this.m_dbCopies != null) { return; } IADDatabaseCopy[] dbCopies = null; Guid dbGuid = this.m_bcsContext.DatabaseGuid; IADDatabase database = this.m_bcsContext.Database; this.m_perfTracker.RunTimedOperation(BcsOperation.GetDatabaseCopies, delegate { dbCopies = AmBestCopySelectionHelper.GetDatabaseCopies(dbGuid, ref database); }); if (database != null) { this.m_bcsContext.Database = database; } this.m_dbCopies = dbCopies; }
// Token: 0x060006F4 RID: 1780 RVA: 0x00021394 File Offset: 0x0001F594 private void PopulateMiniServersForDatabaseCopies() { if (this.m_miniServers != null) { return; } this.PopulateDatabaseCopiesIfNecessary(); List <IADServer> list = new List <IADServer>(this.m_dbCopies.Length); Exception ex = null; foreach (IADDatabaseCopy iaddatabaseCopy in this.m_dbCopies) { AmServerName serverName = new AmServerName(iaddatabaseCopy.HostServerName); IADServer miniServer = AmBestCopySelectionHelper.GetMiniServer(serverName, out ex); if (miniServer == null) { throw ex; } list.Add(miniServer); } this.m_miniServers = list; }
// Token: 0x060006D6 RID: 1750 RVA: 0x00020B4C File Offset: 0x0001ED4C private bool IsServerStartedForDACMode(ref LocalizedString error) { string adError = null; IADDatabaseAvailabilityGroup iaddatabaseAvailabilityGroup; if (this.DagConfig != null) { iaddatabaseAvailabilityGroup = this.DagConfig.Dag; if (iaddatabaseAvailabilityGroup == null) { CouldNotFindDagObjectForServer couldNotFindDagObjectForServer = new CouldNotFindDagObjectForServer(this.ServerToCheck.NetbiosName); adError = couldNotFindDagObjectForServer.Message; } } else { iaddatabaseAvailabilityGroup = AmBestCopySelectionHelper.GetLocalServerDatabaseAvailabilityGroup(out adError); } if (iaddatabaseAvailabilityGroup == null) { error = ReplayStrings.AmBcsDagNotFoundInAd(this.ServerToCheck.Fqdn, adError); this.ReportServerBlocked(AmBcsServerChecks.DatacenterActivationModeStarted, error); return(false); } if (AmBestCopySelectionHelper.IsServerInDacAndStopped(iaddatabaseAvailabilityGroup, this.ServerToCheck)) { AmTrace.Error("AmBcsServerValidation: Rejecting server '{0}' for DB '{1}' since it is stopped in the DAC mode.", new object[] { this.ServerToCheck, this.Database.Name }); error = ReplayStrings.AmBcsTargetServerIsStoppedOnDAC(this.ServerToCheck.Fqdn); this.ReportServerBlocked(AmBcsServerChecks.DatacenterActivationModeStarted, error); return(false); } return(true); }
public static bool IsMaxActivesUnderPreferredLimit(AmServerName serverName, out int?maxActiveDatabases) { return(AmBestCopySelectionHelper.IsMaxActivesUnderThreshold(serverName, (IADServer server) => server.MaximumPreferredActiveDatabases, out maxActiveDatabases)); }
// 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); }
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; } }