public bool ReportResult(AIException exception) { bool flag = true; ExTraceGlobals.GovernorTracer.TraceDebug <Governor, AIException>((long)this.GetHashCode(), "{0}: ReportResult: {1}", this, exception); AITransientException ex = null; if (exception is AITransientException && this.IsFailureRelevant((AITransientException)exception)) { ex = (AITransientException)exception; ExTraceGlobals.GovernorTracer.TraceDebug <Governor>((long)this.GetHashCode(), "{0}: Exception is relevant", this); } lock (this) { switch (this.status) { case GovernorStatus.Running: if (ex != null) { this.numberConsecutiveFailures = 0U; this.lastRunTime = DateTime.UtcNow; this.ReportFailure(ex); flag = false; } break; case GovernorStatus.Retry: if (ex == null) { this.LogRecovery(exception); this.EnterRun(); } else if (ex.RetrySchedule.FinalAction != FinalAction.RetryForever && this.lastRunTime + ex.RetrySchedule.TimeToGiveUp <= DateTime.UtcNow) { this.numberConsecutiveFailures += 1U; this.LogGiveUp(exception); this.EnterRun(); } else { this.ReportFailure(ex); flag = false; } break; case GovernorStatus.Failure: if (ex != null) { flag = false; this.LogFailure(GovernorStatus.Failure, ex); } break; } } if (this.parentGovernor != null) { flag &= this.parentGovernor.ReportResult(exception); } return(flag); }
private void LogFailure(GovernorStatus oldStatus, AITransientException exception) { TimeSpan nextRetryInterval = this.GetNextRetryInterval(exception.RetrySchedule); ExTraceGlobals.GovernorTracer.TraceDebug((long)this.GetHashCode(), "{0}: {1}->Failure. {2} attempts in timespan {3}. Next retry time: now+{4}. Exception: {5}.", new object[] { this, oldStatus, this.numberConsecutiveFailures, DateTime.UtcNow - this.lastRunTime, nextRetryInterval, exception }); base.LogEvent(AssistantsEventLogConstants.Tuple_GovernorFailure, null, new object[] { this, oldStatus, this.numberConsecutiveFailures, DateTime.UtcNow - this.lastRunTime, nextRetryInterval, exception }); if (!this.logged30MinuteWarning && DateTime.UtcNow - this.lastRunTime > TimeSpan.FromMinutes(30.0)) { this.Log30MinuteWarning(exception, nextRetryInterval); this.logged30MinuteWarning = true; } }
protected override void Log30MinuteWarning(AITransientException exception, TimeSpan nextRetryInterval) { base.LogEvent(AssistantsEventLogConstants.Tuple_DatabaseGovernorFailure, null, new object[] { this, base.LastRunTime.ToLocalTime(), nextRetryInterval, exception }); }
private void ReportFailure(AITransientException transientException) { this.numberConsecutiveFailures += 1U; this.LogFailure(this.status, transientException); this.status = GovernorStatus.Failure; ExTraceGlobals.GovernorTracer.TraceDebug <Governor>((long)this.GetHashCode(), "{0}: Starting timer", this); TimeSpan nextRetryInterval = this.GetNextRetryInterval(transientException.RetrySchedule); this.retryTimer = new Timer(Governor.timerCallback, this, nextRetryInterval, TimeSpan.Zero); this.OnFailure(); }
protected override bool IsFailureRelevant(AITransientException exception) { return(exception is TransientMailboxException); }
protected virtual void Log30MinuteWarning(AITransientException exception, TimeSpan nextRetryInterval) { }
protected abstract bool IsFailureRelevant(AITransientException exception);