Search in sources :

Example 1 with PeriodicWatermarkGenerator

use of com.alibaba.jstorm.window.PeriodicWatermarkGenerator in project jstorm by alibaba.

the class FastWordCountEventTimeWindowTopology method test.

public static void test() throws Exception {
    int spout_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPOUT_PARALLELISM_HINT), 1);
    int count_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_COUNT_PARALLELISM_HINT), 1);
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("spout", new FastRandomSentenceSpout(), spout_Parallelism_hint);
    WordCount wordCountBolt = new WordCount();
    builder.setBolt("count", wordCountBolt.eventTimeWindow(Time.milliseconds(3L)).withTimestampExtractor(wordCountBolt).withWatermarkGenerator(new PeriodicWatermarkGenerator(Time.milliseconds(1L), Time.milliseconds(10L))), count_Parallelism_hint).fieldsGrouping("spout", new Fields("word", "ts"));
    String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
    String topologyName = className[className.length - 1];
    JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60, new JStormHelper.CheckAckedFail(conf), true);
}
Also used : JStormHelper(com.alibaba.starter.utils.JStormHelper) Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) PeriodicWatermarkGenerator(com.alibaba.jstorm.window.PeriodicWatermarkGenerator)

Aggregations

TopologyBuilder (backtype.storm.topology.TopologyBuilder)1 Fields (backtype.storm.tuple.Fields)1 PeriodicWatermarkGenerator (com.alibaba.jstorm.window.PeriodicWatermarkGenerator)1 JStormHelper (com.alibaba.starter.utils.JStormHelper)1