public WorkerManager()
{
var log = Context.GetLogger();
var counter = Context.ActorOf<WorkLoadCounter>(name: "workload-counter");
var workerRouter = GetWorkerRouter(counter);
Receive<Batch>(batch =>
{
log.Info("Generating a batch of size {0}", batch.Size);
for (int i = 0; i < batch.Size; i++)
workerRouter.Tell(new Work(i));
Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromSeconds(10), Self, GetBatch(), Self);
});
Receive<Report>(report =>
{
foreach (var entry in report.Counts)
{
var key = entry.Key;
var value = entry.Value;
var name = (string.IsNullOrEmpty(key.Path.Address.Host) ? "local/" : key.Path.Address.Host + ":" + key.Path.Address.Port + "/") + key.Path.Name;
log.Info("{0} -> {1}", name, value);
}
});
Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromSeconds(3), Self, GetBatch(), Self);
Context.System.Scheduler.ScheduleTellRepeatedly(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(10), counter, SendReport.Instance, Self);
}