-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-13888: Addition of Information in DescribeQuorumResponse about Voter Lag #12206
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
Merged
hachikuji
merged 16 commits into
apache:trunk
from
niket-goel:kafka-13888-describe-quorum-additions
Jun 15, 2022
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
efb9c20
KAFKA-13888: Addition of Information in DescribeQuorumResponse about …
niket-goel b85a5d8
Addressing review comments
niket-goel 1b1c022
Addressing review comments
niket-goel d517ac9
Addressing more feedback from the review
niket-goel 805d685
Fixing some minor comments
niket-goel cfde869
minor: removing some unused code
niket-goel 985a8ad
Addressing comments and improving DescribeMetadatga Quorum API handling
niket-goel ca26c56
Addressing more feedback. Adding some missing test scenarios and fixi…
niket-goel 07bcc41
Minor: removing a refactored field from a test
niket-goel 668b368
More review feedback
niket-goel 73f3b31
strengthening a check
niket-goel b4cc945
Fxing a typo in the comments
niket-goel 51f7dd2
minor: additional test checks
niket-goel 868b567
Tightening up the code a bit based on some more feedback
niket-goel 9d1d90f
minor: some code styling fixes
niket-goel 739b400
Removing KRaftClusterTest Integration Test causing flakiness due to K…
niket-goel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
clients/src/main/java/org/apache/kafka/clients/admin/DescribeMetadataQuorumOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.clients.admin; | ||
|
|
||
| /** | ||
| * Options for {@link Admin#describeMetadataQuorum(DescribeMetadataQuorumOptions)} | ||
| */ | ||
| public class DescribeMetadataQuorumOptions extends AbstractOptions<DescribeMetadataQuorumOptions> { | ||
|
|
||
| } |
38 changes: 38 additions & 0 deletions
38
clients/src/main/java/org/apache/kafka/clients/admin/DescribeMetadataQuorumResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.clients.admin; | ||
|
|
||
| import org.apache.kafka.common.KafkaFuture; | ||
|
|
||
| /** | ||
| * The result of {@link Admin#describeMetadataQuorum(DescribeMetadataQuorumOptions)} | ||
| */ | ||
| public class DescribeMetadataQuorumResult { | ||
|
|
||
| private final KafkaFuture<QuorumInfo> quorumInfo; | ||
|
|
||
| DescribeMetadataQuorumResult(KafkaFuture<QuorumInfo> quorumInfo) { | ||
| this.quorumInfo = quorumInfo; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a future containing the QuorumInfo | ||
| */ | ||
| public KafkaFuture<QuorumInfo> quorumInfo() { | ||
| return quorumInfo; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
clients/src/main/java/org/apache/kafka/clients/admin/QuorumInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.clients.admin; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.OptionalLong; | ||
|
|
||
| /** | ||
| * This class is used to describe the state of the quorum received in DescribeQuorumResponse. | ||
| */ | ||
| public class QuorumInfo { | ||
| private final Integer leaderId; | ||
| private final List<ReplicaState> voters; | ||
| private final List<ReplicaState> observers; | ||
|
|
||
| QuorumInfo(Integer leaderId, List<ReplicaState> voters, List<ReplicaState> observers) { | ||
| this.leaderId = leaderId; | ||
| this.voters = voters; | ||
| this.observers = observers; | ||
| } | ||
|
|
||
| public Integer leaderId() { | ||
| return leaderId; | ||
| } | ||
|
|
||
| public List<ReplicaState> voters() { | ||
| return voters; | ||
| } | ||
|
|
||
| public List<ReplicaState> observers() { | ||
| return observers; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| QuorumInfo that = (QuorumInfo) o; | ||
| return leaderId.equals(that.leaderId) | ||
| && voters.equals(that.voters) | ||
| && observers.equals(that.observers); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(leaderId, voters, observers); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "QuorumInfo(" + | ||
| "leaderId=" + leaderId + | ||
| ", voters=" + voters + | ||
| ", observers=" + observers + | ||
| ')'; | ||
| } | ||
|
|
||
| public static class ReplicaState { | ||
| private final int replicaId; | ||
| private final long logEndOffset; | ||
| private final OptionalLong lastFetchTimeMs; | ||
| private final OptionalLong lastCaughtUpTimeMs; | ||
|
|
||
| ReplicaState() { | ||
| this(0, 0, OptionalLong.empty(), OptionalLong.empty()); | ||
| } | ||
|
|
||
| ReplicaState( | ||
| int replicaId, | ||
| long logEndOffset, | ||
| OptionalLong lastFetchTimeMs, | ||
| OptionalLong lastCaughtUpTimeMs | ||
| ) { | ||
| this.replicaId = replicaId; | ||
| this.logEndOffset = logEndOffset; | ||
| this.lastFetchTimeMs = lastFetchTimeMs; | ||
| this.lastCaughtUpTimeMs = lastCaughtUpTimeMs; | ||
| } | ||
|
|
||
| /** | ||
| * Return the ID for this replica. | ||
| * @return The ID for this replica | ||
| */ | ||
| public int replicaId() { | ||
|
dajac marked this conversation as resolved.
Outdated
|
||
| return replicaId; | ||
| } | ||
|
|
||
| /** | ||
| * Return the logEndOffset known by the leader for this replica. | ||
| * @return The logEndOffset for this replica | ||
| */ | ||
| public long logEndOffset() { | ||
| return logEndOffset; | ||
| } | ||
|
|
||
| /** | ||
| * Return the lastFetchTime in milliseconds for this replica. | ||
| * @return The value of the lastFetchTime if known, empty otherwise | ||
| */ | ||
| public OptionalLong lastFetchTimeMs() { | ||
| return lastFetchTimeMs; | ||
| } | ||
|
|
||
| /** | ||
| * Return the lastCaughtUpTime in milliseconds for this replica. | ||
| * @return The value of the lastCaughtUpTime if known, empty otherwise | ||
| */ | ||
| public OptionalLong lastCaughtUpTimeMs() { | ||
| return lastCaughtUpTimeMs; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| ReplicaState that = (ReplicaState) o; | ||
| return replicaId == that.replicaId | ||
| && logEndOffset == that.logEndOffset | ||
| && lastFetchTimeMs.equals(that.lastFetchTimeMs) | ||
| && lastCaughtUpTimeMs.equals(that.lastCaughtUpTimeMs); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(replicaId, logEndOffset, lastFetchTimeMs, lastCaughtUpTimeMs); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ReplicaState(" + | ||
| "replicaId=" + replicaId + | ||
| ", logEndOffset=" + logEndOffset + | ||
| ", lastFetchTimeMs=" + lastFetchTimeMs + | ||
| ", lastCaughtUpTimeMs=" + lastCaughtUpTimeMs + | ||
| ')'; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is very common for API details to change during implementation. Once we're satisfied and ready to merge, we should update the KIP. Typically we would also send a message to the vote thread in case there are any concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update the KIP and the thread once this PR is approved to reflect the changes here.