Class ConsumerNetworkThread
java.lang.Object
java.lang.Thread
org.apache.kafka.common.utils.KafkaThread
org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread
- All Implemented Interfaces:
Closeable,AutoCloseable,Runnable
public class ConsumerNetworkThread
extends org.apache.kafka.common.utils.KafkaThread
implements Closeable
Background thread runnable that consumes
ApplicationEvent and produces BackgroundEvent. It
uses an event loop to consume and produce events, and poll the network client to handle network IO.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionConsumerNetworkThread(org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.common.utils.Time time, Supplier<ApplicationEventProcessor> applicationEventProcessorSupplier, Supplier<NetworkClientDelegate> networkClientDelegateSupplier, Supplier<RequestManagers> requestManagersSupplier) -
Method Summary
Methods inherited from class org.apache.kafka.common.utils.KafkaThread
daemon, nonDaemonMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
ConsumerNetworkThread
public ConsumerNetworkThread(org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.common.utils.Time time, Supplier<ApplicationEventProcessor> applicationEventProcessorSupplier, Supplier<NetworkClientDelegate> networkClientDelegateSupplier, Supplier<RequestManagers> requestManagersSupplier)
-
-
Method Details
-
run
public void run() -
isRunning
public boolean isRunning() -
wakeup
public void wakeup() -
maximumTimeToWait
public long maximumTimeToWait()Returns the delay for which the application thread can safely wait before it should be responsive to results from the request managers. For example, the subscription state can change when heartbeats are sent, so blocking for longer than the heartbeat interval might mean the application thread is not responsive to changes. Because this method is called by the application thread, it's not allowed to access the request managers that actually provide the information. As a result, the consumer network thread periodically caches the information from the request managers and this can then be read safely using this method.- Returns:
- The maximum delay in milliseconds
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
close
-