jerrypeng commented on a change in pull request #12178:
URL: https://github.com/apache/pulsar/pull/12178#discussion_r719734979
##########
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));
+
+ drainOpStatusMap.put(workerId, DrainOpStatus.DrainInProgress);
+
+ val workerRemovealSuccessful = availableWorkers.remove(workerId);
+ Preconditions.checkState(workerRemovealSuccessful);
+
+ List<FunctionMetaData> allFunctions =
functionMetaDataManager.getAllFunctionMetaData();
+ Map<String, Function.Instance> allInstances =
+ computeAllInstances(allFunctions,
functionRuntimeManager.getRuntimeFactory().externallyManaged());
+
+ // Pretend that current assignments is empty, and get the
instances to assign.
+ Pair<List<Function.Instance>, List<Assignment>> instancesToAssign
+ = getUnassignedFunctionInstances(null, allInstances);
Review comment:
This will cause getUnassignedFunctionInstances to just return all
instances as unassigned. Later in the code, the scheduler will create a
scheduling with the assumption that everything is unassigned. This is more
disruptive than necessary. A drain operation does not entail a complete
re-scheduling and moving instances from workers that not the target of the
drain. The unassigned instances should just be the instances currently
assigned to the worker that is 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]