Interface LookupService

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
BinaryProtoLookupService, HttpLookupService

public interface LookupService extends AutoCloseable
Provides lookup service to find broker which serves given topic. It helps to lookup
  • topic-lookup: lookup to find broker-address which serves given topic
  • Partitioned-topic-Metadata-lookup: lookup to find PartitionedMetadata for a given topic
  • Method Details

    • updateServiceUrl

      void updateServiceUrl(String serviceUrl) throws PulsarClientException
      Instruct the LookupService to switch to a new service URL for all subsequent requests.
      Throws:
      PulsarClientException
    • getBroker

      CompletableFuture<org.apache.commons.lang3.tuple.Pair<InetSocketAddress,InetSocketAddress>> getBroker(TopicName topicName)
      Calls broker lookup-api to get broker InetSocketAddress which serves namespace bundle that contains given topic.
      Parameters:
      topicName - topic-name
      Returns:
      a pair of addresses, representing the logical and physical address of the broker that serves given topic
    • getPartitionedTopicMetadata

      @Deprecated default CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> getPartitionedTopicMetadata(TopicName topicName)
      Returns PartitionedTopicMetadata for a given topic. Note: this method will try to create the topic partitioned metadata if it does not exist.
    • getPartitionedTopicMetadata

      default CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> getPartitionedTopicMetadata(TopicName topicName, boolean metadataAutoCreationEnabled)
    • getPartitionedTopicMetadata

      CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> getPartitionedTopicMetadata(TopicName topicName, boolean metadataAutoCreationEnabled, boolean useFallbackForNonPIP344Brokers)
      1.Get the partitions if the topic exists. Return "{partition: n}" if a partitioned topic exists; return "{partition: 0}" if a non-partitioned topic exists. 2. When is "false," neither partitioned topic nor non-partitioned topic does not exist. You will get a PulsarClientException.NotFoundException or a PulsarClientException.TopicDoesNotExistException. 2-1. You will get a PulsarClientException.NotSupportedException with metadataAutoCreationEnabled=false on an old broker version which does not support getting partitions without partitioned metadata auto-creation. 3.When is "true," it will trigger an auto-creation for this topic(using the default topic auto-creation strategy you set for the broker), and the corresponding result is returned. For the result, see case 1.
      Parameters:
      useFallbackForNonPIP344Brokers -

      If true, fallback to the prior behavior of the method getPartitionedTopicMetadata(TopicName) if the broker does not support the PIP-344 feature 'supports_get_partitioned_metadata_without_auto_creation'. This parameter only affects the behavior when is false.

    • getSchema

      Returns current SchemaInfo SchemaInfo for a given topic.
      Parameters:
      topicName - topic-name
      Returns:
      SchemaInfo
    • getSchema

      CompletableFuture<Optional<SchemaInfo>> getSchema(TopicName topicName, byte[] version)
      Returns specific version SchemaInfo SchemaInfo for a given topic.
      Parameters:
      topicName - topic-name
      version - schema info version
      Returns:
      SchemaInfo
    • getServiceUrl

      String getServiceUrl()
      Returns broker-service lookup api url.
      Returns:
    • resolveHost

      InetSocketAddress resolveHost()
      Resolves pulsar service url.
      Returns:
      the service url resolved to a socket address
    • getTopicsUnderNamespace

      CompletableFuture<GetTopicsResult> getTopicsUnderNamespace(NamespaceName namespace, CommandGetTopicsOfNamespace.Mode mode, String topicPattern, String topicsHash)
      Returns all the topics that matches for a given namespace. Note: it relate to the topic name(without the partition suffix). For example: - There is a partitioned topic "tp-a" with two partitions. - tp-a-partition-0 - tp-a-partition-1 - If is "tp-a", the consumer will subscribe to the two partitions. - if is "tp-a-partition-0", the consumer will subscribe nothing.
      Parameters:
      namespace - : namespace-name
      Returns: