-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-20790: Promote streams assignor API to public module #22788
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
Open
gabriellefu
wants to merge
16
commits into
apache:trunk
Choose a base branch
from
gabriellefu:kip1357
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
da33159
adding the new api
gabriellefu 1a44a8b
reshape the api and fix the bugs
gabriellefu d88e439
clean up the extra code
gabriellefu d7f6a4a
rename the api
gabriellefu dc38322
Merge branch 'trunk' into kip1357
gabriellefu 316278d
change taskid to interface
gabriellefu 664ce5e
adding comment about keep taskoffset
gabriellefu 034a7aa
nit
gabriellefu 5fedce1
mover compareto to taskidimpl
gabriellefu 9c6ac46
rename some param
gabriellefu 488e7cb
clean requirement logic
gabriellefu 91f106e
revert taskid
gabriellefu 8d3bd5d
rename taskidimpl back
gabriellefu aff0de5
rename memberSpec to membermetadata
gabriellefu 29f7c13
clean the newline
gabriellefu 6750fbb
wire memberassigmentstate to member.assignedTasks().warmupTasks() to …
gabriellefu 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
58 changes: 58 additions & 0 deletions
58
...-api/src/main/java/org/apache/kafka/coordinator/group/api/assignor/streams/GroupSpec.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,58 @@ | ||
| /* | ||
| * 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.streams; | ||
|
|
||
| import org.apache.kafka.common.annotation.InterfaceAudience; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * The group metadata specifications required to compute the target assignment. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| @InterfaceStability.Evolving | ||
| public interface GroupSpec { | ||
|
|
||
| /** | ||
| * @return The member Ids of all members in the group. | ||
| */ | ||
| Collection<String> memberIds(); | ||
|
|
||
| /** | ||
| * Gets the static metadata for a given member. | ||
| * | ||
| * @param memberId The member Id. | ||
| * @return The static member metadata. | ||
| */ | ||
| MemberAssignmentMetadata memberMetadata(String memberId); | ||
|
|
||
| /** | ||
| * Gets the current assignment state for a given member. | ||
| * | ||
| * @param memberId The member Id. | ||
| * @return The current member assignment state. | ||
| */ | ||
| MemberAssignmentState memberAssignmentState(String memberId); | ||
|
|
||
| /** | ||
| * @return Any configurations passed to the assignor. | ||
| */ | ||
| Map<String, String> configs(); | ||
|
|
||
| } |
45 changes: 45 additions & 0 deletions
45
...c/main/java/org/apache/kafka/coordinator/group/api/assignor/streams/MemberAssignment.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,45 @@ | ||
| /* | ||
| * 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.streams; | ||
|
|
||
| import org.apache.kafka.common.annotation.InterfaceAudience; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * The task assignment for a streams group member. | ||
| * | ||
| * <p>Only active and standby tasks are assigned by the {@link TaskAssignor}. Warm-up tasks are | ||
| * not assigned by the assignor; they are decided during reconciliation. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| @InterfaceStability.Evolving | ||
| public interface MemberAssignment { | ||
|
|
||
| /** | ||
| * @return The active tasks assigned to this member keyed by subtopology Id. | ||
| */ | ||
| Map<String, Set<Integer>> activeTasks(); | ||
|
|
||
| /** | ||
| * @return The standby tasks assigned to this member keyed by subtopology Id. | ||
| */ | ||
| Map<String, Set<Integer>> standbyTasks(); | ||
|
|
||
| } |
56 changes: 56 additions & 0 deletions
56
...ava/org/apache/kafka/coordinator/group/api/assignor/streams/MemberAssignmentMetadata.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,56 @@ | ||
| /* | ||
| * 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.streams; | ||
|
|
||
| import org.apache.kafka.common.annotation.InterfaceAudience; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Interface representing the static metadata for a streams group member. | ||
| * | ||
| * <p>The metadata contains the per-member information that does not change during the assignment | ||
| * computation. The member's current task assignment state is exposed separately through | ||
| * {@link MemberAssignmentState}. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| @InterfaceStability.Evolving | ||
| public interface MemberAssignmentMetadata { | ||
|
|
||
| /** | ||
| * @return The instance ID if provided. | ||
| */ | ||
| Optional<String> instanceId(); | ||
|
|
||
| /** | ||
| * @return The rack ID if provided. | ||
| */ | ||
| Optional<String> rackId(); | ||
|
|
||
| /** | ||
| * @return The process ID. | ||
| */ | ||
| String processId(); | ||
|
|
||
| /** | ||
| * @return The client tags for a rack-aware assignment. | ||
| */ | ||
| Map<String, String> clientTags(); | ||
|
|
||
| } |
73 changes: 73 additions & 0 deletions
73
...n/java/org/apache/kafka/coordinator/group/api/assignor/streams/MemberAssignmentState.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,73 @@ | ||
| /* | ||
| * 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.streams; | ||
|
|
||
| import org.apache.kafka.common.annotation.InterfaceAudience; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Interface representing the current assignment state for a streams group member, used by the | ||
| * {@link TaskAssignor} to compute a new, sticky target assignment. | ||
| * | ||
| * <p>The active and standby tasks are the member's current <em>target</em> assignment (the last | ||
| * assignment committed for the member). Using the committed target as the stickiness baseline keeps | ||
| * in-flight task moves converging rather than reverting them. Warm-up tasks are not assigned by the | ||
| * assignor (they are decided during reconciliation); the tasks the member is <em>currently</em> | ||
| * warming up are exposed here so that the assignor can take them into account. As a result, a task | ||
| * that is being moved to this member can appear both as an active or standby task (from the target) | ||
| * and as a warm-up task (currently in progress). | ||
| * | ||
| * <p>All accessors are keyed by subtopology ID. The task-set accessors ({@link #activeTasks()}, | ||
| * {@link #standbyTasks()}, {@link #warmupTasks()}) map each subtopology ID to its set of | ||
| * partitions, while {@link #taskOffsets()} and {@link #taskEndOffsets()} map each subtopology ID | ||
| * to a map from partition to offset. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| @InterfaceStability.Evolving | ||
| public interface MemberAssignmentState { | ||
|
|
||
| /** | ||
| * @return The member's current target active tasks keyed by subtopology Id. | ||
| */ | ||
| Map<String, Set<Integer>> activeTasks(); | ||
|
|
||
| /** | ||
| * @return The member's current target standby tasks keyed by subtopology Id. | ||
| */ | ||
| Map<String, Set<Integer>> standbyTasks(); | ||
|
|
||
| /** | ||
| * @return The tasks the member is currently warming up, keyed by subtopology Id. | ||
| */ | ||
| Map<String, Set<Integer>> warmupTasks(); | ||
|
|
||
| /** | ||
| * @return The last received cumulative task offsets of assigned tasks or dormant tasks. | ||
| * The outer map is keyed by subtopology ID and the inner map by partition. | ||
| */ | ||
| Map<String, Map<Integer, Long>> taskOffsets(); | ||
|
|
||
| /** | ||
| * @return The last received cumulative task end offsets of assigned tasks or dormant tasks. | ||
| * The outer map is keyed by subtopology ID and the inner map by partition. | ||
| */ | ||
| Map<String, Map<Integer, Long>> taskEndOffsets(); | ||
|
|
||
| } |
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
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
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
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
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.
The KIP defines this as a class, not a record. -- Given that this is an output/return type, not an input to the assignor, it might actually be ok to keep as record, and we could also update the KIP?
\cc @lianetm for input
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.
Thanks, I will update my kip and make it into a record.