rdhabalia commented on a change in pull request #2613: Avoid scheduling
heartbeat function if owner-worker not available
URL: https://github.com/apache/pulsar/pull/2613#discussion_r219949212
##########
File path:
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/scheduler/IScheduler.java
##########
@@ -22,9 +22,22 @@
import org.apache.pulsar.functions.proto.Function.Instance;
import java.util.List;
+import java.util.Set;
public interface IScheduler {
- List<Assignment> schedule(List<Instance> unassignedFunctionInstances,
- List<Assignment> currentAssignments,
List<String> workers);
+ /**
+ * Scheduler schedules assignments to appropriate workers and adds into
#resultAssignments
+ *
+ * @param resultAssignments
Review comment:
> list of assignments calculated by the scheduler?
1. earlier in this PR it was calculated by a RoundRobinScheduler only but
then we decided to remove heartbeat logic out from
Scheduler-Impl(RoundRobinScheduler) and move it to SchedulerManager as this
logic will be same across different Scheduler-implementation.
2. `getUnassignedFunctionInstances(..)` already iterates through all list of
instances, current-assignments and prepares list of unassignment instances so,
scheduler can schedule it. so, if we just skip it heartbeat function in that
call then it requires to iterate to the `allInstance` (`O(n)`) list again to
find out list of heart-beat function again.
So, to optimize it , we are adding heartbeat function to assignment-list in
the same iteration and pass the same result-list to the scheduler so, scheduler
can add new assignment to the list. I don't think it will confuse the interface
because, if caller (SchedulerManager) is modifying and sharing the
result-assignment-list then it can be passed to the implementation-scheduler
where they can add more assignments.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services