Search in sources :

Example 11 with IRichBolt

use of org.apache.storm.topology.IRichBolt in project storm by apache.

the class Thrift method buildTopology.

public static StormTopology buildTopology(Map<String, SpoutDetails> spoutMap, Map<String, BoltDetails> boltMap) {
    TopologyBuilder builder = new TopologyBuilder();
    for (Entry<String, SpoutDetails> entry : spoutMap.entrySet()) {
        String spoutID = entry.getKey();
        SpoutDetails spec = entry.getValue();
        SpoutDeclarer spoutDeclarer = builder.setSpout(spoutID, spec.getSpout(), spec.getParallelism());
        spoutDeclarer.addConfigurations(spec.getConf());
    }
    for (Entry<String, BoltDetails> entry : boltMap.entrySet()) {
        String spoutID = entry.getKey();
        BoltDetails spec = entry.getValue();
        BoltDeclarer boltDeclarer = null;
        if (spec.bolt instanceof IRichBolt) {
            boltDeclarer = builder.setBolt(spoutID, (IRichBolt) spec.getBolt(), spec.getParallelism());
        } else {
            boltDeclarer = builder.setBolt(spoutID, (IBasicBolt) spec.getBolt(), spec.getParallelism());
        }
        boltDeclarer.addConfigurations(spec.getConf());
        addInputs(boltDeclarer, spec.getInputs());
    }
    return builder.createTopology();
}
Also used : IRichBolt(org.apache.storm.topology.IRichBolt) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) BoltDeclarer(org.apache.storm.topology.BoltDeclarer) SpoutDeclarer(org.apache.storm.topology.SpoutDeclarer) IBasicBolt(org.apache.storm.topology.IBasicBolt)

Aggregations

IRichBolt (org.apache.storm.topology.IRichBolt)11 Fields (org.apache.storm.tuple.Fields)6 Configuration (org.apache.flink.configuration.Configuration)4 UnmodifiableConfiguration (org.apache.flink.configuration.UnmodifiableConfiguration)4 AbstractTest (org.apache.flink.storm.util.AbstractTest)4 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)4 StreamingRuntimeContext (org.apache.flink.streaming.api.operators.StreamingRuntimeContext)4 HashMap (java.util.HashMap)3 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)3 UnregisteredMetricsGroup (org.apache.flink.metrics.groups.UnregisteredMetricsGroup)3 Output (org.apache.flink.streaming.api.operators.Output)3 ComponentCommon (org.apache.storm.generated.ComponentCommon)3 BoltDeclarer (org.apache.storm.topology.BoltDeclarer)3 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Tuple (org.apache.flink.api.java.tuple.Tuple)2 StormConfig (org.apache.flink.storm.util.StormConfig)2