Search in sources :

Example 6 with MockSource

use of org.apache.flink.api.connector.source.mocks.MockSource in project flink by apache.

the class StreamGraphGeneratorExecutionModeDetectionTest method testExecutionModePropagationFromEnvWithBatchAndUnboundedSource.

@Test
public void testExecutionModePropagationFromEnvWithBatchAndUnboundedSource() {
    final Configuration config = new Configuration();
    config.set(ExecutionOptions.RUNTIME_MODE, RuntimeExecutionMode.BATCH);
    final StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
    environment.configure(config, getClass().getClassLoader());
    environment.fromSource(new MockSource(Boundedness.CONTINUOUS_UNBOUNDED, 100), WatermarkStrategy.noWatermarks(), "unbounded-source").print();
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("combination is not allowed");
    environment.getStreamGraph();
}
Also used : MockSource(org.apache.flink.api.connector.source.mocks.MockSource) Configuration(org.apache.flink.configuration.Configuration) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 7 with MockSource

use of org.apache.flink.api.connector.source.mocks.MockSource in project flink by apache.

the class StreamGraphGeneratorExecutionModeDetectionTest method testExecutionModePropagationFromEnvWithDefaultAndBoundedSource.

@Test
public void testExecutionModePropagationFromEnvWithDefaultAndBoundedSource() {
    final StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
    environment.enableCheckpointing(100);
    environment.fromSource(new MockSource(Boundedness.BOUNDED, 100), WatermarkStrategy.noWatermarks(), "bounded-source").print();
    assertThat(environment.getStreamGraph(), hasProperties(GlobalStreamExchangeMode.ALL_EDGES_PIPELINED, JobType.STREAMING, true, true));
}
Also used : MockSource(org.apache.flink.api.connector.source.mocks.MockSource) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 8 with MockSource

use of org.apache.flink.api.connector.source.mocks.MockSource in project flink by apache.

the class StreamGraphGeneratorBatchExecutionTest method testFeedbackThrowsExceptionInBatch.

@Test
public void testFeedbackThrowsExceptionInBatch() {
    final SourceTransformation<Integer, ?, ?> bounded = new SourceTransformation<>("Bounded Source", new MockSource(Boundedness.BOUNDED, 100), WatermarkStrategy.noWatermarks(), IntegerTypeInfo.of(Integer.class), 1);
    final FeedbackTransformation<Integer> feedbackTransformation = new FeedbackTransformation<>(bounded, 5L);
    testNoSupportForIterationsInBatchHelper(bounded, feedbackTransformation);
}
Also used : MockSource(org.apache.flink.api.connector.source.mocks.MockSource) SourceTransformation(org.apache.flink.streaming.api.transformations.SourceTransformation) FeedbackTransformation(org.apache.flink.streaming.api.transformations.FeedbackTransformation) CoFeedbackTransformation(org.apache.flink.streaming.api.transformations.CoFeedbackTransformation) Test(org.junit.Test)

Example 9 with MockSource

use of org.apache.flink.api.connector.source.mocks.MockSource in project flink by apache.

the class MultipleInputNodeCreationProcessorTest method createChainableStream.

private void createChainableStream(TableTestUtil util) {
    DataStreamSource<Integer> dataStream = util.getStreamEnv().fromSource(new MockSource(Boundedness.BOUNDED, 1), WatermarkStrategy.noWatermarks(), "chainableStream");
    TableTestUtil.createTemporaryView(util.tableEnv(), "chainableStream", dataStream, scala.Option.apply(new Expression[] { ApiExpressionUtils.unresolvedRef("a") }), scala.Option.empty(), scala.Option.empty());
}
Also used : MockSource(org.apache.flink.api.connector.source.mocks.MockSource) Expression(org.apache.flink.table.expressions.Expression)

Example 10 with MockSource

use of org.apache.flink.api.connector.source.mocks.MockSource in project flink by apache.

the class SourceOperatorLatencyMetricsTest method testLatencyMarkEmission.

private void testLatencyMarkEmission(boolean shouldExpectLatencyMarkers, Configuration taskManagerConfig, ExecutionConfig executionConfig) throws Exception {
    try (SourceOperatorTestHarness testHarness = new SourceOperatorTestHarness(new SourceOperatorFactory(new MockSource(Boundedness.CONTINUOUS_UNBOUNDED, 1), WatermarkStrategy.noWatermarks()), new MockEnvironmentBuilder().setTaskManagerRuntimeInfo(new TestingTaskManagerRuntimeInfo(taskManagerConfig)).setExecutionConfig(executionConfig).build())) {
        testHarness.open();
        testHarness.setup();
        for (long processingTime = 0; processingTime <= MAX_PROCESSING_TIME; processingTime++) {
            testHarness.getProcessingTimeService().setCurrentTime(processingTime);
            testHarness.emitNext();
        }
        List<LatencyMarker> expectedOutput = new ArrayList<>();
        if (!shouldExpectLatencyMarkers) {
            assertTrue(testHarness.getOutput().isEmpty());
        } else {
            expectedOutput.add(new LatencyMarker(1, testHarness.getOperator().getOperatorID(), 0));
            for (long markedTime = LATENCY_MARK_INTERVAL; markedTime <= MAX_PROCESSING_TIME; markedTime += LATENCY_MARK_INTERVAL) {
                expectedOutput.add(new LatencyMarker(markedTime, testHarness.getOperator().getOperatorID(), 0));
            }
            assertThat((Collection<Object>) testHarness.getOutput(), contains(expectedOutput.toArray()));
        }
    }
}
Also used : MockSource(org.apache.flink.api.connector.source.mocks.MockSource) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) TestingTaskManagerRuntimeInfo(org.apache.flink.runtime.util.TestingTaskManagerRuntimeInfo) SourceOperatorTestHarness(org.apache.flink.streaming.util.SourceOperatorTestHarness) LatencyMarker(org.apache.flink.streaming.runtime.streamrecord.LatencyMarker) ArrayList(java.util.ArrayList) SourceOperatorFactory(org.apache.flink.streaming.api.operators.SourceOperatorFactory)

Aggregations

MockSource (org.apache.flink.api.connector.source.mocks.MockSource)18 Test (org.junit.Test)16 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)7 SourceOperatorFactory (org.apache.flink.streaming.api.operators.SourceOperatorFactory)6 ArrayList (java.util.ArrayList)5 ArrayDeque (java.util.ArrayDeque)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2 JobID (org.apache.flink.api.common.JobID)2 SourceReaderContext (org.apache.flink.api.connector.source.SourceReaderContext)2 MockSourceSplit (org.apache.flink.api.connector.source.mocks.MockSourceSplit)2 Gauge (org.apache.flink.metrics.Gauge)2 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)2 CheckpointMetrics (org.apache.flink.runtime.checkpoint.CheckpointMetrics)2 TaskStateSnapshot (org.apache.flink.runtime.checkpoint.TaskStateSnapshot)2 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)2 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)2