Class ModularLoadManagerImpl
java.lang.Object
org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl
- All Implemented Interfaces:
ModularLoadManager
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitializes fields which do not depend on PulsarService.ModularLoadManagerImpl(PulsarService pulsar) Initialize this load manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidAs the leader broker, attempt to automatically detect and split hot namespace bundles.voidAs any broker, disable the broker this manager is running on.voidAs the leader broker, select bundles for the namespace service to unload so that they may be reassigned to new brokers.Get available broker list in cluster.Get available broker list in cluster by async invoke.org.apache.pulsar.policies.data.loadbalancer.LocalBrokerDatagetBrokerLocalData(String broker) Fetch local-broker data from load-manager broker cache.org.apache.pulsar.policies.data.loadbalancer.BundleDatagetBundleDataOrDefault(String bundle) Fetch bundle's load report data.static StringgetBundleDataPath(String bundle) List<org.apache.pulsar.common.stats.Metrics>Fetch load balancing metrics.voidhandleDataNotification(org.apache.pulsar.metadata.api.Notification t) voidinitialize(PulsarService pulsar) Initialize this load manager using the given PulsarService.selectBrokerForAssignment(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) As the leader broker, find a suitable broker for the assignment of the given bundle.booleanshouldAntiAffinityNamespaceUnload(String namespace, String bundle, String currentBroker) booleanshouldNamespacePoliciesUnload(String namespace, String bundle, String currentBroker) voidstart()As any broker, start the load manager.voidstop()As any broker, stop the load manager.voidorg.apache.pulsar.policies.data.loadbalancer.LocalBrokerDataAs any broker, retrieve the namespace bundle stats and system resource usage to update data local to this broker.voidAs any broker, write the local broker data to metadata store.voidwriteBrokerDataOnZooKeeper(boolean force) As any broker, write the local broker data to ZooKeeper, forced or not.voidAs the leader broker, write bundle data aggregated from all brokers to metadata store.
-
Field Details
-
BUNDLE_DATA_PATH
- See Also:
-
DEFAULT_MESSAGE_RATE
public static final double DEFAULT_MESSAGE_RATE- See Also:
-
DEFAULT_MESSAGE_THROUGHPUT
public static final double DEFAULT_MESSAGE_THROUGHPUT- See Also:
-
NUM_LONG_SAMPLES
public static final int NUM_LONG_SAMPLES- See Also:
-
NUM_SHORT_SAMPLES
public static final int NUM_SHORT_SAMPLES- See Also:
-
RESOURCE_QUOTA_ZPATH
- See Also:
-
TIME_AVERAGE_BROKER_ZPATH
- See Also:
-
-
Constructor Details
-
ModularLoadManagerImpl
public ModularLoadManagerImpl()Initializes fields which do not depend on PulsarService. initialize(PulsarService) should subsequently be called. -
ModularLoadManagerImpl
Initialize this load manager.- Parameters:
pulsar- Client to construct this manager from.
-
-
Method Details
-
initialize
Initialize this load manager using the given PulsarService. Should be called only once, after invoking the default constructor.- Specified by:
initializein interfaceModularLoadManager- Parameters:
pulsar- The service to initialize with.
-
handleDataNotification
public void handleDataNotification(org.apache.pulsar.metadata.api.Notification t) -
getAvailableBrokers
Description copied from interface:ModularLoadManagerGet available broker list in cluster.- Specified by:
getAvailableBrokersin interfaceModularLoadManager- Returns:
-
getAvailableBrokersAsync
Description copied from interface:ModularLoadManagerGet available broker list in cluster by async invoke.- Specified by:
getAvailableBrokersAsyncin interfaceModularLoadManager
-
getBundleDataOrDefault
public org.apache.pulsar.policies.data.loadbalancer.BundleData getBundleDataOrDefault(String bundle) Description copied from interface:ModularLoadManagerFetch bundle's load report data.- Specified by:
getBundleDataOrDefaultin interfaceModularLoadManager- Returns:
- bundle data
-
getBundleDataPath
-
updateAll
public void updateAll() -
disableBroker
public void disableBroker() throws org.apache.pulsar.broker.PulsarServerExceptionAs any broker, disable the broker this manager is running on.- Specified by:
disableBrokerin interfaceModularLoadManager- 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:
doLoadSheddingin interfaceModularLoadManager
-
shouldNamespacePoliciesUnload
-
shouldAntiAffinityNamespaceUnload
-
checkNamespaceBundleSplit
public void checkNamespaceBundleSplit()As the leader broker, attempt to automatically detect and split hot namespace bundles.- Specified by:
checkNamespaceBundleSplitin interfaceModularLoadManager
-
selectBrokerForAssignment
public Optional<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:
selectBrokerForAssignmentin interfaceModularLoadManager- 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.PulsarServerExceptionAs any broker, start the load manager.- Specified by:
startin interfaceModularLoadManager- 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.PulsarServerExceptionAs any broker, stop the load manager.- Specified by:
stopin interfaceModularLoadManager- 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:
updateLocalBrokerDatain interfaceModularLoadManager- Returns:
-
writeBrokerDataOnZooKeeper
public void writeBrokerDataOnZooKeeper()As any broker, write the local broker data to metadata store.- Specified by:
writeBrokerDataOnZooKeeperin interfaceModularLoadManager
-
writeBrokerDataOnZooKeeper
public void writeBrokerDataOnZooKeeper(boolean force) Description copied from interface:ModularLoadManagerAs any broker, write the local broker data to ZooKeeper, forced or not.- Specified by:
writeBrokerDataOnZooKeeperin interfaceModularLoadManager
-
writeBundleDataOnZooKeeper
public void writeBundleDataOnZooKeeper()As the leader broker, write bundle data aggregated from all brokers to metadata store.- Specified by:
writeBundleDataOnZooKeeperin interfaceModularLoadManager
-
getBrokerLocalData
public org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData getBrokerLocalData(String broker) Description copied from interface:ModularLoadManagerFetch local-broker data from load-manager broker cache.- Specified by:
getBrokerLocalDatain interfaceModularLoadManager- Parameters:
broker- load-balancer path- Returns:
-
getLoadBalancingMetrics
Description copied from interface:ModularLoadManagerFetch load balancing metrics.- Specified by:
getLoadBalancingMetricsin interfaceModularLoadManager- Returns:
- List of LoadBalancing Metrics
-