Search in sources :

Example 71 with ExecutorDetails

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;
}
Also used : ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) SpoutSpec(org.apache.storm.generated.SpoutSpec) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) BaseRichBolt(org.apache.storm.topology.base.BaseRichBolt) Bolt(org.apache.storm.generated.Bolt) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 72 with ExecutorDetails

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;
}
Also used : ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) HashMap(java.util.HashMap) SchedulerAssignment(org.apache.storm.scheduler.SchedulerAssignment) WorkerSlot(org.apache.storm.scheduler.WorkerSlot) AtomicLong(java.util.concurrent.atomic.AtomicLong) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) NavigableMap(java.util.NavigableMap) RotatingMap(org.apache.storm.utils.RotatingMap) ImmutableMap(org.apache.storm.shade.com.google.common.collect.ImmutableMap) TimeCacheMap(org.apache.storm.utils.TimeCacheMap) HashMap(java.util.HashMap)

Aggregations

ExecutorDetails (org.apache.storm.scheduler.ExecutorDetails)72 HashMap (java.util.HashMap)50 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)42 WorkerSlot (org.apache.storm.scheduler.WorkerSlot)41 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)36 ArrayList (java.util.ArrayList)35 Map (java.util.Map)34 Cluster (org.apache.storm.scheduler.Cluster)31 Config (org.apache.storm.Config)29 HashSet (java.util.HashSet)28 List (java.util.List)28 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)28 Topologies (org.apache.storm.scheduler.Topologies)23 LinkedList (java.util.LinkedList)21 INimbus (org.apache.storm.scheduler.INimbus)21 Collection (java.util.Collection)20 StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)19 StormTopology (org.apache.storm.generated.StormTopology)18 TestUtilsForResourceAwareScheduler (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler)18 ResourceMetrics (org.apache.storm.scheduler.resource.normalization.ResourceMetrics)18