Search in sources :

Example 1 with MockStreamConfig

use of org.apache.flink.streaming.util.MockStreamConfig in project flink by apache.

the class SourceOperatorEventTimeTest method createTestOperator.

// ------------------------------------------------------------------------
// test setup helpers
// ------------------------------------------------------------------------
private static <T> SourceOperator<T, MockSourceSplit> createTestOperator(SourceReader<T, MockSourceSplit> reader, WatermarkStrategy<T> watermarkStrategy, ProcessingTimeService timeService, boolean emitProgressiveWatermarks) throws Exception {
    final OperatorStateStore operatorStateStore = new MemoryStateBackend().createOperatorStateBackend(new MockEnvironmentBuilder().build(), "test-operator", Collections.emptyList(), new CloseableRegistry());
    final StateInitializationContext stateContext = new StateInitializationContextImpl(null, operatorStateStore, null, null, null);
    final SourceOperator<T, MockSourceSplit> sourceOperator = new TestingSourceOperator<>(reader, watermarkStrategy, timeService, emitProgressiveWatermarks);
    sourceOperator.setup(new SourceOperatorStreamTask<Integer>(new StreamMockEnvironment(new Configuration(), new Configuration(), new ExecutionConfig(), 1L, new MockInputSplitProvider(), 1, new TestTaskStateManager())), new MockStreamConfig(new Configuration(), 1), new MockOutput<>(new ArrayList<>()));
    sourceOperator.initializeState(stateContext);
    sourceOperator.open();
    return sourceOperator;
}
Also used : OperatorStateStore(org.apache.flink.api.common.state.OperatorStateStore) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) Configuration(org.apache.flink.configuration.Configuration) MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) ArrayList(java.util.ArrayList) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry) TestTaskStateManager(org.apache.flink.runtime.state.TestTaskStateManager) StateInitializationContext(org.apache.flink.runtime.state.StateInitializationContext) StateInitializationContextImpl(org.apache.flink.runtime.state.StateInitializationContextImpl) MockStreamConfig(org.apache.flink.streaming.util.MockStreamConfig) StreamMockEnvironment(org.apache.flink.streaming.runtime.tasks.StreamMockEnvironment) MockSourceSplit(org.apache.flink.api.connector.source.mocks.MockSourceSplit) MockInputSplitProvider(org.apache.flink.runtime.operators.testutils.MockInputSplitProvider)

Example 2 with MockStreamConfig

use of org.apache.flink.streaming.util.MockStreamConfig in project flink by apache.

the class StreamTaskTest method setupEnvironment.

private MockEnvironment setupEnvironment(boolean... outputAvailabilities) {
    final Configuration configuration = new Configuration();
    new MockStreamConfig(configuration, outputAvailabilities.length);
    final List<ResultPartitionWriter> writers = new ArrayList<>(outputAvailabilities.length);
    for (int i = 0; i < outputAvailabilities.length; i++) {
        writers.add(new AvailabilityTestResultPartitionWriter(outputAvailabilities[i]));
    }
    final MockEnvironment environment = new MockEnvironmentBuilder().setTaskConfiguration(configuration).build();
    environment.addOutputs(writers);
    return environment;
}
Also used : MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) Configuration(org.apache.flink.configuration.Configuration) AvailabilityTestResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.AvailabilityTestResultPartitionWriter) ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) AvailabilityTestResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.AvailabilityTestResultPartitionWriter) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment) ArrayList(java.util.ArrayList) MockStreamConfig(org.apache.flink.streaming.util.MockStreamConfig)

Aggregations

ArrayList (java.util.ArrayList)2 Configuration (org.apache.flink.configuration.Configuration)2 MockEnvironmentBuilder (org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder)2 MockStreamConfig (org.apache.flink.streaming.util.MockStreamConfig)2 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 OperatorStateStore (org.apache.flink.api.common.state.OperatorStateStore)1 MockSourceSplit (org.apache.flink.api.connector.source.mocks.MockSourceSplit)1 CloseableRegistry (org.apache.flink.core.fs.CloseableRegistry)1 AvailabilityTestResultPartitionWriter (org.apache.flink.runtime.io.network.api.writer.AvailabilityTestResultPartitionWriter)1 ResultPartitionWriter (org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter)1 MockEnvironment (org.apache.flink.runtime.operators.testutils.MockEnvironment)1 MockInputSplitProvider (org.apache.flink.runtime.operators.testutils.MockInputSplitProvider)1 StateInitializationContext (org.apache.flink.runtime.state.StateInitializationContext)1 StateInitializationContextImpl (org.apache.flink.runtime.state.StateInitializationContextImpl)1 TestTaskStateManager (org.apache.flink.runtime.state.TestTaskStateManager)1 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)1 StreamMockEnvironment (org.apache.flink.streaming.runtime.tasks.StreamMockEnvironment)1