Class NamespaceService
java.lang.Object
org.apache.pulsar.broker.namespace.NamespaceService
- All Implemented Interfaces:
AutoCloseable
The
NamespaceService provides resource ownership lookup as well as resource ownership claiming services
for the PulsarService.
The PulsarService relies on this service for resource ownership operations.
The focus of this phase is to bring up the system and be able to iterate and improve the services effectively.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic StringcheckHeartbeatNamespace(org.apache.pulsar.common.naming.ServiceUnitId ns) static StringcheckHeartbeatNamespaceV2(org.apache.pulsar.common.naming.ServiceUnitId ns) checkTopicExists(org.apache.pulsar.common.naming.TopicName topic) checkTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName) voidclose()protected CompletableFuture<LookupResult>createLookupResult(String candidateBroker, boolean authoritativeRedirect, String advertisedListenerName) getAllPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName) getBrokerServiceUrlAsync(org.apache.pulsar.common.naming.TopicName topic, LookupOptions options) getBundle(org.apache.pulsar.common.naming.TopicName topicName) getBundleAsync(org.apache.pulsar.common.naming.TopicName topic) intgetBundleCount(org.apache.pulsar.common.naming.NamespaceName namespace) getBundleIfPresent(org.apache.pulsar.common.naming.TopicName topicName) getFullListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) static org.apache.pulsar.common.naming.NamespaceNamegetHeartbeatNamespace(String host, org.apache.pulsar.broker.ServiceConfiguration config) static org.apache.pulsar.common.naming.NamespaceNamegetHeartbeatNamespaceV2(String host, org.apache.pulsar.broker.ServiceConfiguration config) getListOfNonPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) getListOfPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) getListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace.Mode mode) org.apache.pulsar.client.impl.PulsarClientImplgetNamespaceClient(org.apache.pulsar.common.policies.data.ClusterDataImpl cluster) CompletableFuture<Map<String,org.apache.pulsar.common.policies.data.NamespaceOwnershipStatus>> getOwner(NamespaceBundle bundle) getOwnerAsync(NamespaceBundle bundle) getPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.naming.TopicDomain topicDomain) org.apache.pulsar.common.naming.ServiceUnitIdgetServiceUnitId(org.apache.pulsar.common.naming.TopicName topicName) static StringgetSLAMonitorBrokerName(org.apache.pulsar.common.naming.ServiceUnitId ns) static org.apache.pulsar.common.naming.NamespaceNamegetSLAMonitorNamespace(String host, org.apache.pulsar.broker.ServiceConfiguration config) intgetWebServiceUrl(org.apache.pulsar.common.naming.ServiceUnitId suName, LookupOptions options) Return the URL of the broker who's owning a particular service unit.getWebServiceUrlAsync(org.apache.pulsar.common.naming.ServiceUnitId suName, LookupOptions options) Return the URL of the broker who's owning a particular service unit in asynchronous way.voidstatic booleanisHeartbeatNamespace(org.apache.pulsar.common.naming.ServiceUnitId ns) booleanbooleanisServiceUnitActive(org.apache.pulsar.common.naming.TopicName topicName) isServiceUnitActiveAsync(org.apache.pulsar.common.naming.TopicName topicName) booleanisServiceUnitOwned(org.apache.pulsar.common.naming.ServiceUnitId suName) isServiceUnitOwnedAsync(org.apache.pulsar.common.naming.ServiceUnitId suName) static booleanisSystemServiceNamespace(String namespace) protected voidprotected voidvoidRegister all the bootstrap name spaces including the heartbeat namespace.booleanregisterNamespace(org.apache.pulsar.common.naming.NamespaceName nsname, boolean ensureOwned) Tried to registers a namespace to this instance.booleanremoveOwnedServiceUnitAsync(NamespaceBundle nsBundle) splitAndOwnBundle(NamespaceBundle bundle, boolean unload, NamespaceBundleSplitAlgorithm splitAlgorithm, List<Long> boundaries) 1.unloadNamespaceBundle(NamespaceBundle bundle) unloadNamespaceBundle(NamespaceBundle bundle, long timeout, TimeUnit timeoutUnit) unloadNamespaceBundle(NamespaceBundle bundle, long timeout, TimeUnit timeoutUnit, boolean closeWithoutWaitingClientDisconnect) void
-
Field Details
-
SLA_NAMESPACE_PROPERTY
- See Also:
-
HEARTBEAT_NAMESPACE_PATTERN
-
HEARTBEAT_NAMESPACE_PATTERN_V2
-
SLA_NAMESPACE_PATTERN
-
HEARTBEAT_NAMESPACE_FMT
- See Also:
-
HEARTBEAT_NAMESPACE_FMT_V2
- See Also:
-
SLA_NAMESPACE_FMT
- See Also:
-
-
Constructor Details
-
NamespaceService
Default constructor.- Throws:
org.apache.pulsar.broker.PulsarServerException
-
-
Method Details
-
initialize
public void initialize() -
getBrokerServiceUrlAsync
public CompletableFuture<Optional<LookupResult>> getBrokerServiceUrlAsync(org.apache.pulsar.common.naming.TopicName topic, LookupOptions options) -
getBundleAsync
public CompletableFuture<NamespaceBundle> getBundleAsync(org.apache.pulsar.common.naming.TopicName topic) -
getBundleIfPresent
public Optional<NamespaceBundle> getBundleIfPresent(org.apache.pulsar.common.naming.TopicName topicName) -
getBundle
-
getBundleCount
- Throws:
Exception
-
getWebServiceUrlAsync
public CompletableFuture<Optional<URL>> getWebServiceUrlAsync(org.apache.pulsar.common.naming.ServiceUnitId suName, LookupOptions options) Return the URL of the broker who's owning a particular service unit in asynchronous way. If the service unit is not owned, return a CompletableFuture with empty optional. -
getWebServiceUrl
public Optional<URL> getWebServiceUrl(org.apache.pulsar.common.naming.ServiceUnitId suName, LookupOptions options) throws Exception Return the URL of the broker who's owning a particular service unit. If the service unit is not owned, return an empty optional- Throws:
Exception
-
registerBootstrapNamespaces
public void registerBootstrapNamespaces() throws org.apache.pulsar.broker.PulsarServerExceptionRegister all the bootstrap name spaces including the heartbeat namespace.- Throws:
org.apache.pulsar.broker.PulsarServerException
-
registerNamespace
public boolean registerNamespace(org.apache.pulsar.common.naming.NamespaceName nsname, boolean ensureOwned) throws org.apache.pulsar.broker.PulsarServerException Tried to registers a namespace to this instance.- Parameters:
nsname-ensureOwned-- Returns:
- Throws:
org.apache.pulsar.broker.PulsarServerExceptionException
-
createLookupResult
protected CompletableFuture<LookupResult> createLookupResult(String candidateBroker, boolean authoritativeRedirect, String advertisedListenerName) -
unloadNamespaceBundle
-
unloadNamespaceBundle
public CompletableFuture<Void> unloadNamespaceBundle(NamespaceBundle bundle, long timeout, TimeUnit timeoutUnit) -
unloadNamespaceBundle
public CompletableFuture<Void> unloadNamespaceBundle(NamespaceBundle bundle, long timeout, TimeUnit timeoutUnit, boolean closeWithoutWaitingClientDisconnect) -
isNamespaceBundleOwned
-
getOwnedNameSpacesStatusAsync
public CompletableFuture<Map<String,org.apache.pulsar.common.policies.data.NamespaceOwnershipStatus>> getOwnedNameSpacesStatusAsync() -
isNamespaceBundleDisabled
- Throws:
Exception
-
splitAndOwnBundle
public CompletableFuture<Void> splitAndOwnBundle(NamespaceBundle bundle, boolean unload, NamespaceBundleSplitAlgorithm splitAlgorithm, List<Long> boundaries) 1. split the given bundle into two bundles 2. assign ownership of both the bundles to current broker 3. update policies with newly created bundles into LocalZK 4. disable original bundle and refresh the cache. It will call splitAndOwnBundleOnceAndRetry to do the real retry work, which will retry "retryTimes".- Parameters:
bundle-- Returns:
- Throws:
Exception
-
getOwnershipCache
-
getTotalServiceUnitsLoaded
public int getTotalServiceUnitsLoaded() -
getOwnedServiceUnits
-
isServiceUnitOwned
public boolean isServiceUnitOwned(org.apache.pulsar.common.naming.ServiceUnitId suName) throws Exception - Throws:
Exception
-
isServiceUnitOwnedAsync
public CompletableFuture<Boolean> isServiceUnitOwnedAsync(org.apache.pulsar.common.naming.ServiceUnitId suName) -
isServiceUnitActive
public boolean isServiceUnitActive(org.apache.pulsar.common.naming.TopicName topicName) -
isServiceUnitActiveAsync
public CompletableFuture<Boolean> isServiceUnitActiveAsync(org.apache.pulsar.common.naming.TopicName topicName) -
checkTopicOwnership
public CompletableFuture<Boolean> checkTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName) -
removeOwnedServiceUnitAsync
-
onNamespaceBundleOwned
-
onNamespaceBundleUnload
-
addNamespaceBundleOwnershipListener
-
getNamespaceBundleFactory
-
getServiceUnitId
public org.apache.pulsar.common.naming.ServiceUnitId getServiceUnitId(org.apache.pulsar.common.naming.TopicName topicName) throws Exception - Throws:
Exception
-
getFullListOfTopics
public CompletableFuture<List<String>> getFullListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) -
getOwnedTopicListForNamespaceBundle
-
checkTopicExists
-
getListOfTopics
public CompletableFuture<List<String>> getListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace.Mode mode) -
getAllPartitions
public CompletableFuture<List<String>> getAllPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName) -
getPartitions
public CompletableFuture<List<String>> getPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.naming.TopicDomain topicDomain) -
getListOfPersistentTopics
public CompletableFuture<List<String>> getListOfPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) -
getListOfNonPersistentTopics
public CompletableFuture<List<String>> getListOfNonPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) -
getNamespaceClient
public org.apache.pulsar.client.impl.PulsarClientImpl getNamespaceClient(org.apache.pulsar.common.policies.data.ClusterDataImpl cluster) -
getOwner
- Throws:
Exception
-
getOwnerAsync
-
unloadSLANamespace
- Throws:
Exception
-
getHeartbeatNamespace
public static org.apache.pulsar.common.naming.NamespaceName getHeartbeatNamespace(String host, org.apache.pulsar.broker.ServiceConfiguration config) -
getHeartbeatNamespaceV2
public static org.apache.pulsar.common.naming.NamespaceName getHeartbeatNamespaceV2(String host, org.apache.pulsar.broker.ServiceConfiguration config) -
getSLAMonitorNamespace
public static org.apache.pulsar.common.naming.NamespaceName getSLAMonitorNamespace(String host, org.apache.pulsar.broker.ServiceConfiguration config) -
checkHeartbeatNamespace
-
checkHeartbeatNamespaceV2
-
getSLAMonitorBrokerName
-
isSystemServiceNamespace
-
isHeartbeatNamespace
public static boolean isHeartbeatNamespace(org.apache.pulsar.common.naming.ServiceUnitId ns) -
registerSLANamespace
public boolean registerSLANamespace() throws org.apache.pulsar.broker.PulsarServerException- Throws:
org.apache.pulsar.broker.PulsarServerException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-