Exemplo n.º 1
0
        private void OnTaskCompletedMasterCommand(TaskCompletedMasterCommand message)
        {
            Trace.WriteLine("ENTER: Task '{0}' completed by processor '{1}' ...".FormatInvariant(message.TaskId, message.TaskProcessorId));

            if (!message.IsTaskProcessorStopping)
            {
                this.AssignTasksToProcessor(message.TaskProcessorId);
            }

            Trace.WriteLine("EXIT: Task '{0}' completed by processor '{1}'.".FormatInvariant(message.TaskId, message.TaskProcessorId));
        }
Exemplo n.º 2
0
        public void AddTaskCompletedMasterCommand()
        {
            Guid taskId = Guid.NewGuid();

            Guid taskProcessorId = Guid.NewGuid();

            DateTime timestamp = DateTime.UtcNow;

            this.Sender.NotifyTaskCompleted(taskId, timestamp, taskProcessorId, true, TimeSpan.FromMinutes(1));

            Thread.Sleep(this.Timeout);

            TaskCompletedMasterCommand command = this.MasterCommands.OfType <TaskCompletedMasterCommand>().First(c => c.TaskId == taskId);

            Assert.AreEqual(taskProcessorId, command.TaskProcessorId);

            this.AssertEquals(timestamp, command.TimestampUtc);

            Assert.AreEqual(TimeSpan.FromMinutes(1), command.TotalCpuTime);

            Assert.IsTrue(command.IsTaskProcessorStopping);
        }