Class ClientCnx

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.apache.pulsar.common.protocol.PulsarDecoder
org.apache.pulsar.common.protocol.PulsarHandler
org.apache.pulsar.client.impl.ClientCnx
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class ClientCnx extends org.apache.pulsar.common.protocol.PulsarHandler
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static enum 
     

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.apache.pulsar.client.api.Authentication
     
    protected org.apache.pulsar.client.api.AuthenticationDataProvider
     
    protected final int
     
    protected String
     
    protected String
     
    protected ClientCnx.State
     

    Fields inherited from class org.apache.pulsar.common.protocol.PulsarHandler

    ctx

    Fields inherited from class org.apache.pulsar.common.protocol.PulsarDecoder

    proxyMessage
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup)
     
    ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, int protocolVersion)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
     
    protected void
     
    io.netty.channel.ChannelHandlerContext
    ctx()
     
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
     
    static org.apache.pulsar.client.api.PulsarClientException
    getPulsarClientException(org.apache.pulsar.common.api.proto.ServerError error, String errorMsg)
     
    protected void
    handleAckResponse(org.apache.pulsar.common.api.proto.CommandAckResponse ackResponse)
     
    protected void
    handleActiveConsumerChange(org.apache.pulsar.common.api.proto.CommandActiveConsumerChange change)
     
    protected void
    handleAddPartitionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxnResponse command)
     
    protected void
    handleAddSubscriptionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxnResponse command)
     
    protected void
    handleAuthChallenge(org.apache.pulsar.common.api.proto.CommandAuthChallenge authChallenge)
     
    protected void
    handleCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer closeConsumer)
     
    protected void
    handleCloseProducer(org.apache.pulsar.common.api.proto.CommandCloseProducer closeProducer)
     
    protected void
    handleCommandWatchTopicListSuccess(org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess commandWatchTopicListSuccess)
     
    protected void
    handleCommandWatchTopicUpdate(org.apache.pulsar.common.api.proto.CommandWatchTopicUpdate commandWatchTopicUpdate)
     
    protected void
    handleConnected(org.apache.pulsar.common.api.proto.CommandConnected connected)
     
    protected void
    handleEndTxnOnPartitionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartitionResponse command)
     
    protected void
    handleEndTxnOnSubscriptionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscriptionResponse command)
     
    protected void
    handleEndTxnResponse(org.apache.pulsar.common.api.proto.CommandEndTxnResponse command)
     
    protected void
    handleError(org.apache.pulsar.common.api.proto.CommandError error)
     
    protected void
    handleGetLastMessageIdSuccess(org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse success)
     
    protected void
    handleGetOrCreateSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchemaResponse commandGetOrCreateSchemaResponse)
     
    protected void
    handleGetSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetSchemaResponse commandGetSchemaResponse)
     
    protected void
    handleGetTopicsOfNamespaceSuccess(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespaceResponse success)
     
    protected void
    handleLookupResponse(org.apache.pulsar.common.api.proto.CommandLookupTopicResponse lookupResult)
     
    protected void
    handleMessage(org.apache.pulsar.common.api.proto.CommandMessage cmdMessage, io.netty.buffer.ByteBuf headersAndPayload)
     
    protected void
    handleNewTxnResponse(org.apache.pulsar.common.api.proto.CommandNewTxnResponse command)
     
    protected void
    handlePartitionResponse(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse lookupResult)
     
    protected void
    handleProducerSuccess(org.apache.pulsar.common.api.proto.CommandProducerSuccess success)
     
    protected void
    handleReachedEndOfTopic(org.apache.pulsar.common.api.proto.CommandReachedEndOfTopic commandReachedEndOfTopic)
     
    protected void
    handleSendError(org.apache.pulsar.common.api.proto.CommandSendError sendError)
     
    protected void
    handleSendReceipt(org.apache.pulsar.common.api.proto.CommandSendReceipt sendReceipt)
     
    protected void
    handleSuccess(org.apache.pulsar.common.api.proto.CommandSuccess success)
     
    protected void
    handleTcClientConnectResponse(org.apache.pulsar.common.api.proto.CommandTcClientConnectResponse response)
     
    boolean
    Check client connection is now free.
    protected boolean
     
    static boolean
     
    newAckForReceipt(io.netty.buffer.ByteBuf request, long requestId)
     
    void
    newAckForReceiptWithFuture(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<Void> future)
     
    protected io.netty.buffer.ByteBuf
     
    CompletableFuture<org.apache.pulsar.common.lookup.GetTopicsResult>
    newGetTopicsOfNamespace(io.netty.buffer.ByteBuf request, long requestId)
     
    newLookup(io.netty.buffer.ByteBuf request, long requestId)
     
    CompletableFuture<org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess>
    newWatchTopicList(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicList, long requestId)
     
    CompletableFuture<org.apache.pulsar.common.api.proto.CommandSuccess>
    newWatchTopicListClose(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicListClose, long requestId)
     
    void
     
    CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse>
    sendGetLastMessageId(io.netty.buffer.ByteBuf request, long requestId)
     
    sendGetOrCreateSchema(io.netty.buffer.ByteBuf request, long requestId)
     
    CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetSchemaResponse>
    sendGetRawSchema(io.netty.buffer.ByteBuf request, long requestId)
     
    CompletableFuture<Optional<org.apache.pulsar.common.schema.SchemaInfo>>
    sendGetSchema(io.netty.buffer.ByteBuf request, long requestId)
     

    Methods inherited from class org.apache.pulsar.common.protocol.PulsarHandler

    cancelKeepAliveTask, getRemoteEndpointProtocolVersion, handlePing, handlePong, messageReceived, setRemoteEndpointProtocolVersion

    Methods inherited from class org.apache.pulsar.common.protocol.PulsarDecoder

    channelRead, handleAck, handleAddPartitionToTxn, handleAddSubscriptionToTxn, handleAuthResponse, handleCommandWatchTopicList, handleCommandWatchTopicListClose, handleConnect, handleConsumerStats, handleConsumerStatsResponse, handleEndTxn, handleEndTxnOnPartition, handleEndTxnOnSubscription, handleFlow, handleGetLastMessageId, handleGetOrCreateSchema, handleGetSchema, handleGetTopicsOfNamespace, handleLookup, handleNewTxn, handlePartitionMetadataRequest, handleProducer, handleRedeliverUnacknowledged, handleSeek, handleSend, handleSubscribe, handleTcClientConnectRequest, handleUnsubscribe, interceptCommand

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Field Details

    • authentication

      protected final org.apache.pulsar.client.api.Authentication authentication
    • state

      protected ClientCnx.State state
    • protocolVersion

      protected final int protocolVersion
    • proxyToTargetBrokerAddress

      protected String proxyToTargetBrokerAddress
    • remoteHostName

      protected String remoteHostName
    • authenticationDataProvider

      protected org.apache.pulsar.client.api.AuthenticationDataProvider authenticationDataProvider
  • Constructor Details

    • ClientCnx

      public ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup)
    • ClientCnx

      public ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, int protocolVersion)
  • Method Details

    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class org.apache.pulsar.common.protocol.PulsarHandler
      Throws:
      Exception
    • newConnectCommand

      protected io.netty.buffer.ByteBuf newConnectCommand() throws Exception
      Throws:
      Exception
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class org.apache.pulsar.common.protocol.PulsarHandler
      Throws:
      Exception
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • isKnownException

      public static boolean isKnownException(Throwable t)
    • handleConnected

      protected void handleConnected(org.apache.pulsar.common.api.proto.CommandConnected connected)
      Overrides:
      handleConnected in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleAuthChallenge

      protected void handleAuthChallenge(org.apache.pulsar.common.api.proto.CommandAuthChallenge authChallenge)
      Overrides:
      handleAuthChallenge in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleSendReceipt

      protected void handleSendReceipt(org.apache.pulsar.common.api.proto.CommandSendReceipt sendReceipt)
      Overrides:
      handleSendReceipt in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleAckResponse

      protected void handleAckResponse(org.apache.pulsar.common.api.proto.CommandAckResponse ackResponse)
      Overrides:
      handleAckResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleMessage

      protected void handleMessage(org.apache.pulsar.common.api.proto.CommandMessage cmdMessage, io.netty.buffer.ByteBuf headersAndPayload)
      Overrides:
      handleMessage in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleActiveConsumerChange

      protected void handleActiveConsumerChange(org.apache.pulsar.common.api.proto.CommandActiveConsumerChange change)
      Overrides:
      handleActiveConsumerChange in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleSuccess

      protected void handleSuccess(org.apache.pulsar.common.api.proto.CommandSuccess success)
      Overrides:
      handleSuccess in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleGetLastMessageIdSuccess

      protected void handleGetLastMessageIdSuccess(org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse success)
      Overrides:
      handleGetLastMessageIdSuccess in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleProducerSuccess

      protected void handleProducerSuccess(org.apache.pulsar.common.api.proto.CommandProducerSuccess success)
      Overrides:
      handleProducerSuccess in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleLookupResponse

      protected void handleLookupResponse(org.apache.pulsar.common.api.proto.CommandLookupTopicResponse lookupResult)
      Overrides:
      handleLookupResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handlePartitionResponse

      protected void handlePartitionResponse(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse lookupResult)
      Overrides:
      handlePartitionResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleReachedEndOfTopic

      protected void handleReachedEndOfTopic(org.apache.pulsar.common.api.proto.CommandReachedEndOfTopic commandReachedEndOfTopic)
      Overrides:
      handleReachedEndOfTopic in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleSendError

      protected void handleSendError(org.apache.pulsar.common.api.proto.CommandSendError sendError)
      Overrides:
      handleSendError in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleError

      protected void handleError(org.apache.pulsar.common.api.proto.CommandError error)
      Overrides:
      handleError in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleCloseProducer

      protected void handleCloseProducer(org.apache.pulsar.common.api.proto.CommandCloseProducer closeProducer)
      Overrides:
      handleCloseProducer in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleCloseConsumer

      protected void handleCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer closeConsumer)
      Overrides:
      handleCloseConsumer in class org.apache.pulsar.common.protocol.PulsarDecoder
    • isHandshakeCompleted

      protected boolean isHandshakeCompleted()
      Specified by:
      isHandshakeCompleted in class org.apache.pulsar.common.protocol.PulsarHandler
    • newLookup

      public CompletableFuture<BinaryProtoLookupService.LookupDataResult> newLookup(io.netty.buffer.ByteBuf request, long requestId)
    • newGetTopicsOfNamespace

      public CompletableFuture<org.apache.pulsar.common.lookup.GetTopicsResult> newGetTopicsOfNamespace(io.netty.buffer.ByteBuf request, long requestId)
    • newAckForReceipt

      public CompletableFuture<Void> newAckForReceipt(io.netty.buffer.ByteBuf request, long requestId)
    • newAckForReceiptWithFuture

      public void newAckForReceiptWithFuture(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<Void> future)
    • handleGetTopicsOfNamespaceSuccess

      protected void handleGetTopicsOfNamespaceSuccess(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespaceResponse success)
      Overrides:
      handleGetTopicsOfNamespaceSuccess in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleGetSchemaResponse

      protected void handleGetSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetSchemaResponse commandGetSchemaResponse)
      Overrides:
      handleGetSchemaResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleGetOrCreateSchemaResponse

      protected void handleGetOrCreateSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchemaResponse commandGetOrCreateSchemaResponse)
      Overrides:
      handleGetOrCreateSchemaResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • ctx

      public io.netty.channel.ChannelHandlerContext ctx()
    • sendGetLastMessageId

      public CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse> sendGetLastMessageId(io.netty.buffer.ByteBuf request, long requestId)
    • sendGetSchema

      public CompletableFuture<Optional<org.apache.pulsar.common.schema.SchemaInfo>> sendGetSchema(io.netty.buffer.ByteBuf request, long requestId)
    • sendGetRawSchema

      public CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetSchemaResponse> sendGetRawSchema(io.netty.buffer.ByteBuf request, long requestId)
    • sendGetOrCreateSchema

      public CompletableFuture<byte[]> sendGetOrCreateSchema(io.netty.buffer.ByteBuf request, long requestId)
    • handleNewTxnResponse

      protected void handleNewTxnResponse(org.apache.pulsar.common.api.proto.CommandNewTxnResponse command)
      Overrides:
      handleNewTxnResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleAddPartitionToTxnResponse

      protected void handleAddPartitionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxnResponse command)
      Overrides:
      handleAddPartitionToTxnResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleAddSubscriptionToTxnResponse

      protected void handleAddSubscriptionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxnResponse command)
      Overrides:
      handleAddSubscriptionToTxnResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleEndTxnOnPartitionResponse

      protected void handleEndTxnOnPartitionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartitionResponse command)
      Overrides:
      handleEndTxnOnPartitionResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleEndTxnOnSubscriptionResponse

      protected void handleEndTxnOnSubscriptionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscriptionResponse command)
      Overrides:
      handleEndTxnOnSubscriptionResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleEndTxnResponse

      protected void handleEndTxnResponse(org.apache.pulsar.common.api.proto.CommandEndTxnResponse command)
      Overrides:
      handleEndTxnResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleTcClientConnectResponse

      protected void handleTcClientConnectResponse(org.apache.pulsar.common.api.proto.CommandTcClientConnectResponse response)
      Overrides:
      handleTcClientConnectResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
    • newWatchTopicList

      public CompletableFuture<org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess> newWatchTopicList(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicList, long requestId)
    • newWatchTopicListClose

      public CompletableFuture<org.apache.pulsar.common.api.proto.CommandSuccess> newWatchTopicListClose(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicListClose, long requestId)
    • handleCommandWatchTopicListSuccess

      protected void handleCommandWatchTopicListSuccess(org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess commandWatchTopicListSuccess)
      Overrides:
      handleCommandWatchTopicListSuccess in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleCommandWatchTopicUpdate

      protected void handleCommandWatchTopicUpdate(org.apache.pulsar.common.api.proto.CommandWatchTopicUpdate commandWatchTopicUpdate)
      Overrides:
      handleCommandWatchTopicUpdate in class org.apache.pulsar.common.protocol.PulsarDecoder
    • registerTransactionBufferHandler

      public void registerTransactionBufferHandler(TransactionBufferHandler handler)
    • getPulsarClientException

      public static org.apache.pulsar.client.api.PulsarClientException getPulsarClientException(org.apache.pulsar.common.api.proto.ServerError error, String errorMsg)
    • close

      public void close()
    • closeWithException

      protected void closeWithException(Throwable e)
    • idleCheck

      public boolean idleCheck()
      Check client connection is now free. This method will not change the state to idle.
      Returns:
      true if the connection is eligible.