public TaskStatus(HeartBeatManager heartBeatManager, string contextId, string taskId, Optional <ISet <ITaskMessageSource> > evaluatorMessageSources) { _contextId = contextId; _taskId = taskId; _heartBeatManager = heartBeatManager; _taskLifeCycle = new TaskLifeCycle(); _evaluatorMessageSources = evaluatorMessageSources; State = TaskState.Init; }
public TaskRuntime(IInjector taskInjector, string contextId, string taskId, HeartBeatManager heartBeatManager, string memento = null) { _injector = taskInjector; _heartBeatManager = heartBeatManager; Optional <ISet <ITaskMessageSource> > messageSources = Optional <ISet <ITaskMessageSource> > .Empty(); try { _task = _injector.GetInstance <ITask>(); } catch (Exception e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.CaughtAndThrow(new InvalidOperationException("Unable to inject task.", e), Level.Error, "Unable to inject task.", LOGGER); } try { ITaskMessageSource taskMessageSource = _injector.GetInstance <ITaskMessageSource>(); messageSources = Optional <ISet <ITaskMessageSource> > .Of(new HashSet <ITaskMessageSource>() { taskMessageSource }); } catch (Exception e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Warning, "Cannot inject task message source with error: " + e.StackTrace, LOGGER); // do not rethrow since this is benign } try { _nameClient = _injector.GetInstance <INameClient>(); _heartBeatManager.EvaluatorSettings.NameClient = _nameClient; } catch (InjectionException) { LOGGER.Log(Level.Warning, "Cannot inject name client from task configuration."); // do not rethrow since user is not required to provide name client } LOGGER.Log(Level.Info, "task message source injected"); _currentStatus = new TaskStatus(_heartBeatManager, contextId, taskId, messageSources); _memento = memento == null ? Optional <byte[]> .Empty() : Optional <byte[]> .Of(ByteUtilities.StringToByteArrays(memento)); }
public EvaluatorRuntime( ContextManager contextManager, HeartBeatManager heartBeatManager) { using (LOGGER.LogFunction("EvaluatorRuntime::EvaluatorRuntime")) { _clock = heartBeatManager.EvaluatorSettings.RuntimeClock; _heartBeatManager = heartBeatManager; _contextManager = contextManager; _evaluatorId = heartBeatManager.EvaluatorSettings.EvalutorId; _remoteManager = heartBeatManager.EvaluatorSettings.RemoteManager; ReefMessageProtoObserver driverObserver = new ReefMessageProtoObserver(); // subscribe to driver proto message driverObserver.Subscribe(o => OnNext(o.Message)); // register the driver observer _evaluatorControlChannel = _remoteManager.RegisterObserver(driverObserver); // start the hearbeat _clock.ScheduleAlarm(0, heartBeatManager); } }