Class SchedulerManager
java.lang.Object
org.apache.pulsar.functions.worker.SchedulerManager
- All Implemented Interfaces:
AutoCloseable
The scheduler manager is used to compute scheduling of function instances
Only the leader computes new schedulings and writes assignments to the assignment topic
The lifecyle of this class is the following:
1. When worker becomes leader, this class with be initialized
2. When worker loses leadership, this class will be closed which
also closes the worker's producer to the assignments topic
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSchedulerManager(WorkerConfig workerConfig, org.apache.pulsar.client.api.PulsarClient pulsarClient, PulsarAdmin admin, WorkerStatsManager workerStatsManager, ErrorNotifier errorNotifier) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pulsar.client.api.Producer<byte[]> acquireExclusiveWrite(Supplier<Boolean> isLeader) Acquires a exclusive producer.voidclose()Future<?> drainIfNotInProgress(String workerId) getDrainStatus(String workerId) voidinitialize(org.apache.pulsar.client.api.Producer<byte[]> exclusiveProducer) Future<?> Future<?> schedule()protected int
-
Field Details
-
HEARTBEAT_TENANT
- See Also:
-
HEARTBEAT_NAMESPACE
- See Also:
-
-
Constructor Details
-
SchedulerManager
public SchedulerManager(WorkerConfig workerConfig, org.apache.pulsar.client.api.PulsarClient pulsarClient, PulsarAdmin admin, WorkerStatsManager workerStatsManager, ErrorNotifier errorNotifier)
-
-
Method Details
-
acquireExclusiveWrite
public org.apache.pulsar.client.api.Producer<byte[]> acquireExclusiveWrite(Supplier<Boolean> isLeader) throws WorkerUtils.NotLeaderAnymore Acquires a exclusive producer. This method cannot return null. It can only return a valid exclusive producer or throw NotLeaderAnymore exception.- Parameters:
isLeader- if the worker is still the leader- Returns:
- A valid exclusive producer
- Throws:
WorkerUtils.NotLeaderAnymore- if the worker is no longer the leader.
-
initialize
public void initialize(org.apache.pulsar.client.api.Producer<byte[]> exclusiveProducer) -
schedule
-
rebalanceIfNotInprogress
-
drainIfNotInProgress
-
getDrainStatus
-
updateWorkerDrainMap
protected int updateWorkerDrainMap() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-