Example #1
0
 public void OnNext(IActiveContext value)
 {
     value.SubmitTask(TaskConfiguration.ConfigurationModule
                      .Set(TaskConfiguration.Identifier, TaskId)
                      .Set(TaskConfiguration.Task, GenericType <SleepTask> .Class)
                      .Build());
 }
        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();
                    }
                }
            }
        }
Example #3
0
 public void OnNext(IActiveContext value)
 {
     lock (_lock)
     {
         value.SubmitTask(GetTaskConfigurationForCloseTask(TaskId + _taskNumber));
         _taskContextMapping.Add(TaskId + _taskNumber, value.Id);
         _taskNumber++;
     }
 }
Example #4
0
        private void StartTask(
            string taskId,
            IConfiguration userPartialTaskConf,
            IActiveContext activeContext)
        {
            IConfiguration groupCommTaskConfiguration = _groupCommDriver.GetGroupCommTaskConfiguration(taskId);
            IConfiguration mergedTaskConf             = Configurations.Merge(userPartialTaskConf, groupCommTaskConfiguration);

            activeContext.SubmitTask(mergedTaskConf);
        }
Example #5
0
 public void OnNext(IActiveContext value)
 {
     Logger.Log(Level.Info, "ActiveContext: " + value.Id);
     value.SubmitTask(TaskConfiguration.ConfigurationModule
                      .Set(TaskConfiguration.Identifier, TaskId + Interlocked.Increment(ref _taskNumber))
                      .Set(TaskConfiguration.Task, GenericType <FailEvaluatorTask> .Class)
                      .Set(TaskConfiguration.OnMessage, GenericType <FailEvaluatorTask> .Class)
                      .Set(TaskConfiguration.OnClose, GenericType <FailEvaluatorTask> .Class)
                      .Build());
 }
Example #6
0
        public void OnNext(IActiveContext activeContext)
        {
            Logger.Log(Level.Info, "Received IActiveContext");

            const string taskId            = "TaskID";
            var          taskConfiguration = TaskConfiguration.ConfigurationModule
                                             .Set(TaskConfiguration.Identifier, taskId)
                                             .Set(TaskConfiguration.Task, GenericType <MetricsTask> .Class)
                                             .Build();

            activeContext.SubmitTask(taskConfiguration);
        }
Example #7
0
            public void OnNext(IActiveContext value)
            {
                Logger.Log(Level.Info, "ContextId: " + value.Id);
                if (value.Id != ContextId)
                {
                    throw new Exception("Unexpected ContextId: " + value.Id);
                }

                value.SubmitTask(
                    TaskConfiguration.ConfigurationModule.Set(TaskConfiguration.Identifier, "helloTaskId")
                    .Set(TaskConfiguration.Task, GenericType <HelloTask> .Class)
                    .Build());
            }
Example #8
0
        public void OnNext(IActiveContext activeContext)
        {
            const string taskId = "TaskID";

            Logger.Log(Level.Info, SendingMessageToContextLog);
            activeContext.SendMessage(ByteUtilities.StringToByteArrays(Message));

            var taskConfiguration = TaskConfiguration.ConfigurationModule
                                    .Set(TaskConfiguration.Identifier, taskId)
                                    .Set(TaskConfiguration.Task, GenericType <MessageTask> .Class)
                                    .Set(TaskConfiguration.OnMessage, GenericType <MessageTask> .Class)
                                    .Set(TaskConfiguration.OnSendMessage, GenericType <MessageTask> .Class)
                                    .Build();

            activeContext.SubmitTask(taskConfiguration);
        }
Example #9
0
 public void OnNext(IActiveContext context)
 {
     CheckMsgOrder(context);
     try
     {
         context.SubmitTask(TaskConfiguration.ConfigurationModule
                            .Set(TaskConfiguration.Identifier, "FailTask_" + context.Id)
                            .Set(TaskConfiguration.Task, GenericType <NoopTask> .Class)
                            .Set(TaskConfiguration.OnMessage, GenericType <NoopTask> .Class)
                            .Set(TaskConfiguration.OnSuspend, GenericType <NoopTask> .Class)
                            .Set(TaskConfiguration.OnClose, GenericType <NoopTask> .Class)
                            .Set(TaskConfiguration.OnTaskStop, GenericType <NoopTask> .Class)
                            .Set(TaskConfiguration.OnSendMessage, GenericType <NoopTask> .Class)
                            .Build());
     }
     catch (BindException ex)
     {
         Log.Log(Level.Warning, "Task configuration error", ex);
         throw new IllegalStateException("task configuration error", ex);
     }
 }
            public void OnNext(IActiveContext value)
            {
                Logger.Log(Level.Info, "IActiveContext: " + value.Id);

                if (_first)
                {
                    Assert.Equal(value.Id, ContextId1);
                    _first = false;
                    value.SubmitContext(
                        ContextConfiguration.ConfigurationModule
                        .Set(ContextConfiguration.Identifier, ContextId2)
                        .Set(ContextConfiguration.OnContextStart, GenericType <ContextStartHandler> .Class)
                        .Build());
                }
                else
                {
                    Assert.Equal(value.Id, ContextId2);
                    var c = TaskConfiguration.ConfigurationModule
                            .Set(TaskConfiguration.Identifier, TaskId)
                            .Set(TaskConfiguration.Task, GenericType <TestTask> .Class)
                            .Build();
                    value.SubmitTask(c);
                }
            }
Example #11
0
            public void OnNext(IActiveContext value)
            {
                Logger.Log(Level.Verbose, "ContextId: " + value.Id);
                switch (value.Id)
                {
                case ContextOneId:
                    var contextConfig =
                        Common.Context.ContextConfiguration.ConfigurationModule.Set(
                            Common.Context.ContextConfiguration.Identifier, ContextTwoId)
                        .Build();
                    var stackingContextConfig =
                        TangFactory.GetTang()
                        .NewConfigurationBuilder()
                        .BindImplementation(GenericType <IInjectableInterface> .Class,
                                            GenericType <InjectableInterfaceImpl> .Class)
                        .Build();

                    Assert.False(value.ParentId.IsPresent());

                    value.SubmitContext(Configurations.Merge(stackingContextConfig, contextConfig));
                    break;

                case ContextTwoId:
                    Assert.True(value.ParentId.IsPresent());
                    Assert.Equal(value.ParentId.Value, ContextOneId);

                    value.SubmitTask(
                        TaskConfiguration.ConfigurationModule.Set(TaskConfiguration.Identifier, "contextStackTestTask")
                        .Set(TaskConfiguration.Task, GenericType <TestContextStackTask> .Class)
                        .Build());
                    break;

                default:
                    throw new Exception("Unexpected ContextId: " + value.Id);
                }
            }
Example #12
0
 public void OnNext(IActiveContext value)
 {
     // Submit the Task on the first time receiving an active context.
     value.SubmitTask(GetTaskConfiguration());
 }
Example #13
0
 public void OnNext(IActiveContext value)
 {
     value.SubmitTask(_taskConfiguration);
 }
Example #14
0
 public void OnNext(IActiveContext value)
 {
     value.SubmitTask(GetTaskConfigurationForCloseTask(TaskId + _taskNumber));
 }
Example #15
0
 private void StartTask(
     string taskId,
     IConfiguration userPartialTaskConf,
     IActiveContext activeContext)
 {
     IConfiguration groupCommTaskConfiguration = _groupCommDriver.GetGroupCommTaskConfiguration(taskId);
     IConfiguration mergedTaskConf = Configurations.Merge(userPartialTaskConf, groupCommTaskConfiguration);
     activeContext.SubmitTask(mergedTaskConf);
 }