public void OnNext(IActiveContext activeContext) { IConfiguration taskConfiguration; if (_groupCommDriver.IsMasterTaskContext(activeContext)) { // Configure Master Task taskConfiguration = TaskConfiguration.ConfigurationModule .Set(TaskConfiguration.Identifier, Constants.MasterTaskId) .Set(TaskConfiguration.Task, GenericType <KMeansMasterTask> .Class) .Build(); _commGroup.AddTask(Constants.MasterTaskId); } else { string slaveTaskId = Constants.SlaveTaskIdPrefix + activeContext.Id; // Configure Slave Task taskConfiguration = TaskConfiguration.ConfigurationModule .Set(TaskConfiguration.Identifier, Constants.SlaveTaskIdPrefix + activeContext.Id) .Set(TaskConfiguration.Task, GenericType <KMeansSlaveTask> .Class) .Build(); _commGroup.AddTask(slaveTaskId); } _groupCommTaskStarter.QueueTask(taskConfiguration, activeContext); }
/// <summary> /// Specifies the Map or Update task to run on the active context /// </summary> /// <param name="activeContext"></param> public void OnNext(IActiveContext activeContext) { Logger.Log(Level.Verbose, string.Format("Received Active Context {0}", activeContext.Id)); if (_serviceAndContextConfigurationProvider.IsMasterEvaluatorId(activeContext.EvaluatorId)) { Logger.Log(Level.Verbose, "Submitting master task"); _commGroup.AddTask(IMRUConstants.UpdateTaskName); _groupCommTaskStarter.QueueTask(GetUpdateTaskConfiguration(), activeContext); RequestMapEvaluators(_totalMappers); } else { Logger.Log(Level.Verbose, "Submitting map task"); _serviceAndContextConfigurationProvider.RecordActiveContextPerEvaluatorId(activeContext.EvaluatorId); string taskId = GetTaskIdByEvaluatorId(activeContext.EvaluatorId); _commGroup.AddTask(taskId); _groupCommTaskStarter.QueueTask(GetMapTaskConfiguration(activeContext, taskId), activeContext); Interlocked.Increment(ref _numberOfReadyTasks); Logger.Log(Level.Verbose, string.Format("{0} Tasks are ready for submission", _numberOfReadyTasks)); } }
/// <summary> /// Specfies the Map or Update task to run on the active context /// </summary> /// <param name="activeContext"></param> public void OnNext(IActiveContext activeContext) { Logger.Log(Level.Verbose, string.Format("Received Active Context {0}", activeContext.Id)); if (_groupCommDriver.IsMasterTaskContext(activeContext)) { _reachedUpdateTaskActiveContext = true; RequestMapEvaluators(_dataSet.Count); var partialTaskConf = TangFactory.GetTang() .NewConfigurationBuilder(new[] { TaskConfiguration.ConfigurationModule .Set(TaskConfiguration.Identifier, IMRUConstants.UpdateTaskName) .Set(TaskConfiguration.Task, GenericType <UpdateTaskHost <TMapInput, TMapOutput, TResult> > .Class) .Build(), _configurationManager.UpdateFunctionConfiguration, _configurationManager.ResultHandlerConfiguration }) .BindNamedParameter(typeof(InvokeGC), _invokeGC.ToString()) .Build(); try { TangFactory.GetTang() .NewInjector(partialTaskConf, _configurationManager.UpdateFunctionCodecsConfiguration) .GetInstance <IIMRUResultHandler <TResult> >(); } catch (InjectionException) { partialTaskConf = TangFactory.GetTang().NewConfigurationBuilder(partialTaskConf) .BindImplementation(GenericType <IIMRUResultHandler <TResult> > .Class, GenericType <DefaultResultHandler <TResult> > .Class) .Build(); Logger.Log(Level.Warning, "User has not given any way to handle IMRU result, defaulting to ignoring it"); } _commGroup.AddTask(IMRUConstants.UpdateTaskName); _groupCommTaskStarter.QueueTask(partialTaskConf, activeContext); } else { string taskId; if (!_taskIdStack.TryPop(out taskId)) { Logger.Log(Level.Warning, "No task Ids exist for the active context {0}. Disposing the context.", activeContext.Id); activeContext.Dispose(); return; } IConfiguration mapSpecificConfig; if (!_perMapperConfiguration.TryPop(out mapSpecificConfig)) { Logger.Log(Level.Warning, "No per map configuration exist for the active context {0}. Disposing the context.", activeContext.Id); activeContext.Dispose(); return; } var partialTaskConf = TangFactory.GetTang() .NewConfigurationBuilder(new[] { TaskConfiguration.ConfigurationModule .Set(TaskConfiguration.Identifier, taskId) .Set(TaskConfiguration.Task, GenericType <MapTaskHost <TMapInput, TMapOutput> > .Class) .Build(), _configurationManager.MapFunctionConfiguration, mapSpecificConfig }) .BindNamedParameter(typeof(InvokeGC), _invokeGC.ToString()) .Build(); _commGroup.AddTask(taskId); _groupCommTaskStarter.QueueTask(partialTaskConf, activeContext); } }