-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-20790: add AssignmentConfigs interface #23092
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
7
commits into
apache:trunk
Choose a base branch
from
gabriellefu:assignmentconfig
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 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7a09a49
add AssignmentConfigs interface
gabriellefu bad3070
replias is not optional
gabriellefu f5324e2
bug fix
gabriellefu 63259d4
Merge branch 'trunk' into assignmentconfig
gabriellefu 74c97bc
Merge branch 'trunk' into assignmentconfig
gabriellefu 2117499
added AssignmentConfigsImpl
gabriellefu 5016b90
don't broden the scope
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
41 changes: 41 additions & 0 deletions
41
.../main/java/org/apache/kafka/coordinator/group/api/streams/assignor/AssignmentConfigs.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,41 @@ | ||
| /* | ||
| * 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.streams.assignor; | ||
|
|
||
| import org.apache.kafka.common.annotation.InterfaceAudience; | ||
| import org.apache.kafka.common.annotation.InterfaceStability; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * The assignment configurations that the group coordinator passes to the task assignor. | ||
| */ | ||
| @InterfaceAudience.Public | ||
| @InterfaceStability.Evolving | ||
| public interface AssignmentConfigs { | ||
|
|
||
| /** | ||
| * @return The number of standby replicas for each task. | ||
| */ | ||
| int numStandbyReplicas(); | ||
|
|
||
| /** | ||
| * @return The client tags used to distribute standby tasks across racks. The list is unmodifiable. | ||
| */ | ||
| List<String> rackAwareAssignmentTags(); | ||
|
|
||
| } |
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
39 changes: 39 additions & 0 deletions
39
.../main/java/org/apache/kafka/coordinator/group/streams/assignor/AssignmentConfigsImpl.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,39 @@ | ||
| /* | ||
| * 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.streams.assignor; | ||
|
|
||
| import org.apache.kafka.coordinator.group.api.streams.assignor.AssignmentConfigs; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * The assignment configurations for a streams group. | ||
| * | ||
| * @param numStandbyReplicas The number of standby replicas for each task. | ||
| * @param rackAwareAssignmentTags The client tags used to distribute standby tasks across racks. | ||
| */ | ||
| public record AssignmentConfigsImpl( | ||
| int numStandbyReplicas, | ||
| List<String> rackAwareAssignmentTags | ||
| ) implements AssignmentConfigs { | ||
|
|
||
| public AssignmentConfigsImpl { | ||
| // The list is exposed to a custom assignor through the public AssignmentConfigs interface. | ||
| rackAwareAssignmentTags = List.copyOf(Objects.requireNonNull(rackAwareAssignmentTags)); | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -54,7 +53,7 @@ public void testZeroMembers() { | |
| TaskAssignorException ex = assertThrows(TaskAssignorException.class, () -> assignor.assign( | ||
| new GroupSpecImpl( | ||
| Map.of(), | ||
| new HashMap<>() | ||
| new AssignmentConfigsImpl(0, List.of()) | ||
|
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's going to be really annoying to update all these tests when we add new assignment configs. |
||
| ), | ||
| new TopologyDescriberImpl(5, List.of("test-subtopology")) | ||
| )); | ||
|
|
@@ -92,7 +91,7 @@ public void testDoubleAssignment() { | |
| TaskAssignorException ex = assertThrows(TaskAssignorException.class, () -> assignor.assign( | ||
| new GroupSpecImpl( | ||
| Map.of("member1", memberMetadata1, "member2", memberMetadata2), | ||
| new HashMap<>() | ||
| new AssignmentConfigsImpl(0, List.of()) | ||
| ), | ||
| new TopologyDescriberImpl(5, List.of("test-subtopology")) | ||
| )); | ||
|
|
@@ -106,7 +105,7 @@ public void testBasicScenario() { | |
| final GroupAssignment result = assignor.assign( | ||
| new GroupSpecImpl( | ||
| Map.of(), | ||
| new HashMap<>() | ||
| new AssignmentConfigsImpl(0, List.of()) | ||
| ), | ||
| new TopologyDescriberImpl(5, List.of()) | ||
| ); | ||
|
|
@@ -133,7 +132,7 @@ public void testSingleMember() { | |
| final GroupAssignment result = assignor.assign( | ||
| new GroupSpecImpl( | ||
| Map.of("test_member", memberMetadata), | ||
| new HashMap<>() | ||
| new AssignmentConfigsImpl(0, List.of()) | ||
| ), | ||
| new TopologyDescriberImpl(4, List.of("test-subtopology")) | ||
| ); | ||
|
|
@@ -177,7 +176,7 @@ public void testTwoMembersTwoSubtopologies() { | |
| final GroupAssignment result = assignor.assign( | ||
| new GroupSpecImpl( | ||
| mkMap(mkEntry("test_member1", memberMetadata1), mkEntry("test_member2", memberMetadata2)), | ||
| new HashMap<>() | ||
| new AssignmentConfigsImpl(0, List.of()) | ||
| ), | ||
| new TopologyDescriberImpl(4, List.of("test-subtopology1", "test-subtopology2")) | ||
| ); | ||
|
|
@@ -235,7 +234,7 @@ public void testTwoMembersTwoSubtopologiesStickiness() { | |
| final GroupAssignment result = assignor.assign( | ||
| new GroupSpecImpl( | ||
| mkMap(mkEntry("test_member1", memberMetadata1), mkEntry("test_member2", memberMetadata2)), | ||
| new HashMap<>() | ||
| new AssignmentConfigsImpl(0, List.of()) | ||
| ), | ||
| new TopologyDescriberImpl(4, List.of("test-subtopology1", "test-subtopology2")) | ||
| ); | ||
|
|
||
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.
A better place for this method could be as a constructor or static method on
AssignmentConfigsImpl.