Class SchedulerManager

java.lang.Object
org.apache.pulsar.functions.worker.SchedulerManager
All Implemented Interfaces:
AutoCloseable

public class SchedulerManager extends Object implements 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
  • Field Details

  • Constructor Details

  • 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

      public Future<?> schedule()
    • rebalanceIfNotInprogress

      public Future<?> rebalanceIfNotInprogress()
    • drainIfNotInProgress

      public Future<?> drainIfNotInProgress(String workerId)
    • getDrainStatus

      public LongRunningProcessStatus getDrainStatus(String workerId)
    • updateWorkerDrainMap

      protected int updateWorkerDrainMap()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable