private MailboxDispatcher GetDispatcherForMailbox(Guid mailboxGuid, long eventCounter)
        {
            MailboxDispatcher mailboxDispatcher = null;
            bool flag2;

            lock (this.dispatchers)
            {
                flag2 = this.dispatchers.TryGetValue(mailboxGuid, out mailboxDispatcher);
            }
            if (!flag2)
            {
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPrivate, Guid>((long)this.GetHashCode(), "{0}: creating dispatcher for mailbox {1}", this, mailboxGuid);
                bool dispatcherIsUpToDate = false;
                lock (this.upToDateDispatchers)
                {
                    dispatcherIsUpToDate = this.upToDateDispatchers.Contains(mailboxGuid);
                }
                Bookmark bookmark = null;
                if (this.initialBookmarks != null && this.initialBookmarks.Remove(mailboxGuid, out bookmark) && bookmark != null && bookmark.Identity != Guid.Empty)
                {
                    ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPrivate, Bookmark>((long)this.GetHashCode(), "{0}: Initializing mailbox dispatcher from {1}", this, bookmark);
                    mailboxDispatcher = MailboxDispatcher.CreateFromBookmark(this, base.EventAccess, null, bookmark, base.DatabaseBookmark);
                }
                if (mailboxDispatcher == null)
                {
                    mailboxDispatcher = MailboxDispatcher.CreateWithoutBookmark(this, base.EventAccess, mailboxGuid, base.DatabaseBookmark, dispatcherIsUpToDate);
                }
                lock (this.dispatchers)
                {
                    this.dispatchers[mailboxGuid] = mailboxDispatcher;
                }
                this.UpdateNumberOfDispatchers();
            }
            return(mailboxDispatcher);
        }
        private List <QueryableObject> QueryEventDispatcher(object[] parameters, QueryFilter filter)
        {
            List <QueryableObject> list            = new List <QueryableObject>(50);
            IList <OnlineDatabase> onlineDatabases = OnlineDiagnostics.Instance.databaseManager.GetOnlineDatabases((Guid?)parameters[0]);

            if (onlineDatabases == null || onlineDatabases.Count != 1)
            {
                throw new ArgumentException("Could not find the database specified by DatabaseGuid", "DatabaseGuid");
            }
            EventControllerPrivate    eventControllerPrivate = (EventControllerPrivate)onlineDatabases[0].EventController;
            IList <MailboxDispatcher> mailboxDispatcher      = eventControllerPrivate.GetMailboxDispatcher((Guid?)parameters[1]);

            if (mailboxDispatcher == null)
            {
                return(list);
            }
            MailboxDispatcher mailboxDispatcher2 = mailboxDispatcher[0];

            foreach (EventDispatcherPrivate eventDispatcherPrivate in mailboxDispatcher2.GetEventDispatcher((Guid?)parameters[2]))
            {
                QueryableEventDispatcher queryableEventDispatcher = new QueryableEventDispatcher();
                eventDispatcherPrivate.ExportToQueryableObject(queryableEventDispatcher);
                if (filter == null || OpathFilterEvaluator.FilterMatches(filter, queryableEventDispatcher))
                {
                    list.Add(queryableEventDispatcher);
                }
            }
            return(list);
        }
 public void DeadDispatcher(MailboxDispatcher dispatcher)
 {
     ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPrivate, MailboxDispatcher>((long)this.GetHashCode(), "{0}: Adding dispatcher to dead queue: {1}", this, dispatcher);
     lock (this.deadQueue)
     {
         this.deadQueue.Enqueue(dispatcher);
     }
     lock (this.upToDateDispatchers)
     {
         this.upToDateDispatchers.Remove(dispatcher.MailboxGuid);
     }
 }
        private void DisposeDecayedDispatchers()
        {
            bool flag = false;

            try
            {
                Monitor.Enter(this.deadQueue);
                flag = true;
                while (this.deadQueue.Count > 0)
                {
                    MailboxDispatcher mailboxDispatcher = this.deadQueue.Peek();
                    if (base.HighestEventPolled <= mailboxDispatcher.DecayedEventCounter)
                    {
                        ExTraceGlobals.EventControllerTracer.TraceDebug((long)this.GetHashCode(), "{0}: finished disposingDecayedDispatchers, highestEventPolled {1}, dispatcher.DecayedEventCounter: {2}, dispatcher: {3}", new object[]
                        {
                            this,
                            base.HighestEventPolled,
                            mailboxDispatcher.DecayedEventCounter,
                            mailboxDispatcher
                        });
                        break;
                    }
                    ExTraceGlobals.EventControllerTracer.TraceDebug((long)this.GetHashCode(), "{0}: dead dispatcher has decayed, highestEventPolled {1}, dispatcher.DecayedEventCounter: {2}, dispatcher: {3}", new object[]
                    {
                        this,
                        base.HighestEventPolled,
                        mailboxDispatcher.DecayedEventCounter,
                        mailboxDispatcher
                    });
                    this.deadQueue.Dequeue();
                    Monitor.Exit(this.deadQueue);
                    flag = false;
                    if (this.dispatchers.ContainsKey(mailboxDispatcher.MailboxGuid) && this.dispatchers[mailboxDispatcher.MailboxGuid] == mailboxDispatcher)
                    {
                        this.dispatchers.Remove(mailboxDispatcher.MailboxGuid);
                        this.UpdateNumberOfDispatchers();
                    }
                    mailboxDispatcher.WaitForShutdown();
                    mailboxDispatcher.Dispose();
                    Monitor.Enter(this.deadQueue);
                    flag = true;
                }
            }
            finally
            {
                if (flag)
                {
                    Monitor.Exit(this.deadQueue);
                }
            }
        }
        private MailboxDispatcher GetDispatcherForMapiEvent(MapiEvent mapiEvent)
        {
            MailboxDispatcher dispatcherForMailbox = this.GetDispatcherForMailbox(mapiEvent.MailboxGuid, mapiEvent.EventCounter);

            if (dispatcherForMailbox.IsMailboxDead && mapiEvent.EventCounter > dispatcherForMailbox.DecayedEventCounter)
            {
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPrivate, MailboxDispatcher>((long)this.GetHashCode(), "{0}: Dispatcher has decayed.  Removing it from table: {1}", this, dispatcherForMailbox);
                lock (this.dispatchers)
                {
                    this.dispatchers.Remove(dispatcherForMailbox.MailboxGuid);
                }
                this.UpdateNumberOfDispatchers();
                return(this.GetDispatcherForMailbox(mapiEvent.MailboxGuid, mapiEvent.EventCounter));
            }
            return(dispatcherForMailbox);
        }
