Package org.apache.pulsar.common.naming
Class TopicName
- java.lang.Object
-
- org.apache.pulsar.common.naming.TopicName
-
- All Implemented Interfaces:
ServiceUnitId
public class TopicName extends java.lang.Object implements ServiceUnitId
Encapsulate the parsing of the completeTopicName name.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_NAMESPACEstatic java.lang.StringPARTITIONED_TOPIC_SUFFIXstatic java.lang.StringPUBLIC_TENANTstatic TopicNameTRANSACTION_COORDINATOR_ASSIGNstatic TopicNameTRANSACTION_COORDINATOR_LOG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)static TopicNameget(java.lang.String topic)static TopicNameget(java.lang.String domain, java.lang.String tenant, java.lang.String namespace, java.lang.String topic)static TopicNameget(java.lang.String domain, java.lang.String tenant, java.lang.String cluster, java.lang.String namespace, java.lang.String topic)static TopicNameget(java.lang.String domain, NamespaceName namespaceName, java.lang.String topic)java.lang.StringgetCluster()Deprecated.org.apache.pulsar.common.naming.TopicDomaingetDomain()java.lang.StringgetEncodedLocalName()java.lang.StringgetLocalName()java.lang.StringgetLookupName()Get a string suitable for completeTopicName lookup.java.lang.StringgetNamespace()Extract the namespace portion out of a completeTopicName name.NamespaceNamegetNamespaceObject()Get the namespace object that this completeTopicName belongs to.java.lang.StringgetNamespacePortion()TopicNamegetPartition(int index)java.lang.StringgetPartitionedTopicName()For partitions in a topic, return the base partitioned topic name.static TopicNamegetPartitionedTopicName(java.lang.String topic)intgetPartitionIndex()static intgetPartitionIndex(java.lang.String topic)java.lang.StringgetPersistenceNamingEncoding()Returns the name of the persistence resource associated with the completeTopicName.java.lang.StringgetRestPath()Returns the http rest path for use in the admin web service.java.lang.StringgetRestPath(boolean includeDomain)java.lang.StringgetSchemaName()java.lang.StringgetTenant()inthashCode()booleanincludes(TopicName otherTopicName)Check whether a fully-qualified topic is included in thisServiceUnitIdobject.booleanisGlobal()booleanisPartitioned()booleanisPersistent()booleanisV2()Returns true if this a V2 topic name prop/ns/topic-name.static booleanisValid(java.lang.String topic)java.lang.StringtoString()
-
-
-
Field Detail
-
PUBLIC_TENANT
public static final java.lang.String PUBLIC_TENANT
- See Also:
- Constant Field Values
-
DEFAULT_NAMESPACE
public static final java.lang.String DEFAULT_NAMESPACE
- See Also:
- Constant Field Values
-
PARTITIONED_TOPIC_SUFFIX
public static final java.lang.String PARTITIONED_TOPIC_SUFFIX
- See Also:
- Constant Field Values
-
TRANSACTION_COORDINATOR_ASSIGN
public static final TopicName TRANSACTION_COORDINATOR_ASSIGN
-
TRANSACTION_COORDINATOR_LOG
public static final TopicName TRANSACTION_COORDINATOR_LOG
-
-
Method Detail
-
get
public static TopicName get(java.lang.String domain, NamespaceName namespaceName, java.lang.String topic)
-
get
public static TopicName get(java.lang.String domain, java.lang.String tenant, java.lang.String namespace, java.lang.String topic)
-
get
public static TopicName get(java.lang.String domain, java.lang.String tenant, java.lang.String cluster, java.lang.String namespace, java.lang.String topic)
-
get
public static TopicName get(java.lang.String topic)
-
getPartitionedTopicName
public static TopicName getPartitionedTopicName(java.lang.String topic)
-
isValid
public static boolean isValid(java.lang.String topic)
-
isPersistent
public boolean isPersistent()
-
getNamespace
public java.lang.String getNamespace()
Extract the namespace portion out of a completeTopicName name.Works both with old & new convention.
- Returns:
- the namespace
-
getNamespaceObject
public NamespaceName getNamespaceObject()
Get the namespace object that this completeTopicName belongs to.- Specified by:
getNamespaceObjectin interfaceServiceUnitId- Returns:
- namespace object
-
getDomain
public org.apache.pulsar.common.naming.TopicDomain getDomain()
-
getTenant
public java.lang.String getTenant()
-
getCluster
@Deprecated public java.lang.String getCluster()
Deprecated.
-
getNamespacePortion
public java.lang.String getNamespacePortion()
-
getLocalName
public java.lang.String getLocalName()
-
getEncodedLocalName
public java.lang.String getEncodedLocalName()
-
getPartition
public TopicName getPartition(int index)
-
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
public java.lang.String 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-topicpersistent://prop/cluster/ns/my-topic-->persistent://prop/cluster/ns/my-topic
-
getPartitionIndex
public static int getPartitionIndex(java.lang.String topic)
- Returns:
- partition index of the completeTopicName. It returns -1 if the completeTopicName (topic) is not partitioned.
-
getRestPath
public java.lang.String 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
public java.lang.String getRestPath(boolean includeDomain)
-
getPersistenceNamingEncoding
public java.lang.String getPersistenceNamingEncoding()
Returns the name of the persistence resource associated with the completeTopicName.- Returns:
- the relative path to be used in persistence
-
getLookupName
public java.lang.String 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
public java.lang.String getSchemaName()
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfaceServiceUnitId- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
includes
public boolean includes(TopicName otherTopicName)
Description copied from interface:ServiceUnitIdCheck whether a fully-qualified topic is included in thisServiceUnitIdobject.- Specified by:
includesin 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
-
-