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);
}
}
Aggregations