Class SimpleLoadManagerImpl
- java.lang.Object
-
- org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl
-
- All Implemented Interfaces:
java.util.function.Consumer<org.apache.pulsar.metadata.api.Notification>,LoadManager
public class SimpleLoadManagerImpl extends java.lang.Object implements LoadManager, java.util.function.Consumer<org.apache.pulsar.metadata.api.Notification>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLOADBALANCER_DYNAMIC_SETTING_STRATEGY_ZPATHstatic java.lang.StringLOADBALANCER_STRATEGY_LEAST_MSGstatic java.lang.StringLOADBALANCER_STRATEGY_LLSstatic java.lang.StringLOADBALANCER_STRATEGY_RANDstatic longRESOURCE_QUOTA_GO_DOWN_TIMEWINDOWstatic longRESOURCE_QUOTA_GO_UP_TIMEWINDOWstatic java.lang.StringSETTING_NAME_STRATEGY-
Fields inherited from interface org.apache.pulsar.broker.loadbalance.LoadManager
LOADBALANCE_BROKERS_ROOT, LOG
-
-
Constructor Summary
Constructors Constructor Description SimpleLoadManagerImpl()SimpleLoadManagerImpl(PulsarService pulsar)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(org.apache.pulsar.metadata.api.Notification n)voiddisableBroker()Removes 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.voiddoLoadShedding()Unload a candidate service unit to balance the load.voiddoNamespaceBundleSplit()Detect and split hot namespace bundles.org.apache.pulsar.policies.data.loadbalancer.LoadReportgenerateLoadReport()Generate the load report.java.util.Set<java.lang.String>getAvailableBrokers()Get list of available brokers in cluster.java.util.concurrent.CompletableFuture<java.util.Set<java.lang.String>>getAvailableBrokersAsync()java.util.Optional<ResourceUnit>getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit)Returns the Least Loaded Resource Unit decided by some algorithm or criteria which is implementation specific.java.util.List<org.apache.pulsar.common.stats.Metrics>getLoadBalancingMetrics()Generate load balancing stats metrics.com.google.common.collect.Multimap<java.lang.Long,ResourceUnit>getResourceAvailabilityFor(org.apache.pulsar.common.naming.ServiceUnitId serviceUnitId)org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsagegetSystemResourceUsage()java.util.concurrent.Future<?>getUpdateRankingHandle()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)booleanisCentralized()Is centralized decision making to assign a new bundle.voidsetLoadReportForceUpdateFlag()Set flag to force load report update.voidstart()voidstop()voidwriteLoadReportOnZookeeper()Publish the current load report on ZK.voidwriteResourceQuotasToZooKeeper()Update namespace bundle resource quota on ZK.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pulsar.broker.loadbalance.LoadManager
writeLoadReportOnZookeeper
-
-
-
-
Field Detail
-
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
public static final java.lang.String LOADBALANCER_DYNAMIC_SETTING_STRATEGY_ZPATH
- See Also:
- Constant Field Values
-
SETTING_NAME_STRATEGY
public static final java.lang.String SETTING_NAME_STRATEGY
- See Also:
- Constant Field Values
-
LOADBALANCER_STRATEGY_LLS
public static final java.lang.String LOADBALANCER_STRATEGY_LLS
- See Also:
- Constant Field Values
-
LOADBALANCER_STRATEGY_RAND
public static final java.lang.String LOADBALANCER_STRATEGY_RAND
- See Also:
- Constant Field Values
-
LOADBALANCER_STRATEGY_LEAST_MSG
public static final java.lang.String LOADBALANCER_STRATEGY_LEAST_MSG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SimpleLoadManagerImpl
public SimpleLoadManagerImpl()
-
SimpleLoadManagerImpl
public SimpleLoadManagerImpl(PulsarService pulsar)
-
-
Method Detail
-
initialize
public void initialize(PulsarService pulsar)
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
public void disableBroker() throws java.lang.ExceptionDescription 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:
java.lang.Exception
-
getAvailableBrokers
public java.util.Set<java.lang.String> getAvailableBrokers() throws java.lang.ExceptionDescription copied from interface:LoadManagerGet list of available brokers in cluster.- Specified by:
getAvailableBrokersin interfaceLoadManager- Returns:
- Throws:
java.lang.Exception
-
getAvailableBrokersAsync
public java.util.concurrent.CompletableFuture<java.util.Set<java.lang.String>> 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
public void writeResourceQuotasToZooKeeper() throws java.lang.ExceptionDescription copied from interface:LoadManagerUpdate namespace bundle resource quota on ZK.- Specified by:
writeResourceQuotasToZooKeeperin interfaceLoadManager- Throws:
java.lang.Exception
-
getLoadBalancingMetrics
public java.util.List<org.apache.pulsar.common.stats.Metrics> getLoadBalancingMetrics()
Description copied from interface:LoadManagerGenerate load balancing stats metrics.- Specified by:
getLoadBalancingMetricsin interfaceLoadManager
-
getLeastLoaded
public java.util.Optional<ResourceUnit> getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) throws java.lang.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:
java.lang.Exception
-
getResourceAvailabilityFor
public com.google.common.collect.Multimap<java.lang.Long,ResourceUnit> getResourceAvailabilityFor(org.apache.pulsar.common.naming.ServiceUnitId serviceUnitId) throws java.lang.Exception
- Throws:
java.lang.Exception
-
accept
public void accept(org.apache.pulsar.metadata.api.Notification n)
- Specified by:
acceptin interfacejava.util.function.Consumer<org.apache.pulsar.metadata.api.Notification>
-
getUpdateRankingHandle
public java.util.concurrent.Future<?> 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 java.lang.ExceptionDescription copied from interface:LoadManagerGenerate the load report.- Specified by:
generateLoadReportin interfaceLoadManager- Throws:
java.lang.Exception
-
setLoadReportForceUpdateFlag
public void setLoadReportForceUpdateFlag()
Description copied from interface:LoadManagerSet flag to force load report update.- Specified by:
setLoadReportForceUpdateFlagin interfaceLoadManager
-
writeLoadReportOnZookeeper
public void writeLoadReportOnZookeeper() throws java.lang.ExceptionDescription copied from interface:LoadManagerPublish the current load report on ZK.- Specified by:
writeLoadReportOnZookeeperin interfaceLoadManager- Throws:
java.lang.Exception
-
doLoadShedding
public void doLoadShedding()
Description copied from interface:LoadManagerUnload a candidate service unit to balance the load.- Specified by:
doLoadSheddingin interfaceLoadManager
-
doNamespaceBundleSplit
public void doNamespaceBundleSplit() throws java.lang.ExceptionDetect and split hot namespace bundles.- Specified by:
doNamespaceBundleSplitin interfaceLoadManager- Throws:
java.lang.Exception
-
stop
public void stop() throws org.apache.pulsar.broker.PulsarServerException- Specified by:
stopin interfaceLoadManager- Throws:
org.apache.pulsar.broker.PulsarServerException
-
-