Search in sources :

Example 1 with DruidBeamBolt

use of org.apache.storm.druid.bolt.DruidBeamBolt in project storm by apache.

the class SampleDruidBoltTopology method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        throw new IllegalArgumentException("There should be at least one argument. Run as `SampleDruidBoltTopology <zk-url>`");
    }
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout("event-gen", new SimpleSpout(), 5);
    DruidBeamFactory druidBeamFactory = new SampleDruidBeamFactoryImpl(new HashMap<String, Object>());
    DruidConfig.Builder builder = DruidConfig.newBuilder().discardStreamId(DruidConfig.DEFAULT_DISCARD_STREAM_ID);
    ITupleDruidEventMapper<Map<String, Object>> eventMapper = new TupleDruidEventMapper<>(TupleDruidEventMapper.DEFAULT_FIELD_NAME);
    DruidBeamBolt<Map<String, Object>> druidBolt = new DruidBeamBolt<Map<String, Object>>(druidBeamFactory, eventMapper, builder);
    topologyBuilder.setBolt("druid-bolt", druidBolt).shuffleGrouping("event-gen");
    topologyBuilder.setBolt("printer-bolt", new PrinterBolt()).shuffleGrouping("druid-bolt", DruidConfig.DEFAULT_DISCARD_STREAM_ID);
    Config conf = new Config();
    conf.setDebug(true);
    conf.put("druid.tranquility.zk.connect", args[0]);
    if (args.length > 1) {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[1], conf, topologyBuilder.createTopology());
    } else {
        conf.setMaxTaskParallelism(3);
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("druid-test", conf, topologyBuilder.createTopology())) {
            Thread.sleep(30000);
        }
        System.exit(0);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) DruidConfig(org.apache.storm.druid.bolt.DruidConfig) Config(org.apache.storm.Config) DruidBeamFactory(org.apache.storm.druid.bolt.DruidBeamFactory) DruidConfig(org.apache.storm.druid.bolt.DruidConfig) LocalTopology(org.apache.storm.LocalCluster.LocalTopology) DruidBeamBolt(org.apache.storm.druid.bolt.DruidBeamBolt) TupleDruidEventMapper(org.apache.storm.druid.bolt.TupleDruidEventMapper) ITupleDruidEventMapper(org.apache.storm.druid.bolt.ITupleDruidEventMapper) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Config (org.apache.storm.Config)1 LocalCluster (org.apache.storm.LocalCluster)1 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)1 DruidBeamBolt (org.apache.storm.druid.bolt.DruidBeamBolt)1 DruidBeamFactory (org.apache.storm.druid.bolt.DruidBeamFactory)1 DruidConfig (org.apache.storm.druid.bolt.DruidConfig)1 ITupleDruidEventMapper (org.apache.storm.druid.bolt.ITupleDruidEventMapper)1 TupleDruidEventMapper (org.apache.storm.druid.bolt.TupleDruidEventMapper)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1