use of org.apache.storm.scheduler.ExecutorDetails in project storm by apache.
the class TestUtilsForResourceAwareScheduler method genExecsAndComps.
public static Map<ExecutorDetails, String> genExecsAndComps(StormTopology topology) {
Map<ExecutorDetails, String> retMap = new HashMap<>();
int startTask = 0;
int endTask = 0;
for (Map.Entry<String, SpoutSpec> entry : topology.get_spouts().entrySet()) {
SpoutSpec spout = entry.getValue();
String spoutId = entry.getKey();
int spoutParallelism = spout.get_common().get_parallelism_hint();
for (int i = 0; i < spoutParallelism; i++) {
retMap.put(new ExecutorDetails(startTask, endTask), spoutId);
startTask++;
endTask++;
}
}
for (Map.Entry<String, Bolt> entry : topology.get_bolts().entrySet()) {
String boltId = entry.getKey();
Bolt bolt = entry.getValue();
int boltParallelism = bolt.get_common().get_parallelism_hint();
for (int i = 0; i < boltParallelism; i++) {
retMap.put(new ExecutorDetails(startTask, endTask), boltId);
startTask++;
endTask++;
}
}
return retMap;
}
use of org.apache.storm.scheduler.ExecutorDetails in project storm by apache.
the class Nimbus method computeTopoToExecToNodePort.
/**
* convert {topology-id -> SchedulerAssignment} to {topology-id -> {executor [node port]}}.
*
* @return {topology-id -> {executor [node port]}} mapping
*/
private static Map<String, Map<List<Long>, List<Object>>> computeTopoToExecToNodePort(Map<String, SchedulerAssignment> schedAssignments, List<String> assignedTopologyIds) {
Map<String, Map<List<Long>, List<Object>>> ret = new HashMap<>();
for (Entry<String, SchedulerAssignment> schedEntry : schedAssignments.entrySet()) {
Map<List<Long>, List<Object>> execToNodePort = new HashMap<>();
for (Entry<ExecutorDetails, WorkerSlot> execAndNodePort : schedEntry.getValue().getExecutorToSlot().entrySet()) {
ExecutorDetails exec = execAndNodePort.getKey();
WorkerSlot slot = execAndNodePort.getValue();
execToNodePort.put(exec.toList(), slot.toList());
}
ret.put(schedEntry.getKey(), execToNodePort);
}
for (String id : assignedTopologyIds) {
ret.putIfAbsent(id, null);
}
return ret;
}
Aggregations