-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-8179: Part 3, Add PartitionsLost API for resetGenerations and metadata/subscription change #6884
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
KAFKA-8179: Part 3, Add PartitionsLost API for resetGenerations and metadata/subscription change #6884
Changes from all commits
4cf89e6
094ab43
368f2bc
cb9fb49
f7ab5e2
347ca5f
b290283
d3af860
cb25f6c
801dd0b
0a4aa1d
3f2fe2e
bb98793
d1064c4
829d3c2
2b2d8b1
c22266b
1fa089a
16f75ab
e049e5f
92320ba
ff1b9a6
908fda4
3e1fb1c
2e9a291
bd60fd2
74a9895
c85ed6e
16c13ad
ec80f42
60b55e1
5325e56
72e70d6
ba97f99
e54d8e1
dfb3583
b3daf5e
cc4c292
99cafcd
dd37aa1
cf66222
d56b1f3
f67942f
e9a3071
11b1915
a862df0
8440e7d
30452db
091062e
c95e176
d112c5c
332c213
9ceb83f
dc4ad4d
3b0b667
cc30e1d
65f7c68
a4f584f
e4fdcb0
fb5b1e1
0436146
10c1f97
ca7bf32
8373b41
ddfe28f
4e46690
0c2486c
60f8c9c
b1d779f
6082f24
90e6050
33688bf
234f237
700be68
8edb9e1
ac67975
4b0e170
53cd8ea
f1baeb4
178f35e
0e51217
c1a265a
56b54a2
ef901b0
8220d8e
5ed5a0a
58913e4
6d07d42
fde3c9b
67b33ab
6041a79
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 |
|---|---|---|
|
|
@@ -1046,14 +1046,18 @@ public void subscribe(Pattern pattern) { | |
| /** | ||
| * Unsubscribe from topics currently subscribed with {@link #subscribe(Collection)} or {@link #subscribe(Pattern)}. | ||
| * This also clears any partitions directly assigned through {@link #assign(Collection)}. | ||
| * | ||
| * @throws org.apache.kafka.common.KafkaException for any other unrecoverable errors (e.g. rebalance callback errors) | ||
|
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. It might be worth mentioning in the upgrade notes the fact that we now invoke revocation logic in
Contributor
Author
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. Yes, that's in my plan -- I have another PR on web docs for the changes related, but wanted to keep this one from continue growing. |
||
| */ | ||
| public void unsubscribe() { | ||
| acquireAndEnsureOpen(); | ||
| try { | ||
| fetcher.clearBufferedDataForUnassignedPartitions(Collections.emptySet()); | ||
| this.subscriptions.unsubscribe(); | ||
| if (this.coordinator != null) | ||
| if (this.coordinator != null) { | ||
| this.coordinator.onLeavePrepare(); | ||
| this.coordinator.maybeLeaveGroup("the consumer unsubscribed from all topics"); | ||
| } | ||
| log.info("Unsubscribed all topics or patterns and assigned partitions"); | ||
| } finally { | ||
| release(); | ||
|
|
@@ -1176,7 +1180,8 @@ public ConsumerRecords<K, V> poll(final long timeoutMs) { | |
| * @throws org.apache.kafka.common.errors.AuthorizationException if caller lacks Read access to any of the subscribed | ||
| * topics or to the configured groupId. See the exception for more details | ||
| * @throws org.apache.kafka.common.KafkaException for any other unrecoverable errors (e.g. invalid groupId or | ||
| * session timeout, errors deserializing key/value pairs, or any new error cases in future versions) | ||
| * session timeout, errors deserializing key/value pairs, your rebalance callback thrown exceptions, | ||
| * or any new error cases in future versions) | ||
| * @throws java.lang.IllegalArgumentException if the timeout value is negative | ||
| * @throws java.lang.IllegalStateException if the consumer is not subscribed to any topics or manually assigned any | ||
| * partitions to consume from | ||
|
|
@@ -1190,6 +1195,9 @@ public ConsumerRecords<K, V> poll(final Duration timeout) { | |
| return poll(time.timer(timeout), true); | ||
| } | ||
|
|
||
| /** | ||
| * @throws KafkaException if the rebalance callback throws exception | ||
| */ | ||
| private ConsumerRecords<K, V> poll(final Timer timer, final boolean includeMetadataInTimeout) { | ||
| acquireAndEnsureOpen(); | ||
| try { | ||
|
|
@@ -1244,6 +1252,9 @@ boolean updateAssignmentMetadataIfNeeded(final Timer timer) { | |
| return updateFetchPositions(timer); | ||
| } | ||
|
|
||
| /** | ||
| * @throws KafkaException if the rebalance callback throws exception | ||
| */ | ||
| private Map<TopicPartition, List<ConsumerRecord<K, V>>> pollForFetches(Timer timer) { | ||
| long pollTimeout = coordinator == null ? timer.remainingMs() : | ||
| Math.min(coordinator.timeToNextPoll(timer.currentTimeMs()), timer.remainingMs()); | ||
|
|
@@ -2162,10 +2173,12 @@ public void close(Duration timeout) { | |
| acquire(); | ||
| try { | ||
| if (!closed) { | ||
| closed = true; | ||
| // need to close before setting the flag since the close function | ||
| // itself may trigger rebalance callback that needs the consumer to be open still | ||
| close(timeout.toMillis(), false); | ||
| } | ||
| } finally { | ||
| closed = true; | ||
| release(); | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.