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(); }
public ReceivedJobStatus(Job job, JobStatusUpdate runningStatus) { Job = job; RunningStatus = runningStatus; }
public JobComplete(Job job, JobStatusUpdate jobStatusUpdate) { Job = job; JobStatusUpdate = jobStatusUpdate; }
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(); }); }