Class ModularLoadManagerImpl

    • Constructor Detail

      • ModularLoadManagerImpl

        public ModularLoadManagerImpl()
        Initializes fields which do not depend on PulsarService. initialize(PulsarService) should subsequently be called.
      • ModularLoadManagerImpl

        public ModularLoadManagerImpl​(PulsarService pulsar)
        Initialize this load manager.
        Parameters:
        pulsar - Client to construct this manager from.
    • Method Detail

      • initialize

        public void initialize​(PulsarService pulsar)
        Initialize this load manager using the given PulsarService. Should be called only once, after invoking the default constructor.
        Specified by:
        initialize in interface ModularLoadManager
        Parameters:
        pulsar - The service to initialize with.
      • handleDataNotification

        public void handleDataNotification​(org.apache.pulsar.metadata.api.Notification t)
      • updateAll

        public void updateAll()
      • disableBroker

        public void disableBroker()
                           throws org.apache.pulsar.broker.PulsarServerException
        As any broker, disable the broker this manager is running on.
        Specified by:
        disableBroker in interface ModularLoadManager
        Throws:
        org.apache.pulsar.broker.PulsarServerException - If there's a failure when disabling broker on metadata store.
      • doLoadShedding

        public void doLoadShedding()
        As the leader broker, select bundles for the namespace service to unload so that they may be reassigned to new brokers.
        Specified by:
        doLoadShedding in interface ModularLoadManager
      • shouldAntiAffinityNamespaceUnload

        public boolean shouldAntiAffinityNamespaceUnload​(java.lang.String namespace,
                                                         java.lang.String bundle,
                                                         java.lang.String currentBroker)
      • checkNamespaceBundleSplit

        public void checkNamespaceBundleSplit()
        As the leader broker, attempt to automatically detect and split hot namespace bundles.
        Specified by:
        checkNamespaceBundleSplit in interface ModularLoadManager
      • selectBrokerForAssignment

        public java.util.Optional<java.lang.String> selectBrokerForAssignment​(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit)
        As the leader broker, find a suitable broker for the assignment of the given bundle.
        Specified by:
        selectBrokerForAssignment in interface ModularLoadManager
        Parameters:
        serviceUnit - ServiceUnitId for the bundle.
        Returns:
        The name of the selected broker, as it appears on metadata store.
      • start

        public void start()
                   throws org.apache.pulsar.broker.PulsarServerException
        As any broker, start the load manager.
        Specified by:
        start in interface ModularLoadManager
        Throws:
        org.apache.pulsar.broker.PulsarServerException - If an unexpected error prevented the load manager from being started.
      • stop

        public void stop()
                  throws org.apache.pulsar.broker.PulsarServerException
        As any broker, stop the load manager.
        Specified by:
        stop in interface ModularLoadManager
        Throws:
        org.apache.pulsar.broker.PulsarServerException - If an unexpected error occurred when attempting to stop the load manager.
      • updateLocalBrokerData

        public org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData updateLocalBrokerData()
        As any broker, retrieve the namespace bundle stats and system resource usage to update data local to this broker.
        Specified by:
        updateLocalBrokerData in interface ModularLoadManager
        Returns:
      • writeBundleDataOnZooKeeper

        public void writeBundleDataOnZooKeeper()
        As the leader broker, write bundle data aggregated from all brokers to metadata store.
        Specified by:
        writeBundleDataOnZooKeeper in interface ModularLoadManager
      • getBrokerLocalData

        public org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData getBrokerLocalData​(java.lang.String broker)
        Description copied from interface: ModularLoadManager
        Fetch local-broker data from load-manager broker cache.
        Specified by:
        getBrokerLocalData in interface ModularLoadManager
        Parameters:
        broker - load-balancer path
        Returns:
      • getLoadBalancingMetrics

        public java.util.List<org.apache.pulsar.common.stats.Metrics> getLoadBalancingMetrics()
        Description copied from interface: ModularLoadManager
        Fetch load balancing metrics.
        Specified by:
        getLoadBalancingMetrics in interface ModularLoadManager
        Returns:
        List of LoadBalancing Metrics