Class NetworkClientDelegate
java.lang.Object
org.apache.kafka.clients.consumer.internals.NetworkClientDelegate
- All Implemented Interfaces:
AutoCloseable
A wrapper around the
NetworkClient to handle network poll and send operations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
ConstructorsConstructorDescriptionNetworkClientDelegate(org.apache.kafka.common.utils.Time time, ConsumerConfig config, org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.clients.KafkaClient client) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddAll(List<NetworkClientDelegate.UnsentRequest> requests) longaddAll(NetworkClientDelegate.PollResult pollResult) protected voidcheckDisconnects(long currentTimeMs) voidclose()booleanisUnavailable(org.apache.kafka.common.Node node) Check if the node is disconnected and unavailable for immediate reconnection (i.e.org.apache.kafka.common.NodevoidmaybeThrowAuthFailure(org.apache.kafka.common.Node node) Checks for an authentication error on a given node and throws the exception if it exists.booleannodeUnavailable(org.apache.kafka.common.Node node) Check if the code is disconnected and unavailable for immediate reconnection (i.e.voidpoll(long timeoutMs, long currentTimeMs) Returns the responses of the sent requests.static Supplier<NetworkClientDelegate> supplier(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.utils.LogContext logContext, ConsumerMetadata metadata, ConsumerConfig config, org.apache.kafka.clients.ApiVersions apiVersions, org.apache.kafka.common.metrics.Metrics metrics, FetchMetricsManager fetchMetricsManager, org.apache.kafka.common.telemetry.internals.ClientTelemetrySender clientTelemetrySender) Creates aSupplierfor deferred creation during invocation byConsumerNetworkThread.voidtryConnect(org.apache.kafka.common.Node node) Initiate a connection if currently possible.voidwakeup()
-
Constructor Details
-
NetworkClientDelegate
public NetworkClientDelegate(org.apache.kafka.common.utils.Time time, ConsumerConfig config, org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.clients.KafkaClient client)
-
-
Method Details
-
maybeThrowAuthFailure
public void maybeThrowAuthFailure(org.apache.kafka.common.Node node) Checks for an authentication error on a given node and throws the exception if it exists.- Parameters:
node-Nodeto check for a previousAuthenticationException; if found it is thrown- See Also:
-
tryConnect
public void tryConnect(org.apache.kafka.common.Node node) Initiate a connection if currently possible. This is only really useful for resetting the failed status of a socket.- Parameters:
node- The node to connect to
-
poll
public void poll(long timeoutMs, long currentTimeMs) Returns the responses of the sent requests. This method will try to send the unsent requests, poll for responses, and check the disconnected nodes.- Parameters:
timeoutMs- timeout timecurrentTimeMs- current time
-
checkDisconnects
protected void checkDisconnects(long currentTimeMs) -
leastLoadedNode
public org.apache.kafka.common.Node leastLoadedNode() -
wakeup
public void wakeup() -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
addAll
-
addAll
-
add
-
supplier
public static Supplier<NetworkClientDelegate> supplier(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.utils.LogContext logContext, ConsumerMetadata metadata, ConsumerConfig config, org.apache.kafka.clients.ApiVersions apiVersions, org.apache.kafka.common.metrics.Metrics metrics, FetchMetricsManager fetchMetricsManager, org.apache.kafka.common.telemetry.internals.ClientTelemetrySender clientTelemetrySender) Creates aSupplierfor deferred creation during invocation byConsumerNetworkThread.