public class NamespaceService extends Object implements AutoCloseable
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.
PulsarService| Modifier and Type | Class and Description |
|---|---|
static class |
NamespaceService.AddressType |
| Modifier and Type | Field and Description |
|---|---|
static String |
HEARTBEAT_NAMESPACE_FMT |
static String |
HEARTBEAT_NAMESPACE_FMT_V2 |
static Pattern |
HEARTBEAT_NAMESPACE_PATTERN |
static Pattern |
HEARTBEAT_NAMESPACE_PATTERN_V2 |
static String |
SLA_NAMESPACE_FMT |
static Pattern |
SLA_NAMESPACE_PATTERN |
static String |
SLA_NAMESPACE_PROPERTY |
| Constructor and Description |
|---|
NamespaceService(PulsarService pulsar)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNamespaceBundleOwnershipListener(NamespaceBundleOwnershipListener... listeners) |
static String |
checkHeartbeatNamespace(org.apache.pulsar.common.naming.ServiceUnitId ns) |
static String |
checkHeartbeatNamespaceV2(org.apache.pulsar.common.naming.ServiceUnitId ns) |
CompletableFuture<Boolean> |
checkTopicExists(org.apache.pulsar.common.naming.TopicName topic) |
CompletableFuture<Boolean> |
checkTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName) |
void |
close() |
protected CompletableFuture<LookupResult> |
createLookupResult(String candidateBroker,
boolean authoritativeRedirect,
String advertisedListenerName) |
CompletableFuture<List<String>> |
getAllPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName) |
CompletableFuture<Optional<LookupResult>> |
getBrokerServiceUrlAsync(org.apache.pulsar.common.naming.TopicName topic,
LookupOptions options) |
NamespaceBundle |
getBundle(org.apache.pulsar.common.naming.TopicName topicName) |
CompletableFuture<NamespaceBundle> |
getBundleAsync(org.apache.pulsar.common.naming.TopicName topic) |
int |
getBundleCount(org.apache.pulsar.common.naming.NamespaceName namespace) |
Optional<NamespaceBundle> |
getBundleIfPresent(org.apache.pulsar.common.naming.TopicName topicName) |
CompletableFuture<List<String>> |
getFullListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) |
static org.apache.pulsar.common.naming.NamespaceName |
getHeartbeatNamespace(String host,
ServiceConfiguration config) |
static org.apache.pulsar.common.naming.NamespaceName |
getHeartbeatNamespaceV2(String host,
ServiceConfiguration config) |
CompletableFuture<List<String>> |
getListOfNonPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) |
CompletableFuture<List<String>> |
getListOfPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName) |
CompletableFuture<List<String>> |
getListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName,
org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace.Mode mode) |
NamespaceBundleFactory |
getNamespaceBundleFactory() |
PulsarClientImpl |
getNamespaceClient(org.apache.pulsar.common.policies.data.ClusterDataImpl cluster) |
Map<String,org.apache.pulsar.common.policies.data.NamespaceOwnershipStatus> |
getOwnedNameSpacesStatus() |
Set<NamespaceBundle> |
getOwnedServiceUnits() |
CompletableFuture<List<String>> |
getOwnedTopicListForNamespaceBundle(NamespaceBundle bundle) |
Optional<NamespaceEphemeralData> |
getOwner(NamespaceBundle bundle) |
CompletableFuture<Optional<NamespaceEphemeralData>> |
getOwnerAsync(NamespaceBundle bundle) |
OwnershipCache |
getOwnershipCache() |
CompletableFuture<List<String>> |
getPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName,
org.apache.pulsar.common.naming.TopicDomain topicDomain) |
org.apache.pulsar.common.naming.ServiceUnitId |
getServiceUnitId(org.apache.pulsar.common.naming.TopicName topicName) |
static String |
getSLAMonitorBrokerName(org.apache.pulsar.common.naming.ServiceUnitId ns) |
static org.apache.pulsar.common.naming.NamespaceName |
getSLAMonitorNamespace(String host,
ServiceConfiguration config) |
int |
getTotalServiceUnitsLoaded() |
Optional<URL> |
getWebServiceUrl(org.apache.pulsar.common.naming.ServiceUnitId suName,
LookupOptions options)
Return the URL of the broker who's owning a particular service unit.
|
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.
|
void |
initialize() |
boolean |
isNamespaceBundleDisabled(NamespaceBundle bundle) |
CompletableFuture<Boolean> |
isNamespaceBundleOwned(NamespaceBundle bundle) |
boolean |
isServiceUnitActive(org.apache.pulsar.common.naming.TopicName topicName) |
CompletableFuture<Boolean> |
isServiceUnitActiveAsync(org.apache.pulsar.common.naming.TopicName topicName) |
boolean |
isServiceUnitOwned(org.apache.pulsar.common.naming.ServiceUnitId suName) |
CompletableFuture<Boolean> |
isServiceUnitOwnedAsync(org.apache.pulsar.common.naming.ServiceUnitId suName) |
static boolean |
isSystemServiceNamespace(String namespace) |
protected void |
onNamespaceBundleOwned(NamespaceBundle bundle) |
protected void |
onNamespaceBundleUnload(NamespaceBundle bundle) |
void |
registerBootstrapNamespaces()
Register all the bootstrap name spaces including the heartbeat namespace.
|
boolean |
registerNamespace(org.apache.pulsar.common.naming.NamespaceName nsname,
boolean ensureOwned)
Tried to registers a namespace to this instance.
|
boolean |
registerSLANamespace() |
void |
removeOwnedServiceUnit(NamespaceBundle nsBundle) |
CompletableFuture<Void> |
splitAndOwnBundle(NamespaceBundle bundle,
boolean unload,
NamespaceBundleSplitAlgorithm splitAlgorithm)
1.
|
CompletableFuture<Void> |
unloadNamespaceBundle(NamespaceBundle bundle) |
CompletableFuture<Void> |
unloadNamespaceBundle(NamespaceBundle bundle,
long timeout,
TimeUnit timeoutUnit) |
void |
unloadSLANamespace() |
public static final String SLA_NAMESPACE_PROPERTY
public static final Pattern HEARTBEAT_NAMESPACE_PATTERN
public static final Pattern HEARTBEAT_NAMESPACE_PATTERN_V2
public static final Pattern SLA_NAMESPACE_PATTERN
public static final String HEARTBEAT_NAMESPACE_FMT
public static final String HEARTBEAT_NAMESPACE_FMT_V2
public static final String SLA_NAMESPACE_FMT
public NamespaceService(PulsarService pulsar)
PulsarServerExceptionpublic void initialize()
public CompletableFuture<Optional<LookupResult>> getBrokerServiceUrlAsync(org.apache.pulsar.common.naming.TopicName topic, LookupOptions options)
public CompletableFuture<NamespaceBundle> getBundleAsync(org.apache.pulsar.common.naming.TopicName topic)
public Optional<NamespaceBundle> getBundleIfPresent(org.apache.pulsar.common.naming.TopicName topicName)
public NamespaceBundle getBundle(org.apache.pulsar.common.naming.TopicName topicName)
public int getBundleCount(org.apache.pulsar.common.naming.NamespaceName namespace)
throws Exception
Exceptionpublic CompletableFuture<Optional<URL>> getWebServiceUrlAsync(org.apache.pulsar.common.naming.ServiceUnitId suName, LookupOptions options)
public Optional<URL> getWebServiceUrl(org.apache.pulsar.common.naming.ServiceUnitId suName, LookupOptions options) throws Exception
Exceptionpublic void registerBootstrapNamespaces()
throws PulsarServerException
PulsarServerExceptionpublic boolean registerNamespace(org.apache.pulsar.common.naming.NamespaceName nsname,
boolean ensureOwned)
throws PulsarServerException
nsname - ensureOwned - PulsarServerExceptionExceptionprotected CompletableFuture<LookupResult> createLookupResult(String candidateBroker, boolean authoritativeRedirect, String advertisedListenerName)
public CompletableFuture<Void> unloadNamespaceBundle(NamespaceBundle bundle)
public CompletableFuture<Void> unloadNamespaceBundle(NamespaceBundle bundle, long timeout, TimeUnit timeoutUnit)
public CompletableFuture<Boolean> isNamespaceBundleOwned(NamespaceBundle bundle)
public Map<String,org.apache.pulsar.common.policies.data.NamespaceOwnershipStatus> getOwnedNameSpacesStatus() throws Exception
Exceptionpublic boolean isNamespaceBundleDisabled(NamespaceBundle bundle) throws Exception
Exceptionpublic CompletableFuture<Void> splitAndOwnBundle(NamespaceBundle bundle, boolean unload, NamespaceBundleSplitAlgorithm splitAlgorithm)
bundle - Exceptionpublic OwnershipCache getOwnershipCache()
public int getTotalServiceUnitsLoaded()
public Set<NamespaceBundle> getOwnedServiceUnits()
public boolean isServiceUnitOwned(org.apache.pulsar.common.naming.ServiceUnitId suName)
throws Exception
Exceptionpublic CompletableFuture<Boolean> isServiceUnitOwnedAsync(org.apache.pulsar.common.naming.ServiceUnitId suName)
public boolean isServiceUnitActive(org.apache.pulsar.common.naming.TopicName topicName)
public CompletableFuture<Boolean> isServiceUnitActiveAsync(org.apache.pulsar.common.naming.TopicName topicName)
public CompletableFuture<Boolean> checkTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName)
public void removeOwnedServiceUnit(NamespaceBundle nsBundle) throws Exception
Exceptionprotected void onNamespaceBundleOwned(NamespaceBundle bundle)
protected void onNamespaceBundleUnload(NamespaceBundle bundle)
public void addNamespaceBundleOwnershipListener(NamespaceBundleOwnershipListener... listeners)
public NamespaceBundleFactory getNamespaceBundleFactory()
public org.apache.pulsar.common.naming.ServiceUnitId getServiceUnitId(org.apache.pulsar.common.naming.TopicName topicName)
throws Exception
Exceptionpublic CompletableFuture<List<String>> getFullListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName)
public CompletableFuture<List<String>> getOwnedTopicListForNamespaceBundle(NamespaceBundle bundle)
public CompletableFuture<Boolean> checkTopicExists(org.apache.pulsar.common.naming.TopicName topic)
public CompletableFuture<List<String>> getListOfTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace.Mode mode)
public CompletableFuture<List<String>> getAllPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName)
public CompletableFuture<List<String>> getPartitions(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.naming.TopicDomain topicDomain)
public CompletableFuture<List<String>> getListOfPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName)
public CompletableFuture<List<String>> getListOfNonPersistentTopics(org.apache.pulsar.common.naming.NamespaceName namespaceName)
public PulsarClientImpl getNamespaceClient(org.apache.pulsar.common.policies.data.ClusterDataImpl cluster)
public Optional<NamespaceEphemeralData> getOwner(NamespaceBundle bundle) throws Exception
Exceptionpublic CompletableFuture<Optional<NamespaceEphemeralData>> getOwnerAsync(NamespaceBundle bundle)
public static org.apache.pulsar.common.naming.NamespaceName getHeartbeatNamespace(String host, ServiceConfiguration config)
public static org.apache.pulsar.common.naming.NamespaceName getHeartbeatNamespaceV2(String host, ServiceConfiguration config)
public static org.apache.pulsar.common.naming.NamespaceName getSLAMonitorNamespace(String host, ServiceConfiguration config)
public static String checkHeartbeatNamespace(org.apache.pulsar.common.naming.ServiceUnitId ns)
public static String checkHeartbeatNamespaceV2(org.apache.pulsar.common.naming.ServiceUnitId ns)
public static String getSLAMonitorBrokerName(org.apache.pulsar.common.naming.ServiceUnitId ns)
public static boolean isSystemServiceNamespace(String namespace)
public boolean registerSLANamespace()
throws PulsarServerException
PulsarServerExceptionpublic void close()
close in interface AutoCloseableCopyright © 2017–2022 Apache Software Foundation. All rights reserved.