Class 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 class  ClientCnx.State  
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void channelActive​(io.netty.channel.ChannelHandlerContext ctx)  
      void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)  
      void close()  
      protected void closeWithException​(java.lang.Throwable e)  
      io.netty.channel.ChannelHandlerContext ctx()  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)  
      static org.apache.pulsar.client.api.PulsarClientException getPulsarClientException​(org.apache.pulsar.common.api.proto.ServerError error, java.lang.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 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)  
      protected boolean isHandshakeCompleted()  
      static boolean isKnownException​(java.lang.Throwable t)  
      java.util.concurrent.CompletableFuture<java.lang.Void> newAckForReceipt​(io.netty.buffer.ByteBuf request, long requestId)  
      void newAckForReceiptWithFuture​(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<java.lang.Void> future)  
      protected io.netty.buffer.ByteBuf newConnectCommand()  
      java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> newGetTopicsOfNamespace​(io.netty.buffer.ByteBuf request, long requestId)  
      java.util.concurrent.CompletableFuture<BinaryProtoLookupService.LookupDataResult> newLookup​(io.netty.buffer.ByteBuf request, long requestId)  
      void registerTransactionBufferHandler​(TransactionBufferHandler handler)  
      java.util.concurrent.CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse> sendGetLastMessageId​(io.netty.buffer.ByteBuf request, long requestId)  
      java.util.concurrent.CompletableFuture<byte[]> sendGetOrCreateSchema​(io.netty.buffer.ByteBuf request, long requestId)  
      java.util.concurrent.CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetSchemaResponse> sendGetRawSchema​(io.netty.buffer.ByteBuf request, long requestId)  
      java.util.concurrent.CompletableFuture<java.util.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, 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 Detail

      • authentication

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

        protected final int protocolVersion
      • proxyToTargetBrokerAddress

        protected java.lang.String proxyToTargetBrokerAddress
      • remoteHostName

        protected java.lang.String remoteHostName
      • authenticationDataProvider

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

      • ClientCnx

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

      • channelActive

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

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

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

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    java.lang.Throwable cause)
                             throws java.lang.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:
        java.lang.Exception
      • isKnownException

        public static boolean isKnownException​(java.lang.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
      • newGetTopicsOfNamespace

        public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> newGetTopicsOfNamespace​(io.netty.buffer.ByteBuf request,
                                                                                                                long requestId)
      • newAckForReceipt

        public java.util.concurrent.CompletableFuture<java.lang.Void> newAckForReceipt​(io.netty.buffer.ByteBuf request,
                                                                                       long requestId)
      • newAckForReceiptWithFuture

        public void newAckForReceiptWithFuture​(io.netty.buffer.ByteBuf request,
                                               long requestId,
                                               TimedCompletableFuture<java.lang.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 java.util.concurrent.CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse> sendGetLastMessageId​(io.netty.buffer.ByteBuf request,
                                                                                                                                               long requestId)
      • sendGetSchema

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

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

        public java.util.concurrent.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
      • getPulsarClientException

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

        public void close()
      • closeWithException

        protected void closeWithException​(java.lang.Throwable e)