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