-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-14365: Extract common logic from Fetcher #13425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,8 @@ | |||||
| import org.apache.kafka.clients.consumer.internals.ConsumerMetadata; | ||||||
| import org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient; | ||||||
| import org.apache.kafka.clients.consumer.internals.Fetch; | ||||||
| import org.apache.kafka.clients.consumer.internals.FetchConfig; | ||||||
| import org.apache.kafka.clients.consumer.internals.FetchMetricsManager; | ||||||
| import org.apache.kafka.clients.consumer.internals.Fetcher; | ||||||
| import org.apache.kafka.clients.consumer.internals.FetchMetricsRegistry; | ||||||
| import org.apache.kafka.clients.consumer.internals.KafkaConsumerMetrics; | ||||||
|
|
@@ -590,7 +592,7 @@ public class KafkaConsumer<K, V> implements Consumer<K, V> { | |||||
| private final long requestTimeoutMs; | ||||||
| private final int defaultApiTimeoutMs; | ||||||
| private volatile boolean closed = false; | ||||||
| private List<ConsumerPartitionAssignor> assignors; | ||||||
| private final List<ConsumerPartitionAssignor> assignors; | ||||||
|
|
||||||
| // currentThread holds the threadId of the current thread accessing KafkaConsumer | ||||||
| // and is used to prevent multi-threaded access | ||||||
|
|
@@ -738,10 +740,10 @@ public KafkaConsumer(Map<String, Object> configs, | |||||
| String metricGrpPrefix = "consumer"; | ||||||
|
|
||||||
| FetchMetricsRegistry metricsRegistry = new FetchMetricsRegistry(Collections.singleton(CLIENT_ID_METRIC_TAG), metricGrpPrefix); | ||||||
| FetchMetricsManager fetchMetricsManager = new FetchMetricsManager(metrics, metricsRegistry); | ||||||
| ChannelBuilder channelBuilder = ClientUtils.createChannelBuilder(config, time, logContext); | ||||||
| this.isolationLevel = IsolationLevel.valueOf( | ||||||
| config.getString(ConsumerConfig.ISOLATION_LEVEL_CONFIG).toUpperCase(Locale.ROOT)); | ||||||
| Sensor throttleTimeSensor = Fetcher.throttleTimeSensor(metrics, metricsRegistry); | ||||||
| int heartbeatIntervalMs = config.getInt(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG); | ||||||
|
|
||||||
| ApiVersions apiVersions = new ApiVersions(); | ||||||
|
|
@@ -760,7 +762,7 @@ public KafkaConsumer(Map<String, Object> configs, | |||||
| time, | ||||||
| true, | ||||||
| apiVersions, | ||||||
| throttleTimeSensor, | ||||||
| fetchMetricsManager.throttleTimeSensor(), | ||||||
| logContext); | ||||||
| this.client = new ConsumerNetworkClient( | ||||||
| logContext, | ||||||
|
|
@@ -797,24 +799,15 @@ public KafkaConsumer(Map<String, Object> configs, | |||||
| config.getBoolean(ConsumerConfig.THROW_ON_FETCH_STABLE_OFFSET_UNSUPPORTED), | ||||||
| config.getString(ConsumerConfig.CLIENT_RACK_CONFIG)); | ||||||
| } | ||||||
| FetchConfig<K, V> fetchConfig = new FetchConfig<>(config, keyDeserializer, valueDeserializer, isolationLevel); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a nice improvement, +1!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kirktrue , these should be |
||||||
| this.fetcher = new Fetcher<>( | ||||||
| logContext, | ||||||
| this.client, | ||||||
| config.getInt(ConsumerConfig.FETCH_MIN_BYTES_CONFIG), | ||||||
| config.getInt(ConsumerConfig.FETCH_MAX_BYTES_CONFIG), | ||||||
| config.getInt(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG), | ||||||
| config.getInt(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG), | ||||||
| config.getInt(ConsumerConfig.MAX_POLL_RECORDS_CONFIG), | ||||||
| config.getBoolean(ConsumerConfig.CHECK_CRCS_CONFIG), | ||||||
| config.getString(ConsumerConfig.CLIENT_RACK_CONFIG), | ||||||
| this.keyDeserializer, | ||||||
| this.valueDeserializer, | ||||||
| this.metadata, | ||||||
| this.subscriptions, | ||||||
| metrics, | ||||||
| metricsRegistry, | ||||||
| this.time, | ||||||
| isolationLevel); | ||||||
| fetchConfig, | ||||||
| fetchMetricsManager, | ||||||
| this.time); | ||||||
| this.offsetFetcher = new OffsetFetcher(logContext, | ||||||
| client, | ||||||
| metadata, | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.