KAFKA-17750: Extend kafka-consumer-groups command line tool to support new consumer group (part 2)#18034
Conversation
dajac
left a comment
There was a problem hiding this comment.
@FrankYang0529 Thanks for the patch. I left a few suggestions and questions for consideration.
| Optional.empty(), Optional.empty()); | ||
| } | ||
|
|
||
| public ConsumerGroupDescription(String groupId, |
There was a problem hiding this comment.
Was this constructor introduced in 4.0 only? It seems to be the case but we need to double check. If it is not, we would need to introduce a new one in order to not break existing usages.
There was a problem hiding this comment.
This constructor is introduced in 4.0. It is not existent in 3.9.
There was a problem hiding this comment.
We can remove the two constructors directly, as doing so does not result in any compatibility issues.
| private final Optional<Integer> memberEpoch; | ||
| private final Optional<Boolean> isClassic; | ||
|
|
||
| public MemberDescription(String memberId, |
There was a problem hiding this comment.
Here, I suppose that we must introduce a new overload of the constructor with the new arguments in order to not break compatibility of existing usages.
There was a problem hiding this comment.
Thanks for reminder. Updated it.
There was a problem hiding this comment.
Have we considered deprecating the other constructors? It seems odd to have so many constructors.
There was a problem hiding this comment.
Updated both PR and KIP. Thanks for the suggestion.
| ) { | ||
| Optional<MemberAssignment> targetAssignment, | ||
| Optional<Integer> memberEpoch, | ||
| Optional<Boolean> isClassic) { |
There was a problem hiding this comment.
nit: Let's keep the closing ) on a new line as it was before.
| } | ||
|
|
||
| /** | ||
| * The flag indicating whether a member is classic. |
There was a problem hiding this comment.
nit: How about The flag indicating whether a member with a consumer group uses the classic protocol. It indicates that the member was perhaps not upgraded?
| /** | ||
| * The flag indicating whether a member is classic. | ||
| */ | ||
| public Optional<Boolean> isClassic() { |
There was a problem hiding this comment.
Sorry for coming back on this one but I just thought about an alternative. How about calling it nonUpgraded? We could set it to true when the group is a consumer group and the member uses classic protocol. We could also only set it when the group is a consumer group vs a classic group. This may be even more explicit for users. What do you think? @chia7712 Do you have any thoughts too?
There was a problem hiding this comment.
How about calling it nonUpgraded? We could set it to true when the group is a consumer group and the member uses classic protocol.
How about using "upgraded"? it is true only if the group is a consumer group and the member uses the consumer protocol.
There was a problem hiding this comment.
That works too. Something as follow?
- Classic Group -> Optional.empty
- Consumer Group -> Optional.empty if unknown
- Consumer Group -> Optional.of(false) if classic
- Consumer Group -> Optional.of(true) if consumer
There was a problem hiding this comment.
Thanks for the suggestion. Updated PR and KIP.
bf9ea6b to
b61e4b5
Compare
chia7712
left a comment
There was a problem hiding this comment.
@FrankYang0529 thanks for this patch
| Optional.empty(), Optional.empty()); | ||
| } | ||
|
|
||
| public ConsumerGroupDescription(String groupId, |
There was a problem hiding this comment.
We can remove the two constructors directly, as doing so does not result in any compatibility issues.
| ", targetAssignment=" + targetAssignment + ")"; | ||
| ", targetAssignment=" + targetAssignment + | ||
| ", memberEpoch=" + memberEpoch.orElse(null) + | ||
| ", isClassic=" + upgraded.orElse(null) + |
| private final Optional<Integer> memberEpoch; | ||
| private final Optional<Boolean> isClassic; | ||
|
|
||
| public MemberDescription(String memberId, |
There was a problem hiding this comment.
Have we considered deprecating the other constructors? It seems odd to have so many constructors.
b61e4b5 to
22f9dd6
Compare
1486622 to
9361113
Compare
dajac
left a comment
There was a problem hiding this comment.
@FrankYang0529 Thanks for the update. I left some more comments for consideration.
| public MemberDescription(String memberId, | ||
| Optional<String> groupInstanceId, | ||
| String clientId, | ||
| String host, | ||
| MemberAssignment assignment, | ||
| Optional<MemberAssignment> targetAssignment | ||
| ) { |
There was a problem hiding this comment.
nit: I think that we are mixing two code styles here. We would usually use:
public MemberDescription(
String memberId,
Optional<String> groupInstanceId,
String clientId,
String host,
MemberAssignment assignment,
Optional<MemberAssignment> targetAssignment
) {
or
public MemberDescription(String memberId,
Optional<String> groupInstanceId,
String clientId,
String host,
MemberAssignment assignment,
Optional<MemberAssignment> targetAssignment) {
I personally prefer the first one but it is up to you.
| * True for consumer member. | ||
| * False for classic member | ||
| * Empty for unknown or members in classic group. |
There was a problem hiding this comment.
nit: I suggest to reference the group type in the java doc in order to be crystal clear. e.g.
The flag indicating whether a member within a {CONSUMER} group uses the {CONSUMER} protocol.
The optional is set to true if it does, to false if it does not, and to empty if it is unknown or if the group
is a {CLASSIC} group.
| ))) | ||
| ))), | ||
| Optional.of(10), | ||
| Optional.of(true) |
There was a problem hiding this comment.
Should we cover the unknown and the classic cases in the tests too?
There was a problem hiding this comment.
Add classic case to testSuccessfulHandleConsumerGroupResponse. For unknown case, I think it's covered by testSuccessfulHandleClassicGroupResponse. Thanks.
| assertEquals(groupType == GroupType.CLASSIC, testGroupDescription.groupEpoch.isEmpty) | ||
| assertEquals(groupType == GroupType.CLASSIC, testGroupDescription.targetAssignmentEpoch.isEmpty) |
There was a problem hiding this comment.
Would it be possible to actually verify the values too?
There was a problem hiding this comment.
I would like to verify values here, but the case is only for classic now. It's waiting for https://issues.apache.org/jira/browse/KAFKA-17960. Could we add it after we reopen consumer for this case? Thanks.
| members.asScala.foreach(member => { | ||
| assertEquals(testClientId, member.clientId) | ||
| assertEquals(if (groupType == GroupType.CLASSIC) Optional.empty else Optional.of(true), member.upgraded) | ||
| }) |
There was a problem hiding this comment.
nit: foreach(member => { -> foreach { member =>
|
|
||
| val classicMember = group.members.asScala.find(_.clientId == testClassicClientId) | ||
| assertTrue(classicMember.isDefined) | ||
| assertTrue(classicMember.get.memberEpoch.isPresent && classicMember.get.memberEpoch.get > 0) |
There was a problem hiding this comment.
assertEquals(Optional.of(2), classicMember.get.memberEpoch).
| val classicMember = group.members.asScala.find(_.clientId == testClassicClientId) | ||
| assertTrue(classicMember.isDefined) | ||
| assertTrue(classicMember.get.memberEpoch.isPresent && classicMember.get.memberEpoch.get > 0) | ||
| assertTrue(classicMember.get.upgraded.isPresent && !classicMember.get.upgraded.get) |
There was a problem hiding this comment.
assertEquals(Optional.of(false), classicMember.get.upgraded).
| assertTrue(classicMember.get.memberEpoch.isPresent && classicMember.get.memberEpoch.get > 0) | ||
| assertTrue(consumerMember.get.upgraded.isPresent && consumerMember.get.upgraded.get) |
| } | ||
|
|
||
| /** | ||
| * The epoch of the group member. |
There was a problem hiding this comment.
nit: Let's also mention that this is only provided in the CONSUMER group case.
| /** | ||
| * The epoch of the consumer group. | ||
| */ | ||
| public Optional<Integer> groupEpoch() { | ||
| return groupEpoch; | ||
| } | ||
|
|
||
| /** | ||
| * The epoch of the target assignment. | ||
| */ | ||
| public Optional<Integer> targetAssignmentEpoch() { | ||
| return targetAssignmentEpoch; | ||
| } |
There was a problem hiding this comment.
Let's also mention here that they are only provided when the type is consumer.
263c615 to
69bd0f3
Compare
…t new consumer group (part 2) Signed-off-by: PoAn Yang <payang@apache.org>
69bd0f3 to
9c37588
Compare
|
Hi @dajac, could you please help me review this PR when you have time? I would like to keep working on last part of KIP-1099 (tool). Thanks. |
|
@FrankYang0529 Done :) |
|
@FrankYang0529 Could you please file a minor to fix the deprecation warning introduced by this PR? |
Thanks for finding this. Create a PR for it. |
…t new consumer group (part 2) (apache#18034) * Add fields `groupEpoch` and `targetAssignmentEpoch` to `ConsumerGroupDescription.java`. * Add fields `memberEpoch` and `upgraded` to `MemberDescription.java`. * Add assertion to `PlaintextAdminIntegrationTest#testDescribeClassicGroups` to make sure member in classic group returns `upgraded` as `Optional.empty`. * Add new case `testConsumerGroupWithMemberMigration` to `PlaintextAdminIntegrationTest` to make sure migration member has correct `upgraded` value. Add assertion for `groupEpoch`, `targetAssignmentEpoch`, `memberEpoch` as well. Reviewers: David Jacot <djacot@confluent.io> Signed-off-by: PoAn Yang <payang@apache.org>
…t new consumer group (part 2) (apache#18034) * Add fields `groupEpoch` and `targetAssignmentEpoch` to `ConsumerGroupDescription.java`. * Add fields `memberEpoch` and `upgraded` to `MemberDescription.java`. * Add assertion to `PlaintextAdminIntegrationTest#testDescribeClassicGroups` to make sure member in classic group returns `upgraded` as `Optional.empty`. * Add new case `testConsumerGroupWithMemberMigration` to `PlaintextAdminIntegrationTest` to make sure migration member has correct `upgraded` value. Add assertion for `groupEpoch`, `targetAssignmentEpoch`, `memberEpoch` as well. Reviewers: David Jacot <djacot@confluent.io> Signed-off-by: PoAn Yang <payang@apache.org>
groupEpochandtargetAssignmentEpochtoConsumerGroupDescription.java.memberEpochandupgradedtoMemberDescription.java.PlaintextAdminIntegrationTest#testDescribeClassicGroupsto make sure member in classic group returnsupgradedasOptional.empty.testConsumerGroupWithMemberMigrationtoPlaintextAdminIntegrationTestto make sure migration member has correctupgradedvalue. Add assertion forgroupEpoch,targetAssignmentEpoch,memberEpochas well.Committer Checklist (excluded from commit message)