Search in sources :

Example 6 with DevNullBolt

use of org.apache.storm.perf.bolt.DevNullBolt in project storm by apache.

the class ConstSpoutIdBoltNullBoltTopo method getTopology.

static StormTopology getTopology(Map<String, Object> conf) {
    // 1 -  Setup Spout   --------
    ConstSpout spout = new ConstSpout("some data").withOutputFields("str");
    // 2 -  Setup IdBolt & DevNullBolt   --------
    IdBolt bolt1 = new IdBolt();
    DevNullBolt bolt2 = new DevNullBolt();
    // 3 - Setup Topology  --------
    TopologyBuilder builder = new TopologyBuilder();
    int numSpouts = Helper.getInt(conf, SPOUT_COUNT, 1);
    builder.setSpout(SPOUT_ID, spout, numSpouts);
    int numBolt1 = Helper.getInt(conf, BOLT1_COUNT, 1);
    builder.setBolt(BOLT1_ID, bolt1, numBolt1).localOrShuffleGrouping(SPOUT_ID);
    int numBolt2 = Helper.getInt(conf, BOLT2_COUNT, 1);
    builder.setBolt(BOLT2_ID, bolt2, numBolt2).localOrShuffleGrouping(BOLT1_ID);
    System.err.printf("====> Using : numSpouts = %d , numBolt1 = %d, numBolt2=%d\n", numSpouts, numBolt1, numBolt2);
    return builder.createTopology();
}
Also used : IdBolt(org.apache.storm.perf.bolt.IdBolt) ConstSpout(org.apache.storm.perf.spout.ConstSpout) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) DevNullBolt(org.apache.storm.perf.bolt.DevNullBolt)

Example 7 with DevNullBolt

use of org.apache.storm.perf.bolt.DevNullBolt in project storm by apache.

the class ConstSpoutNullBoltTopo method getTopology.

static StormTopology getTopology(Map<String, Object> conf) {
    // 1 -  Setup Spout   --------
    ConstSpout spout = new ConstSpout("some data").withOutputFields("str");
    // 2 -  Setup DevNull Bolt   --------
    DevNullBolt bolt = new DevNullBolt();
    // 3 - Setup Topology  --------
    TopologyBuilder builder = new TopologyBuilder();
    int numSpouts = Helper.getInt(conf, SPOUT_COUNT, 1);
    builder.setSpout(SPOUT_ID, spout, numSpouts);
    int numBolts = Helper.getInt(conf, BOLT_COUNT, 1);
    BoltDeclarer bd = builder.setBolt(BOLT_ID, bolt, numBolts);
    System.err.printf("====> Using : numSpouts = %d , numBolts = %d\n", numSpouts, numBolts);
    String groupingType = Helper.getStr(conf, GROUPING);
    if (groupingType == null || groupingType.equalsIgnoreCase(DEFAULT_GROUPING)) {
        bd.localOrShuffleGrouping(SPOUT_ID);
    } else if (groupingType.equalsIgnoreCase(SHUFFLE_GROUPING)) {
        bd.shuffleGrouping(SPOUT_ID);
    }
    return builder.createTopology();
}
Also used : ConstSpout(org.apache.storm.perf.spout.ConstSpout) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) BoltDeclarer(org.apache.storm.topology.BoltDeclarer) DevNullBolt(org.apache.storm.perf.bolt.DevNullBolt)

Example 8 with DevNullBolt

use of org.apache.storm.perf.bolt.DevNullBolt in project storm by apache.

the class KafkaClientSpoutNullBoltTopo method getTopology.

/**
 * Create and configure the topology.
 */
public static StormTopology getTopology(Map<String, Object> config) {
    final int spoutNum = Helper.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM);
    final int boltNum = Helper.getInt(config, BOLT_NUM, DEFAULT_BOLT_NUM);
    // 1 -  Setup Kafka Spout   --------
    String bootstrapServers = Optional.ofNullable(Helper.getStr(config, BOOTSTRAP_SERVERS)).orElse("127.0.0.1:9092");
    String kafkaTopic = Optional.ofNullable(Helper.getStr(config, KAFKA_TOPIC)).orElse("storm-perf-null-bolt-topic");
    ProcessingGuarantee processingGuarantee = ProcessingGuarantee.valueOf(Optional.ofNullable(Helper.getStr(config, PROCESSING_GUARANTEE)).orElse(ProcessingGuarantee.AT_LEAST_ONCE.name()));
    int offsetCommitPeriodMs = Helper.getInt(config, OFFSET_COMMIT_PERIOD_MS, 30_000);
    KafkaSpoutConfig<String, String> kafkaSpoutConfig = KafkaSpoutConfig.builder(bootstrapServers, kafkaTopic).setProcessingGuarantee(processingGuarantee).setOffsetCommitPeriodMs(offsetCommitPeriodMs).setFirstPollOffsetStrategy(FirstPollOffsetStrategy.EARLIEST).setTupleTrackingEnforced(true).build();
    KafkaSpout<String, String> spout = new KafkaSpout<>(kafkaSpoutConfig);
    // 2 -   DevNull Bolt   --------
    DevNullBolt bolt = new DevNullBolt();
    // 3 - Setup Topology  --------
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(SPOUT_ID, spout, spoutNum);
    builder.setBolt(BOLT_ID, bolt, boltNum).localOrShuffleGrouping(SPOUT_ID);
    return builder.createTopology();
}
Also used : ProcessingGuarantee(org.apache.storm.kafka.spout.KafkaSpoutConfig.ProcessingGuarantee) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) DevNullBolt(org.apache.storm.perf.bolt.DevNullBolt) KafkaSpout(org.apache.storm.kafka.spout.KafkaSpout)

Aggregations

DevNullBolt (org.apache.storm.perf.bolt.DevNullBolt)8 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)8 ConstSpout (org.apache.storm.perf.spout.ConstSpout)4 HdfsSpout (org.apache.storm.hdfs.spout.HdfsSpout)2 IdBolt (org.apache.storm.perf.bolt.IdBolt)2 BoltDeclarer (org.apache.storm.topology.BoltDeclarer)2 BrokerHosts (org.apache.storm.kafka.BrokerHosts)1 KafkaSpout (org.apache.storm.kafka.KafkaSpout)1 SpoutConfig (org.apache.storm.kafka.SpoutConfig)1 StringMultiSchemeWithTopic (org.apache.storm.kafka.StringMultiSchemeWithTopic)1 ZkHosts (org.apache.storm.kafka.ZkHosts)1 KafkaSpout (org.apache.storm.kafka.spout.KafkaSpout)1 ProcessingGuarantee (org.apache.storm.kafka.spout.KafkaSpoutConfig.ProcessingGuarantee)1