Esempio n. 6
0
        public static MailboxDispatcher CreateFromBookmark(EventControllerPrivate controller, EventAccess eventAccess, MapiEvent[] eventTable, Bookmark mailboxBookmark, Bookmark databaseBookmark)
        {
            MailboxDispatcher mailboxDispatcher = new MailboxDispatcher(mailboxBookmark.Identity, controller, controller.Assistants.Count);

            foreach (AssistantCollectionEntry assistantCollectionEntry in controller.Assistants)
            {
                EventDispatcherPrivate value = new EventDispatcherPrivate(mailboxDispatcher, assistantCollectionEntry, controller, mailboxBookmark[assistantCollectionEntry.Identity]);
                mailboxDispatcher.assistantDispatchers.Add(assistantCollectionEntry.Identity, value);
                assistantCollectionEntry.PerformanceCounters.EventDispatchers.Increment();
            }
            foreach (EventDispatcherPrivate eventDispatcherPrivate in mailboxDispatcher.assistantDispatchers.Values)
            {
                eventDispatcherPrivate.Initialize(eventAccess, eventTable, databaseBookmark[eventDispatcherPrivate.AssistantIdentity]);
            }
            return(mailboxDispatcher);
        }
        protected override void ProcessPolledEvent(MapiEvent mapiEvent)
        {
            if (mapiEvent.MailboxGuid == Guid.Empty)
            {
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPrivate, long>((long)this.GetHashCode(), "{0}: Ignoring event {1} with empty mailbox Guid", this, mapiEvent.EventCounter);
                return;
            }
            if (base.DatabaseInfo.IsSystemAttendantMailbox(mapiEvent.MailboxGuid))
            {
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventControllerPrivate, long>((long)this.GetHashCode(), "{0}: Ignoring event {1} for SA mailbox", this, mapiEvent.EventCounter);
                return;
            }
            base.TracePfd("PFD AIS {0} {1}: Processing event {2}", new object[]
            {
                18519,
                this,
                mapiEvent.EventCounter
            });
            MailboxDispatcher dispatcherForMapiEvent = this.GetDispatcherForMapiEvent(mapiEvent);

            dispatcherForMapiEvent.ProcessPolledEvent(mapiEvent);
        }
