windowLengthCount = new Count(((Number) topoConf.get(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_COUNT)).intValue()); } else if (topoConf.containsKey(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_DURATION_MS)) { windowLengthDuration = new Duration( slidingIntervalCount = new Count(((Number) topoConf.get(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_COUNT)).intValue()); } else if (topoConf.containsKey(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS)) { slidingIntervalDuration = } else { slidingIntervalCount = new Count(1);
windowLengthCount = new Count(((Number) stormConf.get(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_COUNT)).intValue()); } else if (stormConf.containsKey(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_DURATION_MS)) { windowLengthDuration = new Duration( slidingIntervalCount = new Count(((Number) stormConf.get(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_COUNT)).intValue()); } else if (stormConf.containsKey(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS)) { slidingIntervalDuration = new Duration(((Number) stormConf.get(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS)).intValue(), TimeUnit.MILLISECONDS); } else { slidingIntervalCount = new Count(1);
withWindow(windowLength, slidingInterval); } else if (windowConfig.getSlidingInterval() instanceof Window.Count) { BaseWindowedBolt.Count slidingInterval = new BaseWindowedBolt.Count(((Window.Count) windowConfig.getSlidingInterval()).getCount()); withWindow(windowLength, slidingInterval); } else { BaseWindowedBolt.Count windowLength = new BaseWindowedBolt.Count(((Window.Count) windowConfig.getWindowLength()).getCount()); if (windowConfig.getSlidingInterval() instanceof Window.Duration) { BaseWindowedBolt.Duration slidingInterval = new BaseWindowedBolt.Duration(((Window.Duration) windowConfig.getWindowLength()).getDurationMs(), TimeUnit.MILLISECONDS); withWindow(windowLength, slidingInterval); } else if (windowConfig.getSlidingInterval() instanceof Window.Count) { BaseWindowedBolt.Count slidingInterval = new BaseWindowedBolt.Count(((Window.Count) windowConfig.getWindowLength()).getCount()); withWindow(windowLength, slidingInterval); } else {
withWindow(windowLength, slidingInterval); } else if (windowConfig.getSlidingInterval() instanceof Window.Count) { Count slidingInterval = new Count(((Window.Count) windowConfig.getSlidingInterval()).getCount()); withWindow(windowLength, slidingInterval); } else { Count windowLength = new Count(((Window.Count) windowConfig.getWindowLength()).getCount()); if (windowConfig.getSlidingInterval() instanceof Window.Duration) { Duration slidingInterval = new Duration(((Window.Duration) windowConfig.getWindowLength()).getDurationMs(), TimeUnit.MILLISECONDS); withWindow(windowLength, slidingInterval); } else if (windowConfig.getSlidingInterval() instanceof Window.Count) { Count slidingInterval = new Count(((Window.Count) windowConfig.getWindowLength()).getCount()); withWindow(windowLength, slidingInterval); } else {
/** * A time duration based window that slides with every incoming tuple. * * @param windowLength the time duration of the window */ public BaseWindowedBolt withWindow(Duration windowLength) { return withWindowLength(windowLength).withSlidingInterval(new Count(1)); }
/** * Returns a {@link Count} of given value. * * @param value the count value * @return the Count */ public static Count of(int value) { return new Count(value); }
/** * A tuple count based window that slides with every incoming tuple. * * @param windowLength the number of tuples in the window */ public BaseWindowedBolt withWindow(Count windowLength) { return withWindowLength(windowLength).withSlidingInterval(new Count(1)); }
/** * Returns a {@link Count} of given value. * * @param value the count value * @return the Count */ public static Count of(int value) { return new Count(value); }
/** * A tuple count based window that slides with every incoming tuple. * * @param windowLength the number of tuples in the window */ public BaseWindowedBolt withWindow(Count windowLength) { return withWindowLength(windowLength).withSlidingInterval(new Count(1)); }
/** * A time duration based window that slides with every incoming tuple. * * @param windowLength the time duration of the window */ public BaseWindowedBolt withWindow(Duration windowLength) { return withWindowLength(windowLength).withSlidingInterval(new Count(1)); }
public static void main(String[] args) throws Exception { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("spout", new RandomIntegerSpout()); builder.setBolt("sumbolt", new WindowSumBolt().withWindow(new Count(5), new Count(3)) .withMessageIdField("msgid"), 1).shuffleGrouping("spout"); builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("sumbolt"); Config conf = new Config(); conf.setDebug(false); //conf.put(Config.TOPOLOGY_STATE_PROVIDER, "org.apache.storm.redis.state.RedisKeyValueStateProvider"); String topoName = "test"; if (args != null && args.length > 0) { topoName = args[0]; } conf.setNumWorkers(1); StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createTopology()); }
/** * A tuple count based window that slides with every incoming tuple. * * @param windowLength the number of tuples in the window */ public BaseWindowedBolt withWindow(Count windowLength) { return withWindowLength(windowLength).withSlidingInterval(new Count(1)); }
/** * Returns a {@link Count} of given value. * * @param value the count value * @return the Count */ public static Count of(int value) { return new Count(value); }
/** * A time duration based window that slides with every incoming tuple. * * @param windowLength the time duration of the window */ public BaseWindowedBolt withWindow(Duration windowLength) { return withWindowLength(windowLength).withSlidingInterval(new Count(1)); }
@Override public StormTopology newTopology() { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(getSpoutName(), new IncrementingSpout(), spoutExecutors); builder.setBolt(getBoltName(), new VerificationBolt() .withWindow(new BaseWindowedBolt.Count(windowSize), new BaseWindowedBolt.Count(slideSize)), boltExecutors) .shuffleGrouping(getSpoutName()); return builder.createTopology(); } }
@Override public StormTopology newTopology() { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(getSpoutName(), new IncrementingSpout(), spoutExecutors); builder.setBolt(getBoltName(), new VerificationBolt() .withTumblingWindow(new BaseWindowedBolt.Count(tumbleSize)), boltExecutors) .shuffleGrouping(getSpoutName()); return builder.createTopology(); } }