vvcephei commented on a change in pull request #8696:
URL: https://github.com/apache/kafka/pull/8696#discussion_r429346417



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/TaskMovement.java
##########
@@ -132,22 +132,97 @@ static boolean assignTaskMovements(final Map<TaskId, 
SortedSet<UUID>> tasksToCau
         return movementsNeeded;
     }
 
+    static int assignStandbyTaskMovements(final Map<TaskId, SortedSet<UUID>> 
tasksToCaughtUpClients,
+                                          final Map<UUID, ClientState> 
clientStates,
+                                          final AtomicInteger 
remainingWarmupReplicas,
+                                          final Map<UUID, Set<TaskId>> 
warmups) {
+        final BiFunction<UUID, TaskId, Boolean> caughtUpPredicate =
+            (client, task) -> 
taskIsCaughtUpOnClientOrNoCaughtUpClientsExist(task, client, 
tasksToCaughtUpClients);
+
+        final ConstrainedPrioritySet caughtUpClientsByTaskLoad = new 
ConstrainedPrioritySet(
+            caughtUpPredicate,
+            client -> clientStates.get(client).assignedTaskLoad()
+        );
+
+        final Queue<TaskMovement> taskMovements = new PriorityQueue<>(
+            
Comparator.comparing(TaskMovement::numCaughtUpClients).thenComparing(TaskMovement::task)
+        );
+
+        for (final Map.Entry<UUID, ClientState> clientStateEntry : 
clientStates.entrySet()) {
+            final UUID destination = clientStateEntry.getKey();
+            final ClientState state = clientStateEntry.getValue();
+            for (final TaskId task : state.standbyTasks()) {
+                if (warmups.getOrDefault(destination, 
Collections.emptySet()).contains(task)) {
+                    // this is a warmup, so we won't move it.
+                } else if 
(!taskIsCaughtUpOnClientOrNoCaughtUpClientsExist(task, destination, 
tasksToCaughtUpClients)) {

Review comment:
       Haha, sure :) 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to