// Token: 0x060003ED RID: 1005 RVA: 0x00012C1C File Offset: 0x00010E1C
 protected void RunNow(MailboxData mailboxData)
 {
     lock (this.instanceLock)
     {
         if (this.windowJob != null && this.windowJob.Remove(mailboxData))
         {
             ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string>((long)this.GetHashCode(), "{0}: Removed mailbox {1} from windowJob so it can be added to a DemandJob.", this, mailboxData.DisplayName);
         }
         if (!this.demandJobs.Any((TimeBasedDatabaseDemandJob demandJob) => demandJob.GetMailboxGuidList(true).Contains(mailboxData.MailboxGuid) || demandJob.GetMailboxGuidList(false).Contains(mailboxData.MailboxGuid)))
         {
             this.demandJobs.Add(new TimeBasedDatabaseDemandJob(this, mailboxData, this.poisonControl, this.performanceCounters));
             ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string, uint>((long)this.GetHashCode(), "{0}: Adding demand job with the following mailbox {1}, total queued: {2}", this, mailboxData.DisplayName, this.TotalMailboxesQueued);
         }
         else
         {
             ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string, uint>((long)this.GetHashCode(), "{0}: Mailbox {1} has already been requested for a demand job, not queueing it again, total queued: {2}", this, mailboxData.DisplayName, this.TotalMailboxesQueued);
         }
     }
 }
        public MailboxData GetNextMailbox()
        {
            MailboxData result;

            lock (this.instanceLock)
            {
                if (this.pendingQueue.Count <= 0)
                {
                    result = null;
                }
                else
                {
                    MailboxData mailboxData = this.pendingQueue[0];
                    this.pendingQueue.RemoveAt(0);
                    this.activeQueue.Add(mailboxData);
                    result = mailboxData;
                }
            }
            return(result);
        }
        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);
        }
 public bool Remove(MailboxData mailbox)
 {
     lock (this.instanceLock)
     {
         if (this.pendingQueue.Remove(mailbox))
         {
             this.OnDemandMailboxCount++;
             this.Driver.DecrementNumberOfMailboxes();
             ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceDebug((long)this.GetHashCode(), "{0}: Removed mailbox.  total removed: {1}, mailboxesProcessedSuccessfully: {2}, mailboxesProcessedError: {3}, mailboxesFailedToOpenStoreSession: {4}, mailboxesRetriedCount: {5},remaining: {6}", new object[]
             {
                 this,
                 this.OnDemandMailboxCount,
                 this.mailboxesProcessedSuccessfullyCount,
                 this.mailboxesProcessedFailureCount,
                 this.mailboxesFailedToOpenStoreSessionCount,
                 this.mailboxesRetriedCount,
                 this.pendingQueue.Count
             });
             this.FinishIfNecessary();
             return(true);
         }
     }
     return(false);
 }
 // Token: 0x06000459 RID: 1113 RVA: 0x000164C0 File Offset: 0x000146C0
 public TimeBasedDatabaseDemandJob(TimeBasedDatabaseDriver driver, MailboxData mailboxData, PoisonMailboxControl poisonControl, PerformanceCountersPerDatabaseInstance databaseCounters) : base(driver, new List <MailboxData>(new MailboxData[]
 {
     mailboxData
 }), poisonControl, databaseCounters)
 {
 }
Пример #6
0
 private InvokeArgs(StoreSession storeSession, MailboxData mailboxData)
 {
     this.StoreSession = storeSession;
     this.mailboxData  = mailboxData;
 }
Пример #7
0
        public static InvokeArgs Create(StoreSession storeSession, TimeSpan timePerTask, MailboxData mailboxData)
        {
            InvokeArgs invokeArgs = InvokeArgs.Create(storeSession, mailboxData);

            invokeArgs.TimePerTask = timePerTask;
            MailboxDataForDemandJob mailboxDataForDemandJob = mailboxData as MailboxDataForDemandJob;

            if (mailboxDataForDemandJob != null)
            {
                invokeArgs.Parameters = mailboxDataForDemandJob.Parameters;
            }
            return(invokeArgs);
        }
Пример #8
0
 public bool Equals(MailboxData other)
 {
     return(other != null && this.DatabaseGuid == other.DatabaseGuid);
 }
Пример #9
0
 public void SetContext(IAssistantBase assistant, MailboxData mailboxData)
 {
     this.assistant   = assistant;
     this.mailboxData = mailboxData;
 }
        // 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);
        }
Пример #11
0
 private void PostProcessMailbox(AIException exception, AssistantTaskContext nextContext, MailboxData mailbox)
 {
     lock (this.instanceLock)
     {
         bool flag2 = this.Driver.Governor.ReportResult(exception);
         if (flag2)
         {
             if (nextContext == null)
             {
                 this.FinalizeMailboxProcessing(mailbox, exception);
             }
         }
         else
         {
             this.AddForRetry(mailbox);
         }
     }
 }