Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
 public ReceivedJobStatus(Job job, JobStatusUpdate runningStatus)
 {
     Job = job;
     RunningStatus = runningStatus;
 }
Ejemplo n.º 3
0
 public JobComplete(Job job, JobStatusUpdate jobStatusUpdate)
 {
     Job = job;
     JobStatusUpdate = jobStatusUpdate;
 }
Ejemplo n.º 4
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();
            });

        }