Class TopicName

  • All Implemented Interfaces:
    ServiceUnitId

    public class TopicName
    extends java.lang.Object
    implements ServiceUnitId
    Encapsulate the parsing of the completeTopicName name.
    • Field Detail

      • 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
      • 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-topic
        • persistent://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:
        toString in interface ServiceUnitId
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • includes

        public boolean includes​(TopicName otherTopicName)
        Description copied from interface: ServiceUnitId
        Check whether a fully-qualified topic is included in this ServiceUnitId object.
        Specified by:
        includes in interface ServiceUnitId
        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