@Internal public class KafkaConsumerThread extends Thread
KafkaConsumer, connecting to the brokers and polling records.
The thread pushes the data into a Handover to be picked up by the fetcher that will
deserialize and emit the records.
IMPORTANT: This thread must not be interrupted when attempting to shut it down. The Kafka consumer code was found to not always handle interrupts well, and to even deadlock in certain situations.
Implementation Note: This code is written to be reusable in later versions of the KafkaConsumer. Because Kafka is not maintaining binary compatibility, we use a "call bridge" as an indirection to the KafkaConsumer calls that change signature.
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| 构造器和说明 |
|---|
KafkaConsumerThread(org.slf4j.Logger log,
Handover handover,
Properties kafkaProperties,
org.apache.flink.streaming.connectors.kafka.internals.ClosableBlockingQueue<org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartitionState<org.apache.kafka.common.TopicPartition>> unassignedPartitionsQueue,
KafkaConsumerCallBridge09 consumerCallBridge,
String threadName,
long pollTimeout,
boolean useMetrics,
org.apache.flink.metrics.MetricGroup consumerMetricGroup,
org.apache.flink.metrics.MetricGroup subtaskMetricGroup,
org.apache.flink.api.common.io.ratelimiting.FlinkConnectorRateLimiter rateLimiter) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected org.apache.kafka.clients.consumer.ConsumerRecords<byte[],byte[]> |
getRecordsFromKafka()
Get records from Kafka.
|
void |
run() |
void |
shutdown()
Shuts this thread down, waking up the thread gracefully if blocked (without Thread.interrupt() calls).
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic KafkaConsumerThread(org.slf4j.Logger log,
Handover handover,
Properties kafkaProperties,
org.apache.flink.streaming.connectors.kafka.internals.ClosableBlockingQueue<org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartitionState<org.apache.kafka.common.TopicPartition>> unassignedPartitionsQueue,
KafkaConsumerCallBridge09 consumerCallBridge,
String threadName,
long pollTimeout,
boolean useMetrics,
org.apache.flink.metrics.MetricGroup consumerMetricGroup,
org.apache.flink.metrics.MetricGroup subtaskMetricGroup,
org.apache.flink.api.common.io.ratelimiting.FlinkConnectorRateLimiter rateLimiter)
public void shutdown()
@VisibleForTesting protected org.apache.kafka.clients.consumer.ConsumerRecords<byte[],byte[]> getRecordsFromKafka()
rateLimiter.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.