internal ClientStatisticsManager(IStatisticsConfiguration config) { runtimeStats = new RuntimeStatisticsGroup(); logStatistics = new LogStatistics(config.StatisticsLogWriteInterval, false); logger = TraceLogger.GetLogger(GetType().Name); }
public Logger GetLogger(string loggerName, TraceLogger.LoggerType logType) { return(TraceLogger.GetLogger(loggerName, logType)); }
static Message() { lifecycleStatistics = new Dictionary <string, TransitionStats[, ]>(); logger = TraceLogger.GetLogger("Message", TraceLogger.LoggerType.Runtime); }
private static void AgentThreadProc(Object obj) { var agent = obj as AsynchAgent; if (agent == null) { var log = TraceLogger.GetLogger("RuntimeCore.AsynchAgent"); log.Error(ErrorCode.Runtime_Error_100022, "Agent thread started with incorrect parameter type"); return; } try { LogStatus(agent.Log, "Starting AsyncAgent {0} on managed thread {1}", agent.Name, Thread.CurrentThread.ManagedThreadId); CounterStatistic.SetOrleansManagedThread(); // do it before using CounterStatistic. CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.RUNTIME_THREADS_ASYNC_AGENT_PERAGENTTYPE, agent.type)).Increment(); CounterStatistic.FindOrCreate(StatisticNames.RUNTIME_THREADS_ASYNC_AGENT_TOTAL_THREADS_CREATED).Increment(); agent.Run(); } catch (Exception exc) { if (agent.State == ThreadState.Running) // If we're stopping, ignore exceptions { var log = agent.Log; switch (agent.OnFault) { case FaultBehavior.CrashOnFault: Console.WriteLine( "The {0} agent has thrown an unhandled exception, {1}. The process will be terminated.", agent.Name, exc); log.Error(ErrorCode.Runtime_Error_100023, "AsynchAgent Run method has thrown an unhandled exception. The process will be terminated.", exc); log.Fail(ErrorCode.Runtime_Error_100024, "Terminating process because of an unhandled exception caught in AsynchAgent.Run."); break; case FaultBehavior.IgnoreFault: log.Error(ErrorCode.Runtime_Error_100025, "AsynchAgent Run method has thrown an unhandled exception. The agent will exit.", exc); agent.State = ThreadState.Stopped; break; case FaultBehavior.RestartOnFault: log.Error(ErrorCode.Runtime_Error_100026, "AsynchAgent Run method has thrown an unhandled exception. The agent will be restarted.", exc); agent.State = ThreadState.Stopped; try { agent.Start(); } catch (Exception ex) { log.Error(ErrorCode.Runtime_Error_100027, "Unable to restart AsynchAgent", ex); agent.State = ThreadState.Stopped; } break; } } } finally { CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.RUNTIME_THREADS_ASYNC_AGENT_PERAGENTTYPE, agent.type)).DecrementBy(1); agent.Log.Info(ErrorCode.Runtime_Error_100328, "Stopping AsyncAgent {0} that runs on managed thread {1}", agent.Name, Thread.CurrentThread.ManagedThreadId); } }
internal LocalReminderServiceFactory() { logger = TraceLogger.GetLogger("ReminderFactory", TraceLogger.LoggerType.Runtime); }
static Message() { logger = TraceLogger.GetLogger("Message", TraceLogger.LoggerType.Runtime); }
internal LogStatistics(TimeSpan writeInterval, bool isSilo) { reportFrequency = writeInterval; logger = TraceLogger.GetLogger(isSilo ? "SiloLogStatistics" : "ClientLogStatistics", TraceLogger.LoggerType.Runtime); }
internal Silo(string name, SiloType siloType, ClusterConfiguration config, ILocalDataStore keyStore) { SystemStatus.Current = SystemStatus.Creating; CurrentSilo = this; var startTime = DateTime.UtcNow; this.siloType = siloType; Name = name; siloTerminatedEvent = new ManualResetEvent(false); OrleansConfig = config; globalConfig = config.Globals; config.OnConfigChange("Defaults", () => nodeConfig = config.GetConfigurationForNode(name)); if (!TraceLogger.IsInitialized) { TraceLogger.Initialize(nodeConfig); } config.OnConfigChange("Defaults/Tracing", () => TraceLogger.Initialize(nodeConfig, true), false); LimitManager.Initialize(nodeConfig); ActivationData.Init(config); StatisticsCollector.Initialize(nodeConfig); SerializationManager.Initialize(globalConfig.UseStandardSerializer); initTimeout = globalConfig.MaxJoinAttemptTime; if (Debugger.IsAttached) { initTimeout = StandardExtensions.Max(TimeSpan.FromMinutes(10), globalConfig.MaxJoinAttemptTime); stopTimeout = initTimeout; } IPEndPoint here = nodeConfig.Endpoint; int generation = nodeConfig.Generation; if (generation == 0) { generation = SiloAddress.AllocateNewGeneration(); nodeConfig.Generation = generation; } TraceLogger.MyIPEndPoint = here; logger = TraceLogger.GetLogger("Silo", TraceLogger.LoggerType.Runtime); logger.Info(ErrorCode.SiloInitializing, "-------------- Initializing {0} silo on {1} at {2}, gen {3} --------------", siloType, nodeConfig.DNSHostName, here, generation); logger.Info(ErrorCode.SiloInitConfig, "Starting silo {0} with runtime Version='{1}' Config= " + Environment.NewLine + "{2}", name, RuntimeVersion.Current, config.ToString(name)); if (keyStore != null) { // Re-establish reference to shared local key store in this app domain LocalDataStoreInstance.LocalDataStore = keyStore; } healthCheckParticipants = new List <IHealthCheckParticipant>(); BufferPool.InitGlobalBufferPool(globalConfig); PlacementStrategy.Initialize(globalConfig); UnobservedExceptionsHandlerClass.SetUnobservedExceptionHandler(UnobservedExceptionHandler); AppDomain.CurrentDomain.UnhandledException += (obj, ev) => DomainUnobservedExceptionHandler(obj, (Exception)ev.ExceptionObject); typeManager = new GrainTypeManager(here.Address.Equals(IPAddress.Loopback)); // Performance metrics siloStatistics = new SiloStatisticsManager(globalConfig, nodeConfig); config.OnConfigChange("Defaults/LoadShedding", () => siloStatistics.MetricsTable.NodeConfig = nodeConfig, false); // The scheduler scheduler = new OrleansTaskScheduler(globalConfig, nodeConfig); healthCheckParticipants.Add(scheduler); // Initialize the message center var mc = new MessageCenter(here, generation, globalConfig, siloStatistics.MetricsTable); if (nodeConfig.IsGatewayNode) { mc.InstallGateway(nodeConfig.ProxyGatewayEndpoint); } messageCenter = mc; // Now the router/directory service // This has to come after the message center //; note that it then gets injected back into the message center.; localGrainDirectory = new LocalGrainDirectory(this); // Now the activation directory. // This needs to know which router to use so that it can keep the global directory in synch with the local one. activationDirectory = new ActivationDirectory(); // Now the consistent ring provider RingProvider = GlobalConfig.UseVirtualBucketsConsistentRing ? (IConsistentRingProvider) new VirtualBucketsRingProvider(SiloAddress, GlobalConfig.NumVirtualBucketsConsistentRing) : new ConsistentRingProvider(SiloAddress); Action <Dispatcher> setDispatcher; catalog = new Catalog(Constants.CatalogId, SiloAddress, Name, LocalGrainDirectory, typeManager, scheduler, activationDirectory, config, out setDispatcher); var dispatcher = new Dispatcher(scheduler, messageCenter, catalog, config); setDispatcher(dispatcher); RuntimeClient.Current = new InsideRuntimeClient( dispatcher, catalog, LocalGrainDirectory, SiloAddress, config, RingProvider, typeManager); messageCenter.RerouteHandler = InsideRuntimeClient.Current.RerouteMessage; messageCenter.SniffIncomingMessage = InsideRuntimeClient.Current.SniffIncomingMessage; siloStatistics.MetricsTable.Scheduler = scheduler; siloStatistics.MetricsTable.ActivationDirectory = activationDirectory; siloStatistics.MetricsTable.ActivationCollector = catalog.ActivationCollector; siloStatistics.MetricsTable.MessageCenter = messageCenter; DeploymentLoadPublisher.CreateDeploymentLoadPublisher(this, globalConfig); PlacementDirectorsManager.CreatePlacementDirectorsManager(globalConfig); // Now the incoming message agents incomingSystemAgent = new IncomingMessageAgent(Message.Categories.System, messageCenter, activationDirectory, scheduler, dispatcher); incomingPingAgent = new IncomingMessageAgent(Message.Categories.Ping, messageCenter, activationDirectory, scheduler, dispatcher); incomingAgent = new IncomingMessageAgent(Message.Categories.Application, messageCenter, activationDirectory, scheduler, dispatcher); membershipFactory = new MembershipFactory(); reminderFactory = new LocalReminderServiceFactory(); SystemStatus.Current = SystemStatus.Created; StringValueStatistic.FindOrCreate(StatisticNames.SILO_START_TIME, () => TraceLogger.PrintDate(startTime)); // this will help troubleshoot production deployment when looking at MDS logs. TestHookup = new TestHookups(this); logger.Info(ErrorCode.SiloInitializingFinished, "-------------- Started silo {0}, ConsistentHashCode {1:X} --------------", SiloAddress.ToLongString(), SiloAddress.GetConsistentHashCode()); }