Esempio n. 8
0
 public void SetAsDeadMailbox(long problemEventCounter, long decayedEventCounter)
 {
     if (MailboxDispatcher.syncWithTestCodeBeginningOfSetAsDead != null)
     {
         MailboxDispatcher.syncWithTestCodeBeginningOfSetAsDead();
     }
     lock (this.deadMailboxLocker)
     {
         ExTraceGlobals.EventDispatcherTracer.TraceDebug <MailboxDispatcher, long, long>((long)this.GetHashCode(), "{0}: Setting mailbox dead events [{1}-{2}]", this, problemEventCounter, decayedEventCounter);
         if (this.IsMailboxDead)
         {
             this.decayedEventCounter = Math.Min(this.decayedEventCounter, decayedEventCounter);
             ExTraceGlobals.EventDispatcherTracer.TraceDebug <MailboxDispatcher, long>((long)this.GetHashCode(), "{0}: this.decayedEventCounter: {1}", this, this.decayedEventCounter);
         }
         else
         {
             this.decayedEventCounter = decayedEventCounter;
             base.LogEvent(AssistantsEventLogConstants.Tuple_DeadMailbox, null, new object[]
             {
                 problemEventCounter,
                 decayedEventCounter,
                 this.MailboxDisplayName,
                 (this.mailboxOwner == null) ? null : this.mailboxOwner.MailboxInfo.OrganizationId.GetTenantGuid().ToString(),
                 (this.mailboxOwner == null) ? null : this.mailboxOwner.MailboxInfo.Location.ServerFqdn,
                 this.DatabaseInfo.DisplayName
             });
             foreach (EventDispatcherPrivate eventDispatcherPrivate in this.assistantDispatchers.Values)
             {
                 ExTraceGlobals.EventDispatcherTracer.TraceDebug <MailboxDispatcher>((long)this.GetHashCode(), "{0}: Clearing event queue", this);
                 eventDispatcherPrivate.ClearPendingQueue();
             }
             this.controller.DeadDispatcher(this);
         }
     }
     if (MailboxDispatcher.syncWithTestCodeEndOfSetAsDead != null)
     {
         MailboxDispatcher.syncWithTestCodeEndOfSetAsDead();
     }
 }
 // Token: 0x06000255 RID: 597 RVA: 0x0000D178 File Offset: 0x0000B378
 public EventDispatcherPrivate(MailboxDispatcher parentMailboxDispatcher, AssistantCollectionEntry assistant, EventControllerPrivate controller, long watermark) : base(assistant, new MailboxGovernor(controller.Governor, new Throttle("EventDispatcherPrivate", 1, controller.Throttle)), controller)
 {
     this.parentMailboxDispatcher = parentMailboxDispatcher;
     this.committedWatermark      = watermark;
     this.highestEventQueued      = watermark;
 }
Esempio n. 10
0
        public static MailboxDispatcher CreateWithoutBookmark(EventControllerPrivate controller, EventAccess eventAccess, Guid mailboxGuid, Bookmark databaseBookmark, bool dispatcherIsUpToDate)
        {
            Bookmark mailboxBookmark = eventAccess.GetMailboxBookmark(mailboxGuid, databaseBookmark, dispatcherIsUpToDate);

            return(MailboxDispatcher.CreateFromBookmark(controller, eventAccess, null, mailboxBookmark, databaseBookmark));
        }