Package org.apache.pulsar.common.naming
Class TopicName
java.lang.Object
org.apache.pulsar.common.naming.TopicName
- All Implemented Interfaces:
ServiceUnitId
Encapsulate the parsing of the completeTopicName name.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static String
fromPersistenceNamingEncoding
(String mlName) get topic full name from managedLedgerName.static TopicName
static TopicName
static TopicName
static TopicName
get
(String domain, NamespaceName namespaceName, String topic) Deprecated.Get a string suitable for completeTopicName lookup.Extract the namespace portion out of a completeTopicName name.Get the namespace object that this completeTopicName belongs to.getPartition
(int index) For partitions in a topic, return the base partitioned topic name.static TopicName
getPartitionedTopicName
(String topic) int
static int
getPartitionIndex
(String topic) Returns the name of the persistence resource associated with the completeTopicName.Returns the http rest path for use in the admin web service.getRestPath
(boolean includeDomain) static String
getTopicPartitionNameString
(String topic, int partitionIndex) A helper method to get a partition name of a topic in String.int
hashCode()
boolean
Check whether a fully-qualified topic is included in thisServiceUnitId
object.boolean
isGlobal()
boolean
boolean
boolean
isV2()
Returns true if this a V2 topic name prop/ns/topic-name.static boolean
toString()
-
Field Details
-
PUBLIC_TENANT
- See Also:
-
DEFAULT_NAMESPACE
- See Also:
-
PARTITIONED_TOPIC_SUFFIX
- See Also:
-
-
Method Details
-
get
-
get
-
get
-
get
-
getPartitionedTopicName
-
isValid
-
isPersistent
public boolean isPersistent() -
getNamespace
Extract the namespace portion out of a completeTopicName name.Works both with old & new convention.
- Returns:
- the namespace
-
getNamespaceObject
Get the namespace object that this completeTopicName belongs to.- Specified by:
getNamespaceObject
in interfaceServiceUnitId
- Returns:
- namespace object
-
getDomain
-
getTenant
-
getCluster
Deprecated. -
getNamespacePortion
-
getLocalName
-
getEncodedLocalName
-
getPartition
-
getPartitionIndex
public int getPartitionIndex()- Returns:
- partition index of the completeTopicName. It returns -1 if the completeTopicName (topic) is not partitioned.
-
isPartitioned
public boolean isPartitioned() -
getPartitionedTopicName
For partitions in a topic, return the base partitioned topic name. Eg:persistent://prop/cluster/ns/my-topic-partition-1
-->persistent://prop/cluster/ns/my-topic
persistent://prop/cluster/ns/my-topic
-->persistent://prop/cluster/ns/my-topic
-
getPartitionIndex
- Returns:
- partition index of the completeTopicName. It returns -1 if the completeTopicName (topic) is not partitioned.
-
getTopicPartitionNameString
A helper method to get a partition name of a topic in String.- Returns:
- topic + "-partition-" + partition.
-
getRestPath
Returns the http rest path for use in the admin web service. Eg: * "persistent/my-tenant/my-namespace/my-topic" * "non-persistent/my-tenant/my-namespace/my-topic"- Returns:
- topic rest path
-
getRestPath
-
getPersistenceNamingEncoding
Returns the name of the persistence resource associated with the completeTopicName.- Returns:
- the relative path to be used in persistence
-
fromPersistenceNamingEncoding
get topic full name from managedLedgerName.- Returns:
- the topic full name, format -> domain://tenant/namespace/topic
-
getLookupName
Get a string suitable for completeTopicName lookup.Example:
persistent://tenant/cluster/namespace/completeTopicName -> persistent/tenant/cluster/namespace/completeTopicName
- Returns:
-
isGlobal
public boolean isGlobal() -
getSchemaName
-
toString
- Specified by:
toString
in interfaceServiceUnitId
- Overrides:
toString
in classObject
-
equals
-
hashCode
public int hashCode() -
includes
Description copied from interface:ServiceUnitId
Check whether a fully-qualified topic is included in thisServiceUnitId
object.- Specified by:
includes
in interfaceServiceUnitId
- Parameters:
otherTopicName
- a fully-qualified topic object- Returns:
- true or false
-
isV2
public boolean isV2()Returns true if this a V2 topic name prop/ns/topic-name.- Returns:
- true if V2
-