Search in sources :

Example 6 with TestingSplitEnumeratorContext

use of org.apache.flink.connector.testutils.source.reader.TestingSplitEnumeratorContext in project flink by apache.

the class StaticFileSplitEnumeratorTest method testCheckpointNoSplitRequested.

@Test
public void testCheckpointNoSplitRequested() throws Exception {
    final TestingSplitEnumeratorContext<FileSourceSplit> context = new TestingSplitEnumeratorContext<>(4);
    final FileSourceSplit split = createRandomSplit();
    final StaticFileSplitEnumerator enumerator = createEnumerator(context, split);
    final PendingSplitsCheckpoint<FileSourceSplit> checkpoint = enumerator.snapshotState(1L);
    assertThat(checkpoint.getSplits(), contains(split));
}
Also used : FileSourceSplit(org.apache.flink.connector.file.src.FileSourceSplit) TestingSplitEnumeratorContext(org.apache.flink.connector.testutils.source.reader.TestingSplitEnumeratorContext) Test(org.junit.Test)

Example 7 with TestingSplitEnumeratorContext

use of org.apache.flink.connector.testutils.source.reader.TestingSplitEnumeratorContext in project flink by apache.

the class StaticFileSplitEnumeratorTest method testNoMoreSplits.

@Test
public void testNoMoreSplits() throws Exception {
    final TestingSplitEnumeratorContext<FileSourceSplit> context = new TestingSplitEnumeratorContext<>(4);
    final FileSourceSplit split = createRandomSplit();
    final StaticFileSplitEnumerator enumerator = createEnumerator(context, split);
    // first split assignment
    context.registerReader(1, "somehost");
    enumerator.addReader(1);
    enumerator.handleSplitRequest(1, "somehost");
    // second request has no more split
    enumerator.handleSplitRequest(1, "somehost");
    assertThat(context.getSplitAssignments().get(1).getAssignedSplits(), contains(split));
    assertTrue(context.getSplitAssignments().get(1).hasReceivedNoMoreSplitsSignal());
}
Also used : FileSourceSplit(org.apache.flink.connector.file.src.FileSourceSplit) TestingSplitEnumeratorContext(org.apache.flink.connector.testutils.source.reader.TestingSplitEnumeratorContext) Test(org.junit.Test)

Aggregations

FileSourceSplit (org.apache.flink.connector.file.src.FileSourceSplit)7 TestingSplitEnumeratorContext (org.apache.flink.connector.testutils.source.reader.TestingSplitEnumeratorContext)7 Test (org.junit.Test)7 TestingFileEnumerator (org.apache.flink.connector.file.src.testutils.TestingFileEnumerator)3