Search in sources :

Example 11 with FutureCompletingBlockingQueue

use of org.apache.flink.connector.base.source.reader.synchronization.FutureCompletingBlockingQueue in project flink by apache.

the class MockBaseSource method createReader.

@Override
public SourceReader<Integer, MockSourceSplit> createReader(SourceReaderContext readerContext) {
    FutureCompletingBlockingQueue<RecordsWithSplitIds<int[]>> elementsQueue = new FutureCompletingBlockingQueue<>();
    Configuration config = new Configuration();
    config.setInteger(SourceReaderOptions.ELEMENT_QUEUE_CAPACITY, 1);
    config.setLong(SourceReaderOptions.SOURCE_READER_CLOSE_TIMEOUT, 30000L);
    MockSplitReader.Builder builder = MockSplitReader.newBuilder().setNumRecordsPerSplitPerFetch(2).setBlockingFetch(true);
    return new MockSourceReader(elementsQueue, builder::build, config, readerContext);
}
Also used : FutureCompletingBlockingQueue(org.apache.flink.connector.base.source.reader.synchronization.FutureCompletingBlockingQueue) Configuration(org.apache.flink.configuration.Configuration) RecordsWithSplitIds(org.apache.flink.connector.base.source.reader.RecordsWithSplitIds)

Aggregations

FutureCompletingBlockingQueue (org.apache.flink.connector.base.source.reader.synchronization.FutureCompletingBlockingQueue)11 TestingRecordsWithSplitIds (org.apache.flink.connector.base.source.reader.mocks.TestingRecordsWithSplitIds)7 TestingReaderContext (org.apache.flink.connector.testutils.source.reader.TestingReaderContext)6 MockSourceSplit (org.apache.flink.api.connector.source.mocks.MockSourceSplit)5 RecordsWithSplitIds (org.apache.flink.connector.base.source.reader.RecordsWithSplitIds)5 MockSourceReader (org.apache.flink.connector.base.source.reader.mocks.MockSourceReader)5 MockSplitReader (org.apache.flink.connector.base.source.reader.mocks.MockSplitReader)4 Test (org.junit.jupiter.api.Test)4 InputStatus (org.apache.flink.core.io.InputStatus)3 Configuration (org.apache.flink.configuration.Configuration)2 TestingSourceSplit (org.apache.flink.connector.base.source.reader.mocks.TestingSourceSplit)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Supplier (java.util.function.Supplier)1 VisibleForTesting (org.apache.flink.annotation.VisibleForTesting)1 DeserializationSchema (org.apache.flink.api.common.serialization.DeserializationSchema)1 KafkaSourceReaderMetrics (org.apache.flink.connector.kafka.source.metrics.KafkaSourceReaderMetrics)1