// Token: 0x06000274 RID: 628 RVA: 0x0000DE40 File Offset: 0x0000C040
 private void InitFromWatermark(EventAccess eventAccess, MapiEvent[] eventTable, long databaseCounter)
 {
     if (this.committedWatermark != 0L && this.committedWatermark < databaseCounter)
     {
         ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate>((long)this.GetHashCode(), "{0}: Searching for retryEvent...", this);
         MapiEvent mapiEvent;
         if (eventTable != null)
         {
             mapiEvent = this.FindNextEventForMailboxFromEventTable(eventTable, this.committedWatermark + 1L);
         }
         else
         {
             mapiEvent = this.FindNextEventForMailbox(eventAccess, this.committedWatermark + 1L);
         }
         if (mapiEvent != null && mapiEvent.EventCounter < databaseCounter)
         {
             ExTraceGlobals.EventDispatcherTracer.TraceDebug((long)this.GetHashCode(), "{0}: Starting in retry.  mailboxWatermark: {1}, databaseCounter: {2}, retryEvent: {3}", new object[]
             {
                 this,
                 this.committedWatermark,
                 databaseCounter,
                 mapiEvent.EventCounter
             });
             this.IsInRetry = true;
             ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate>((long)this.GetHashCode(), "{0}: Starting in retry.", this);
             base.Assistant.PerformanceCounters.FailedDispatchers.Increment();
             base.EnqueueItem(InterestingEvent.CreateUnprocessed(mapiEvent));
         }
     }
 }
Exemple #2
0
        // Token: 0x060001E0 RID: 480 RVA: 0x00009D48 File Offset: 0x00007F48
        public EventController(DatabaseInfo databaseInfo, EventBasedAssistantCollection assistants, PoisonEventControl poisonControl, PerformanceCountersPerDatabaseInstance databaseCounters, ThrottleGovernor serverGovernor, MapiEventTypeFlags moreEvents)
        {
            this.databaseInfo     = databaseInfo;
            this.databaseCounters = databaseCounters;
            this.assistants       = assistants;
            this.shutdownState    = 0;
            this.poisonControl    = poisonControl;
            MapiEventTypeFlags mapiEventTypeFlags = this.assistants.EventMask | moreEvents;

            this.filter      = (((MapiEventTypeFlags)(-1) == mapiEventTypeFlags) ? null : Restriction.BitMaskNonZero(PropTag.EventMask, (int)mapiEventTypeFlags));
            this.governor    = new DatabaseGovernor("event processing on '" + databaseInfo.DisplayName + "'", serverGovernor, new Throttle("EventDatabase", serverGovernor.Throttle.OpenThrottleValue, serverGovernor.Throttle));
            this.eventAccess = EventAccess.Create(this.DatabaseInfo, this.assistants);
        }
        // Token: 0x06000272 RID: 626 RVA: 0x0000DCFC File Offset: 0x0000BEFC
        private MapiEvent FindNextEventForMailbox(EventAccess eventAccess, long beginCounter)
        {
            Restriction restriction = Restriction.EQ(PropTag.EventMailboxGuid, this.MailboxGuid.ToByteArray());
            Restriction filter      = (base.Controller.Filter == null) ? restriction : Restriction.And(new Restriction[]
            {
                restriction,
                base.Controller.Filter
            });

            ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate, long>((long)this.GetHashCode(), "{0}: Finding next for this mailbox from {1}...", this, beginCounter);
            long num;

            MapiEvent[] array = eventAccess.ReadEvents(beginCounter, 1, int.MaxValue, filter, out num);
            if (array.Length > 0)
            {
                ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate, long, MapiEvent>((long)this.GetHashCode(), "{0}: Found next event for this mailbox from {1}: {2}", this, beginCounter, array[0]);
                return(array[0]);
            }
            ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate, long>((long)this.GetHashCode(), "{0}: Found no events for mailbox after {1}", this, beginCounter);
            return(null);
        }
 // Token: 0x06000263 RID: 611 RVA: 0x0000D274 File Offset: 0x0000B474
 public void Initialize(EventAccess eventAccess, MapiEvent[] eventTable, long databaseCounter)
 {
     try
     {
         this.InitFromWatermark(eventAccess, eventTable, databaseCounter);
     }
     catch (MapiExceptionUnknownMailbox arg)
     {
         ExTraceGlobals.EventDispatcherTracer.TraceError <EventDispatcherPrivate, MapiExceptionUnknownMailbox>((long)this.GetHashCode(), "{0}: Unable to InitFromWatermark: {1}", this, arg);
         long lastEventCounter = this.ControllerPrivate.GetLastEventCounter();
         try
         {
             this.InitFromWatermark(eventAccess, eventTable, databaseCounter);
         }
         catch (MapiExceptionUnknownMailbox arg2)
         {
             ExTraceGlobals.EventDispatcherTracer.TraceError <EventDispatcherPrivate, MapiExceptionUnknownMailbox>((long)this.GetHashCode(), "{0}: Still unable to InitFromWatermark: {1}", this, arg2);
             this.SetAsDeadMailbox(databaseCounter, lastEventCounter);
         }
     }
     ExTraceGlobals.EventDispatcherTracer.TraceDebug <EventDispatcherPrivate>((long)this.GetHashCode(), "{0}: Constructed", this);
 }
