use of org.apache.flink.api.common.state.OperatorStateStore in project flink by apache.
the class SourceOperatorTestContext method createStateContext.
public StateInitializationContext createStateContext() throws Exception {
// Create a mock split.
byte[] serializedSplitWithVersion = SimpleVersionedSerialization.writeVersionAndSerialize(new MockSourceSplitSerializer(), MOCK_SPLIT);
// Crate the state context.
OperatorStateStore operatorStateStore = createOperatorStateStore();
StateInitializationContext stateContext = new StateInitializationContextImpl(null, operatorStateStore, null, null, null);
// Update the context.
stateContext.getOperatorStateStore().getListState(SourceOperator.SPLITS_STATE_DESC).update(Collections.singletonList(serializedSplitWithVersion));
return stateContext;
}
use of org.apache.flink.api.common.state.OperatorStateStore in project beam by apache.
the class ImpulseSourceFunctionTest method getInitializationContext.
private static <T> FunctionInitializationContext getInitializationContext(ListState<T> listState) throws Exception {
FunctionInitializationContext mock = Mockito.mock(FunctionInitializationContext.class);
OperatorStateStore mockOperatorState = getMockOperatorState(listState);
when(mock.getOperatorStateStore()).thenReturn(mockOperatorState);
return mock;
}
Aggregations