Search in sources :

Example 1 with AbstractFetcher

use of org.apache.flink.streaming.connectors.kafka.internals.AbstractFetcher in project flink by apache.

the class FlinkKafkaConsumerBaseTest method testClosePartitionDiscovererWhenKafkaFetcherFails.

@Test
public void testClosePartitionDiscovererWhenKafkaFetcherFails() throws Exception {
    final FlinkException failureCause = new FlinkException("Run Kafka fetcher failure.");
    // in this scenario, the partition discoverer will be concurrently accessed;
    // use the WakeupBeforeCloseTestingPartitionDiscoverer to verify that we always call
    // wakeup() before closing the discoverer
    final WakeupBeforeCloseTestingPartitionDiscoverer testPartitionDiscoverer = new WakeupBeforeCloseTestingPartitionDiscoverer();
    final AbstractFetcher<String, ?> mock = (AbstractFetcher<String, ?>) mock(AbstractFetcher.class);
    doThrow(failureCause).when(mock).runFetchLoop();
    final DummyFlinkKafkaConsumer<String> consumer = new DummyFlinkKafkaConsumer<>(() -> mock, testPartitionDiscoverer, 100L);
    testFailingConsumerLifecycle(consumer, failureCause);
    assertTrue("partitionDiscoverer should be closed when consumer is closed", testPartitionDiscoverer.isClosed());
}
Also used : AbstractFetcher(org.apache.flink.streaming.connectors.kafka.internals.AbstractFetcher) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Aggregations

AbstractFetcher (org.apache.flink.streaming.connectors.kafka.internals.AbstractFetcher)1 FlinkException (org.apache.flink.util.FlinkException)1 Test (org.junit.Test)1