コード例 #1
0
 // Token: 0x06000192 RID: 402 RVA: 0x00007F40 File Offset: 0x00006140
 private void CheckDatabaseStatusTimerProc(object state)
 {
     if (!Monitor.TryEnter(this.checkDatabaseStatusLock))
     {
         ExTraceGlobals.DatabaseManagerTracer.TraceDebug <DatabaseManager>((long)this.GetHashCode(), "{0}: Currently unable to CheckDatabaseStatus -- we're busy", this);
         return;
     }
     try
     {
         RpcHangDetector rpcHangDetector = RpcHangDetector.Create();
         rpcHangDetector.InvokeUnderHangDetection(delegate(HangDetector hangDetector)
         {
             AIBreadcrumbs.DatabaseStatusTrail.Drop("Checking Database Status. Waiting on lock..");
             this.CheckDatabaseStatus(rpcHangDetector);
             AIBreadcrumbs.DatabaseStatusTrail.Drop("Exiting database status check.");
         });
         if (rpcHangDetector.HangsDetected > 0)
         {
             ExTraceGlobals.DatabaseManagerTracer.TraceDebug <DatabaseManager, DateTime>((long)this.GetHashCode(), "{0}: The DatabaseStatus check finally returned. It was invoked at {1} (Utc).", this, rpcHangDetector.InvokeTime);
             base.LogEvent(AssistantsEventLogConstants.Tuple_DatabaseStatusThreadResumed, null, new object[]
             {
                 rpcHangDetector.InvokeTime.ToLocalTime()
             });
         }
     }
     finally
     {
         Monitor.Exit(this.checkDatabaseStatusLock);
     }
 }
コード例 #2
0
        // Token: 0x060001F4 RID: 500 RVA: 0x0000A4F8 File Offset: 0x000086F8
        public void Stop()
        {
            RpcHangDetector rpcHangDetector = RpcHangDetector.Create();

            rpcHangDetector.InvokeUnderHangDetection(delegate(HangDetector hangDetector)
            {
                AIBreadcrumbs.StatusTrail.Drop("Event controller stop called.");
                this.RequestStop(rpcHangDetector);
                this.WaitUntilStopped();
                AIBreadcrumbs.StatusTrail.Drop("Exiting event controller stop.");
            });
        }
コード例 #3
0
 // Token: 0x06000201 RID: 513 RVA: 0x0000A848 File Offset: 0x00008A48
 private void TimerRoutine(object stateNotUsed)
 {
     using (ExPerfTrace.RelatedActivity(this.pollingActivityId))
     {
         ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: TimerRoutine", this);
         if (!Monitor.TryEnter(this.timerLock))
         {
             ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: timer already busy", this);
         }
         else
         {
             try
             {
                 long timestamp = Stopwatch.GetTimestamp();
                 if (ExTraceGlobals.FaultInjectionTracer.IsTraceEnabled(TraceType.FaultInjection))
                 {
                     ExTraceGlobals.FaultInjectionTracer.TraceTest <long>(3443928381U, ref timestamp);
                     long rawValue  = 0L;
                     long rawValue2 = 0L;
                     ExTraceGlobals.FaultInjectionTracer.TraceTest <long>(2764451133U, ref rawValue);
                     ExTraceGlobals.FaultInjectionTracer.TraceTest <long>(3838192957U, ref rawValue2);
                     this.DatabaseCounters.EventsInQueueCurrent.RawValue            = rawValue2;
                     this.DatabaseCounters.ElapsedTimeSinceLastEventPolled.RawValue = rawValue;
                     ExTraceGlobals.FaultInjectionTracer.TraceTest(3703975229U);
                 }
                 this.DatabaseCounters.ElapsedTimeSinceLastEventPollingAttempt.RawValue = timestamp;
                 bool noMoreEvents = false;
                 while (this.ReadyToPoll() && !noMoreEvents)
                 {
                     try
                     {
                         base.CatchMeIfYouCan(delegate
                         {
                             noMoreEvents = this.PollAndQueueEvents();
                         }, "EventController");
                     }
                     catch (AIException ex)
                     {
                         ExTraceGlobals.EventControllerTracer.TraceError <EventController, AIException>((long)this.GetHashCode(), "{0}: Exception while polling: {1}", this, ex);
                         this.governor.ReportResult(ex);
                     }
                     this.PeriodicMaintenance();
                 }
                 ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: Out of polling loop", this);
                 if (!this.Shutdown && this.RestartRequired)
                 {
                     ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: Restart required; stopping...", this);
                     RpcHangDetector rpcHangDetector = RpcHangDetector.Create();
                     rpcHangDetector.InvokeUnderHangDetection(delegate(HangDetector hangDetector)
                     {
                         AIBreadcrumbs.StatusTrail.Drop("Restart required, stopping.");
                         this.RequestStop(rpcHangDetector);
                         AIBreadcrumbs.StatusTrail.Drop("Exiting stop due to restart.");
                     });
                 }
                 if (!this.Shutdown && this.governor.Status != GovernorStatus.Failure && this.timeToSaveWatermarks < DateTime.UtcNow)
                 {
                     ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: Time to update watermarks...", this);
                     AIBreadcrumbs.StatusTrail.Drop("Begin Update Watermarks");
                     this.UpdateWatermarks();
                     AIBreadcrumbs.StatusTrail.Drop("End Update Watermarks");
                     ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: Updated watermarks.", this);
                     this.timeToSaveWatermarks = DateTime.UtcNow + Configuration.ActiveWatermarksSaveInterval;
                     ExTraceGlobals.EventControllerTracer.TraceDebug <EventController, DateTime>((long)this.GetHashCode(), "{0}: Next watermark update: {1}", this, this.timeToSaveWatermarks);
                 }
             }
             finally
             {
                 Monitor.Exit(this.timerLock);
             }
         }
     }
 }
