예제 #1
0
        public void OnNext(ICompletedTask value)
        {
            IActiveContext activeContext = value.ActiveContext;

            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received CompletedTask: {0} :: CLOSING context: {1}", value.Id, activeContext.Id));
            activeContext.Dispose();
        }
예제 #2
0
        private void SubmitNextTask(IActiveContext activeContext)
        {
            Logger.Log(Level.Info, "SubmitNextTask with evaluator id: " + activeContext.EvaluatorId);
            IConfiguration finalConfiguration = GetNextTaskConfiguration();

            if (null != finalConfiguration)
            {
                Logger.Log(Level.Info, "Executing task id " + _taskContext.CurrentTaskId());
                Logger.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submitting Task {0}", _taskContext.CurrentTaskId()));

                activeContext.SubmitTask(finalConfiguration);
            }
            else
            {
                if (_taskContext.TaskCompleted == _taskContext.TotalTasks)
                {
                    Logger.Log(Level.Info, "All tasks submitted and completed, active context remains idle");
                    _driveStatus = DriverStatus.Idle;
                    if (!_isRetain)
                    {
                        activeContext.Dispose();
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// IActiveContext handler. It will take the following actions based on the system state:
        /// Case WaitingForEvaluator:
        ///    Adds Active Context to Active Context Manager
        /// Case Fail:
        ///    Closes the ActiveContext
        /// Other cases - not expected
        /// </summary>
        /// <param name="activeContext"></param>
        public void OnNext(IActiveContext activeContext)
        {
            Logger.Log(Level.Info, "Received Active Context {0}, systemState {1}.", activeContext.Id, _systemState.CurrentState);
            lock (_lock)
            {
                using (Logger.LogFunction("IMRUDriver::IActiveContext"))
                {
                    switch (_systemState.CurrentState)
                    {
                    case SystemState.WaitingForEvaluator:
                        _contextManager.Add(activeContext);
                        break;

                    case SystemState.Fail:
                        Logger.Log(Level.Info,
                                   "Received IActiveContext event, but system is in FAIL state. Closing the context.");
                        activeContext.Dispose();
                        break;

                    default:
                        UnexpectedState(activeContext.Id, "IActiveContext");
                        break;
                    }
                }
            }
        }
 public void OnNext(IActiveContext value)
 {
     if (value.Id.Equals(FailEvaluatorContextId))
     {
         // Close context and trigger failure immediately.
         value.Dispose();
     }
     else
     {
         if (value.Id.Equals(ContextId0))
         {
             // Stack Context with ContextId1 on top of Context with ContextId0.
             value.SubmitContext(GetContextStopExceptionContextConfiguration(ContextId1));
         }
         else
         {
             // Verify the stacked Context and close it.
             Assert.Equal(ContextId1, value.Id);
             value.Dispose();
         }
     }
 }
예제 #5
0
파일: IMRUDriver.cs 프로젝트: dkm2110/veyor
        /// <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);
            }
        }