Search in sources :

Example 6 with SourceArgs

use of backtype.storm.coordination.CoordinatedBolt.SourceArgs in project storm by nathanmarz.

the class BatchSubtopologyBuilder method extendTopology.

public void extendTopology(TopologyBuilder builder) {
    BoltDeclarer declarer = builder.setBolt(_masterId, new CoordinatedBolt(_masterBolt.bolt), _masterBolt.parallelism);
    for (InputDeclaration decl : _masterBolt.declarations) {
        decl.declare(declarer);
    }
    for (Map conf : _masterBolt.componentConfs) {
        declarer.addConfigurations(conf);
    }
    for (String id : _bolts.keySet()) {
        Component component = _bolts.get(id);
        Map<String, SourceArgs> coordinatedArgs = new HashMap<String, SourceArgs>();
        for (String c : componentBoltSubscriptions(component)) {
            SourceArgs source;
            if (c.equals(_masterId)) {
                source = SourceArgs.single();
            } else {
                source = SourceArgs.all();
            }
            coordinatedArgs.put(c, source);
        }
        BoltDeclarer input = builder.setBolt(id, new CoordinatedBolt(component.bolt, coordinatedArgs, null), component.parallelism);
        for (Map conf : component.componentConfs) {
            input.addConfigurations(conf);
        }
        for (String c : componentBoltSubscriptions(component)) {
            input.directGrouping(c, Constants.COORDINATED_STREAM_ID);
        }
        for (InputDeclaration d : component.declarations) {
            d.declare(input);
        }
    }
}
Also used : SourceArgs(backtype.storm.coordination.CoordinatedBolt.SourceArgs) BoltDeclarer(backtype.storm.topology.BoltDeclarer) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SourceArgs (backtype.storm.coordination.CoordinatedBolt.SourceArgs)6 BoltDeclarer (backtype.storm.topology.BoltDeclarer)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 CoordinatedBolt (backtype.storm.coordination.CoordinatedBolt)4 IdStreamSpec (backtype.storm.coordination.CoordinatedBolt.IdStreamSpec)4 TopologyBuilder (backtype.storm.topology.TopologyBuilder)4 FinishedCallback (backtype.storm.coordination.CoordinatedBolt.FinishedCallback)2 StreamInfo (backtype.storm.generated.StreamInfo)2 IRichBolt (backtype.storm.topology.IRichBolt)2 OutputFieldsGetter (backtype.storm.topology.OutputFieldsGetter)2 SpoutDeclarer (backtype.storm.topology.SpoutDeclarer)2 Fields (backtype.storm.tuple.Fields)2