コード例 #4
0
        // Token: 0x060001F1 RID: 497 RVA: 0x00009F98 File Offset: 0x00008198
        public void Start()
        {
            ExTraceGlobals.EventControllerTracer.TraceDebug <EventController>((long)this.GetHashCode(), "{0}: Starting", this);
            bool flag = false;

            try
            {
                AIBreadcrumbs.StartupTrail.Drop("Starting database: " + this.DatabaseInfo.Guid);
                this.DatabaseBookmark = this.eventAccess.GetDatabaseBookmark();
                Btree <Guid, Bookmark> btree = this.eventAccess.LoadAllMailboxBookmarks(this.DatabaseBookmark);
                bool flag2 = false;
                int  num   = 0;
                using (List <AssistantCollectionEntry> .Enumerator enumerator = this.assistants.ToList <AssistantCollectionEntry>().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AssistantCollectionEntry assistant = enumerator.Current;
                        do
                        {
                            try
                            {
                                base.CatchMeIfYouCan(delegate
                                {
                                    assistant.Start(EventBasedStartInfo.NoInformation);
                                }, assistant.Name);
                            }
                            catch (AIException ex)
                            {
                                if (num >= 1 || this.assistants.Count <= 1)
                                {
                                    throw;
                                }
                                if (!flag2)
                                {
                                    ExTraceGlobals.EventControllerTracer.TraceError <AssistantCollectionEntry, AIException>((long)this.GetHashCode(), "Event Based Assistant {0} cannot start due to Exception: {1}, Retrying now", assistant, ex);
                                    SingletonEventLogger.Logger.LogEvent(AssistantsEventLogConstants.Tuple_RetryAssistantFailedToStart, null, new object[]
                                    {
                                        assistant.Identity.ToString(),
                                        ex.ToString(),
                                        EventController.sleepStartingThread.TotalSeconds.ToString()
                                    });
                                    Thread.Sleep(EventController.sleepStartingThread);
                                    flag2 = true;
                                }
                                else
                                {
                                    ExTraceGlobals.EventControllerTracer.TraceError <AssistantCollectionEntry, AIException>((long)this.GetHashCode(), "Event Based Assistant {0} cannot start after retry, due to Exception: {1}, will not start it anymore", assistant, ex);
                                    SingletonEventLogger.Logger.LogEvent(AssistantsEventLogConstants.Tuple_AssistantFailedToStart, null, new object[]
                                    {
                                        assistant.Identity.ToString(),
                                        ex.ToString()
                                    });
                                    flag2 = false;
                                    this.assistants.RemoveAssistant(assistant);
                                    num++;
                                }
                            }
                        }while (flag2);
                    }
                }
                this.InitializeEventDispatchers(btree);
                this.timeToSaveWatermarks = DateTime.UtcNow + Configuration.ActiveWatermarksSaveInterval;
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventController, DateTime>((long)this.GetHashCode(), "{0}: Next time to save watermarks: {1}", this, this.timeToSaveWatermarks);
                long num2 = long.MaxValue;
                foreach (Bookmark bookmark in btree)
                {
                    num2 = Math.Min(num2, bookmark.GetLowestWatermark());
                }
                num2 = Math.Min(this.DatabaseBookmark.GetLowestWatermark(), num2);
                ExTraceGlobals.EventControllerTracer.TraceDebug <EventController, long>((long)this.GetHashCode(), "{0}: Smallest watermark after initialization is: {1}", this, num2);
                this.HighestEventPolled = num2;
                this.timer = new Timer(new TimerCallback(this.TimerRoutine), null, TimeSpan.Zero, Configuration.EventPollingInterval);
                flag       = true;
            }
            finally
            {
                if (!flag)
                {
                    RpcHangDetector rpcHangDetector = RpcHangDetector.Create();
                    rpcHangDetector.InvokeUnderHangDetection(delegate(HangDetector hangDetector)
                    {
                        AIBreadcrumbs.StatusTrail.Drop("Did not succeed to start event controller, stopping.");
                        this.RequestStop(rpcHangDetector);
                        this.WaitUntilAssistantsStopped();
                        AIBreadcrumbs.StatusTrail.Drop("Exiting stop on fail to start event controller to start.");
                    });
                }
                else
                {
                    AIBreadcrumbs.StartupTrail.Drop("Finished starting " + this.DatabaseInfo.Guid);
                }
            }
            base.TracePfd("PFD AIS {0} {1}: Started successfully", new object[]
            {
                21335,
                this
            });
        }
