/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withTimestampField(String fieldName) { super.withTimestampField(fieldName); return this; }
@Override public JoinBolt withTimestampField(String fieldName) { return (JoinBolt) super.withTimestampField(fieldName); }
@Override public StormTopology newTopology() { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(getSpoutName(), new TimeDataIncrementingSpout(), spoutExecutors); builder.setBolt(getBoltName(), new TimeDataVerificationBolt() .withTumblingWindow(new BaseWindowedBolt.Duration(tumbleSec, TimeUnit.SECONDS)) .withLag(new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS)) .withTimestampField(TimeData.getTimestampFieldName()), boltExecutors) .globalGrouping(getSpoutName()); return builder.createTopology(); } }
@Override public StormTopology newTopology() { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(getSpoutName(), new TimeDataIncrementingSpout(), spoutExecutors); builder.setBolt(getBoltName(), new TimeDataVerificationBolt() .withWindow(new BaseWindowedBolt.Duration(windowSec, TimeUnit.SECONDS), new BaseWindowedBolt.Duration(slideSec, TimeUnit.SECONDS)) .withTimestampField(TimeData.getTimestampFieldName()) .withLag(new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS)), boltExecutors) .globalGrouping(getSpoutName()); return builder.createTopology(); } }
public static void main(String[] args) throws Exception { TopologyBuilder builder = new TopologyBuilder(); BaseWindowedBolt bolt = new SlidingWindowSumBolt() .withWindow(new Duration(5, TimeUnit.SECONDS), new Duration(3, TimeUnit.SECONDS)) .withTimestampField("ts") .withLag(new Duration(5, TimeUnit.SECONDS)); builder.setSpout("integer", new RandomIntegerSpout(), 1); builder.setBolt("slidingsum", bolt, 1).shuffleGrouping("integer"); builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("slidingsum"); Config conf = new Config(); conf.setDebug(true); String topoName = "test"; if (args != null && args.length > 0) { topoName = args[0]; } conf.setNumWorkers(1); StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createTopology()); } }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withTimestampField(String fieldName) { super.withTimestampField(fieldName); return this; }
@Override public JoinBolt withTimestampField(String fieldName) { return (JoinBolt) super.withTimestampField(fieldName); }