// This function will add elements in timeoutTargets boolean timeout() { timeoutTargets.clear(); for (Map.Entry<ActorRef, Boolean> probeEntry : probes.entrySet()) { if (!probeEntry.getValue()) { int timeoutTime = timeoutTimes.get(probeEntry.getKey()); ++timeoutTime; System.out.println("Timeout!!!!!!!!!!!!!!!!!!TimeoutTime: " + timeoutTime); if (timeoutTime >= reactionFactor) { timeoutTargets.offer(probeEntry.getKey()); timeoutTimes.put(probeEntry.getKey(), 0); // It's time to do split, we don't want the history } else timeoutTimes.put(probeEntry.getKey(), timeoutTime); } probeEntry.setValue(false); } ++currentId; // Probes with old id will be treated as timeout probe return !timeoutTargets.isEmpty(); }
void fill(Probe probe) { if (probe.id < currentId) return; // This is a timeout probe assert probe.id == currentId; probes.put(probe.target, true); timeoutTimes.put(probe.target, 0); }
void addTarget(ActorRef target) { probes.put(target, true); // The target will be monitored from next iteration timeoutTimes.put(target, 0); }
void removeTarget(ActorRef target) { timeoutTimes.remove(target); probes.remove(target); }
Probes(List<ActorRef> targets) { probes = new HashMap<ActorRef, Boolean>(); for (ActorRef target : targets) probes.put(target, true); timeoutTimes = new HashMap<ActorRef, Integer>(); for (ActorRef target : targets) timeoutTimes.put(target, 0); }