/** * need to take executor->node+port in explicitly so that we don't run into a situation where a long dead worker with a skewed clock * overrides all the timestamps. By only checking heartbeats with an assigned node+port, and only reading executors from that heartbeat * that are actually assigned, we avoid situations like that. * * @param stormId topology id * @param executorNodePort executor id -> node + port * @return mapping of executorInfo -> executor beat */ @Override public Map<ExecutorInfo, ExecutorBeat> executorBeats(String stormId, Map<List<Long>, NodeInfo> executorNodePort) { Map<ExecutorInfo, ExecutorBeat> executorWhbs = new HashMap<>(); Map<NodeInfo, List<List<Long>>> nodePortExecutors = Utils.reverseMap(executorNodePort); for (Map.Entry<NodeInfo, List<List<Long>>> entry : nodePortExecutors.entrySet()) { String node = entry.getKey().get_node(); Long port = entry.getKey().get_port_iterator().next(); ClusterWorkerHeartbeat whb = getWorkerHeartbeat(stormId, node, port); List<ExecutorInfo> executorInfoList = new ArrayList<>(); for (List<Long> list : entry.getValue()) { executorInfoList.add(new ExecutorInfo(list.get(0).intValue(), list.get(list.size() - 1).intValue())); } if (whb != null) { executorWhbs.putAll(ClusterUtils.convertExecutorBeats(executorInfoList, whb)); } } return executorWhbs; }
/** * need to take executor->node+port in explicitly so that we don't run into a situation where a long dead worker with a skewed clock overrides all the * timestamps. By only checking heartbeats with an assigned node+port, and only reading executors from that heartbeat that are actually assigned, we avoid * situations like that * * @param stormId * @param executorNodePort * @return */ @Override public Map<ExecutorInfo, ExecutorBeat> executorBeats(String stormId, Map<List<Long>, NodeInfo> executorNodePort) { Map<ExecutorInfo, ExecutorBeat> executorWhbs = new HashMap<>(); Map<NodeInfo, List<List<Long>>> nodePortExecutors = Utils.reverseMap(executorNodePort); for (Map.Entry<NodeInfo, List<List<Long>>> entry : nodePortExecutors.entrySet()) { String node = entry.getKey().get_node(); Long port = entry.getKey().get_port_iterator().next(); ClusterWorkerHeartbeat whb = getWorkerHeartbeat(stormId, node, port); List<ExecutorInfo> executorInfoList = new ArrayList<>(); for (List<Long> list : entry.getValue()) { executorInfoList.add(new ExecutorInfo(list.get(0).intValue(), list.get(list.size() - 1).intValue())); } if (whb != null) executorWhbs.putAll(ClusterUtils.convertExecutorBeats(executorInfoList, whb)); } return executorWhbs; }