Search in sources :

Example 1 with OpenTsdbBolt

use of org.apache.storm.opentsdb.bolt.OpenTsdbBolt in project storm by apache.

the class SampleOpenTsdbBoltTopology 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 `SampleOpenTsdbBoltTopology <tsdb-url>`");
    }
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout("metric-gen", new MetricGenSpout(), 5);
    String openTsdbUrl = args[0];
    OpenTsdbClient.Builder builder = OpenTsdbClient.newBuilder(openTsdbUrl).sync(30_000).returnDetails();
    final OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(builder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER));
    openTsdbBolt.withBatchSize(10).withFlushInterval(2).failTupleForFailedMetrics();
    topologyBuilder.setBolt("opentsdb", openTsdbBolt).shuffleGrouping("metric-gen");
    Config conf = new Config();
    conf.setDebug(true);
    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("word-count", conf, topologyBuilder.createTopology())) {
            Thread.sleep(30000);
        }
        System.exit(0);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) OpenTsdbClient(org.apache.storm.opentsdb.client.OpenTsdbClient) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) OpenTsdbBolt(org.apache.storm.opentsdb.bolt.OpenTsdbBolt) Config(org.apache.storm.Config) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Aggregations

Config (org.apache.storm.Config)1 LocalCluster (org.apache.storm.LocalCluster)1 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)1 OpenTsdbBolt (org.apache.storm.opentsdb.bolt.OpenTsdbBolt)1 OpenTsdbClient (org.apache.storm.opentsdb.client.OpenTsdbClient)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1