public bool IsVersionCheckSatisfied() { if (this.m_isVersionCheckSatisfied) { return(true); } ManualOneShotEvent.Result result = this.m_firstPollCompleted.WaitOne(); DiagCore.AssertOrWatson(result != ManualOneShotEvent.Result.WaitTimedOut, "waitResult cannot be WaitTimedOut!", new object[0]); if (result == ManualOneShotEvent.Result.ShuttingDown) { SafetyNetVersionChecker.Tracer.TraceError((long)this.GetHashCode(), "SafetyNetVersionChecker.IsVersionCheckSatisfied(): Service is shutting down."); throw new SafetyNetVersionCheckException(ReplayStrings.MonitoringADServiceShuttingDownException); } bool result2; lock (this.m_locker) { if (this.m_isVersionCheckSatisfied) { result2 = true; } else { if (this.m_lastException != null) { SafetyNetVersionChecker.Tracer.TraceError <Exception>((long)this.GetHashCode(), "SafetyNetVersionChecker.IsVersionCheckSatisfied(): Throwing last exception: {0}", this.m_lastException); throw this.m_lastException; } result2 = false; } } return(result2); }
// 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); } }
protected void RunAllRpcs(TimeSpan timeout) { if (this.m_nodeList != null && this.m_nodeList.Count > 0) { ReplayStopwatch replayStopwatch = new ReplayStopwatch(); replayStopwatch.Start(); try { bool flag = false; lock (this.m_locker) { flag = (this.m_rpcAttemptMap.Count == 0); } if (flag) { this.Tracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: RunAllRpcs(): Beginning to issue parallel RPCs.", this.m_name); List <AmServerName> list = new List <AmServerName>(this.m_nodeList.Count); foreach (AmServerName amServerName in this.m_nodeList) { if (this.TryStartRpc(amServerName)) { list.Add(amServerName); } else { this.SkipSingleRpc(amServerName); } } foreach (AmServerName state in list) { ThreadPool.QueueUserWorkItem(new WaitCallback(this.RunSingleRpc), state); } } this.Tracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: RunAllRpcs(): Waiting for RPCs to complete...", this.m_name); ManualOneShotEvent.Result result = this.m_completionEvent.WaitOne(timeout); if (!this.m_isTimedout) { this.m_isTimedout = (result == ManualOneShotEvent.Result.WaitTimedOut); } this.Tracer.TraceDebug <string, ManualOneShotEvent.Result>((long)this.GetHashCode(), "{0}: RunAllRpcs(): Waiting for RPCs returned: {1}", this.m_name, result); if (timeout == InvokeWithTimeout.InfiniteTimeSpan) { DiagCore.AssertOrWatson(result == ManualOneShotEvent.Result.Success, "waitResult cannot be anything other than Success! Actual: {0}", new object[] { result }); } return; } finally { replayStopwatch.Stop(); this.m_elapsedTime = replayStopwatch.Elapsed; this.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "{0}: RunAllRpcs(): Completed in {1}.", this.m_name, replayStopwatch.ToString()); } } this.Tracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: RunAllRpcs(): No servers to contact since m_nodeList is null/empty. Setting completion event.", this.m_name); this.m_completionEvent.Set(); this.m_completionEvent.Close(); }
// Token: 0x060001DC RID: 476 RVA: 0x0000C18C File Offset: 0x0000A38C internal bool Initialize(TimeSpan timeToWait) { if (RegistryParameters.DatabaseStateTrackerDisabled) { AmDatabaseStateTracker.Tracer.TraceWarning(0L, "Initialize(): AmDatabaseStateTracker disabled by registry override"); return(false); } if (!AmSystemManager.Instance.Config.IsPAM) { return(false); } if (this.isInitSuccess) { return(true); } if (!this.isInitInProgress) { ThreadPool.QueueUserWorkItem(delegate(object unused) { Stopwatch stopwatch = Stopwatch.StartNew(); try { this.InternalInitialize(); } finally { AmDatabaseStateTracker.Tracer.TraceDebug <TimeSpan>(0L, "AmDatabaseStateTracker.InternalInitialize() took {0} to complete.", stopwatch.Elapsed); } }); AmDatabaseStateTracker.Tracer.TraceDebug <TimeSpan>(0L, "Waiting for initialization to complete in {0}.", timeToWait); ManualOneShotEvent.Result arg = this.initializationCompleteEvent.WaitOne(timeToWait); AmDatabaseStateTracker.Tracer.TraceDebug <ManualOneShotEvent.Result>(0L, "initializationCompleteEvent.WaitOne() returned {0}", arg); } return(this.isInitSuccess); }
public bool WaitForCompletion(TimeSpan timeout) { ManualOneShotEvent.Result result = this.m_completionEvent.WaitOne(timeout); if (result != ManualOneShotEvent.Result.Success) { this.Tracer.TraceError <string, string, ManualOneShotEvent.Result>((long)this.GetHashCode(), "{0}: Multinode rpc timedout after {1}. WaitOne Result: {2}", this.m_name, timeout.ToString(), result); this.m_isTimedout = true; return(false); } return(true); }
private IMonitoringADConfig GetConfig(bool waitForInit, TimeSpan allowedStaleness) { if (waitForInit) { TimeSpan getConfigWaitTimeout = MonitoringADConfigManager.GetConfigWaitTimeout; ManualOneShotEvent.Result result = this.m_firstLookupCompleted.WaitOne(getConfigWaitTimeout); if (result == ManualOneShotEvent.Result.WaitTimedOut) { MonitoringADConfigManager.Tracer.TraceError <TimeSpan>((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): AD initial lookup timed out after {0}.", getConfigWaitTimeout); throw new MonitoringADFirstLookupTimeoutException((int)getConfigWaitTimeout.TotalMilliseconds); } if (result == ManualOneShotEvent.Result.ShuttingDown) { MonitoringADConfigManager.Tracer.TraceError((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): m_firstLookupCompleted event is null, which means the service is shutting down!"); throw new MonitoringADServiceShuttingDownException(); } } Exception ex = null; IMonitoringADConfig monitoringADConfig = null; lock (this.m_locker) { monitoringADConfig = this.m_config; ex = this.LastException; } if (monitoringADConfig != null) { TimeSpan timeSpan = DateTime.UtcNow.Subtract(monitoringADConfig.CreateTimeUtc); if (allowedStaleness != InvokeWithTimeout.InfiniteTimeSpan) { if (timeSpan > allowedStaleness) { MonitoringADConfigManager.Tracer.TraceError <TimeSpan, TimeSpan>((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): Cached config is older ({0}) than max TTL ({1})", timeSpan, allowedStaleness); throw new MonitoringADConfigStaleException(timeSpan.ToString(), allowedStaleness.ToString(), AmExceptionHelper.GetExceptionMessageOrNoneString(ex), ex); } } else { MonitoringADConfigManager.Tracer.TraceDebug((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): Ignoring cached config staleness check."); } MonitoringADConfigManager.Tracer.TraceDebug <TimeSpan, DateTime>((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): Returning cached config of age ({0}), created at '{1} UTC'", timeSpan, monitoringADConfig.CreateTimeUtc); return(monitoringADConfig); } if (ex == null) { MonitoringADConfigManager.Tracer.TraceError((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): AD initial lookup has not completed yet."); throw new MonitoringADInitNotCompleteException(); } MonitoringADConfigManager.Tracer.TraceError <Exception>((long)this.GetHashCode(), "MonitoringADConfigManager.GetConfig(): Throwing last exception: {0}", ex); throw ex; }
public HealthInfoPersisted GetDagHealthInfo() { DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "GetDagHealthInfo() called."); ManualOneShotEvent.Result result = this.m_initCompleted.WaitOne(this.InitWaitTimeout); if (result == ManualOneShotEvent.Result.WaitTimedOut) { DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "GetDagHealthInfo() timed out waiting for initialization to complete."); throw new DbHTFirstLookupTimeoutException((int)this.InitWaitTimeout.TotalMilliseconds); } if (result == ManualOneShotEvent.Result.ShuttingDown) { DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "GetDagHealthInfo(): Errorring out since the service is shutting down."); throw new DbHTServiceShuttingDownException(); } HealthInfoPersisted healthInfo = this.m_healthTable.GetHealthInfo(); DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GetDagHealthInfo() returning health info serialized structure of update time '{0}'.", healthInfo.LastUpdateTimeUtcStr); return(healthInfo); }
public DateTime GetDagHealthInfoUpdateTimeUtc() { DatabaseHealthTracker.Tracer.TraceDebug((long)this.GetHashCode(), "GetDagHealthInfoUpdateTimeUtc() called."); ManualOneShotEvent.Result result = this.m_initCompleted.WaitOne(this.InitWaitTimeout); if (result == ManualOneShotEvent.Result.WaitTimedOut) { DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "GetDagHealthInfoUpdateTimeUtc() timed out waiting for initialization to complete."); throw new DbHTFirstLookupTimeoutException((int)this.InitWaitTimeout.TotalMilliseconds); } if (result == ManualOneShotEvent.Result.ShuttingDown) { DatabaseHealthTracker.Tracer.TraceError((long)this.GetHashCode(), "GetDagHealthInfoUpdateTimeUtc(): Errorring out since the service is shutting down."); throw new DbHTServiceShuttingDownException(); } DateTime lastUpdateTime = this.m_healthTable.GetLastUpdateTime(); DatabaseHealthTracker.Tracer.TraceDebug <DateTime>((long)this.GetHashCode(), "GetDagHealthInfoUpdateTimeUtc() returning '{0}'", lastUpdateTime); return(lastUpdateTime); }
private RpcDatabaseCopyStatus2 GetCachedCopyStatus(RpcGetDatabaseCopyStatusFlags2 flags) { CopyStatusServerCachedEntry copyStatusServerCachedEntry = this.m_cachedStatus; if (this.IsCopyStatusReadThroughNeeded(copyStatusServerCachedEntry)) { TimeSpan copyStatusServerTimeout = ReplicaInstanceContainer.CopyStatusServerTimeout; bool flag = Monitor.TryEnter(this.m_statusCallLocker); try { if (!flag) { ManualOneShotEvent.Result result = this.m_firstCachedStatusCallCompleted.WaitOne(copyStatusServerTimeout); if (result != ManualOneShotEvent.Result.Success) { throw new ReplayServiceRpcCopyStatusTimeoutException(this.ReplicaInstance.Configuration.DisplayName, (int)copyStatusServerTimeout.TotalSeconds); } lock (this.m_statusCacheLocker) { copyStatusServerCachedEntry = this.m_cachedStatus; if (copyStatusServerCachedEntry == null) { throw new ReplayServiceRpcCopyStatusTimeoutException(this.ReplicaInstance.Configuration.DisplayName, (int)copyStatusServerTimeout.TotalSeconds); } if (copyStatusServerCachedEntry.CreateTimeUtc < DateTime.UtcNow - ReplicaInstanceContainer.CopyStatusStaleTimeout) { Exception ex = new ReplayServiceRpcCopyStatusTimeoutException(this.ReplicaInstance.Configuration.DisplayName, (int)ReplicaInstanceContainer.CopyStatusStaleTimeout.TotalSeconds); copyStatusServerCachedEntry.CopyStatus.CopyStatus = CopyStatusEnum.Failed; copyStatusServerCachedEntry.CopyStatus.ErrorMessage = ex.Message; copyStatusServerCachedEntry.CopyStatus.ExtendedErrorInfo = new ExtendedErrorInfo(ex); } return(copyStatusServerCachedEntry.CopyStatus); } } copyStatusServerCachedEntry = this.m_cachedStatus; if (this.IsCopyStatusReadThroughNeeded(copyStatusServerCachedEntry)) { try { ExTraceGlobals.ReplayServiceRpcTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "GetCachedCopyStatus() for DB '{0}' ({1}): Cache TTL expired or force refresh requested.", this.ReplicaInstance.Configuration.DisplayName, this.ReplicaInstance.Configuration.IdentityGuid); RpcDatabaseCopyStatus2 copyStatusWithTimeout = this.GetCopyStatusWithTimeout(flags); copyStatusServerCachedEntry = this.UpdateCachedCopyStatus(copyStatusWithTimeout); } catch (TimeoutException arg) { ExTraceGlobals.ReplayServiceRpcTracer.TraceError <string, TimeoutException>((long)this.GetHashCode(), "GetCachedCopyStatus() Timeout for DB '{0}': {1}", this.ReplicaInstance.Configuration.DisplayName, arg); throw new ReplayServiceRpcCopyStatusTimeoutException(this.ReplicaInstance.Configuration.DisplayName, (int)copyStatusServerTimeout.TotalSeconds); } finally { this.m_firstCachedStatusCallCompleted.Set(); } } } finally { if (flag) { Monitor.Exit(this.m_statusCallLocker); } } } return(copyStatusServerCachedEntry.CopyStatus); }