/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withLag(Duration duration) { super.withLag(duration); return this; }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withTimestampField(String fieldName) { super.withTimestampField(fieldName); return this; }
/** * Time duration and count based sliding window configuration. * * @param windowLength the time duration of the window * @param slidingInterval the number of tuples after which the window slides */ public BaseWindowedBolt withWindow(Duration windowLength, Count slidingInterval) { return withWindowLength(windowLength).withSlidingInterval(slidingInterval); }
@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(); } }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withWindow(Duration windowLength) { super.withWindow(windowLength); return this; }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withTumblingWindow(Duration duration) { super.withTumblingWindow(duration); return this; }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withTimestampExtractor(TimestampExtractor timestampExtractor) { super.withTimestampExtractor(timestampExtractor); return this; }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withWatermarkInterval(Duration interval) { super.withWatermarkInterval(interval); return this; }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withLateTupleStream(String streamName) { super.withLateTupleStream(streamName); return this; }
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector);
@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(); } }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withWindow(Count windowLength, Count slidingInterval) { super.withWindow(windowLength, slidingInterval); return this; }
/** * {@inheritDoc} */ @Override public BaseStatefulWindowedBolt<T> withTumblingWindow(Count count) { super.withTumblingWindow(count); return this; }
@Override public JoinBolt withTimestampExtractor(TimestampExtractor timestampExtractor) { return (JoinBolt) super.withTimestampExtractor(timestampExtractor); }
@Override public BaseWindowedBolt withWatermarkInterval(Duration interval) { return (JoinBolt) super.withWatermarkInterval(interval); }
@Override public JoinBolt withLateTupleStream(String streamId) { return (JoinBolt) super.withLateTupleStream(streamId); }
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { EventLoggingOutputCollector outputCollector = new EventLoggingOutputCollector(context, collector, TestRunEventLogger.getEventLogger(eventLogFilePath)); processorBolt.prepare(stormConf, context, outputCollector); }
/** * A time duration based tumbling window. * * @param duration the time duration after which the window tumbles */ public BaseWindowedBolt withTumblingWindow(Duration duration) { return withWindowLength(duration).withSlidingInterval(duration); }
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> withWindow(Duration windowLength, Count slidingInterval) { super.withWindow(windowLength, slidingInterval); return this; }