private void Ready()
        {
            ColorConsole.WriteLineGreen("Commander's current state is Ready.");

            Receive <ProcessJobMessage>(job =>
            {
                ColorConsole.WriteLineWhite($"Commander has received Task {job.ID}.{job.Description} for processing.");
                _currentJob = job;

                // ask the coordinator for job
                _coordinator.Tell(new CanAcceptJobMessage(job.Description, job.ID));

                // move to next state
                BecomeAsking();
            });

            Receive <JobCompletedMessage>(job =>
            {
                // send response to parent
                _currentJob.Client.Tell(job);

                _logger.Debug($"Task {job.ID} is completed by commander and {Sender.Path.Name}.");
            });

            Receive <JobFailedMessage>(job =>
            {
                // send response to parent
                _currentJob.Client.Tell(job);

                _logger.Debug("Commander has received JobFailedMessage from {0} for Task ID: {1}",
                              Sender.Path.Name, job.ID);

                ColorConsole.WriteLineGreen($"Task {job.ID} is failed.");
            });
        }
        protected override void PreRestart(Exception reason, object message)
        {
            ColorConsole.WriteLineWhite("Commander's PreRestart called because: {0} ", reason.Message);

            //kill off the old coordinator so we can recreate it from scratch
            ColorConsole.WriteLineWhite("kill off the old coordinator so we can recreate it from scratch");
            _coordinator.Tell(PoisonPill.Instance);

            base.PreRestart(reason, message);
        }
Beispiel #3
0
        private void InitializeJobs(string fileName)
        {
            ParseTxtFile(fileName);
            ColorConsole.WriteLineCyan("Initializing Job Pool...");
            ColorConsole.WriteLineCyan("-----------------------------------------");
            foreach (var job in _jobsToProcessed)
            {
                ColorConsole.WriteLineWhite("Task {0}. {1}", job.ID, job.Description);
            }

            ColorConsole.WriteLineCyan("-----------------------------------------");
            ColorConsole.WriteLineWhite("Total tasks to be processed are : {0}", _jobsToProcessed.Count);
            ColorConsole.WriteLineCyan("=========================================");
        }
        private static void Main(string[] args)
        {
            ColorConsole.WriteLineWhite("Creating Batch processor system at node localhost:8091");
            TaskExecuterActorSystem = ActorSystem.Create("batchprocessor");

            IActorRef commanderActor = TaskExecuterActorSystem.ActorOf(Props.Create <CommanderActor>(),
                                                                       ActorPaths.CommanderActor.Name);

            IActorRef jobPoolControllerActor = TaskExecuterActorSystem.ActorOf(Props.Create <JobPoolControllerActor>(commanderActor),
                                                                               ActorPaths.JobPoolControllerActor.Name);

            jobPoolControllerActor.Tell(new ProcessFileMessage("JobPool.txt"));

            TaskExecuterActorSystem.WhenTerminated.Wait();
        }
Beispiel #5
0
        private void PrintSummary()
        {
            ColorConsole.WriteLineWhite("=======================================================================================================");
            ColorConsole.WriteLineWhite("                                         Job Summary                                                   ");
            ColorConsole.WriteLineWhite("=======================================================================================================");

            ColorConsole.WriteLineWhite(" ID       Task Description         Node             Status    Start Time     End Time      Duration");
            ColorConsole.WriteLineWhite("-------------------------------------------------------------------------------------------------------");
            foreach (var task in _taskList.Values)
            {
                TimeSpan taskDuration = TimeSpan.FromMilliseconds(task.Duration);
                ColorConsole.WriteLineYellow($"Task {task.ID} | {task.Description} | {task.MachineNode} | {task.Status.ToString()} | {task.StartTime.ToString("hh:mm:ss tt")} | {task.EndTime.ToString("hh:mm:ss tt")} | {taskDuration.ToString(@"hh\:mm\:ss\:fff")}");
            }

            ColorConsole.WriteLineWhite("========================================================================================================");
        }
Beispiel #6
0
        private void PrintFailedJobsSummary(List <Job> filedJobs)
        {
            if (filedJobs.Count() > 0)
            {
                ColorConsole.WriteLineWhite("============================================================================");
                ColorConsole.WriteLineWhite("           Failed Job Summary                                               ");
                ColorConsole.WriteLineWhite("============================================================================");

                ColorConsole.WriteLineWhite(" ID       Task Description         Status          Reason                   ");
                ColorConsole.WriteLineWhite("----------------------------------------------------------------------------");
                foreach (var task in filedJobs)
                {
                    ColorConsole.WriteLineYellow($"Task {task.ID} | {task.Description} | {task.Status.ToString()} | {task.Status.GetStringValue()}");
                }

                ColorConsole.WriteLineWhite("============================================================================");
            }
        }
Beispiel #7
0
 protected override void PreRestart(Exception reason, object message)
 {
     _logger.Debug("Cordinator {0}'s PreRestart called because: {1} ", Self.Path.Name, reason.Message);
     ColorConsole.WriteLineWhite("Cordinator{0}'s PreRestart called because: {1} ", Self.Path.Name, reason.Message);
     base.PreRestart(reason, message);
 }
 protected override void PreRestart(Exception reason, object message)
 {
     ColorConsole.WriteLineWhite("WorkerActor for Coordinator {0} called PreReStart because: {1}", Context.Parent.Path.Name, reason.Message);
     _logger.Info("Restarting Task ID: {0} of Coordinator {0} because: {1}", _myJob.ID, Context.Parent.Path.Name, reason.Message);
     Self.Tell(_myJob);
 }
        protected override void PostRestart(Exception reason)
        {
            ColorConsole.WriteLineWhite(string.Concat("PlaybackStatisticsActor PostRestart because: ", reason));

            base.PostRestart(reason);
        }
        protected override void PreRestart(Exception reason, object message)
        {
            ColorConsole.WriteLineWhite(string.Concat("PlaybackStatisticsActor PreRestart because: ", reason));

            base.PreRestart(reason, message);
        }
 protected override void PostStop()
 {
     ColorConsole.WriteLineWhite("PlaybackStatisticsActor PostStop");
 }
 protected override void PreStart()
 {
     ColorConsole.WriteLineWhite("PlaybackStatisticsActor PreStart");
 }
Beispiel #13
0
 protected override void PreRestart(Exception reason, object message)
 {
     ColorConsole.WriteLineWhite("PlaybackStatisticsActor PreRestart because: " + reason);
 }
 protected override void PostRestart(Exception reason)
 {
     ColorConsole.WriteLineWhite("WorkerActor for Coordinator {0} called PostRestart because: {1}", Context.Parent.Path.Name, reason.Message);
     base.PostRestart(reason);
 }
 protected override void PreRestart(Exception reason, object message)
 {
     ColorConsole.WriteLineWhite("WorkerActor for Coordinator {0} called PreReStart because: {1}", Context.Parent.Path.Name, reason.Message);
     Self.Tell(_myJob);
     base.PreRestart(reason, message);
 }
 protected override void PostRestart(Exception reason)
 {
     ColorConsole.WriteLineWhite($"PlaybackStatisticsActor PostRestart because: {reason.Message}");
     base.PostRestart(reason);
 }