Package org.apache.pulsar.client.impl
Class HttpLookupService
java.lang.Object
org.apache.pulsar.client.impl.HttpLookupService
- All Implemented Interfaces:
AutoCloseable,LookupService
-
Constructor Summary
ConstructorsConstructorDescriptionHttpLookupService(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()CompletableFuture<org.apache.commons.lang3.tuple.Pair<InetSocketAddress,InetSocketAddress>> Calls http-lookup api to find broker-service address which can serve a given topic.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 topicsPattern, 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pulsar.client.impl.LookupService
getPartitionedTopicMetadata, getPartitionedTopicMetadata
-
Constructor Details
-
HttpLookupService
public HttpLookupService(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) throws PulsarClientException - Throws:
PulsarClientException
-
-
Method Details
-
updateServiceUrl
Description copied from interface:LookupServiceInstruct the LookupService to switch to a new service URL for all subsequent requests.- Specified by:
updateServiceUrlin interfaceLookupService- Throws:
PulsarClientException
-
getBroker
public CompletableFuture<org.apache.commons.lang3.tuple.Pair<InetSocketAddress,InetSocketAddress>> getBroker(TopicName topicName) Calls http-lookup api to find broker-service address which can serve a given topic.- Specified by:
getBrokerin interfaceLookupService- Parameters:
topicName- topic-name- Returns:
- broker-socket-address that serves given topic
-
getPartitionedTopicMetadata
public 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.- Specified by:
getPartitionedTopicMetadatain interfaceLookupService- Parameters:
useFallbackForNonPIP344Brokers- HttpLookupService ignores this parameter
-
getServiceUrl
Description copied from interface:LookupServiceReturns broker-service lookup api url.- Specified by:
getServiceUrlin interfaceLookupService- Returns:
-
resolveHost
Description copied from interface:LookupServiceResolves pulsar service url.- Specified by:
resolveHostin interfaceLookupService- Returns:
- the service url resolved to a socket address
-
getTopicsUnderNamespace
public CompletableFuture<GetTopicsResult> getTopicsUnderNamespace(NamespaceName namespace, CommandGetTopicsOfNamespace.Mode mode, String topicsPattern, String topicsHash) Description copied from interface:LookupServiceReturns 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.- Specified by:
getTopicsUnderNamespacein interfaceLookupService- Parameters:
namespace- : namespace-name- Returns:
-
getSchema
Description copied from interface:LookupServiceReturns current SchemaInfoSchemaInfofor a given topic.- Specified by:
getSchemain interfaceLookupService- Parameters:
topicName- topic-name- Returns:
- SchemaInfo
-
getSchema
Description copied from interface:LookupServiceReturns specific version SchemaInfoSchemaInfofor a given topic.- Specified by:
getSchemain interfaceLookupService- Parameters:
topicName- topic-nameversion- schema info version- Returns:
- SchemaInfo
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-