Package org.apache.pulsar.client.impl
Interface LookupService
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BinaryProtoLookupService,HttpLookupService
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 Summary
Modifier and TypeMethodDescriptionCompletableFuture<org.apache.commons.lang3.tuple.Pair<InetSocketAddress,InetSocketAddress>> Calls broker lookup-api to get brokerInetSocketAddresswhich serves namespace bundle that contains given topic.default CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata>getPartitionedTopicMetadata(TopicName topicName) Deprecated.default CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata>getPartitionedTopicMetadata(TopicName topicName, boolean metadataAutoCreationEnabled) CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata>getPartitionedTopicMetadata(TopicName topicName, boolean metadataAutoCreationEnabled, boolean useFallbackForNonPIP344Brokers) 1.Get the partitions if the topic exists.Returns current SchemaInfoSchemaInfofor a given topic.Returns specific version SchemaInfoSchemaInfofor a given topic.Returns broker-service lookup api url.getTopicsUnderNamespace(NamespaceName namespace, CommandGetTopicsOfNamespace.Mode mode, String topicPattern, String topicsHash) Returns all the topics that matches for a given namespace.Resolves pulsar service url.voidupdateServiceUrl(String serviceUrl) Instruct the LookupService to switch to a new service URL for all subsequent requests.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
updateServiceUrl
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 brokerInetSocketAddresswhich 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) Deprecated.Please call {getPartitionedTopicMetadata(TopicName, boolean, boolean)}.ReturnsPartitionedTopicMetadatafor 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 aPulsarClientException.NotFoundExceptionor aPulsarClientException.TopicDoesNotExistException. 2-1. You will get aPulsarClientException.NotSupportedExceptionwith 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 SchemaInfoSchemaInfofor a given topic.- Parameters:
topicName- topic-name- Returns:
- SchemaInfo
-
getSchema
Returns specific version SchemaInfoSchemaInfofor a given topic.- Parameters:
topicName- topic-nameversion- 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:
-
getPartitionedTopicMetadata(TopicName, boolean, boolean)}.