Exemple #5
0
        public Btree <Guid, Bookmark> LoadAllMailboxBookmarks(Bookmark currentDatabaseBookmark)
        {
            ExTraceGlobals.EventAccessTracer.TraceDebug <EventAccess, Bookmark>((long)this.GetHashCode(), "{0}: Loading all mailbox bookmarks. Current database watermark is {1}", this, currentDatabaseBookmark);
            int numberOfActiveMailboxesWithDecayedWatermarks = 0;
            int numberOfStaleMailboxesWithDecayedWatermarks  = 0;
            Dictionary <Guid, MailboxInformation> mailboxesWithDecayedWatermarks = new Dictionary <Guid, MailboxInformation>();
            Btree <Guid, Bookmark> allBookmarks = new Btree <Guid, Bookmark>(100);

            this.CallEventManager(delegate
            {
                long lowestEventCounter = this.GetLowestEventCounter();
                ExTraceGlobals.EventAccessTracer.TraceDebug <EventAccess, long>((long)this.GetHashCode(), "{0}: Lowest Event Counter: {1}", this, lowestEventCounter);
                foreach (AssistantCollectionEntry assistantCollectionEntry in this.assistantCollection)
                {
                    Watermark[] watermarksForAssistant = this.GetWatermarksForAssistant(assistantCollectionEntry.Identity);
                    ExTraceGlobals.EventAccessTracer.TraceDebug <EventAccess, int, LocalizedString>((long)this.GetHashCode(), "{0}: Retrieved {1} watermarks for assistant {2}", this, watermarksForAssistant.Length, assistantCollectionEntry.Instance.Name);
                    foreach (Watermark watermark in watermarksForAssistant)
                    {
                        if (watermark.MailboxGuid == Guid.Empty)
                        {
                            ExTraceGlobals.EventAccessTracer.TraceDebug <EventAccess>((long)this.GetHashCode(), "{0}: Skipping database watermark.", this);
                        }
                        else
                        {
                            if (EventAccess.IsWatermarkBehindEventCounter(watermark.EventCounter, lowestEventCounter))
                            {
                                MailboxInformation mailboxInformation;
                                if (!mailboxesWithDecayedWatermarks.TryGetValue(watermark.MailboxGuid, out mailboxInformation))
                                {
                                    ExTraceGlobals.EventAccessTracer.TraceDebug((long)this.GetHashCode(), "{0}: Found a decayed watermark {1} for mailbox {2} and assistant {3}", new object[]
                                    {
                                        this,
                                        watermark.EventCounter,
                                        watermark.MailboxGuid,
                                        assistantCollectionEntry.Name
                                    });
                                    mailboxInformation = MailboxInformation.Create(this.exRpcAdmin, watermark.MailboxGuid, this.databaseInfo.Guid);
                                    mailboxesWithDecayedWatermarks.Add(watermark.MailboxGuid, mailboxInformation);
                                    if (!mailboxInformation.Active)
                                    {
                                        numberOfStaleMailboxesWithDecayedWatermarks++;
                                    }
                                    else
                                    {
                                        numberOfActiveMailboxesWithDecayedWatermarks++;
                                    }
                                }
                                else
                                {
                                    ExTraceGlobals.EventAccessTracer.TraceDebug((long)this.GetHashCode(), "{0}: Found another decayed watermark {1} for mailbox {2} and assistant {3}", new object[]
                                    {
                                        this,
                                        watermark.EventCounter,
                                        watermark.MailboxGuid,
                                        assistantCollectionEntry.Name
                                    });
                                }
                                if (!mailboxInformation.Active)
                                {
                                    ExTraceGlobals.EventAccessTracer.TraceDebug <EventAccess, Guid>((long)this.GetHashCode(), "{0}: Mailbox {1} was identified as stale.", this, mailboxInformation.MailboxGuid);
                                    this.DeleteWatermark(assistantCollectionEntry.Identity, mailboxInformation.MailboxGuid);
                                    goto IL_2A5;
                                }
                            }
                            Bookmark bookmark;
                            if (!allBookmarks.TryGetValue(watermark.MailboxGuid, out bookmark))
                            {
                                bookmark = Bookmark.CreateFromDatabaseBookmark(watermark.MailboxGuid, currentDatabaseBookmark);
                                allBookmarks.Add(bookmark);
                            }
                            bookmark[assistantCollectionEntry.Identity] = watermark.EventCounter;
                        }
                        IL_2A5:;
                    }
                }
            });
            if (numberOfStaleMailboxesWithDecayedWatermarks != 0 || numberOfActiveMailboxesWithDecayedWatermarks != 0)
            {
                ExTraceGlobals.EventAccessTracer.TraceDebug <EventAccess, int, int>((long)this.GetHashCode(), "{0}: Found a total of {1} active mailbox(s) and {2} stale mailbox(s) with decayed watermarks.", this, numberOfActiveMailboxesWithDecayedWatermarks, numberOfStaleMailboxesWithDecayedWatermarks);
                int           num           = Math.Min(100, numberOfActiveMailboxesWithDecayedWatermarks + numberOfStaleMailboxesWithDecayedWatermarks);
                StringBuilder stringBuilder = new StringBuilder(num * 100);
                using (Dictionary <Guid, MailboxInformation> .Enumerator enumerator = mailboxesWithDecayedWatermarks.GetEnumerator())
                {
                    while (enumerator.MoveNext() && num-- > 0)
                    {
                        stringBuilder.Append(Environment.NewLine);
                        StringBuilder stringBuilder2 = stringBuilder;
                        object[]      array          = new object[4];
                        object[]      array2         = array;
                        int           num2           = 0;
                        KeyValuePair <Guid, MailboxInformation> keyValuePair = enumerator.Current;
                        array2[num2] = keyValuePair.Value.DisplayName;
                        array[1]     = " (";
                        object[] array3 = array;
                        int      num3   = 2;
                        KeyValuePair <Guid, MailboxInformation> keyValuePair2 = enumerator.Current;
                        array3[num3] = keyValuePair2.Key;
                        array[3]     = ")";
                        stringBuilder2.Append(string.Concat(array));
                    }
                }
                base.LogEvent(AssistantsEventLogConstants.Tuple_MailboxesWithDecayedWatermarks, null, new object[]
                {
                    numberOfActiveMailboxesWithDecayedWatermarks,
                    numberOfStaleMailboxesWithDecayedWatermarks,
                    this.databaseInfo.DisplayName,
                    stringBuilder.ToString()
                });
            }
            return(allBookmarks);
        }
Exemple #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);
        }
Exemple #7
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));
        }