void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector, KeyValueState<TaskStream, WindowState> windowState) { init(topoConf, context, collector, windowState); super.prepare(topoConf, context, collector); }
@Before public void setUp() { testWindowedBolt = new TestWindowedBolt(); testWindowedBolt.withTimestampField("ts"); executor = new WindowedBoltExecutor(testWindowedBolt); Map<String, Object> conf = new HashMap<>(); conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 100000); conf.put(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_DURATION_MS, 20); conf.put(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS, 10); conf.put(Config.TOPOLOGY_BOLTS_TUPLE_TIMESTAMP_MAX_LAG_MS, 5); // trigger manually to avoid timing issues conf.put(Config.TOPOLOGY_BOLTS_WATERMARK_EVENT_INTERVAL_MS, 100000); executor.prepare(conf, getTopologyContext(), getOutputCollector()); }
@Test public void testPrepareLateTupleStreamWithoutTs() throws Exception { Map<String, Object> conf = new HashMap<>(); conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 100000); conf.put(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_DURATION_MS, 20); conf.put(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS, 10); conf.put(Config.TOPOLOGY_BOLTS_LATE_TUPLE_STREAM, "$late"); conf.put(Config.TOPOLOGY_BOLTS_TUPLE_TIMESTAMP_MAX_LAG_MS, 5); conf.put(Config.TOPOLOGY_BOLTS_WATERMARK_EVENT_INTERVAL_MS, 10); testWindowedBolt = new TestWindowedBolt(); executor = new WindowedBoltExecutor(testWindowedBolt); TopologyContext context = getTopologyContext(); // emulate the call of withLateTupleStream method Mockito.when(context.getThisStreams()).thenReturn(new HashSet<>(Arrays.asList("default", "$late"))); try { executor.prepare(conf, context, getOutputCollector()); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Late tuple stream can be defined only when specifying a timestamp field")); } }
@Test public void testPrepareLateTupleStreamWithoutBuilder() throws Exception { Map<String, Object> conf = new HashMap<>(); conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 100000); conf.put(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_DURATION_MS, 20); conf.put(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS, 10); conf.put(Config.TOPOLOGY_BOLTS_LATE_TUPLE_STREAM, "$late"); conf.put(Config.TOPOLOGY_BOLTS_TUPLE_TIMESTAMP_MAX_LAG_MS, 5); conf.put(Config.TOPOLOGY_BOLTS_WATERMARK_EVENT_INTERVAL_MS, 10); testWindowedBolt = new TestWindowedBolt(); testWindowedBolt.withTimestampField("ts"); executor = new WindowedBoltExecutor(testWindowedBolt); TopologyContext context = getTopologyContext(); try { executor.prepare(conf, context, getOutputCollector()); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Stream for late tuples must be defined with the builder method withLateTupleStream")); } }
void prepare(Map stormConf, TopologyContext context, OutputCollector collector, KeyValueState<TaskStream, WindowState> windowState) { init(stormConf, context, collector, windowState); super.prepare(stormConf, context, collector); }