public class ModularLoadManagerImpl extends Object implements ModularLoadManager, ZooKeeperCacheListener<org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData>
| Modifier and Type | Field and Description |
|---|---|
static String |
BUNDLE_DATA_ZPATH |
static double |
DEFAULT_MESSAGE_RATE |
static double |
DEFAULT_MESSAGE_THROUGHPUT |
static int |
NUM_LONG_SAMPLES |
static int |
NUM_SHORT_SAMPLES |
static String |
RESOURCE_QUOTA_ZPATH |
static String |
TIME_AVERAGE_BROKER_ZPATH |
| Constructor and Description |
|---|
ModularLoadManagerImpl()
Initializes fields which do not depend on PulsarService.
|
ModularLoadManagerImpl(PulsarService pulsar)
Initialize this load manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkNamespaceBundleSplit()
As the leader broker, attempt to automatically detect and split hot namespace bundles.
|
void |
disableBroker()
As any broker, disable the broker this manager is running on.
|
void |
doLoadShedding()
As the leader broker, select bundles for the namespace service to unload so that they may be reassigned to new
brokers.
|
Set<String> |
getAvailableBrokers()
Get available broker list in cluster
|
org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData |
getBrokerLocalData(String broker)
Fetch local-broker data from load-manager broker cache
|
List<org.apache.pulsar.common.stats.Metrics> |
getLoadBalancingMetrics()
Fetch load balancing metrics.
|
ZooKeeperCache.Deserializer<org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData> |
getLoadReportDeserializer()
Return :
ZooKeeperCache.Deserializer to deserialize load-manager load report |
void |
initialize(PulsarService pulsar)
Initialize this load manager using the given PulsarService.
|
void |
onUpdate(String path,
org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData data,
org.apache.zookeeper.data.Stat stat)
When the broker data ZooKeeper nodes are updated, update the broker data map.
|
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.
|
boolean |
shouldAntiAffinityNamespaceUnload(String namespace,
String bundle,
String currentBroker) |
void |
start()
As any broker, start the load manager.
|
void |
stop()
As any broker, stop the load manager.
|
void |
updateAll() |
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.
|
void |
writeBrokerDataOnZooKeeper()
As any broker, write the local broker data to ZooKeeper.
|
void |
writeBrokerDataOnZooKeeper(boolean force)
As any broker, write the local broker data to ZooKeeper, forced or not.
|
void |
writeBundleDataOnZooKeeper()
As the leader broker, write bundle data aggregated from all brokers to ZooKeeper.
|
public static final String BUNDLE_DATA_ZPATH
public static final double DEFAULT_MESSAGE_RATE
public static final double DEFAULT_MESSAGE_THROUGHPUT
public static final int NUM_LONG_SAMPLES
public static final int NUM_SHORT_SAMPLES
public static final String RESOURCE_QUOTA_ZPATH
public static final String TIME_AVERAGE_BROKER_ZPATH
public ModularLoadManagerImpl()
public ModularLoadManagerImpl(PulsarService pulsar)
pulsar - Client to construct this manager from.public void initialize(PulsarService pulsar)
initialize in interface ModularLoadManagerpulsar - The service to initialize with.public Set<String> getAvailableBrokers()
ModularLoadManagergetAvailableBrokers in interface ModularLoadManagerpublic void updateAll()
public void disableBroker()
throws PulsarServerException
disableBroker in interface ModularLoadManagerPulsarServerException - If ZooKeeper failed to disable the broker.public void doLoadShedding()
doLoadShedding in interface ModularLoadManagerpublic boolean shouldAntiAffinityNamespaceUnload(String namespace, String bundle, String currentBroker)
public void checkNamespaceBundleSplit()
checkNamespaceBundleSplit in interface ModularLoadManagerpublic void onUpdate(String path, org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData data, org.apache.zookeeper.data.Stat stat)
onUpdate in interface ZooKeeperCacheListener<org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData>public Optional<String> selectBrokerForAssignment(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit)
selectBrokerForAssignment in interface ModularLoadManagerserviceUnit - ServiceUnitId for the bundle.public void start()
throws PulsarServerException
start in interface ModularLoadManagerPulsarServerException - If an unexpected error prevented the load manager from being started.public void stop()
throws PulsarServerException
stop in interface ModularLoadManagerPulsarServerException - If an unexpected error occurred when attempting to stop the load manager.public org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData updateLocalBrokerData()
updateLocalBrokerData in interface ModularLoadManagerpublic void writeBrokerDataOnZooKeeper()
writeBrokerDataOnZooKeeper in interface ModularLoadManagerpublic void writeBrokerDataOnZooKeeper(boolean force)
ModularLoadManagerwriteBrokerDataOnZooKeeper in interface ModularLoadManagerpublic ZooKeeperCache.Deserializer<org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData> getLoadReportDeserializer()
ModularLoadManagerZooKeeperCache.Deserializer to deserialize load-manager load reportgetLoadReportDeserializer in interface ModularLoadManagerpublic void writeBundleDataOnZooKeeper()
writeBundleDataOnZooKeeper in interface ModularLoadManagerpublic org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData getBrokerLocalData(String broker)
ModularLoadManagergetBrokerLocalData in interface ModularLoadManagerbroker - load-balancer zk-pathpublic List<org.apache.pulsar.common.stats.Metrics> getLoadBalancingMetrics()
ModularLoadManagergetLoadBalancingMetrics in interface ModularLoadManagerCopyright © 2017–2021 Apache Software Foundation. All rights reserved.