Search in sources :

Example 1 with BatchTopologyBuilder

use of com.alibaba.jstorm.batch.BatchTopologyBuilder in project jstorm by alibaba.

the class SimpleBatchTopologyTest method testSimpleBatchTopology.

@Test
public void testSimpleBatchTopology() {
    BatchTopologyBuilder batchTopologyBuilder = new BatchTopologyBuilder("SimpleBatchTopology");
    batchTopologyBuilder.setSpout("batchSpout", new SimpleBatchTestSpout(), 1);
    batchTopologyBuilder.setBolt("batchBolt", new SimpleBatchTestBolt(), 2).shuffleGrouping("batchSpout");
    Config config = new Config();
    config.put(Config.TOPOLOGY_NAME, "SimpleBatchTopologyTest");
    config.setMaxSpoutPending(1);
    JStormUnitTestRunner.submitTopology(batchTopologyBuilder.getTopologyBuilder().createTopology(), config, 120, null);
}
Also used : Config(backtype.storm.Config) BatchTopologyBuilder(com.alibaba.jstorm.batch.BatchTopologyBuilder) Test(org.junit.Test)

Example 2 with BatchTopologyBuilder

use of com.alibaba.jstorm.batch.BatchTopologyBuilder in project jstorm by alibaba.

the class BatchMetaTopology method SetBuilder.

public static TopologyBuilder SetBuilder() {
    BatchTopologyBuilder batchTopologyBuilder = new BatchTopologyBuilder(topologyName);
    MetaSpoutConfig metaSpoutConfig = getMetaSpoutConfig(conf);
    BoltDeclarer rebalanceDeclarer = batchTopologyBuilder.setBolt(BatchMetaRebalance.BOLT_NAME, new BatchMetaRebalance(), 1);
    IBatchSpout batchSpout = new BatchMetaSpout(metaSpoutConfig);
    int spoutParal = JStormUtils.parseInt(conf.get("topology.spout.parallel"), 1);
    BoltDeclarer spoutDeclarer = batchTopologyBuilder.setSpout(BatchMetaSpout.SPOUT_NAME, batchSpout, spoutParal);
    spoutDeclarer.allGrouping(BatchMetaRebalance.BOLT_NAME, BatchMetaRebalance.REBALANCE_STREAM_ID);
    int boltParallel = JStormUtils.parseInt(conf.get("topology.bolt.parallel"), 1);
    BoltDeclarer transformDeclarer = batchTopologyBuilder.setBolt(TransformBolt.BOLT_NAME, new TransformBolt(), boltParallel);
    transformDeclarer.shuffleGrouping(BatchMetaSpout.SPOUT_NAME);
    BoltDeclarer countDeclarer = batchTopologyBuilder.setBolt(CountBolt.COUNT_BOLT_NAME, new CountBolt(), boltParallel);
    countDeclarer.shuffleGrouping(TransformBolt.BOLT_NAME);
    BoltDeclarer sumDeclarer = batchTopologyBuilder.setBolt(CountBolt.SUM_BOLT_NAME, new CountBolt(), boltParallel);
    sumDeclarer.shuffleGrouping(TransformBolt.BOLT_NAME);
    BoltDeclarer dbDeclarer = batchTopologyBuilder.setBolt(DBBolt.BOLT_NAME, new DBBolt(), 1);
    dbDeclarer.shuffleGrouping(CountBolt.COUNT_BOLT_NAME).shuffleGrouping(CountBolt.SUM_BOLT_NAME);
    return batchTopologyBuilder.getTopologyBuilder();
}
Also used : IBatchSpout(com.alibaba.jstorm.batch.IBatchSpout) BoltDeclarer(backtype.storm.topology.BoltDeclarer) MetaSpoutConfig(com.alibaba.jstorm.batch.meta.MetaSpoutConfig) BatchTopologyBuilder(com.alibaba.jstorm.batch.BatchTopologyBuilder)

Example 3 with BatchTopologyBuilder

use of com.alibaba.jstorm.batch.BatchTopologyBuilder in project jstorm by alibaba.

the class SimpleBatchTopology method SetBuilder.

public static TopologyBuilder SetBuilder() {
    BatchTopologyBuilder topologyBuilder = new BatchTopologyBuilder(topologyName);
    int spoutParallel = JStormUtils.parseInt(conf.get("topology.spout.parallel"), 1);
    BoltDeclarer boltDeclarer = topologyBuilder.setSpout("Spout", new SimpleSpout(), spoutParallel);
    int boltParallel = JStormUtils.parseInt(conf.get("topology.bolt.parallel"), 2);
    topologyBuilder.setBolt("Bolt", new SimpleBolt(), boltParallel).shuffleGrouping("Spout");
    return topologyBuilder.getTopologyBuilder();
}
Also used : BoltDeclarer(backtype.storm.topology.BoltDeclarer) BatchTopologyBuilder(com.alibaba.jstorm.batch.BatchTopologyBuilder)

Aggregations

BatchTopologyBuilder (com.alibaba.jstorm.batch.BatchTopologyBuilder)3 BoltDeclarer (backtype.storm.topology.BoltDeclarer)2 Config (backtype.storm.Config)1 IBatchSpout (com.alibaba.jstorm.batch.IBatchSpout)1 MetaSpoutConfig (com.alibaba.jstorm.batch.meta.MetaSpoutConfig)1 Test (org.junit.Test)1