Class SimpleLoadManagerImpl
java.lang.Object
org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl
- All Implemented Interfaces:
Consumer<org.apache.pulsar.metadata.api.Notification>,LoadManager
public class SimpleLoadManagerImpl
extends Object
implements LoadManager, Consumer<org.apache.pulsar.metadata.api.Notification>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final longstatic final longstatic final StringFields inherited from interface org.apache.pulsar.broker.loadbalance.LoadManager
LOADBALANCE_BROKERS_ROOT, LOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(org.apache.pulsar.metadata.api.Notification n) voidRemoves visibility of current broker from loadbalancer list so, other brokers can't redirect any request to this broker and this broker won't accept new connection requests.voidUnload a candidate service unit to balance the load.voidDetect and split hot namespace bundles.org.apache.pulsar.policies.data.loadbalancer.LoadReportGenerate the load report.Get list of available brokers in cluster.getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) Returns the Least Loaded Resource Unit decided by some algorithm or criteria which is implementation specific.List<org.apache.pulsar.common.stats.Metrics>Generate load balancing stats metrics.com.google.common.collect.Multimap<Long,ResourceUnit> getResourceAvailabilityFor(org.apache.pulsar.common.naming.ServiceUnitId serviceUnitId) org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsageFuture<?>voidinitialize(PulsarService pulsar) Initialize this LoadManager.static booleanisAboveLoadLevel(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage usage, float thresholdPercentage) static booleanisBelowLoadLevel(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage usage, float thresholdPercentage) booleanIs centralized decision making to assign a new bundle.voidSet flag to force load report update.voidstart()voidstop()voidPublish the current load report on ZK.voidUpdate namespace bundle resource quota on ZK.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pulsar.broker.loadbalance.LoadManager
writeLoadReportOnZookeeper
-
Field Details
-
RESOURCE_QUOTA_GO_UP_TIMEWINDOW
public static final long RESOURCE_QUOTA_GO_UP_TIMEWINDOW -
RESOURCE_QUOTA_GO_DOWN_TIMEWINDOW
public static final long RESOURCE_QUOTA_GO_DOWN_TIMEWINDOW -
LOADBALANCER_DYNAMIC_SETTING_STRATEGY_ZPATH
- See Also:
-
SETTING_NAME_STRATEGY
- See Also:
-
LOADBALANCER_STRATEGY_LLS
- See Also:
-
LOADBALANCER_STRATEGY_RAND
- See Also:
-
LOADBALANCER_STRATEGY_LEAST_MSG
- See Also:
-
-
Constructor Details
-
SimpleLoadManagerImpl
public SimpleLoadManagerImpl() -
SimpleLoadManagerImpl
-
-
Method Details
-
initialize
Description copied from interface:LoadManagerInitialize this LoadManager.- Specified by:
initializein interfaceLoadManager- Parameters:
pulsar- The service to initialize this with.
-
start
public void start() throws org.apache.pulsar.broker.PulsarServerException- Specified by:
startin interfaceLoadManager- Throws:
org.apache.pulsar.broker.PulsarServerException
-
disableBroker
Description copied from interface:LoadManagerRemoves visibility of current broker from loadbalancer list so, other brokers can't redirect any request to this broker and this broker won't accept new connection requests.- Specified by:
disableBrokerin interfaceLoadManager- Throws:
Exception
-
getAvailableBrokers
Description copied from interface:LoadManagerGet list of available brokers in cluster.- Specified by:
getAvailableBrokersin interfaceLoadManager- Returns:
- Throws:
Exception
-
getAvailableBrokersAsync
- Specified by:
getAvailableBrokersAsyncin interfaceLoadManager
-
isCentralized
public boolean isCentralized()Description copied from interface:LoadManagerIs centralized decision making to assign a new bundle.- Specified by:
isCentralizedin interfaceLoadManager
-
writeResourceQuotasToZooKeeper
Description copied from interface:LoadManagerUpdate namespace bundle resource quota on ZK.- Specified by:
writeResourceQuotasToZooKeeperin interfaceLoadManager- Throws:
Exception
-
getLoadBalancingMetrics
Description copied from interface:LoadManagerGenerate load balancing stats metrics.- Specified by:
getLoadBalancingMetricsin interfaceLoadManager
-
getLeastLoaded
public Optional<ResourceUnit> getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) throws Exception Description copied from interface:LoadManagerReturns the Least Loaded Resource Unit decided by some algorithm or criteria which is implementation specific.- Specified by:
getLeastLoadedin interfaceLoadManager- Throws:
Exception
-
getResourceAvailabilityFor
public com.google.common.collect.Multimap<Long,ResourceUnit> getResourceAvailabilityFor(org.apache.pulsar.common.naming.ServiceUnitId serviceUnitId) throws Exception - Throws:
Exception
-
accept
public void accept(org.apache.pulsar.metadata.api.Notification n) -
getUpdateRankingHandle
-
isAboveLoadLevel
public static boolean isAboveLoadLevel(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage usage, float thresholdPercentage) -
isBelowLoadLevel
public static boolean isBelowLoadLevel(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage usage, float thresholdPercentage) -
getSystemResourceUsage
public org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage getSystemResourceUsage() -
generateLoadReport
public org.apache.pulsar.policies.data.loadbalancer.LoadReport generateLoadReport() throws ExceptionDescription copied from interface:LoadManagerGenerate the load report.- Specified by:
generateLoadReportin interfaceLoadManager- Throws:
Exception
-
setLoadReportForceUpdateFlag
public void setLoadReportForceUpdateFlag()Description copied from interface:LoadManagerSet flag to force load report update.- Specified by:
setLoadReportForceUpdateFlagin interfaceLoadManager
-
writeLoadReportOnZookeeper
Description copied from interface:LoadManagerPublish the current load report on ZK.- Specified by:
writeLoadReportOnZookeeperin interfaceLoadManager- Throws:
Exception
-
doLoadShedding
public void doLoadShedding()Description copied from interface:LoadManagerUnload a candidate service unit to balance the load.- Specified by:
doLoadSheddingin interfaceLoadManager
-
doNamespaceBundleSplit
Detect and split hot namespace bundles.- Specified by:
doNamespaceBundleSplitin interfaceLoadManager- Throws:
Exception
-
stop
public void stop() throws org.apache.pulsar.broker.PulsarServerException- Specified by:
stopin interfaceLoadManager- Throws:
org.apache.pulsar.broker.PulsarServerException
-