private void WaitingForTracker() { //stash any further requests for trackers Receive <RequestDownloadTrackerFor>(request => Stash.Stash()); Receive <GetDownloadTracker>(get => { HandleGetDownloadTracker(get); }); Receive <ReceiveTimeout>(timeout => Self.Tell(new TrackerNotFound(RequestedTracker.Key))); Receive <TrackerNotFound>(notfound => { // check to make sure that this broadcast is for the same job if (notfound.Key.Equals(RequestedTracker.Key)) { OutstandingAcknowledgments--; //no one has a copy of this tracker, or it's dead if (OutstandingAcknowledgments == 0) { var tracker = Context.ActorOf(Props.Create(() => new DownloadsTracker()), RequestedTracker.Key.Root.ToActorName()); var found = new TrackerFound(RequestedTracker.Key, tracker); BecomeReadyIfFound(found); MasterBroadcast.Tell(new CreatedTracker(RequestedTracker.Key, tracker)); } } }); Receive <TrackerFound>(found => { Trackers[found.Key] = found.Tracker; BecomeReadyIfFound(found); }); Receive <CreatedTracker>(tracker => { Trackers[tracker.Key] = tracker.Tracker; var found = new TrackerFound(tracker.Key, tracker.Tracker); BecomeReadyIfFound(found); }); Receive <TrackerDead>(dead => { if (Trackers.ContainsKey(dead.Key)) { Trackers.Remove(dead.Key); } }); }
private void BecomeReadyIfFound(TrackerFound found) { //check if this was for the job we're currently coordinating if (found.Key.Equals(RequestedTracker.Key)) { RequestedTracker.Originator.Tell(found); Become(Ready); Stash.UnstashAll(); Context.SetReceiveTimeout(null); } }
private void BecomeReadyIfFound(TrackerFound found) { //check if this was for the job we're currently coordinating if (found.Key.Equals(RequestedTracker.Key)) { RequestedTracker.Originator.Tell(found); Become(Ready); Stash.UnstashAll(); Context.SetReceiveTimeout(null); } }
private void WaitingForTracker() { //stash any further requests for trackers Receive<RequestDownloadTrackerFor>(request => Stash.Stash()); Receive<GetDownloadTracker>(get => { HandleGetDownloadTracker(get); }); Receive<ReceiveTimeout>(timeout => Self.Tell(new TrackerNotFound(RequestedTracker.Key))); Receive<TrackerNotFound>(notfound => { // check to make sure that this broadcast is for the same job if (notfound.Key.Equals(RequestedTracker.Key)) { OutstandingAcknowledgments--; //no one has a copy of this tracker, or it's dead if (OutstandingAcknowledgments == 0) { var tracker = Context.ActorOf(Props.Create(() => new DownloadsTracker()), RequestedTracker.Key.Root.ToActorName()); var found = new TrackerFound(RequestedTracker.Key, tracker); BecomeReadyIfFound(found); MasterBroadcast.Tell(new CreatedTracker(RequestedTracker.Key, tracker)); } } }); Receive<TrackerFound>(found => { Trackers[found.Key] = found.Tracker; BecomeReadyIfFound(found); }); Receive<CreatedTracker>(tracker => { Trackers[tracker.Key] = tracker.Tracker; var found = new TrackerFound(tracker.Key, tracker.Tracker); BecomeReadyIfFound(found); }); Receive<TrackerDead>(dead => { if (Trackers.ContainsKey(dead.Key)) { Trackers.Remove(dead.Key); } }); }