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());
}
Aggregations