// 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(); } }
public static bool HasDatabaseBeenMounted(Guid dbGuid, AmConfig amConfig) { AmServerName amServerName; AmServerName amServerName2; return(AmBestCopySelectionHelper.HasDatabaseBeenMounted(dbGuid, amConfig, out amServerName, out amServerName2)); }
// 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); }