Search in sources :

Example 26 with ResourceWorkerSlot

use of com.alibaba.jstorm.schedule.default_assign.ResourceWorkerSlot in project jstorm by alibaba.

the class SyncSupervisorEvent method getTopologyCodeLocations.

/**
 * get master code dir for each topology
 *
 * @return Map: [topologyId, master-code-dir] from zookeeper
 */
public static Map<String, String> getTopologyCodeLocations(Map<String, Assignment> assignments, String supervisorId) throws Exception {
    Map<String, String> rtn = new HashMap<>();
    for (Entry<String, Assignment> entry : assignments.entrySet()) {
        String topologyId = entry.getKey();
        Assignment assignmentInfo = entry.getValue();
        Set<ResourceWorkerSlot> workers = assignmentInfo.getWorkers();
        for (ResourceWorkerSlot worker : workers) {
            String node = worker.getNodeId();
            if (supervisorId.equals(node)) {
                rtn.put(topologyId, assignmentInfo.getMasterCodeDir());
                break;
            }
        }
    }
    return rtn;
}
Also used : LocalAssignment(com.alibaba.jstorm.daemon.worker.LocalAssignment) Assignment(com.alibaba.jstorm.schedule.Assignment) ResourceWorkerSlot(com.alibaba.jstorm.schedule.default_assign.ResourceWorkerSlot)

Aggregations

ResourceWorkerSlot (com.alibaba.jstorm.schedule.default_assign.ResourceWorkerSlot)26 Assignment (com.alibaba.jstorm.schedule.Assignment)13 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)9 StormClusterState (com.alibaba.jstorm.cluster.StormClusterState)7 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 FailedAssignTopologyException (com.alibaba.jstorm.utils.FailedAssignTopologyException)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 SupervisorInfo (com.alibaba.jstorm.daemon.supervisor.SupervisorInfo)5 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 TreeMap (java.util.TreeMap)5 AlreadyAliveException (backtype.storm.generated.AlreadyAliveException)4 InvalidTopologyException (backtype.storm.generated.InvalidTopologyException)4 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)4 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)4 NotAliveException (backtype.storm.generated.NotAliveException)4 TopologyAssignException (backtype.storm.generated.TopologyAssignException)4 TException (org.apache.thrift.TException)4