@Override public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { // get the last successfully committed state from state store String namespace = context.getThisComponentId() + "-" + context.getThisTaskId(); prepare(topoConf, context, collector, StateFactory.getState(namespace, topoConf, context)); }
@Before public void setUp() throws Exception { mockBolt = Mockito.mock(IStatefulBolt.class); executor = new StatefulBoltExecutor<>(mockBolt); mockTopologyContext = Mockito.mock(TopologyContext.class); mockOutputCollector = Mockito.mock(OutputCollector.class); mockState = Mockito.mock(KeyValueState.class); Mockito.when(mockTopologyContext.getThisComponentId()).thenReturn("test"); Mockito.when(mockTopologyContext.getThisTaskId()).thenReturn(1); GlobalStreamId globalStreamId = new GlobalStreamId("test", CheckpointSpout.CHECKPOINT_STREAM_ID); Map<GlobalStreamId, Grouping> thisSources = Collections.singletonMap(globalStreamId, mock(Grouping.class)); Mockito.when(mockTopologyContext.getThisSources()).thenReturn(thisSources); Mockito.when(mockTopologyContext.getComponentTasks(Mockito.any())).thenReturn(Collections.singletonList(1)); mockTuple = Mockito.mock(Tuple.class); mockCheckpointTuple = Mockito.mock(Tuple.class); executor.prepare(mockStormConf, mockTopologyContext, mockOutputCollector, mockState); }
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { // get the last successfully committed state from state store String namespace = context.getThisComponentId() + "-" + context.getThisTaskId(); prepare(stormConf, context, collector, StateFactory.getState(namespace, stormConf, context)); }