Class NetworkClientDelegate

java.lang.Object
org.apache.kafka.clients.consumer.internals.NetworkClientDelegate
All Implemented Interfaces:
AutoCloseable

public class NetworkClientDelegate extends Object implements AutoCloseable
A wrapper around the NetworkClient to handle network poll and send operations.
  • 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

    • isUnavailable

      public boolean isUnavailable(org.apache.kafka.common.Node node)
      Check if the node is disconnected and unavailable for immediate reconnection (i.e. if it is in reconnect backoff window following the disconnect).
      Parameters:
      node - Node to check for availability
      See Also:
      • NetworkClientUtils.isUnavailable(KafkaClient, Node, Time)
    • 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 - Node to check for a previous AuthenticationException; if found it is thrown
      See Also:
      • NetworkClientUtils.maybeThrowAuthFailure(KafkaClient, Node)
    • 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 time
      currentTimeMs - current time
    • checkDisconnects

      protected void checkDisconnects(long currentTimeMs)
    • leastLoadedNode

      public org.apache.kafka.common.Node leastLoadedNode()
    • wakeup

      public void wakeup()
    • nodeUnavailable

      public boolean nodeUnavailable(org.apache.kafka.common.Node node)
      Check if the code is disconnected and unavailable for immediate reconnection (i.e. if it is in reconnect backoff window following the disconnect).
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException
    • addAll

      public long addAll(NetworkClientDelegate.PollResult pollResult)
    • addAll

      public void addAll(List<NetworkClientDelegate.UnsentRequest> requests)
    • 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 a Supplier for deferred creation during invocation by ConsumerNetworkThread.