Interface LoadManager
- All Known Implementing Classes:
ExtensibleLoadManagerWrapper,ModularLoadManagerWrapper,NoopLoadManager,SimpleLoadManagerImpl
public interface LoadManager
LoadManager runs through set of load reports collected from different brokers and generates a recommendation of
namespace/ServiceUnit placement on machines/ResourceUnit. Each Concrete Load Manager will use different algorithms to
generate this mapping.
Concrete Load Manager is also return the least loaded broker that should own the new namespace.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Boolean>checkOwnershipAsync(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId bundle) static LoadManagercreate(PulsarService pulsar) 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.voidNamespace bundle split.default CompletableFuture<Optional<LookupResult>>findBrokerServiceUrl(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId bundle, LookupOptions options) org.apache.pulsar.policies.data.loadbalancer.LoadManagerReportGenerate the load report.Get list of available brokers in cluster.getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId su) 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.voidinitialize(PulsarService pulsar) Initialize this LoadManager.booleanIs centralized decision making to assign a new bundle.voidSet flag to force load report update.setNamespaceBundleAffinity(String bundle, String broker) voidstart()default booleanstarted()voidstop()voidPublish the current load report on ZK.default voidwriteLoadReportOnZookeeper(boolean force) Publish the current load report on ZK, forced or not.voidUpdate namespace bundle resource quota on ZK.
-
Field Details
-
LOG
static final org.slf4j.Logger LOG -
LOADBALANCE_BROKERS_ROOT
- See Also:
-
-
Method Details
-
start
- Throws:
PulsarServerException
-
started
default boolean started() -
isCentralized
boolean isCentralized()Is centralized decision making to assign a new bundle. -
getLeastLoaded
Optional<ResourceUnit> getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId su) throws Exception Returns the Least Loaded Resource Unit decided by some algorithm or criteria which is implementation specific.- Throws:
Exception
-
findBrokerServiceUrl
default CompletableFuture<Optional<LookupResult>> findBrokerServiceUrl(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId bundle, LookupOptions options) -
checkOwnershipAsync
default CompletableFuture<Boolean> checkOwnershipAsync(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId bundle) -
generateLoadReport
org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport generateLoadReport() throws ExceptionGenerate the load report.- Throws:
Exception
-
setLoadReportForceUpdateFlag
void setLoadReportForceUpdateFlag()Set flag to force load report update. -
writeLoadReportOnZookeeper
Publish the current load report on ZK.- Throws:
Exception
-
writeLoadReportOnZookeeper
Publish the current load report on ZK, forced or not. By default, rely on method writeLoadReportOnZookeeper().- Throws:
Exception
-
writeResourceQuotasToZooKeeper
Update namespace bundle resource quota on ZK.- Throws:
Exception
-
getLoadBalancingMetrics
List<org.apache.pulsar.common.stats.Metrics> getLoadBalancingMetrics()Generate load balancing stats metrics. -
doLoadShedding
void doLoadShedding()Unload a candidate service unit to balance the load. -
doNamespaceBundleSplit
Namespace bundle split.- Throws:
Exception
-
disableBroker
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.- Throws:
Exception- if there is any error while disabling broker
-
getAvailableBrokers
Get list of available brokers in cluster.- Returns:
- the list of available brokers
- Throws:
Exception- if there is any error while getting available brokers
-
getAvailableBrokersAsync
CompletableFuture<Set<String>> getAvailableBrokersAsync() -
setNamespaceBundleAffinity
-
stop
- Throws:
PulsarServerException
-
initialize
Initialize this LoadManager.- Parameters:
pulsar- The service to initialize this with.
-
create
-