use of org.apache.storm.daemon.Acker in project storm by apache.
the class BaseResourceAwareStrategy method createSearcherState.
/**
* Create an instance of {@link SchedulingSearcherState}. This method is called by
* {@link #prepareForScheduling(Cluster, TopologyDetails)} and depends on variables initialized therein prior.
*
* @return a new instance of {@link SchedulingSearcherState}.
*/
private SchedulingSearcherState createSearcherState() {
Map<WorkerSlot, Map<String, Integer>> workerCompCnts = new HashMap<>();
Map<RasNode, Map<String, Integer>> nodeCompCnts = new HashMap<>();
// populate with existing assignments
SchedulerAssignment existingAssignment = cluster.getAssignmentById(topologyDetails.getId());
if (existingAssignment != null) {
existingAssignment.getExecutorToSlot().forEach((exec, ws) -> {
String compId = execToComp.get(exec);
RasNode node = nodes.getNodeById(ws.getNodeId());
Map<String, Integer> compCnts = nodeCompCnts.computeIfAbsent(node, (k) -> new HashMap<>());
// increment
compCnts.put(compId, compCnts.getOrDefault(compId, 0) + 1);
// populate worker to comp assignments
compCnts = workerCompCnts.computeIfAbsent(ws, (k) -> new HashMap<>());
// increment
compCnts.put(compId, compCnts.getOrDefault(compId, 0) + 1);
});
}
LinkedList<ExecutorDetails> unassignedAckers = new LinkedList<>();
if (compToExecs.containsKey(Acker.ACKER_COMPONENT_ID)) {
for (ExecutorDetails acker : compToExecs.get(Acker.ACKER_COMPONENT_ID)) {
if (unassignedExecutors.contains(acker)) {
unassignedAckers.add(acker);
}
}
}
return new SchedulingSearcherState(workerCompCnts, nodeCompCnts, maxStateSearch, maxSchedulingTimeMs, new ArrayList<>(unassignedExecutors), unassignedAckers, topologyDetails, execToComp);
}
Aggregations