-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-14701; Move PartitionAssignor to new group-coordinator-api module
#16198
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
7dd66cc
751a1b6
40be636
0bc37f1
e4e776e
ba759aa
9999430
445eecb
f1e3d32
cf884b9
4479672
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 |
|---|---|---|
|
|
@@ -14,17 +14,17 @@ | |
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.coordinator.group.assignor; | ||
| package org.apache.kafka.coordinator.group.api.assignor; | ||
|
|
||
| import org.apache.kafka.common.Uuid; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * The group metadata specifications required to compute the target assignment. | ||
| */ | ||
| @InterfaceStability.Unstable | ||
| public interface GroupSpec { | ||
| /** | ||
| * @return All the member Ids of the consumer group. | ||
|
|
@@ -45,18 +45,18 @@ public interface GroupSpec { | |
| /** | ||
| * Gets the member subscription specification for a member. | ||
| * | ||
| * @param memberId The member Id. | ||
| * @param memberId The member Id. | ||
| * @return The member's subscription metadata. | ||
| * @throws IllegalArgumentException If the member Id isn't found. | ||
| */ | ||
| MemberSubscriptionSpec memberSubscription(String memberId); | ||
|
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. nit: why did we rename it to MemberSubscription?
Member
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. Now that we have |
||
| MemberSubscription memberSubscription(String memberId); | ||
|
|
||
| /** | ||
| * Gets the current assignment of the member. | ||
| * | ||
| * @param memberId The member Id. | ||
| * @return A map of topic Ids to sets of partition numbers. | ||
| * An empty map is returned if the member Id isn't found. | ||
| * @param memberId The member Id. | ||
| * @return The member's assignment or an empty assignment if the | ||
| * member does not have one. | ||
| */ | ||
| Map<Uuid, Set<Integer>> memberAssignment(String memberId); | ||
| MemberAssignment memberAssignment(String memberId); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * 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.coordinator.group.api.assignor; | ||
|
|
||
| import org.apache.kafka.common.Uuid; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * The partition assignment for a consumer group member. | ||
| */ | ||
| @InterfaceStability.Unstable | ||
| public interface MemberAssignment { | ||
|
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. Thanks for the change! I was wondering if this should be in a separate PR? Since it's not related to moving files to different modules and we're adding a new interface and making changes as a consequence?
Member
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. We could have done a separate PR but it is also fine doing it here as the main reviewer asked for it.
Member
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. oh, i neglected this PR aims to complete the migration, but I do love this change 😄 |
||
| /** | ||
| * @return The assigned partitions keyed by topic Ids. | ||
| */ | ||
| Map<Uuid, Set<Integer>> partitions(); | ||
| } | ||
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 noticed that not all interfaces have
@InterfaceStability.Unstable. Could you share the context to me?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.
For another,
GroupSpec#MemberSubscriptionSpecreturn the interface butGroupSpec#memberAssignmentreturn a map struct. If it is public API now, maybe returnMemberAssignmentis more flexible if we want to enrich it in the future?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.
Fixed. Thanks.
Good question. Reusing
MemberAssignmentis not ideal because we want to have the ability to pass internal objects. In this case, it could be backed by theAssignment. So, we could think of using an interface though.On thing to consider is whether the
MemberAssignmentreturned by the assignor would always be the same as the one provided to the assignor. The actual assignment (the map) is for sure. What do you think?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.
+1
not sure whether I have got the point. The member assignment in
GroupAssignmentreturned fromPartitionAssignor#assignis the new assignment. Hence, it should be different to assignment inGroupSpec.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.
You suggested to use
MemberAssignmentin your previous comment.MemberAssignmentis already used inGroupAssignmentreturned byPartitionAssignor#assign. I am not sure if you meant to reuse the sameMemberAssignmentin both places.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.
ummm, I guess I did not notice MemberAssignment is used by
GroupAssignmentbefore :_Anyway, having a interface to replace
Mapstruct is good way to me. Or we can keep current version if the tag "unstable" give the room to modify those public stuff :)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 am playing with this. I will suggest something a bit later today.
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.
@chia7712 I gave it a go. You can check the last commit to see how it looks like. I also moved some classes between internal packages while here.