public static bool HasDatabaseBeenMounted(Guid dbGuid, AmConfig amConfig) { AmServerName amServerName; AmServerName amServerName2; return(AmBestCopySelectionHelper.HasDatabaseBeenMounted(dbGuid, amConfig, out amServerName, out amServerName2)); }
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>()); }
// Token: 0x060007AC RID: 1964 RVA: 0x00024EE0 File Offset: 0x000230E0 public static List <AmDatabaseMoveResult> Move(AmDbMoveArguments moveArgs) { List <AmDatabaseMoveResult> result; using (BatchDatabaseOperation batchDatabaseOperation = new BatchDatabaseOperation()) { IADConfig adconfig = Dependencies.ADConfig; IEnumerable <IADDatabase> databasesOnServer = adconfig.GetDatabasesOnServer(moveArgs.TargetServer); AmConfig config = AmSystemManager.Instance.Config; foreach (IADDatabase iaddatabase in databasesOnServer) { IADDatabaseCopy databaseCopy = iaddatabase.GetDatabaseCopy(moveArgs.TargetServer.NetbiosName); if (databaseCopy != null && iaddatabase.ReplicationType == ReplicationType.Remote && databaseCopy.ActivationPreference == 1 && !MoveBackToServer.IsAlreadyOnTarget(iaddatabase, moveArgs.TargetServer, config)) { batchDatabaseOperation.AddOperation(new AmDbMoveOperation(iaddatabase, moveArgs.ActionCode) { Arguments = moveArgs }); } } batchDatabaseOperation.DispatchOperations(); batchDatabaseOperation.WaitForComplete(); List <AmDbOperation> completedOperationList = batchDatabaseOperation.GetCompletedOperationList(); List <AmDatabaseMoveResult> list = new List <AmDatabaseMoveResult>(completedOperationList.Count); foreach (AmDbOperation amDbOperation in completedOperationList) { if (amDbOperation.DetailedStatus != null) { list.Add(amDbOperation.ConvertDetailedStatusToRpcMoveResult(amDbOperation.DetailedStatus)); } } result = list; } return(result); }
internal static void SyncDatabaseOwningServerAndLegacyDn(IADDatabase db, AmDbActionCode actionCode) { AmConfig config = AmSystemManager.Instance.Config; AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid); AmServerName amServerName = new AmServerName(db.Server.Name); AmServerName amServerName2; if (amDbStateInfo.IsActiveServerValid) { amServerName2 = amDbStateInfo.ActiveServer; } else { amServerName2 = amServerName; } AmTrace.Debug("Synchronizing AD properties of database {0} (initialOwningServer:{1}, newActiveServer:{2})", new object[] { db.Name, amServerName, amServerName2 }); bool flag = SharedDependencies.WritableADHelper.SetDatabaseLegacyDnAndOwningServer(db.Guid, amDbStateInfo.LastMountedServer, amServerName2, false); if (flag) { ReplayCrimsonEvents.DatabaseAdPropertiesSynchronized.Log <string, Guid, AmServerName, AmServerName>(db.Name, db.Guid, amServerName, amServerName2); return; } AmTrace.Debug("Ignored ad sync request database {0}", new object[] { db.Name }); }
// Token: 0x060001A4 RID: 420 RVA: 0x0000A358 File Offset: 0x00008558 internal static void ValidateForCurrentRole(bool isStandaloneAllowed, string operation) { if (RegistryParameters.ConfigInitializedCheckTimeoutInSec > 0) { ManualOneShotEvent.Result result = AmSystemManager.Instance.ConfigInitializedEvent.WaitOne(TimeSpan.FromSeconds((double)RegistryParameters.ConfigInitializedCheckTimeoutInSec)); if (result != ManualOneShotEvent.Result.Success) { ReplayCrimsonEvents.ConfigInitializedEventNotSet.LogPeriodic <TimeSpan, ManualOneShotEvent.Result, string>(AmSystemManager.Instance, DiagCore.DefaultEventSuppressionInterval, TimeSpan.FromSeconds((double)RegistryParameters.ConfigInitializedCheckTimeoutInSec), result, operation); } } AmConfig config = AmSystemManager.Instance.Config; if (config.Role == AmRole.SAM) { AmReferralException ex = new AmReferralException(config.DagConfig.CurrentPAM.Fqdn); throw ex; } if (!isStandaloneAllowed && config.Role == AmRole.Standalone) { throw new AmOperationInvalidForStandaloneRoleException(); } if (config.Role == AmRole.Unknown) { throw new AmInvalidConfiguration(config.LastError); } }
private void ReportStart() { AmConfig config = AmSystemManager.Instance.Config; this.ReportStoreStartedToReplayManager(); if (config.IsUnknown) { AmServiceMonitor.Tracer.TraceError(0L, "Store service start detected, but configuration is in unknown state"); return; } if (config.IsStandalone) { AmStoreServiceMonitor.ReportStoreStatus(AmServerName.LocalComputerName, AmSystemEventCode.StoreServiceStarted, AmServerName.LocalComputerName); this.m_isStartReported = true; return; } AmServerName currentPAM = config.DagConfig.CurrentPAM; if (config.DagConfig.IsNodePubliclyUp(currentPAM)) { AmStoreServiceMonitor.ReportStoreStatus(currentPAM, AmSystemEventCode.StoreServiceStarted, AmServerName.LocalComputerName); this.m_isStartReported = true; return; } AmServiceMonitor.Tracer.TraceInformation <AmServerName>(0, 0L, "Store service monitor is not reporting the store start to the PAM, since PAM on '{0}'is not up yet. Store monitor will retry once the node is up", currentPAM); }
// Token: 0x0600054F RID: 1359 RVA: 0x0001B024 File Offset: 0x00019224 private void Run(AmSystemFailoverOnReplayDownTracker failoverTracker) { AmConfig config = AmSystemManager.Instance.Config; if (!config.IsPAM) { ReplayCrimsonEvents.FailoverOnReplDownSkipped.Log <AmServerName, string, string>(this.serverName, "RoleNotPAM", "TimerCallback"); return; } if (AmHelper.IsReplayRunning(this.serverName)) { ReplayCrimsonEvents.FailoverOnReplDownSkipped.Log <AmServerName, string, string>(this.serverName, "ReplRunning", "TimerCallback"); return; } AmThrottledActionTracker <FailoverData> .ThrottlingShapshot throttlingSnapshot = failoverTracker.GetThrottlingSnapshot(this.serverName); if (throttlingSnapshot.IsActionCalledTooSoonPerNode || throttlingSnapshot.IsActionCalledTooSoonAcrossDag || throttlingSnapshot.IsMaxActionsPerNodeExceeded || throttlingSnapshot.IsMaxActionsAcrossDagExceeded) { throttlingSnapshot.LogResults(ReplayCrimsonEvents.FailoverOnReplDownThrottlingFailed, TimeSpan.FromMinutes(15.0)); return; } failoverTracker.AddFailoverEntry(this.serverName); throttlingSnapshot.LogResults(ReplayCrimsonEvents.FailoverOnReplDownThrottlingSucceeded, TimeSpan.Zero); AmEvtSystemFailoverOnReplayDown amEvtSystemFailoverOnReplayDown = new AmEvtSystemFailoverOnReplayDown(this.serverName); amEvtSystemFailoverOnReplayDown.Notify(); }
// Token: 0x0600019B RID: 411 RVA: 0x00009D6C File Offset: 0x00007F6C internal static bool IsLocalNodePubliclyUp() { AmServerName localComputerName = AmServerName.LocalComputerName; AmConfig config = AmSystemManager.Instance.Config; bool flag = false; if (config.IsUnknown) { AmTrace.Error("IsLocalNodePubliclyUp( {0} ): Returning 'false' since AM role is Unknown.", new object[] { localComputerName }); } else if (config.IsPamOrSam) { flag = config.DagConfig.IsNodePubliclyUp(localComputerName); AmTrace.Debug("IsLocalNodePubliclyUp( {0} ): Returning '{1}' for PAM/SAM role.", new object[] { localComputerName, flag }); } else { AmTrace.Debug("IsLocalNodePubliclyUp( {0} ): Returning 'true' since AM is in Standalone role.", new object[] { localComputerName }); flag = true; } return(flag); }
// Token: 0x06000631 RID: 1585 RVA: 0x0001E938 File Offset: 0x0001CB38 internal void Initialize() { AmConfig config = AmSystemManager.Instance.Config; if (config.IsPAM) { lock (this.m_locker) { AmServerName[] memberServers = config.DagConfig.MemberServers; foreach (AmServerName amServerName in memberServers) { AmFailoverEntry amFailoverEntry = AmFailoverEntry.ReadFromPersistentStoreBestEffort(amServerName); if (amFailoverEntry != null) { if (!config.DagConfig.IsNodePubliclyUp(amServerName)) { this.AddEntry(amFailoverEntry); } else { AmTrace.Debug("Skipped adding server to deferred failover. Removing from persistent store (server: {0})", new object[] { amServerName }); amFailoverEntry.DeleteFromPersistentStoreBestEffort(); } } } } } }
internal static bool WriteStateSyncMountStatus(AmConfig amConfig, AmDbStateInfo stateInfo, Guid databaseGuid, AmServerName activeServer, MountStatus mountStatus) { bool flag = false; if (mountStatus == MountStatus.Mounted) { stateInfo.UpdateActiveServerAndIncrementFailoverSequenceNumber(activeServer); stateInfo.LastMountedServer = activeServer; stateInfo.IsAdminDismounted = false; stateInfo.MountStatus = mountStatus; stateInfo.IsAutomaticActionsAllowed = true; stateInfo.LastMountedTime = DateTime.UtcNow; flag = true; } else if (stateInfo.IsEntryExist) { stateInfo.MountStatus = mountStatus; if (stateInfo.IsMountSucceededAtleastOnce) { stateInfo.UpdateActiveServerAndIncrementFailoverSequenceNumber(activeServer); stateInfo.LastMountedServer = activeServer; } flag = true; } if (flag && AmDbAction.WriteState(amConfig, stateInfo, false)) { AmDatabaseStateTracker databaseStateTracker = AmSystemManager.Instance.DatabaseStateTracker; if (databaseStateTracker != null) { databaseStateTracker.UpdateActive(databaseGuid, activeServer); } } return(flag); }
public static bool HasDatabaseBeenMounted(Guid dbGuid, AmConfig amConfig, out AmServerName masterServerName, out AmServerName lastMountedServerName) { AmDbStateInfo amDbStateInfo = amConfig.DbState.Read(dbGuid); masterServerName = amDbStateInfo.ActiveServer; lastMountedServerName = amDbStateInfo.LastMountedServer; return(amDbStateInfo.IsActiveServerValid); }
// Token: 0x060003C2 RID: 962 RVA: 0x000146C8 File Offset: 0x000128C8 internal void Start(AmConfig cfg, Func <List <AmServerName> > getServersFunc) { ThreadPool.QueueUserWorkItem(delegate(object param0) { this.Initialize(cfg, getServersFunc(), true); this.Run(); }); }
// 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); } } }
internal void PostMountCopy() { AmConfig config = AmSystemManager.Instance.Config; if (config.IsPamOrSam) { this.dbMountedEvent.Set(); } }
// Token: 0x0600082F RID: 2095 RVA: 0x00027E60 File Offset: 0x00026060 internal static bool IsDebugOptionsEnabled(this AmConfig config) { bool result = false; if (!config.IsUnknown) { result = config.DbState.GetDebugOption <bool>(null, AmDebugOptions.Enabled, false); } return(result); }
// Token: 0x0600019A RID: 410 RVA: 0x00009D2C File Offset: 0x00007F2C internal static bool IsLocalNodePAM() { AmConfig config = AmSystemManager.Instance.Config; AmTrace.Debug("IsLocalNodePAM(): AM is in '{0}' role.", new object[] { config.Role }); return(config.IsPAM); }
// Token: 0x060003C1 RID: 961 RVA: 0x0001464C File Offset: 0x0001284C private void Initialize(AmConfig cfg, List <AmServerName> serverList, bool isBasicInformation) { Dictionary <AmServerName, AmMdbStatusServerInfo> multiNodeServerInfo = AmMultiNodeMdbStatusFetcher.GetMultiNodeServerInfo(cfg, serverList); List <AmServerName> nodeList = multiNodeServerInfo.Keys.ToList <AmServerName>(); base.Initialize(nodeList); this.ServerInfoMap = multiNodeServerInfo; this.m_isBasicInformation = isBasicInformation; this.MdbStatusMap = new Dictionary <AmServerName, MdbStatus[]>(this.m_expectedCount); }
// Token: 0x06000830 RID: 2096 RVA: 0x00027E88 File Offset: 0x00026088 internal static bool IsIgnoreServerDebugOptionEnabled(this AmConfig config, AmServerName serverName) { bool result = false; if (config.IsDebugOptionsEnabled()) { result = config.DbState.GetDebugOption <bool>(serverName, AmDebugOptions.IgnoreServerFromAutomaticActions, false); } return(result); }
// Token: 0x0600019D RID: 413 RVA: 0x00009E8C File Offset: 0x0000808C internal static AmDbStateInfo GetDatabaseStateInfo(Guid dbGuid) { AmConfig config = AmSystemManager.Instance.Config; if (!config.IsUnknown) { return(config.DbState.Read(dbGuid)); } AmTrace.Error("GetDatabaseStateInfo: AmConfig is invalid!", new object[0]); throw new AmInvalidConfiguration(config.LastError); }
// Token: 0x060001AB RID: 427 RVA: 0x0000A874 File Offset: 0x00008A74 internal AmPamInfo GetPrimaryActiveManager() { AmConfig config = AmSystemManager.Instance.Config; if (!config.IsPamOrSam) { AmTrace.Debug("GetPAM called on Standalone machine!!", new object[0]); throw new AmOperationNotValidOnCurrentRole(config.LastError); } return(new AmPamInfo(config.DagConfig.CurrentPAM.Fqdn)); }
internal AmDbAction(AmConfig cfg, IADDatabase db, AmDbActionCode actionCode, string uniqueOperationId) { this.m_database = db; this.m_dbTrace = new AmDbTrace(db); this.Config = cfg; this.DatabaseName = db.Name; this.DatabaseGuid = db.Guid; this.ActionCode = actionCode; this.UniqueOperationId = uniqueOperationId; this.CurrentAttemptNumber = 1; }
// Token: 0x060001A1 RID: 417 RVA: 0x0000A024 File Offset: 0x00008224 internal static void SetLastLogGenerationTimeStamp(Guid dbGuid, ExDateTime timeStamp) { AmConfig config = AmSystemManager.Instance.Config; if (!config.IsUnknown) { config.DbState.SetLastLogGenerationTimeStamp(dbGuid, timeStamp); return; } AmTrace.Error("SetLastLogGenerationTimeStamp: AmConfig is invalid!", new object[0]); throw new AmInvalidConfiguration(config.LastError); }
// Token: 0x060001AC RID: 428 RVA: 0x0000A8CC File Offset: 0x00008ACC internal AmRole GetActiveManagerRole(out string errorMessage) { AmConfig config = AmSystemManager.Instance.Config; errorMessage = config.LastError; AmTrace.Debug("GetActiveManagerRole: AM is in Role {0}. ErrorMessage={1}", new object[] { config.Role, errorMessage }); return(config.Role); }
// Token: 0x06000148 RID: 328 RVA: 0x00007934 File Offset: 0x00005B34 internal void AddEntry(AmConfig cfg) { AmDelayedConfigDisposer.DisposableContainer disposableContainer = new AmDelayedConfigDisposer.DisposableContainer(cfg); lock (this.m_locker) { ExTraceGlobals.AmConfigManagerTracer.TraceDebug <string, string>(0L, "Adding AmConfig for delayed dispose (Queued for Dispose: {0}, Dispose due at: {1})", disposableContainer.TimeRequestSubmitted.ToString(), disposableContainer.DisposeDueAt.ToString()); this.m_waitingList.Add(disposableContainer); if (disposableContainer.DisposeDueAt < this.m_lowestDueTime) { this.m_lowestDueTime = disposableContainer.DisposeDueAt; this.SetupWakeupTime(this.m_lowestDueTime); } } }
protected virtual void CheckIfOperationIsAllowedOnCurrentRole() { AmConfig config = AmSystemManager.Instance.Config; if (config.Role == AmRole.SAM) { AmReferralException ex = new AmReferralException(config.DagConfig.CurrentPAM.Fqdn); throw ex; } if (config.Role == AmRole.Unknown) { throw new AmInvalidConfiguration(config.LastError); } }
// Token: 0x06000627 RID: 1575 RVA: 0x0001E700 File Offset: 0x0001C900 internal void WriteToPersistentStore() { AmConfig config = AmSystemManager.Instance.Config; if (config != null && config.DagConfig != null) { using (AmPersistentClusdbState amPersistentClusdbState = new AmPersistentClusdbState(config.DagConfig.Cluster, AmFailoverEntry.GetPersistentStateKeyName(this.ServerName))) { amPersistentClusdbState.WriteProperty <string>("ReasonCode", this.ReasonCode.ToString()); amPersistentClusdbState.WriteProperty <string>("TimeCreated", this.TimeCreated.ToString("o")); return; } } throw new AmServiceShuttingDownException(); }
internal static AmDbStatusInfo2 GetServerForDatabase(Guid mdbGuid) { AmConfig config = AmSystemManager.Instance.Config; if (config.IsUnknown) { AmTrace.Error("GetSFD: Invalid configuration (db={0})", new object[] { mdbGuid }); throw new AmInvalidConfiguration(config.LastError); } AmDbStateInfo stateInfo = config.DbState.Read(mdbGuid); return(AmServerDbStatusInfoCache.ConvertToDbStatusInfo(stateInfo)); }
// Token: 0x060000B3 RID: 179 RVA: 0x000052F4 File Offset: 0x000034F4 private void PopulateBatch(IClusterDBWriteBatch writeBatch, Dictionary <AmServerName, AmCachedLastLogUpdater.ServerRequestInfo> requestInfoMap) { Dictionary <Guid, AmDbStateInfo> dbStateInfoMap = new Dictionary <Guid, AmDbStateInfo>(); AmConfig config = AmSystemManager.Instance.Config; if (!config.IsPAM) { throw new AmInvalidConfiguration(string.Format("Role = {0}", config.Role)); } AmDbStateInfo[] array = config.DbState.ReadAll(); if (array != null) { dbStateInfoMap = array.ToDictionary((AmDbStateInfo s) => s.DatabaseGuid); } foreach (AmCachedLastLogUpdater.ServerRequestInfo serverRequestInfo in requestInfoMap.Values) { AmServerName serverName = serverRequestInfo.ServerName; Dictionary <Guid, long> databaseLogGenMap = serverRequestInfo.DatabaseLogGenMap; HashSet <Guid> databasesByServer = this.GetDatabasesByServer(serverName); string value = serverRequestInfo.MostRecentRequestReceivedUtc.ToString("s"); foreach (KeyValuePair <Guid, long> keyValuePair in databaseLogGenMap) { Guid key = keyValuePair.Key; long value2 = keyValuePair.Value; string text = key.ToString(); string valueName = AmDbState.ConstructLastLogTimeStampProperty(text); if (this.IsDatabaseActiveOnServer(dbStateInfoMap, key, serverName)) { writeBatch.SetValue(text, value2.ToString()); writeBatch.SetValue(valueName, value); } databasesByServer.Remove(key); } foreach (Guid databaseGuid in databasesByServer) { string valueName2 = AmDbState.ConstructLastLogTimeStampProperty(databaseGuid.ToString()); if (this.IsDatabaseActiveOnServer(dbStateInfoMap, databaseGuid, serverName)) { writeBatch.SetValue(valueName2, value); } } writeBatch.SetValue(serverName.NetbiosName, value); } }
private static void ReportKillStarted() { AmStoreServiceMonitor.s_killWasTriggered = true; AmSystemEventCode eventCode = AmSystemEventCode.StoreServiceUnexpectedlyStopped; AmConfig config = AmSystemManager.Instance.Config; if (!config.IsUnknown && !config.IsStandalone) { AmServerName currentPAM = config.DagConfig.CurrentPAM; if (config.DagConfig.IsNodePubliclyUp(currentPAM)) { AmTrace.Diagnostic("Reporting to PAM ({0}) that store process is being killed.", new object[] { currentPAM }); AmStoreServiceMonitor.ReportStoreStatus(currentPAM, eventCode, AmServerName.LocalComputerName); } } }
protected AmDbAction PrepareDbAction(AmDbActionCode actionCode) { this.CheckIfOperationIsAllowedOnCurrentRole(); AmConfig config = AmSystemManager.Instance.Config; AmDbAction amDbAction; if (config.IsPAM) { amDbAction = new AmDbPamAction(config, this.Database, actionCode, this.UniqueId); } else { amDbAction = new AmDbStandaloneAction(config, this.Database, actionCode, this.UniqueId); } AmDbAction amDbAction2 = amDbAction; amDbAction2.StatusCallback = (AmReportStatusDelegate)Delegate.Combine(amDbAction2.StatusCallback, new AmReportStatusDelegate(this.ReportStatus)); return(amDbAction); }