Package org.apache.pulsar.client.impl
Class PulsarClientImpl
java.lang.Object
org.apache.pulsar.client.impl.PulsarClientImpl
- All Implemented Interfaces:
Closeable
,AutoCloseable
,PulsarClient
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ClientConfigurationData
protected final io.netty.channel.EventLoopGroup
-
Constructor Summary
ConstructorDescriptionPulsarClientImpl
(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) PulsarClientImpl
(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool) PulsarClientImpl
(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool, io.netty.util.Timer timer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
createLookup
(String url) protected <T> CompletableFuture<Reader<T>>
createMultiTopicReaderAsync
(ReaderConfigurationData<T> conf, Schema<T> schema) CompletableFuture<Producer<byte[]>>
<T> CompletableFuture<Producer<T>>
createProducerAsync
(ProducerConfigurationData conf, Schema<T> schema) <T> CompletableFuture<Producer<T>>
createProducerAsync
(ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors interceptors) CompletableFuture<Reader<byte[]>>
createReaderAsync
(ReaderConfigurationData<byte[]> conf) <T> CompletableFuture<Reader<T>>
createReaderAsync
(ReaderConfigurationData<T> conf, Schema<T> schema) protected <T> CompletableFuture<Reader<T>>
createSingleTopicReaderAsync
(ReaderConfigurationData<T> conf, Schema<T> schema) io.netty.channel.EventLoopGroup
getConnection
(String topic) Only for test.CompletableFuture<org.apache.commons.lang3.tuple.Pair<ClientCnx,
Boolean>> getConnection
(String topic, int randomKeyForSelectConnection) getConnection
(String topic, String url) getConnection
(InetSocketAddress logicalAddress, InetSocketAddress physicalAddress, int randomKeyForSelectConnection) getNumberOfPartitions
(String topic) CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata>
getPartitionsForTopic
(String topic) getProxyConnection
(InetSocketAddress logicalAddress, int randomKeyForSelectConnection) Read the schema information for a given topic.com.google.common.cache.LoadingCache<String,
SchemaInfoProvider> getState()
boolean
isClosed()
ConsumerBuilder<byte[]>
<T> ConsumerBuilder<T>
newConsumer
(Schema<T> schema) protected <T> PartitionedProducerImpl<T>
newPartitionedProducerImpl
(String topic, ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors interceptors, CompletableFuture<Producer<T>> producerCreatedFuture, org.apache.pulsar.common.partition.PartitionedTopicMetadata metadata) Factory method for creating PartitionedProducerImpl instance.ProducerBuilder<byte[]>
<T> ProducerBuilder<T>
newProducer
(Schema<T> schema) protected <T> ProducerImpl<T>
newProducerImpl
(String topic, int partitionIndex, ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors interceptors, CompletableFuture<Producer<T>> producerCreatedFuture, Optional<String> overrideProducerName) Factory method for creating ProducerImpl instance.ReaderBuilder<byte[]>
<T> ReaderBuilder<T>
long
TableViewBuilder<byte[]>
<T> TableViewBuilder<T>
newTableView
(Schema<T> schema) <T> TableViewBuilder<T>
newTableViewBuilder
(Schema<T> schema) Deprecated.CompletableFuture<Consumer<byte[]>>
patternTopicSubscribeAsync
(ConsumerConfigurationData<byte[]> conf) protected <T> CompletableFuture<Schema<T>>
preProcessSchemaBeforeSubscribe
(PulsarClientImpl pulsarClientImpl, Schema<T> schema, String topicName) void
void
setLookup
(LookupService lookup) void
shutdown()
CompletableFuture<Consumer<byte[]>>
subscribeAsync
(ConsumerConfigurationData<byte[]> conf) <T> CompletableFuture<Consumer<T>>
subscribeAsync
(ConsumerConfigurationData<T> conf, Schema<T> schema, ConsumerInterceptors<T> interceptors) io.netty.util.Timer
timer()
visible for pulsar-functions.void
updateAuthentication
(Authentication authentication) void
updateServiceUrl
(String serviceUrl) void
updateTlsTrustCertsFilePath
(String tlsTrustCertsFilePath) void
updateTlsTrustStorePathAndPassword
(String tlsTrustStorePath, String tlsTrustStorePassword)
-
Field Details
-
conf
-
eventLoopGroup
protected final io.netty.channel.EventLoopGroup eventLoopGroup
-
-
Constructor Details
-
PulsarClientImpl
- Throws:
PulsarClientException
-
PulsarClientImpl
public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) throws PulsarClientException - Throws:
PulsarClientException
-
PulsarClientImpl
public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool) throws PulsarClientException - Throws:
PulsarClientException
-
PulsarClientImpl
public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool, io.netty.util.Timer timer) throws PulsarClientException - Throws:
PulsarClientException
-
-
Method Details
-
getConfiguration
-
getClientClock
-
getState
-
newProducer
- Specified by:
newProducer
in interfacePulsarClient
-
newProducer
- Specified by:
newProducer
in interfacePulsarClient
-
newConsumer
- Specified by:
newConsumer
in interfacePulsarClient
-
newConsumer
- Specified by:
newConsumer
in interfacePulsarClient
-
newReader
- Specified by:
newReader
in interfacePulsarClient
-
newReader
- Specified by:
newReader
in interfacePulsarClient
-
newTableViewBuilder
Deprecated.usenewTableView(Schema)
instead.- Specified by:
newTableViewBuilder
in interfacePulsarClient
-
newTableView
- Specified by:
newTableView
in interfacePulsarClient
-
newTableView
- Specified by:
newTableView
in interfacePulsarClient
-
createProducerAsync
-
createProducerAsync
public <T> CompletableFuture<Producer<T>> createProducerAsync(ProducerConfigurationData conf, Schema<T> schema) -
createProducerAsync
public <T> CompletableFuture<Producer<T>> createProducerAsync(ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors interceptors) -
newPartitionedProducerImpl
protected <T> PartitionedProducerImpl<T> newPartitionedProducerImpl(String topic, ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors interceptors, CompletableFuture<Producer<T>> producerCreatedFuture, org.apache.pulsar.common.partition.PartitionedTopicMetadata metadata) Factory method for creating PartitionedProducerImpl instance. Allows overriding the PartitionedProducerImpl instance in tests.- Type Parameters:
T
- message type class- Parameters:
topic
- topic nameconf
- producer configurationschema
- topic schemainterceptors
- producer interceptorsproducerCreatedFuture
- future for signaling completion of async producer creationmetadata
- partitioned topic metadata- Returns:
- new PartitionedProducerImpl instance
-
newProducerImpl
protected <T> ProducerImpl<T> newProducerImpl(String topic, int partitionIndex, ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors interceptors, CompletableFuture<Producer<T>> producerCreatedFuture, Optional<String> overrideProducerName) Factory method for creating ProducerImpl instance. Allows overriding the ProducerImpl instance in tests.- Type Parameters:
T
- message type class- Parameters:
topic
- topic namepartitionIndex
- partition index of a partitioned topic. the value -1 is used for non-partitioned topics.conf
- producer configurationschema
- topic schemainterceptors
- producer interceptorsproducerCreatedFuture
- future for signaling completion of async producer creation- Returns:
- a producer instance
-
subscribeAsync
-
subscribeAsync
public <T> CompletableFuture<Consumer<T>> subscribeAsync(ConsumerConfigurationData<T> conf, Schema<T> schema, ConsumerInterceptors<T> interceptors) -
patternTopicSubscribeAsync
public CompletableFuture<Consumer<byte[]>> patternTopicSubscribeAsync(ConsumerConfigurationData<byte[]> conf) -
createReaderAsync
-
createReaderAsync
public <T> CompletableFuture<Reader<T>> createReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) -
createMultiTopicReaderAsync
protected <T> CompletableFuture<Reader<T>> createMultiTopicReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) -
createSingleTopicReaderAsync
protected <T> CompletableFuture<Reader<T>> createSingleTopicReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema) -
getSchema
Read the schema information for a given topic. If the topic does not exist or it has no schema associated, it will return an empty response -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacePulsarClient
- Throws:
PulsarClientException
-
closeAsync
- Specified by:
closeAsync
in interfacePulsarClient
-
shutdown
- Specified by:
shutdown
in interfacePulsarClient
- Throws:
PulsarClientException
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfacePulsarClient
-
updateServiceUrl
- Specified by:
updateServiceUrl
in interfacePulsarClient
- Throws:
PulsarClientException
-
updateAuthentication
- Throws:
IOException
-
updateTlsTrustCertsFilePath
-
updateTlsTrustStorePathAndPassword
-
getConnection
public CompletableFuture<org.apache.commons.lang3.tuple.Pair<ClientCnx,Boolean>> getConnection(String topic, int randomKeyForSelectConnection) -
getConnection
Only for test. -
getConnection
-
getLookup
-
getConnectionToServiceUrl
-
getProxyConnection
public CompletableFuture<ClientCnx> getProxyConnection(InetSocketAddress logicalAddress, int randomKeyForSelectConnection) -
getConnection
public CompletableFuture<ClientCnx> getConnection(InetSocketAddress logicalAddress, InetSocketAddress physicalAddress, int randomKeyForSelectConnection) -
timer
public io.netty.util.Timer timer()visible for pulsar-functions. -
externalExecutorProvider
-
newRequestId
public long newRequestId() -
getCnxPool
-
eventLoopGroup
public io.netty.channel.EventLoopGroup eventLoopGroup() -
setLookup
-
getLookup
-
reloadLookUp
- Throws:
PulsarClientException
-
createLookup
- Throws:
PulsarClientException
-
getNumberOfPartitions
-
getPartitionedTopicMetadata
public CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> getPartitionedTopicMetadata(String topic) -
getPartitionsForTopic
- Specified by:
getPartitionsForTopic
in interfacePulsarClient
-
getSchemaProviderLoadingCache
public com.google.common.cache.LoadingCache<String,SchemaInfoProvider> getSchemaProviderLoadingCache() -
getMemoryLimitController
-
preProcessSchemaBeforeSubscribe
protected <T> CompletableFuture<Schema<T>> preProcessSchemaBeforeSubscribe(PulsarClientImpl pulsarClientImpl, Schema<T> schema, String topicName) -
getInternalExecutorService
-
getScheduledExecutorProvider
-
newTransaction
- Specified by:
newTransaction
in interfacePulsarClient
-
newTableView(Schema)
instead.