コード例 #5
0
        // Token: 0x0600018A RID: 394 RVA: 0x000077C0 File Offset: 0x000059C0
        public void Stop()
        {
            this.isStopping = true;
            ExTraceGlobals.DatabaseManagerTracer.TraceDebug <DatabaseManager>((long)this.GetHashCode(), "{0}: Stopping", this);
            AIBreadcrumbs.DatabaseStatusTrail.Drop("Shutdown requested for DatabaseManager. Waiting for lock.");
            bool flag = false;

            try
            {
                Monitor.Enter(this, ref flag);
                if (this.startState != DatabaseManager.StartState.Initialized)
                {
                    return;
                }
                ExTraceGlobals.DatabaseManagerTracer.TraceDebug <DatabaseManager>((long)this.GetHashCode(), "{0}: Deinitializing...", this);
                AIBreadcrumbs.DatabaseStatusTrail.Drop("Shutdown in progress. Lock acquired");
                if (this.databaseStatusTimer != null)
                {
                    this.databaseStatusTimer.Dispose();
                    this.databaseStatusTimer = null;
                }
                RpcHangDetector rpcHangDetector = RpcHangDetector.Create();
                rpcHangDetector.InvokeUnderHangDetection(delegate(HangDetector hangDetector)
                {
                    foreach (OnlineDatabase onlineDatabase3 in this.onlineDatabases.Values)
                    {
                        AIBreadcrumbs.ShutdownTrail.Drop("Stopping database: " + onlineDatabase3.ToString());
                        onlineDatabase3.RequestStop(rpcHangDetector);
                        AIBreadcrumbs.ShutdownTrail.Drop("Finished stoping " + onlineDatabase3.ToString());
                    }
                    if (this.timeBasedDriverManager != null)
                    {
                        this.timeBasedDriverManager.RequestStop(rpcHangDetector);
                    }
                });
                if (Test.NotifyPhase1ShutdownComplete != null)
                {
                    Test.NotifyPhase1ShutdownComplete();
                }
                foreach (OnlineDatabase onlineDatabase in this.onlineDatabases.Values)
                {
                    AIBreadcrumbs.ShutdownTrail.Drop("Waiting for Online Database to stop: " + onlineDatabase.ToString());
                    onlineDatabase.WaitUntilStopped();
                    AIBreadcrumbs.ShutdownTrail.Drop("Done waiting for " + onlineDatabase.ToString());
                }
                if (this.timeBasedDriverManager != null)
                {
                    AIBreadcrumbs.DatabaseStatusTrail.Drop("Waiting for TimeBasedDriverManager to stop");
                    this.timeBasedDriverManager.WaitUntilStopped();
                }
                AIBreadcrumbs.DatabaseStatusTrail.Drop("Done waiting. Disposing of objects.");
                foreach (OnlineDatabase onlineDatabase2 in this.onlineDatabases.Values)
                {
                    onlineDatabase2.Dispose();
                }
                this.onlineDatabases.Clear();
                this.DisposePerformanceCounters();
                this.startState = DatabaseManager.StartState.Stopped;
            }
            finally
            {
                if (flag)
                {
                    Monitor.Exit(this);
                }
            }
            this.starter.Stop();
            AIBreadcrumbs.DatabaseStatusTrail.Drop("Shutdown completed at DatabaseManager::Stop().");
            base.TracePfd("PFD AIS {0} {1}: Stopped", new object[]
            {
                31575,
                this
            });
        }