mirror of https://github.com/apache/kafka.git
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 <matthias@confluent.io>
This commit is contained in:
parent
53afb1e0c5
commit
009fc7cdbf
|
@ -178,10 +178,10 @@ public class StickyTaskAssignor implements TaskAssignor {
|
||||||
// assign any remaining unassigned tasks
|
// assign any remaining unassigned tasks
|
||||||
final List<TaskId> sortedTasks = new ArrayList<>(unassigned);
|
final List<TaskId> sortedTasks = new ArrayList<>(unassigned);
|
||||||
Collections.sort(sortedTasks);
|
Collections.sort(sortedTasks);
|
||||||
for (final TaskId taskId : sortedTasks) {
|
|
||||||
final Set<ProcessId> candidateClients = clients.stream()
|
final Set<ProcessId> candidateClients = clients.stream()
|
||||||
.map(KafkaStreamsState::processId)
|
.map(KafkaStreamsState::processId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
for (final TaskId taskId : sortedTasks) {
|
||||||
final ProcessId bestClient = assignmentState.findBestClientForTask(taskId, candidateClients);
|
final ProcessId bestClient = assignmentState.findBestClientForTask(taskId, candidateClients);
|
||||||
assignmentState.finalizeAssignment(taskId, bestClient, AssignedTask.Type.ACTIVE);
|
assignmentState.finalizeAssignment(taskId, bestClient, AssignedTask.Type.ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue