private Evaluator( RuntimeClock clock, EvaluatorRuntime evaluatorRuntime, CustomTraceListeners customTraceListeners, CustomTraceLevel customTraceLevel) { _clock = clock; SetCustomTraceListeners(customTraceListeners, customTraceLevel); SetRuntimeHandlers(evaluatorRuntime, clock); }
// set the handlers for runtimeclock manually // we only need runtimestart and runtimestop handlers now private static void SetRuntimeHandlers(EvaluatorRuntime evaluatorRuntime, RuntimeClock clock) { ISet <IObserver <RuntimeStart> > runtimeStarts = new HashSet <IObserver <RuntimeStart> > { evaluatorRuntime }; clock.InjectedRuntimeStartHandler = new InjectionFutureImpl <ISet <IObserver <RuntimeStart> > >(runtimeStarts); ISet <IObserver <RuntimeStop> > runtimeStops = new HashSet <IObserver <RuntimeStop> > { evaluatorRuntime }; clock.InjectedRuntimeStopHandler = new InjectionFutureImpl <ISet <IObserver <RuntimeStop> > >(runtimeStops); }
// set the handlers for runtimeclock manually // we only need runtimestart and runtimestop handlers now private static void SetRuntimeHanlders(EvaluatorRuntime evaluatorRuntime, RuntimeClock clock) { HashSet <IObserver <RuntimeStart> > runtimeStarts = new HashSet <IObserver <RuntimeStart> >(); runtimeStarts.Add(evaluatorRuntime); InjectionFutureImpl <ISet <IObserver <RuntimeStart> > > injectRuntimeStart = new InjectionFutureImpl <ISet <IObserver <RuntimeStart> > >(runtimeStarts); clock.InjectedRuntimeStartHandler = injectRuntimeStart; HashSet <IObserver <RuntimeStop> > runtimeStops = new HashSet <IObserver <RuntimeStop> >(); runtimeStops.Add(evaluatorRuntime); InjectionFutureImpl <ISet <IObserver <RuntimeStop> > > injectRuntimeStop = new InjectionFutureImpl <ISet <IObserver <RuntimeStop> > >(runtimeStops); clock.InjectedRuntimeStopHandler = injectRuntimeStop; }
public static void Main(string[] args) { try { Console.WriteLine("START: {0} Evaluator::InitInjector.", DateTime.Now); Stopwatch timer = new Stopwatch(); InitInjector(); SetCustomTraceListeners(); // logger is reset by this. timer.Stop(); Console.WriteLine("EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed); using (logger.LogScope("Evaluator::Main")) { if (IsDebuggingEnabled()) { AttachDebugger(); } // Register our exception handler AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; // Fetch some settings from the ConfigurationManager SetHeartbeatPeriod(); SetHeartbeatMaxRetry(); // Parse the command line // The error handler RID should now be written in the configuration file instead if (args.Count() != 1) { var e = new InvalidOperationException("must supply only the evaluator config file!"); Utilities.Diagnostics.Exceptions.Throw(e, logger); } // evaluator configuration file string evaluatorConfigurationPath = args[0]; // Parse the evaluator configuration. evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath); string rId = evaluatorConfig.ErrorHandlerRID; ContextConfiguration rootContextConfiguration = evaluatorConfig.RootContextConfiguration; Optional<TaskConfiguration> rootTaskConfig = evaluatorConfig.TaskConfiguration; Optional<ServiceConfiguration> rootServiceConfig = evaluatorConfig.RootServiceConfiguration; // remoteManager used as client-only in evaluator IRemoteManager<REEFMessage> remoteManager = injector.GetInstance<IRemoteManagerFactory>().GetInstance(new REEFMessageCodec()); IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId)); RuntimeClock clock = InstantiateClock(); logger.Log(Level.Info, "Application Id: " + evaluatorConfig.ApplicationId); EvaluatorSettings evaluatorSettings = new EvaluatorSettings( evaluatorConfig.ApplicationId, evaluatorConfig.EvaluatorId, heartbeatPeriodInMs, heartbeatMaxRetry, rootContextConfiguration, clock, remoteManager, injector); HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId); ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig); EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager); // TODO: replace with injectionFuture heartBeatManager._evaluatorRuntime = evaluatorRuntime; heartBeatManager._contextManager = contextManager; SetRuntimeHandlers(evaluatorRuntime, clock); clock.Run(); } } catch (Exception e) { Fail(e); } }
// set the handlers for runtimeclock manually // we only need runtimestart and runtimestop handlers now private static void SetRuntimeHandlers(EvaluatorRuntime evaluatorRuntime, RuntimeClock clock) { ISet<IObserver<RuntimeStart>> runtimeStarts = new HashSet<IObserver<RuntimeStart>> { evaluatorRuntime }; clock.InjectedRuntimeStartHandler = new InjectionFutureImpl<ISet<IObserver<RuntimeStart>>>(runtimeStarts); ISet<IObserver<RuntimeStop>> runtimeStops = new HashSet<IObserver<RuntimeStop>> { evaluatorRuntime }; clock.InjectedRuntimeStopHandler = new InjectionFutureImpl<ISet<IObserver<RuntimeStop>>>(runtimeStops); }
public static void Main(string[] args) { try { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.", DateTime.Now)); Stopwatch timer = new Stopwatch(); InitInjector(); SetCustomTraceListners(); // _logger is reset by this. timer.Stop(); Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed)); using (_logger.LogScope("Evaluator::Main")) { // Wait for the debugger, if enabled AttachDebuggerIfEnabled(); // Register our exception handler AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; // Fetch some settings from the ConfigurationManager SetHeartbeatPeriod(); SetHeartbeatMaxRetry(); // Parse the command line if (args.Count() < 2) { var e = new InvalidOperationException("must supply at least the rId and evaluator config file"); Utilities.Diagnostics.Exceptions.Throw(e, _logger); } // remote driver Id string rId = args[0]; // evaluator configuraiton file string evaluatorConfigurationPath = args[1]; // Parse the evaluator configuration. _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath); ContextConfiguration rootContextConfiguration = _evaluatorConfig.RootContextConfiguration; Optional<TaskConfiguration> rootTaskConfig = _evaluatorConfig.TaskConfiguration; Optional<ServiceConfiguration> rootServiceConfig = _evaluatorConfig.RootServiceConfiguration; // remoteManager used as client-only in evaluator IRemoteManager<REEFMessage> remoteManager = _injector.GetInstance<IRemoteManagerFactory>().GetInstance(new REEFMessageCodec()); IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId)); RuntimeClock clock = InstantiateClock(); _logger.Log(Level.Info, "Application Id: " + _evaluatorConfig.ApplicationId); EvaluatorSettings evaluatorSettings = new EvaluatorSettings( _evaluatorConfig.ApplicationId, _evaluatorConfig.EvaluatorId, _heartbeatPeriodInMs, _heartbeatMaxRetry, rootContextConfiguration, clock, remoteManager, _injector); HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId); ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig); EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager); // TODO: replace with injectionFuture heartBeatManager._evaluatorRuntime = evaluatorRuntime; heartBeatManager._contextManager = contextManager; SetRuntimeHandlers(evaluatorRuntime, clock); Task evaluatorTask = Task.Run(new Action(clock.Run)); evaluatorTask.Wait(); } } catch (Exception e) { Fail(e); } }
public static void Main(string[] args) { try { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.", DateTime.Now)); Stopwatch timer = new Stopwatch(); InitInjector(); SetCustomTraceListners(); // _logger is reset by this. timer.Stop(); Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed)); using (_logger.LogScope("Evaluator::Main")) { // Wait for the debugger, if enabled AttachDebuggerIfEnabled(); // Register our exception handler AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; // Fetch some settings from the ConfigurationManager SetHeartbeatPeriod(); SetHeartbeatMaxRetry(); // Parse the command line if (args.Count() < 2) { var e = new InvalidOperationException("must supply at least the rId and evaluator config file"); Utilities.Diagnostics.Exceptions.Throw(e, _logger); } // remote driver Id string rId = args[0]; // evaluator configuraiton file string evaluatorConfigurationPath = args[1]; // Parse the evaluator configuration. _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath); ContextConfiguration rootContextConfiguration = _evaluatorConfig.RootContextConfiguration; Optional <TaskConfiguration> rootTaskConfig = _evaluatorConfig.TaskConfiguration; Optional <ServiceConfiguration> rootServiceConfig = _evaluatorConfig.RootServiceConfiguration; // remoteManager used as client-only in evaluator IRemoteManager <REEFMessage> remoteManager = _injector.GetInstance <IRemoteManagerFactory>().GetInstance(new REEFMessageCodec()); IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId)); RuntimeClock clock = InstantiateClock(); _logger.Log(Level.Info, "Application Id: " + _evaluatorConfig.ApplicationId); EvaluatorSettings evaluatorSettings = new EvaluatorSettings( _evaluatorConfig.ApplicationId, _evaluatorConfig.EvaluatorId, _heartbeatPeriodInMs, _heartbeatMaxRetry, rootContextConfiguration, clock, remoteManager, _injector); HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId); ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig); EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager); // TODO: replace with injectionFuture heartBeatManager._evaluatorRuntime = evaluatorRuntime; heartBeatManager._contextManager = contextManager; SetRuntimeHandlers(evaluatorRuntime, clock); Task evaluatorTask = Task.Run(new Action(clock.Run)); evaluatorTask.Wait(); } } catch (Exception e) { Fail(e); } }
public static void Main(string[] args) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.", DateTime.Now)); Stopwatch timer = new Stopwatch(); InitInjector(); SetCustomTraceListners(); timer.Stop(); Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed)); RuntimeClock clock; using (_logger.LogScope("Evaluator::Main")) { string debugEnabledString = Environment.GetEnvironmentVariable("Org.Apache.Reef.EvaluatorDebug"); if (!string.IsNullOrWhiteSpace(debugEnabledString) && debugEnabledString.Equals("enabled", StringComparison.OrdinalIgnoreCase)) { while (true) { if (Debugger.IsAttached) { break; } else { _logger.Log(Level.Info, "Evaluator in debug mode, waiting for debugger to be attached..."); Thread.Sleep(2000); } } } AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; string heartbeatPeriodFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatPeriodInMs"]; int heartbeatPeriod = 0; if (!string.IsNullOrWhiteSpace(heartbeatPeriodFromConfig) && int.TryParse(heartbeatPeriodFromConfig, out heartbeatPeriod)) { _heartbeatPeriodInMs = heartbeatPeriod; } _logger.Log(Level.Verbose, "Evaluator heartbeat period set to be " + _heartbeatPeriodInMs + " milliSeconds."); int maxHeartbeatRetry = 0; string heartbeatMaxRetryFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatRetryMaxTimes"]; if (!string.IsNullOrWhiteSpace(heartbeatMaxRetryFromConfig) && int.TryParse(heartbeatMaxRetryFromConfig, out maxHeartbeatRetry)) { _heartbeatMaxRetry = maxHeartbeatRetry; } _logger.Log(Level.Verbose, "Evaluator heatrbeat max retry set to be " + _heartbeatMaxRetry + " times."); if (args.Count() < 2) { var e = new InvalidOperationException("must supply at least the rId and evaluator config file"); Exceptions.Throw(e, _logger); } // remote driver Id string rId = args[0]; // evaluator configuraiton file string evaluatorConfigurationPath = args[1]; ICodec <REEFMessage> reefMessageCodec = new REEFMessageCodec(); _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath); string rootContextConfigString = _evaluatorConfig.RootContextConfiguration; if (string.IsNullOrWhiteSpace(rootContextConfigString)) { Exceptions.Throw(new ArgumentException("empty or null rootContextConfigString"), _logger); } ContextConfiguration rootContextConfiguration = new ContextConfiguration(rootContextConfigString); string taskConfig = _evaluatorConfig.TaskConfiguration; Optional <TaskConfiguration> rootTaskConfig = string.IsNullOrEmpty(taskConfig) ? Optional <TaskConfiguration> .Empty() : Optional <TaskConfiguration> .Of( new TaskConfiguration(taskConfig)); string rootServiceConfigString = _evaluatorConfig.RootServiceConfiguration; Optional <ServiceConfiguration> rootServiceConfig = string.IsNullOrEmpty(rootServiceConfigString) ? Optional <ServiceConfiguration> .Empty() : Optional <ServiceConfiguration> .Of( new ServiceConfiguration( rootServiceConfigString)); // remoteManager used as client-only in evaluator IRemoteManager <REEFMessage> remoteManager = new DefaultRemoteManager <REEFMessage>(reefMessageCodec); IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId)); ConfigurationModule module = new ConfigurationModuleBuilder().Build(); IConfiguration clockConfiguraiton = module.Build(); clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>(); _logger.Log(Level.Info, "Application Id: " + _evaluatorConfig.ApplicationId); EvaluatorSettings evaluatorSettings = new EvaluatorSettings( _evaluatorConfig.ApplicationId, _evaluatorConfig.EvaluatorId, _heartbeatPeriodInMs, _heartbeatMaxRetry, rootContextConfiguration, clock, remoteManager, _injector); HeartBeatManager heartBeatManager = new HeartBeatManager(evaluatorSettings, remoteId); ContextManager contextManager = new ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig); EvaluatorRuntime evaluatorRuntime = new EvaluatorRuntime(contextManager, heartBeatManager); // TODO: repalce with injectionFuture heartBeatManager._evaluatorRuntime = evaluatorRuntime; heartBeatManager._contextManager = contextManager; SetRuntimeHanlders(evaluatorRuntime, clock); } Task evaluatorTask = Task.Run(new Action(clock.Run)); evaluatorTask.Wait(); }