jerrypeng commented on a change in pull request #12178:
URL: https://github.com/apache/pulsar/pull/12178#discussion_r719741667



##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/SchedulerManager.java
##########
@@ -403,6 +548,82 @@ private void scheduleCompaction(ScheduledExecutorService 
executor, long schedule
         }
     }
 
+    @VisibleForTesting
+    List<Assignment> getCurrentPostDrainAssignments() {
+        return currentPostDrainAssignments;
+    }
+
+    @VisibleForTesting
+    void clearCurrentPostDrainAssignments() {
+        currentPostDrainAssignments = null;
+    }
+
+    @VisibleForTesting
+    List<Assignment> invokeDrain(String workerId) {
+
+        long startTime = System.nanoTime();
+
+        Set<String> availableWorkers = getCurrentAvailableWorkers();
+
+        // workerIdToAssignments is a map of the form {workerId : 
{FullyQualifiedInstanceId : Assignment}}
+        Map<String, Map<String, Assignment>> workerIdToAssignments = 
functionRuntimeManager.getCurrentAssignments();
+
+        // initialize stats collection
+        SchedulerStats schedulerStats = new 
SchedulerStats(workerIdToAssignments, availableWorkers);
+
+        boolean drainSuccessful = false;
+        List<Assignment> postDrainAssignments = null;
+
+        try {
+            // The worker was checked to be among the available ones, by the 
caller.
+            Preconditions.checkState(availableWorkers.contains(workerId));

Review comment:
       What if the worker is restarting during when this happens?  The worker 
can temporarily have disappeared from the the membership. Shouldn't we proceed 
to removing the assignments from the worker and still mark it as in progress of 
being drained.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to