Class PulsarClientImpl

java.lang.Object
org.apache.pulsar.client.impl.PulsarClientImpl
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.pulsar.client.api.PulsarClient

public class PulsarClientImpl extends Object implements org.apache.pulsar.client.api.PulsarClient
  • Field Details

    • conf

      protected final ClientConfigurationData conf
    • eventLoopGroup

      protected final io.netty.channel.EventLoopGroup eventLoopGroup
  • Constructor Details

    • PulsarClientImpl

      public PulsarClientImpl(ClientConfigurationData conf) throws org.apache.pulsar.client.api.PulsarClientException
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • PulsarClientImpl

      public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) throws org.apache.pulsar.client.api.PulsarClientException
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • PulsarClientImpl

      public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool) throws org.apache.pulsar.client.api.PulsarClientException
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • PulsarClientImpl

      public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool, io.netty.util.Timer timer) throws org.apache.pulsar.client.api.PulsarClientException
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
  • Method Details

    • getConfiguration

      public ClientConfigurationData getConfiguration()
    • getClientClock

      public Clock getClientClock()
    • getState

    • newProducer

      public org.apache.pulsar.client.api.ProducerBuilder<byte[]> newProducer()
      Specified by:
      newProducer in interface org.apache.pulsar.client.api.PulsarClient
    • newProducer

      public <T> org.apache.pulsar.client.api.ProducerBuilder<T> newProducer(org.apache.pulsar.client.api.Schema<T> schema)
      Specified by:
      newProducer in interface org.apache.pulsar.client.api.PulsarClient
    • newConsumer

      public org.apache.pulsar.client.api.ConsumerBuilder<byte[]> newConsumer()
      Specified by:
      newConsumer in interface org.apache.pulsar.client.api.PulsarClient
    • newConsumer

      public <T> org.apache.pulsar.client.api.ConsumerBuilder<T> newConsumer(org.apache.pulsar.client.api.Schema<T> schema)
      Specified by:
      newConsumer in interface org.apache.pulsar.client.api.PulsarClient
    • newReader

      public org.apache.pulsar.client.api.ReaderBuilder<byte[]> newReader()
      Specified by:
      newReader in interface org.apache.pulsar.client.api.PulsarClient
    • newReader

      public <T> org.apache.pulsar.client.api.ReaderBuilder<T> newReader(org.apache.pulsar.client.api.Schema<T> schema)
      Specified by:
      newReader in interface org.apache.pulsar.client.api.PulsarClient
    • newTableViewBuilder

      public <T> org.apache.pulsar.client.api.TableViewBuilder<T> newTableViewBuilder(org.apache.pulsar.client.api.Schema<T> schema)
      Specified by:
      newTableViewBuilder in interface org.apache.pulsar.client.api.PulsarClient
    • createProducerAsync

      public CompletableFuture<org.apache.pulsar.client.api.Producer<byte[]>> createProducerAsync(ProducerConfigurationData conf)
    • createProducerAsync

      public <T> CompletableFuture<org.apache.pulsar.client.api.Producer<T>> createProducerAsync(ProducerConfigurationData conf, org.apache.pulsar.client.api.Schema<T> schema)
    • createProducerAsync

      public <T> CompletableFuture<org.apache.pulsar.client.api.Producer<T>> createProducerAsync(ProducerConfigurationData conf, org.apache.pulsar.client.api.Schema<T> schema, ProducerInterceptors interceptors)
    • newPartitionedProducerImpl

      protected <T> PartitionedProducerImpl<T> newPartitionedProducerImpl(String topic, ProducerConfigurationData conf, org.apache.pulsar.client.api.Schema<T> schema, ProducerInterceptors interceptors, CompletableFuture<org.apache.pulsar.client.api.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 name
      conf - producer configuration
      schema - topic schema
      interceptors - producer interceptors
      producerCreatedFuture - future for signaling completion of async producer creation
      metadata - partitioned topic metadata
      Returns:
      new PartitionedProducerImpl instance
    • newProducerImpl

      protected <T> ProducerImpl<T> newProducerImpl(String topic, int partitionIndex, ProducerConfigurationData conf, org.apache.pulsar.client.api.Schema<T> schema, ProducerInterceptors interceptors, CompletableFuture<org.apache.pulsar.client.api.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 name
      partitionIndex - partition index of a partitioned topic. the value -1 is used for non-partitioned topics.
      conf - producer configuration
      schema - topic schema
      interceptors - producer interceptors
      producerCreatedFuture - future for signaling completion of async producer creation
      Returns:
      a producer instance
    • subscribeAsync

      public CompletableFuture<org.apache.pulsar.client.api.Consumer<byte[]>> subscribeAsync(ConsumerConfigurationData<byte[]> conf)
    • subscribeAsync

      public <T> CompletableFuture<org.apache.pulsar.client.api.Consumer<T>> subscribeAsync(ConsumerConfigurationData<T> conf, org.apache.pulsar.client.api.Schema<T> schema, ConsumerInterceptors<T> interceptors)
    • patternTopicSubscribeAsync

      public CompletableFuture<org.apache.pulsar.client.api.Consumer<byte[]>> patternTopicSubscribeAsync(ConsumerConfigurationData<byte[]> conf)
    • createReaderAsync

      public CompletableFuture<org.apache.pulsar.client.api.Reader<byte[]>> createReaderAsync(ReaderConfigurationData<byte[]> conf)
    • createReaderAsync

      public <T> CompletableFuture<org.apache.pulsar.client.api.Reader<T>> createReaderAsync(ReaderConfigurationData<T> conf, org.apache.pulsar.client.api.Schema<T> schema)
    • createMultiTopicReaderAsync

      protected <T> CompletableFuture<org.apache.pulsar.client.api.Reader<T>> createMultiTopicReaderAsync(ReaderConfigurationData<T> conf, org.apache.pulsar.client.api.Schema<T> schema)
    • createSingleTopicReaderAsync

      protected <T> CompletableFuture<org.apache.pulsar.client.api.Reader<T>> createSingleTopicReaderAsync(ReaderConfigurationData<T> conf, org.apache.pulsar.client.api.Schema<T> schema)
    • getSchema

      public CompletableFuture<Optional<org.apache.pulsar.common.schema.SchemaInfo>> getSchema(String topic)
      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

      public void close() throws org.apache.pulsar.client.api.PulsarClientException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.pulsar.client.api.PulsarClient
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • closeAsync

      public CompletableFuture<Void> closeAsync()
      Specified by:
      closeAsync in interface org.apache.pulsar.client.api.PulsarClient
    • shutdown

      public void shutdown() throws org.apache.pulsar.client.api.PulsarClientException
      Specified by:
      shutdown in interface org.apache.pulsar.client.api.PulsarClient
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface org.apache.pulsar.client.api.PulsarClient
    • updateServiceUrl

      public void updateServiceUrl(String serviceUrl) throws org.apache.pulsar.client.api.PulsarClientException
      Specified by:
      updateServiceUrl in interface org.apache.pulsar.client.api.PulsarClient
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • updateAuthentication

      public void updateAuthentication(org.apache.pulsar.client.api.Authentication authentication) throws IOException
      Throws:
      IOException
    • updateTlsTrustCertsFilePath

      public void updateTlsTrustCertsFilePath(String tlsTrustCertsFilePath)
    • updateTlsTrustStorePathAndPassword

      public void updateTlsTrustStorePathAndPassword(String tlsTrustStorePath, String tlsTrustStorePassword)
    • getConnection

      public CompletableFuture<ClientCnx> getConnection(String topic)
    • getConnectionToServiceUrl

      public CompletableFuture<ClientCnx> getConnectionToServiceUrl()
    • getConnection

      public CompletableFuture<ClientCnx> getConnection(InetSocketAddress logicalAddress, InetSocketAddress physicalAddress)
    • timer

      public io.netty.util.Timer timer()
      visible for pulsar-functions.
    • externalExecutorProvider

      public ExecutorProvider externalExecutorProvider()
    • newRequestId

      public long newRequestId()
    • getCnxPool

      public ConnectionPool getCnxPool()
    • eventLoopGroup

      public io.netty.channel.EventLoopGroup eventLoopGroup()
    • getLookup

      public LookupService getLookup()
    • reloadLookUp

      public void reloadLookUp() throws org.apache.pulsar.client.api.PulsarClientException
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • getNumberOfPartitions

      public CompletableFuture<Integer> getNumberOfPartitions(String topic)
    • getPartitionedTopicMetadata

      public CompletableFuture<org.apache.pulsar.common.partition.PartitionedTopicMetadata> getPartitionedTopicMetadata(String topic)
    • getPartitionsForTopic

      public CompletableFuture<List<String>> getPartitionsForTopic(String topic)
      Specified by:
      getPartitionsForTopic in interface org.apache.pulsar.client.api.PulsarClient
    • getSchemaProviderLoadingCache

      public com.google.common.cache.LoadingCache<String,org.apache.pulsar.client.api.schema.SchemaInfoProvider> getSchemaProviderLoadingCache()
    • getMemoryLimitController

      public MemoryLimitController getMemoryLimitController()
    • preProcessSchemaBeforeSubscribe

      protected <T> CompletableFuture<org.apache.pulsar.client.api.Schema<T>> preProcessSchemaBeforeSubscribe(PulsarClientImpl pulsarClientImpl, org.apache.pulsar.client.api.Schema<T> schema, String topicName)
    • getInternalExecutorService

      public ExecutorService getInternalExecutorService()
    • getScheduledExecutorProvider

      public ScheduledExecutorProvider getScheduledExecutorProvider()
    • newTransaction

      public org.apache.pulsar.client.api.transaction.TransactionBuilder newTransaction() throws org.apache.pulsar.client.api.PulsarClientException
      Specified by:
      newTransaction in interface org.apache.pulsar.client.api.PulsarClient
      Throws:
      org.apache.pulsar.client.api.PulsarClientException