This is an automated email from the ASF dual-hosted git repository.
mjsax pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 009fc7cdbf5 MINOR: Move candidateClients set creation outside of task
loop for StickyTaskAssignor (#19511)
009fc7cdbf5 is described below
commit 009fc7cdbf50f5556af84366ab18e1ec877fa130
Author: lorcan <[email protected]>
AuthorDate: Wed Apr 30 18:22:04 2025 +0100
MINOR: Move candidateClients set creation outside of task loop for
StickyTaskAssignor (#19511)
This PR moves the computation of the "client list", which is the same
for all tasks, out of the loop, to avoid unnecessary re-computation.
Reviewers: Matthias J. Sax <[email protected]>
---
.../streams/processor/assignment/assignors/StickyTaskAssignor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git
a/streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java
b/streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java
index eb164e2b27f..6ad61851dda 100644
---
a/streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java
+++
b/streams/src/main/java/org/apache/kafka/streams/processor/assignment/assignors/StickyTaskAssignor.java
@@ -178,10 +178,10 @@ public class StickyTaskAssignor implements TaskAssignor {
// assign any remaining unassigned tasks
final List<TaskId> sortedTasks = new ArrayList<>(unassigned);
Collections.sort(sortedTasks);
- for (final TaskId taskId : sortedTasks) {
- final Set<ProcessId> candidateClients = clients.stream()
+ final Set<ProcessId> candidateClients = clients.stream()
.map(KafkaStreamsState::processId)
.collect(Collectors.toSet());
+ for (final TaskId taskId : sortedTasks) {
final ProcessId bestClient =
assignmentState.findBestClientForTask(taskId, candidateClients);
assignmentState.finalizeAssignment(taskId, bestClient,
AssignedTask.Type.ACTIVE);
}