Class ConsumerUtils

java.lang.Object
org.apache.kafka.clients.consumer.internals.ConsumerUtils

public final class ConsumerUtils extends Object
  • Field Details

    • DEFAULT_CLOSE_TIMEOUT_MS

      public static final long DEFAULT_CLOSE_TIMEOUT_MS
      See Also:
    • CONSUMER_JMX_PREFIX

      public static final String CONSUMER_JMX_PREFIX
      See Also:
    • CONSUMER_METRIC_GROUP_PREFIX

      public static final String CONSUMER_METRIC_GROUP_PREFIX
      See Also:
    • CONSUMER_MAX_INFLIGHT_REQUESTS_PER_CONNECTION

      public static final int CONSUMER_MAX_INFLIGHT_REQUESTS_PER_CONNECTION
      A fixed, large enough value will suffice for max.
      See Also:
  • Constructor Details

    • ConsumerUtils

      public ConsumerUtils()
  • Method Details

    • createConsumerNetworkClient

      public static ConsumerNetworkClient createConsumerNetworkClient(ConsumerConfig config, org.apache.kafka.common.metrics.Metrics metrics, org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.clients.ApiVersions apiVersions, org.apache.kafka.common.utils.Time time, org.apache.kafka.clients.Metadata metadata, org.apache.kafka.common.metrics.Sensor throttleTimeSensor, long retryBackoffMs, org.apache.kafka.common.telemetry.internals.ClientTelemetrySender clientTelemetrySender)
    • createLogContext

      public static org.apache.kafka.common.utils.LogContext createLogContext(ConsumerConfig config, org.apache.kafka.clients.GroupRebalanceConfig groupRebalanceConfig)
    • configuredIsolationLevel

      public static org.apache.kafka.common.IsolationLevel configuredIsolationLevel(ConsumerConfig config)
    • createSubscriptionState

      public static SubscriptionState createSubscriptionState(ConsumerConfig config, org.apache.kafka.common.utils.LogContext logContext)
    • createMetrics

      public static org.apache.kafka.common.metrics.Metrics createMetrics(ConsumerConfig config, org.apache.kafka.common.utils.Time time)
    • createMetrics

      public static org.apache.kafka.common.metrics.Metrics createMetrics(ConsumerConfig config, org.apache.kafka.common.utils.Time time, List<org.apache.kafka.common.metrics.MetricsReporter> reporters)
    • createFetchMetricsManager

      public static FetchMetricsManager createFetchMetricsManager(org.apache.kafka.common.metrics.Metrics metrics)
    • configuredConsumerInterceptors

      public static <K, V> List<ConsumerInterceptor<K,V>> configuredConsumerInterceptors(ConsumerConfig config)
    • refreshCommittedOffsets

      public static void refreshCommittedOffsets(Map<org.apache.kafka.common.TopicPartition,OffsetAndMetadata> offsetsAndMetadata, ConsumerMetadata metadata, SubscriptionState subscriptions)
      Update subscription state and metadata using the provided committed offsets:
    • Update partition offsets with the committed offsets
    • Update the metadata with any newer leader epoch discovered in the committed offsets metadata
    • This will ignore any partition included in the offsetsAndMetadata parameter that may no longer be assigned.
      Parameters:
      offsetsAndMetadata - Committed offsets and metadata to be used for updating the subscription state and metadata object.
      metadata - Metadata object to update with a new leader epoch if discovered in the committed offsets' metadata.
      subscriptions - Subscription state to update, setting partitions' offsets to the committed offsets.
    • getResult

      public static <T> T getResult(Future<T> future, org.apache.kafka.common.utils.Timer timer)
    • getResult

      public static <T> T getResult(Future<T> future)
    • maybeWrapAsKafkaException

      public static org.apache.kafka.common.KafkaException maybeWrapAsKafkaException(Throwable t)
    • maybeWrapAsKafkaException

      public static org.apache.kafka.common.KafkaException maybeWrapAsKafkaException(Throwable t, String message)