public void HttpEventHandlersTest() { ConfigurationModule module = new ConfigurationModuleBuilder() .BindSetEntry<HttpEventHandlers, HttpServerReefEventHandler, IHttpHandler>(GenericType<HttpEventHandlers>.Class, GenericType<HttpServerReefEventHandler>.Class) .BindSetEntry<HttpEventHandlers, HttpServerNrtEventHandler, IHttpHandler>(GenericType<HttpEventHandlers>.Class, GenericType<HttpServerNrtEventHandler>.Class) .Build(); IConfiguration c = module.Build(); var service = TangFactory.GetTang().NewInjector(c).GetInstance<HttpServer>(); Assert.NotNull(service); var j = TangFactory.GetTang().NewInjector(c).GetInstance<HttpRunTimeStartHandler>(); Assert.NotNull(j); }
public void TestEvaluatorRuntime() { ConfigurationModule module = new ConfigurationModuleBuilder() .BindSetEntry <RuntimeStartHandler, EvaluatorRuntime, IObserver <RuntimeStart> >(GenericType <RuntimeStartHandler> .Class, GenericType <EvaluatorRuntime> .Class) .Build(); IConfiguration clockConfiguraiton = module.Build(); RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>(); var r = clock.ClockRuntimeStartHandler.Get(); Assert.AreEqual(r.Count, 1); foreach (var e in r) { Assert.IsTrue(e is EvaluatorRuntime); } }
public void HttpEventHandlersTest() { ConfigurationModule module = new ConfigurationModuleBuilder() .BindSetEntry <HttpEventHandlers, HttpServerReefEventHandler, IHttpHandler>(GenericType <HttpEventHandlers> .Class, GenericType <HttpServerReefEventHandler> .Class) .BindSetEntry <HttpEventHandlers, HttpServerNrtEventHandler, IHttpHandler>(GenericType <HttpEventHandlers> .Class, GenericType <HttpServerNrtEventHandler> .Class) .Build(); IConfiguration c = module.Build(); var service = TangFactory.GetTang().NewInjector(c).GetInstance <HttpServer>(); Assert.NotNull(service); var j = TangFactory.GetTang().NewInjector(c).GetInstance <HttpRunTimeStartHandler>(); Assert.NotNull(j); }
public void RuntimeStartHandlerTest() { ConfigurationModule module = new ConfigurationModuleBuilder() .BindSetEntry<RuntimeStartHandler, HttpRunTimeStartHandler, IObserver<RuntimeStart>>( GenericType<RuntimeStartHandler>.Class, GenericType<HttpRunTimeStartHandler>.Class) .Build(); IConfiguration clockConfiguraiton = module.Build(); RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>(); var rh = clock.ClockRuntimeStartHandler.Get(); Assert.Equal(rh.Count, 1); foreach (var e in rh) { Assert.True(e is HttpRunTimeStartHandler); HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e; var s = r.Server; Assert.Equal(s.JettyHandler.HttpeventHanlders.Count, 0); // no handlers are bound } }
public void RuntimeStartHandlerTest() { ConfigurationModule module = new ConfigurationModuleBuilder() .BindSetEntry <RuntimeStartHandler, HttpRunTimeStartHandler, IObserver <RuntimeStart> >( GenericType <RuntimeStartHandler> .Class, GenericType <HttpRunTimeStartHandler> .Class) .Build(); IConfiguration clockConfiguraiton = module.Build(); RuntimeClock clock = TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance <RuntimeClock>(); var rh = clock.ClockRuntimeStartHandler.Get(); Assert.Equal(rh.Count, 1); foreach (var e in rh) { Assert.True(e is HttpRunTimeStartHandler); HttpRunTimeStartHandler r = (HttpRunTimeStartHandler)e; var s = r.Server; Assert.Equal(s.JettyHandler.HttpeventHanlders.Count, 0); // no handlers are bound } }
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(); }