public WorkerCoordinator(Job job, IActorRef jobWorker, IActorRef workerTracker)
 {
     Job = job;
     WorkerTracker = workerTracker;
     JobWorker = jobWorker;
     Stats = new JobStats(Job);
     Become(ReadyToStart);
 }
예제 #2
0
        public JobWorker(Job job, IActorRef jobTrackingMaster)
        {
            _logger = Context.GetLogger();
            Job = job;
            RunningStatus = new JobStatusUpdate(Job);
            TotalStats = new JobStats(Job);
            JobTrackingMaster = jobTrackingMaster;

            // Make the JobTrackingMaster a default subscriber so that it receives all updates.
            Subscribers.Add(JobTrackingMaster);

            BecomeReady();
        }
        private void StopJob()
        {
            JobWorker.Tell(new StopJob(Job, Stats.DeepClone(), Self));

            Stats = Stats.Reset();
            Become(ReadyToStart);
        }
        private void ProcessingItems()
        {
            //Received word from the WorkerTracker that we need to process items
            Receive<ProcessItems>(process =>
            {
                Stats = Stats.WithItemsDiscovered(process.Items.Count);
                JobWorker.Tell(Stats.DeepClone(), Self);

                foreach (var item in process.Items)
                {
                    //hand the work off to the weightedshare workers
                    ItemWorkerRouter.Tell(new ItemWorker.ProcessItemResult(item.Copy()), Self);
                }
                
            });

            Receive<WorkerTracker.AllItemsCompleted>(ic =>
            {
                _logger.Info("{0} Items processed.", ic.Items.Count);
                
                StopJob();
            });

            Receive<WorkerTracker.CompletedItem>(completed =>
            {
                Stats = Stats.WithItemCompleted();
                WorkerTracker.Tell(completed, Self);
                JobWorker.Tell(Stats.DeepClone(), Self);
            });

            ReceiveAny(task =>
            {
                _logger.Error(" [x] Oh Snap! WorkerCoordinator.ProcessingWeightedShare.ReceiveAny: \r\n{0}", task);
            });
        }
 private void ReadyToStart()
 {
     Receive<GetJobData>(ic =>
     {
         Stats = new JobStats(Job);
         JobWorker.Tell(Stats.DeepClone(), Self);
         JobWorker.Tell(JobStatus.GetJobData, Self);
         Become(GetItemsToProcess);
         GetItemDataRef.Tell(new GetJobData(Job.JobInfo), Self);
     });
     ReceiveAny(task =>
     {
         _logger.Error(" [x] Oh Snap! WorkerCoordinator.ReadyToStart.ReceiveAny: \r\n{0}", task);
     });
 }
예제 #6
0
        private void Ready()
        {
            // kick off the job
            Receive<IStartJob>(start =>
            {
                _logger.Info("JobWorker.Ready.IStartJob");

                // Need to reset tracking buckets.
                WorkerTracker.Tell(new WorkerTracker.ResetTrackerBuckets());
                RunningStatus = new JobStatusUpdate(Job) { Status = JobStatus.Starting };
                TotalStats = new JobStats(Job);
                RunningStatus.Stats = TotalStats;

                if (!Subscribers.Contains(start.Requestor))
                {
                    Subscribers.Add(start.Requestor);
                }

                PublishJobStatus();

                Self.Tell(new JobCanStart(start.Job));
            });

            Receive<JobCanStart>(start =>
            {
                RunningStatus.Status = JobStatus.Running;

                CoordinatorRouter.Tell(new WorkerCoordinator.GetJobData(start.Job.JobInfo));

                Become(Started);
                Stash.UnstashAll();
            });

            Receive<JobCanStart>(start =>
            {
                _logger.Warning("Can't start job yet. No routees.");
            });


            Receive<CheckJobStatus>(start =>
            {
                Sender.Tell(new ReceivedJobStatus(Job, RunningStatus), Self);
            });

            Receive<ReceiveTimeout>(ic =>
            {
                _logger.Error("JobWorker.Ready.ReceiveTimeout: \r\n{0}", ic);
            });

            Receive<ISubscribeToJob>(subscribe =>
            {
                Stash.Stash();
            });

            ReceiveAny(o =>
            {
                _logger.Error("JobWorker.Ready.ReceiveAny and stashing: \r\n{0}", o);
                Stash.Stash();
            });

        }
예제 #7
0
 public StopJob(Job job, JobStats jobStats, IActorRef requestor)
 {
     Requestor = requestor;
     Job = job;
     JobStats = jobStats;
 }