private SupervisorWorkerHeartbeats getAndResetWorkerHeartbeats() { Map<String, LSWorkerHeartbeat> localHeartbeats; try { localHeartbeats = SupervisorUtils.readWorkerHeartbeats(this.conf); return getSupervisorWorkerHeartbeatsFromLocal(localHeartbeats); } catch (Exception e) { LOG.error("Read local worker heartbeats error, skipping heartbeats for this round, msg:{}", e.getMessage()); return null; } }
/** * Retrieve the set of alive worker IDs. * * @param nowSecs current time in seconds */ public Set<String> getAliveIds(int nowSecs) { return SupervisorUtils.readWorkerHeartbeats(stormConf).entrySet().stream() .filter(entry -> Objects.nonNull(entry.getValue()) && !SupervisorUtils.isWorkerHbTimedOut(nowSecs, entry.getValue(), stormConf)) .map(Map.Entry::getKey) .collect(toCollection(TreeSet::new)); }