Class ExtensibleLoadManagerImpl
java.lang.Object
org.apache.pulsar.broker.loadbalance.extensions.ExtensibleLoadManagerImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,ExtensibleLoadManager,BrokerSelectionStrategyFactory
public class ExtensibleLoadManagerImpl
extends Object
implements ExtensibleLoadManager, BrokerSelectionStrategyFactory
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final longprotected PulsarServiceprotected ServiceUnitStateTableViewSyncerstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionLife cycle: Constructor -> initialize -> start -> close. -
Method Summary
Modifier and TypeMethodDescriptionassign(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId serviceUnit, LookupOptions options) The incoming service unit (e.g.checkOwnershipAsync(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId bundleUnit) Check the incoming service unit is owned by the current broker.voidclose()Close the load manager.static booleanconfigureSystemTopics(PulsarService pulsar, long target) protected BrokerRegistrycreateBrokerRegistry(PulsarService pulsar) protected ServiceUnitStateChannelstatic voidcreateSystemTopic(PulsarService pulsar, String topic) static booleandebug(ServiceConfiguration config, org.slf4j.Logger log) voidstatic ExtensibleLoadManagerImplget(LoadManager loadManager) static ExtensibleLoadManagerImplget(PulsarService pulsar) A static util func to get the ExtensibleLoadManagerImpl instance.static CompletableFuture<Optional<BrokerLookupData>>getAssignedBrokerLookupData(PulsarService pulsar, String topic) Gets the assigned broker for the given topic.List<org.apache.pulsar.common.stats.Metrics>Deprecated.getOwnershipAsync(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) getOwnershipWithLookupDataAsync(org.apache.pulsar.common.naming.ServiceUnitId bundleUnit) voidinitialize(PulsarService pulsar) Initialize this load manager using the given pulsar service.static booleanisInternalTopic(String topic) static booleanprotected voidmonitor()selectAsync(org.apache.pulsar.common.naming.ServiceUnitId bundle, Set<String> excludeBrokerSet, LookupOptions options) splitNamespaceBundleAsync(org.apache.pulsar.common.naming.ServiceUnitId bundle, NamespaceBundleSplitAlgorithm splitAlgorithm, List<Long> boundaries) voidstart()Start the extensible load manager.tryAcquiringOwnership(NamespaceBundle namespaceBundle) Method to get the current owner of theNamespaceBundleor set the local broker as the owner if absent.unloadNamespaceBundleAsync(org.apache.pulsar.common.naming.ServiceUnitId bundle, Optional<String> destinationBroker, boolean force, long timeout, TimeUnit timeoutUnit)
-
Field Details
-
BROKER_LOAD_DATA_STORE_TOPIC
-
TOP_BUNDLES_LOAD_DATA_STORE_TOPIC
-
COMPACTION_THRESHOLD
public static final long COMPACTION_THRESHOLD- See Also:
-
INTERNAL_TOPICS
-
pulsar
-
serviceUnitStateTableViewSyncer
-
-
Constructor Details
-
ExtensibleLoadManagerImpl
public ExtensibleLoadManagerImpl()Life cycle: Constructor -> initialize -> start -> close.
-
-
Method Details
-
getOwnedServiceUnitsAsync
Deprecated.Get all the bundles that are owned by this broker. -
getOwnedServiceUnits
-
createBrokerSelectionStrategy
- Specified by:
createBrokerSelectionStrategyin interfaceBrokerSelectionStrategyFactory
-
isLoadManagerExtensionEnabled
-
get
-
get
A static util func to get the ExtensibleLoadManagerImpl instance.- Parameters:
pulsar- PulsarService- Returns:
- the ExtensibleLoadManagerImpl instance
-
debug
-
createSystemTopic
public static void createSystemTopic(PulsarService pulsar, String topic) throws PulsarServerException - Throws:
PulsarServerException
-
configureSystemTopics
-
getAssignedBrokerLookupData
public static CompletableFuture<Optional<BrokerLookupData>> getAssignedBrokerLookupData(PulsarService pulsar, String topic) Gets the assigned broker for the given topic.- Parameters:
pulsar- PulsarService instancetopic- Topic Name- Returns:
- the assigned broker's BrokerLookupData instance. Empty, if not assigned by Extensible LoadManager or the optimized bundle unload process is disabled.
-
start
Description copied from interface:ExtensibleLoadManagerStart the extensible load manager. 1. Start the broker registry. 2. Register self to registry. 3. Start the load data store. 4. Init the load manager context. 5. Start load data reporter. 6. Start the namespace unload scheduler. 7. Start the namespace split scheduler. 8. Listen the broker up or down, so we can split immediately.- Specified by:
startin interfaceExtensibleLoadManager- Throws:
PulsarServerException
-
initialize
Description copied from interface:ExtensibleLoadManagerInitialize this load manager using the given pulsar service.- Specified by:
initializein interfaceExtensibleLoadManager
-
assign
public CompletableFuture<Optional<BrokerLookupData>> assign(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId serviceUnit, LookupOptions options) Description copied from interface:ExtensibleLoadManagerThe incoming service unit (e.g. bundle) selects the appropriate broker through strategies.- Specified by:
assignin interfaceExtensibleLoadManager- Parameters:
topic- The optional topic, some method won't provide topic var in this param (e.g.NamespaceService#internalGetWebServiceUrl(NamespaceBundle, LookupOptions)), So the topic is optional.serviceUnit- service unit (e.g. bundle).options- The lookup options.- Returns:
- The broker lookup data.
-
tryAcquiringOwnership
public CompletableFuture<NamespaceEphemeralData> tryAcquiringOwnership(NamespaceBundle namespaceBundle) Method to get the current owner of theNamespaceBundleor set the local broker as the owner if absent.- Parameters:
namespaceBundle- theNamespaceBundle- Returns:
- The ephemeral node data showing the current ownership info in
ServiceUnitStateChannel
-
selectAsync
public CompletableFuture<Optional<String>> selectAsync(org.apache.pulsar.common.naming.ServiceUnitId bundle, Set<String> excludeBrokerSet, LookupOptions options) -
checkOwnershipAsync
public CompletableFuture<Boolean> checkOwnershipAsync(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId bundleUnit) Description copied from interface:ExtensibleLoadManagerCheck the incoming service unit is owned by the current broker.- Specified by:
checkOwnershipAsyncin interfaceExtensibleLoadManager- Parameters:
topic- The optional topic, some method won't provide topic var in this param.bundleUnit- The service unit (e.g. bundle).- Returns:
- The broker lookup data.
-
getOwnershipAsync
public CompletableFuture<Optional<String>> getOwnershipAsync(Optional<org.apache.pulsar.common.naming.ServiceUnitId> topic, org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) -
getOwnershipWithLookupDataAsync
public CompletableFuture<Optional<BrokerLookupData>> getOwnershipWithLookupDataAsync(org.apache.pulsar.common.naming.ServiceUnitId bundleUnit) -
unloadNamespaceBundleAsync
public CompletableFuture<Void> unloadNamespaceBundleAsync(org.apache.pulsar.common.naming.ServiceUnitId bundle, Optional<String> destinationBroker, boolean force, long timeout, TimeUnit timeoutUnit) -
splitNamespaceBundleAsync
public CompletableFuture<Void> splitNamespaceBundleAsync(org.apache.pulsar.common.naming.ServiceUnitId bundle, NamespaceBundleSplitAlgorithm splitAlgorithm, List<Long> boundaries) -
close
Description copied from interface:ExtensibleLoadManagerClose the load manager.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceExtensibleLoadManager- Throws:
PulsarServerException- if it fails to stop the load manager.
-
isInternalTopic
-
getMetrics
-
monitor
protected void monitor() -
disableBroker
- Throws:
Exception
-
createBrokerRegistry
-
createServiceUnitStateChannel
-