Search in sources :

Example 31 with GlobalStreamId

use of backtype.storm.generated.GlobalStreamId in project jstorm by alibaba.

the class TopologyContext method getThisSourceComponentTasks.

public Map<String, List<Integer>> getThisSourceComponentTasks() {
    Map<String, List<Integer>> ret = new HashMap<>();
    Map<GlobalStreamId, Grouping> sources = getThisSources();
    Set<String> sourceComponents = new HashSet<>();
    if (sources != null) {
        for (GlobalStreamId globalStreamId : sources.keySet()) {
            sourceComponents.add(globalStreamId.get_componentId());
        }
    }
    for (String component : sourceComponents) {
        ret.put(component, getComponentTasks(component));
    }
    return ret;
}
Also used : HashMap(java.util.HashMap) GlobalStreamId(backtype.storm.generated.GlobalStreamId) ArrayList(java.util.ArrayList) List(java.util.List) Grouping(backtype.storm.generated.Grouping) HashSet(java.util.HashSet)

Example 32 with GlobalStreamId

use of backtype.storm.generated.GlobalStreamId in project jstorm by alibaba.

the class GeneralTopologyContext method getTargets.

/**
 * Gets information about who is consuming the outputs of the specified component, and how.
 *
 * @return Map from stream id to component id to the Grouping used.
 */
public Map<String, Map<String, Grouping>> getTargets(String componentId) {
    Map<String, Map<String, Grouping>> ret = new HashMap<>();
    for (String otherComponentId : getComponentIds()) {
        Map<GlobalStreamId, Grouping> inputs = getComponentCommon(otherComponentId).get_inputs();
        for (GlobalStreamId id : inputs.keySet()) {
            if (id.get_componentId().equals(componentId)) {
                Map<String, Grouping> curr = ret.get(id.get_streamId());
                if (curr == null)
                    curr = new HashMap<>();
                curr.put(otherComponentId, inputs.get(id));
                ret.put(id.get_streamId(), curr);
            }
        }
    }
    return ret;
}
Also used : GlobalStreamId(backtype.storm.generated.GlobalStreamId) Grouping(backtype.storm.generated.Grouping)

Example 33 with GlobalStreamId

use of backtype.storm.generated.GlobalStreamId in project jstorm by alibaba.

the class TridentTopologyBuilder method fleshOutStreamBatchIds.

Map<GlobalStreamId, String> fleshOutStreamBatchIds(boolean includeCommitStream) {
    Map<GlobalStreamId, String> ret = new HashMap<>(_batchIds);
    Set<String> allBatches = new HashSet(_batchIds.values());
    for (String b : allBatches) {
        ret.put(new GlobalStreamId(masterCoordinator(b), MasterBatchCoordinator.BATCH_STREAM_ID), b);
        if (includeCommitStream) {
            ret.put(new GlobalStreamId(masterCoordinator(b), MasterBatchCoordinator.COMMIT_STREAM_ID), b);
        }
    // DO NOT include the success stream as part of the batch. it should not trigger coordination tuples,
    // and is just a metadata tuple to assist in cleanup, should not trigger batch tracking
    }
    for (String id : _spouts.keySet()) {
        TransactionalSpoutComponent c = _spouts.get(id);
        if (c.batchGroupId != null) {
            ret.put(new GlobalStreamId(spoutCoordinator(id), MasterBatchCoordinator.BATCH_STREAM_ID), c.batchGroupId);
        }
    }
    // this takes care of setting up coord streams for spouts and bolts
    for (GlobalStreamId s : _batchIds.keySet()) {
        String b = _batchIds.get(s);
        ret.put(new GlobalStreamId(s.get_componentId(), TridentBoltExecutor.COORD_STREAM(b)), b);
    }
    return ret;
}
Also used : GlobalStreamId(backtype.storm.generated.GlobalStreamId)

Aggregations

GlobalStreamId (backtype.storm.generated.GlobalStreamId)33 HashMap (java.util.HashMap)13 HashSet (java.util.HashSet)13 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 Grouping (backtype.storm.generated.Grouping)7 ComponentCommon (backtype.storm.generated.ComponentCommon)4 Fields (backtype.storm.tuple.Fields)4 List (java.util.List)4 Set (java.util.Set)4 Bolt (backtype.storm.generated.Bolt)3 CustomStreamGrouping (backtype.storm.grouping.CustomStreamGrouping)3 TopologyContext (backtype.storm.task.TopologyContext)3 BoltDeclarer (backtype.storm.topology.BoltDeclarer)3 ITridentSpout (storm.trident.spout.ITridentSpout)3 Tuple (backtype.storm.tuple.Tuple)2 DefaultDirectedGraph (org.jgrapht.graph.DefaultDirectedGraph)2 GraphGrouper (storm.trident.graph.GraphGrouper)2 Group (storm.trident.graph.Group)2 Node (storm.trident.planner.Node)2