Пример #1
0
        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);
            });
        }
Пример #2
0
        private void GetItemsToProcess()
        {
            Receive <RecievedDataItems>(ic => !ic.Items.Any(), ic =>
            {
                JobWorker.Tell(JobStatus.RecievedDataItems, Self);
                _logger.Info("No items found so no work to do right now; Work Complete.");
                StopJob();
            });

            Receive <RecievedDataItems>(ic =>
            {
                JobWorker.Tell(JobStatus.RecievedDataItems, Self);
                _logger.Info("Ready to process {0} items", ic.Items.Count());
                WorkerTracker.Tell(new RecievedDataItems(ic.Items.ToList()), Self);
                JobWorker.Tell(Stats.DeepClone());

                BecomeProcessingItems();
            });

            ReceiveAny(task =>
            {
                _logger.Error(" [x] Oh Snap! WorkerCoordinator.GetItemToProcess.ReceiveAny: \r\n{0}", task);
            });
        }
Пример #3
0
 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);
     });
 }