public AssistantTaskContext ProcessNextMailbox(AssistantTaskContext context) { ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceDebug <TimeBasedDatabaseJob>((long)this.GetHashCode(), "{0}: ProcessNextMailbox", this); MailboxData mailboxData = context.MailboxData; lock (this.instanceLock) { if (mailboxData == null) { ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceDebug <TimeBasedDatabaseJob>((long)this.GetHashCode(), "{0}: No more mailboxes to process", this); return(null); } if (!this.loggedBegin) { ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceDebug <TimeBasedDatabaseJob, int>((long)this.GetHashCode(), "{0}: Processing first mailbox out of {1}", this, this.initialPendingQueueCount); this.LogJobBegin(this.initialPendingQueueCount); this.loggedBegin = true; } } AssistantTaskContext assistantTaskContext = this.ProcessMailbox(context); AssistantTaskContext result; lock (this.instanceLock) { if (assistantTaskContext == null) { ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceDebug((long)this.GetHashCode(), "{0}: Finished processing of mailbox. mailboxesProcessedSuccessfully: {1}, mailboxesProcessedError: {2}, mailboxesFailedToOpenStoreSession: {3}, mailboxesRetriedCount: {4},remaining: {5}", new object[] { this, this.mailboxesProcessedSuccessfullyCount, this.mailboxesProcessedFailureCount, this.mailboxesFailedToOpenStoreSessionCount, this.mailboxesRetriedCount, this.pendingQueue.Count }); } result = assistantTaskContext; } return(result); }
private AssistantTaskContext ProcessMailbox(AssistantTaskContext context) { TimeBasedDatabaseJob.< > c__DisplayClassd CS$ < > 8__locals1 = new TimeBasedDatabaseJob.< > c__DisplayClassd(); CS$ < > 8__locals1.context = context; CS$ < > 8__locals1.< > 4__this = this; Guid mailboxGuid = CS$ < > 8__locals1.context.MailboxData.MailboxGuid; CS$ < > 8__locals1.nextContext = null; if (this.poisonControl.IsPoisonMailbox(mailboxGuid)) { ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceDebug <TimeBasedDatabaseJob, string, int>((long)this.GetHashCode(), "{0}: Poison mailbox detected and skipped. Mailbox: {1}, crashCount: {2}", this, (CS$ < > 8__locals1.context.MailboxData is StoreMailboxData) ? ((StoreMailboxData)CS$ < > 8__locals1.context.MailboxData).DisplayName : string.Empty, this.poisonControl.GetCrashCount(mailboxGuid)); if (Test.NotifyPoisonMailboxSkipped != null) { Test.NotifyPoisonMailboxSkipped(this.DatabaseInfo, mailboxGuid); } this.mailboxesProcessedFailureCount++; return(null); } CS$ < > 8__locals1.kit = new EmergencyKit(mailboxGuid); this.poisonControl.PoisonCall(CS$ < > 8__locals1.kit, new TryDelegate(CS$ < > 8__locals1, (UIntPtr)ldftn(< ProcessMailbox > b__c))); return(CS$ < > 8__locals1.nextContext); }
private AssistantTaskContext ProcessAdminRpcMailboxUnderPoisonControl(AssistantTaskContext context, EmergencyKit kit) { TimeBasedDatabaseJob.processMailboxTestHook.Value(); AssistantTaskContext result = null; Guid activityId = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty; if (context.Args == null) { context.Args = InvokeArgs.Create(null, this.Driver.TimePerTask, context.MailboxData); } AssistantsLog.LogStartProcessingMailboxEvent(activityId, this.Assistant as AssistantBase, context.MailboxData.MailboxGuid, context.MailboxData.DisplayName, this); try { kit.SetContext(this.Assistant, context.MailboxData); result = context.Step(context); } finally { kit.UnsetContext(); } AssistantsLog.LogEndProcessingMailboxEvent(activityId, this.Assistant as AssistantBase, context.CustomDataToLog, context.MailboxData.MailboxGuid, context.MailboxData.DisplayName, this); return(result); }
private AssistantTaskContext ProcessStoreMailbox(AssistantTaskContext context, EmergencyKit kit) { TimeBasedDatabaseJob.processMailboxTestHook.Value(); StoreMailboxData storeMailboxData = context.MailboxData as StoreMailboxData; AssistantTaskContext assistantTaskContext; using (StoreSession storeSession = this.OpenMailboxSession(storeMailboxData)) { Stopwatch stopwatch = Stopwatch.StartNew(); try { if (context.Args == null) { context.Args = InvokeArgs.Create(storeSession, this.Driver.TimePerTask, storeMailboxData); } kit.SetContext(this.Assistant, storeMailboxData); assistantTaskContext = context.Step(context); } finally { kit.UnsetContext(); if (this.Driver.AssistantType.ControlDataPropertyDefinition != null && context.Args != null) { context.Args.StoreSession.Mailbox[this.Driver.AssistantType.ControlDataPropertyDefinition] = ControlData.Create(DateTime.UtcNow).ToByteArray(); context.Args.StoreSession.Mailbox.Save(); } } stopwatch.Stop(); this.performanceCounters.AverageMailboxProcessingTime.IncrementBy(stopwatch.ElapsedTicks); this.performanceCounters.AverageMailboxProcessingTimeBase.Increment(); if (assistantTaskContext == null) { this.performanceCounters.MailboxesProcessed.Increment(); } } return(assistantTaskContext); }
// Token: 0x060003F3 RID: 1011 RVA: 0x00013198 File Offset: 0x00011398 protected AssistantTaskContext ProcessOneMailbox(ref AssistantTaskContext context) { lock (this.instanceLock) { if (context == null) { if (!this.started) { ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string>((long)this.GetHashCode(), "{0}: Worker bailing (Not started) for assistant: {1}", this, this.Assistant.NonLocalizedName); AssistantsLog.LogNotStartedEvent(this.Assistant.NonLocalizedName, this.Assistant as AssistantBase); return(null); } if (this.TotalMailboxesQueued == 0U) { ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string>((long)this.GetHashCode(), "{0}: Worker bailing (Empty queue) for assistant: {1}", this, this.Assistant.NonLocalizedName); AssistantsLog.LogNoMailboxesPendingEvent(this.Assistant.NonLocalizedName); return(null); } } if (this.workersActive++ == 0) { FastManualResetEvent fastManualResetEvent = this.workerThreadsClear; if (fastManualResetEvent != null) { fastManualResetEvent.Reset(); } } ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int, string>((long)this.GetHashCode(), "{0}: Worker started. Workers Active on this Driver: {1}, assistant: {2}", this, this.workersActive, this.Assistant.NonLocalizedName); } AssistantTaskContext assistantTaskContext = null; TimeBasedDatabaseJob timeBasedDatabaseJob = null; MailboxData mailboxData = null; try { if (context == null) { lock (this.instanceLock) { timeBasedDatabaseJob = this.GetPendingJob(true); ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, uint, string>((long)this.GetHashCode(), "{0}: Total Mailboxes Queued on this database: {1}, assistant: {2}", this, this.TotalMailboxesQueued, this.Assistant.NonLocalizedName); } if (timeBasedDatabaseJob != null) { mailboxData = timeBasedDatabaseJob.GetNextMailbox(); if (mailboxData != null) { context = this.Assistant.InitializeContext(mailboxData, timeBasedDatabaseJob); } } else { AssistantsLog.LogNoJobsEvent(this.Assistant.NonLocalizedName); } } else { timeBasedDatabaseJob = context.Job; mailboxData = context.MailboxData; } if (context != null && context.Job != null) { assistantTaskContext = context.Job.ProcessNextMailbox(context); } } catch { lock (this.instanceLock) { if (--this.workersActive == 0) { ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int, string>((long)this.GetHashCode(), "{0}: Worker exiting due to exception. Workers Active {1}, assistant: {2}", this, this.workersActive, this.Assistant.NonLocalizedName); this.workerThreadsClear.Set(); } } throw; } finally { if (timeBasedDatabaseJob != null && mailboxData != null && (assistantTaskContext == null || context == null)) { timeBasedDatabaseJob.RemoveFromActive(mailboxData); timeBasedDatabaseJob.FinishIfNecessary(); } } lock (this.instanceLock) { try { ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int, uint>((long)this.GetHashCode(), "{0}: Yielding thread. Workers Active: {1}, Remaining Mailboxes on this database: {2}", this, this.workersActive, this.TotalMailboxesQueued); if (context != null && context.Job != null && (context.Job.MailboxesQueued == 0 || context.Job.Finished)) { TimeBasedDatabaseDemandJob timeBasedDatabaseDemandJob = context.Job as TimeBasedDatabaseDemandJob; if (timeBasedDatabaseDemandJob != null) { this.demandJobs.Remove(timeBasedDatabaseDemandJob); ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int>((long)this.GetHashCode(), "{0}: Demand Job is done and has been removed. Remaining Demand Jobs: {1}", this, this.demandJobs.Count); } else { this.RemoveWindowJobWithHistoryEntry(); } } } finally { if (--this.workersActive == 0) { ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int>((long)this.GetHashCode(), "{0}: Worker exiting. Workers Active {1}", this, this.workersActive); this.workerThreadsClear.Set(); } } } return(assistantTaskContext); }