Class ServerCnx

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, TransportCnx

    public class ServerCnx
    extends org.apache.pulsar.common.protocol.PulsarHandler
    implements TransportCnx
    • Nested Class Summary

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

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

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

        ctx, remoteAddress
      • Fields inherited from class org.apache.pulsar.common.protocol.PulsarDecoder

        proxyMessage
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancelPublishBufferLimiting()  
      void cancelPublishRateLimiting()  
      void channelActive​(io.netty.channel.ChannelHandlerContext ctx)  
      void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)  
      void channelWritabilityChanged​(io.netty.channel.ChannelHandlerContext ctx)  
      java.net.SocketAddress clientAddress()  
      java.lang.String clientSourceAddress()  
      protected void close()
      It closes the connection with client which triggers channelInactive() which clears all producers and consumers from connection-map.
      void closeConsumer​(Consumer consumer)  
      void closeProducer​(Producer producer)  
      void completedSendOperation​(boolean isNonPersistentTopic, int msgSize)  
      io.netty.channel.ChannelHandlerContext ctx()  
      void disableCnxAutoRead()  
      void enableCnxAutoRead()  
      boolean equals​(java.lang.Object o)  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)  
      void execute​(java.lang.Runnable runnable)  
      protected org.apache.pulsar.broker.authentication.AuthenticationDataSource getAuthData()  
      org.apache.pulsar.broker.authentication.AuthenticationDataSource getAuthenticationData()  
      org.apache.pulsar.broker.authentication.AuthenticationProvider getAuthenticationProvider()  
      java.lang.String getAuthMethod()  
      java.lang.String getAuthRole()
      The security role for this connection.
      org.apache.pulsar.broker.authentication.AuthenticationState getAuthState()  
      BrokerService getBrokerService()  
      java.lang.String getClientVersion()  
      PulsarCommandSender getCommandSender()  
      org.apache.pulsar.common.util.collections.ConcurrentLongHashMap<java.util.concurrent.CompletableFuture<Consumer>> getConsumers()  
      io.netty.handler.codec.haproxy.HAProxyMessage getHAProxyMessage()  
      protected org.apache.pulsar.broker.authentication.AuthenticationDataSource getOriginalAuthData()  
      protected org.apache.pulsar.broker.authentication.AuthenticationState getOriginalAuthState()  
      protected java.lang.String getOriginalPrincipal()  
      java.lang.String getPrincipal()  
      org.apache.pulsar.common.util.collections.ConcurrentLongHashMap<java.util.concurrent.CompletableFuture<Producer>> getProducers()  
      java.net.SocketAddress getRemoteAddress()  
      java.lang.String getRole()  
      org.apache.pulsar.broker.service.ServerCnx.State getState()
      Helper method for testability.
      protected void handleAck​(org.apache.pulsar.common.api.proto.CommandAck ack)  
      protected void handleAddPartitionToTxn​(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxn command)  
      protected void handleAddSubscriptionToTxn​(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxn command)  
      protected void handleAuthResponse​(org.apache.pulsar.common.api.proto.CommandAuthResponse authResponse)  
      protected void handleCloseConsumer​(org.apache.pulsar.common.api.proto.CommandCloseConsumer closeConsumer)  
      protected void handleCloseProducer​(org.apache.pulsar.common.api.proto.CommandCloseProducer closeProducer)  
      protected void handleConnect​(org.apache.pulsar.common.api.proto.CommandConnect connect)  
      protected void handleConsumerStats​(org.apache.pulsar.common.api.proto.CommandConsumerStats commandConsumerStats)  
      protected void handleEndTxn​(org.apache.pulsar.common.api.proto.CommandEndTxn command)  
      protected void handleEndTxnOnPartition​(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartition command)  
      protected void handleEndTxnOnSubscription​(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscription command)  
      protected void handleFlow​(org.apache.pulsar.common.api.proto.CommandFlow flow)  
      protected void handleGetLastMessageId​(org.apache.pulsar.common.api.proto.CommandGetLastMessageId getLastMessageId)  
      protected void handleGetOrCreateSchema​(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchema commandGetOrCreateSchema)  
      protected void handleGetSchema​(org.apache.pulsar.common.api.proto.CommandGetSchema commandGetSchema)  
      protected void handleGetTopicsOfNamespace​(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace commandGetTopicsOfNamespace)  
      protected void handleLookup​(org.apache.pulsar.common.api.proto.CommandLookupTopic lookup)  
      protected void handleNewTxn​(org.apache.pulsar.common.api.proto.CommandNewTxn command)  
      protected void handlePartitionMetadataRequest​(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadata partitionMetadata)  
      protected void handleProducer​(org.apache.pulsar.common.api.proto.CommandProducer cmdProducer)  
      protected void handleRedeliverUnacknowledged​(org.apache.pulsar.common.api.proto.CommandRedeliverUnacknowledgedMessages redeliver)  
      protected void handleSeek​(org.apache.pulsar.common.api.proto.CommandSeek seek)  
      protected void handleSend​(org.apache.pulsar.common.api.proto.CommandSend send, io.netty.buffer.ByteBuf headersAndPayload)  
      protected void handleSubscribe​(org.apache.pulsar.common.api.proto.CommandSubscribe subscribe)  
      protected void handleTcClientConnectRequest​(org.apache.pulsar.common.api.proto.CommandTcClientConnectRequest command)  
      protected void handleUnsubscribe​(org.apache.pulsar.common.api.proto.CommandUnsubscribe unsubscribe)  
      boolean hasHAProxyMessage()  
      int hashCode()  
      boolean hasProducers()  
      protected void interceptCommand​(org.apache.pulsar.common.api.proto.BaseCommand command)  
      boolean isActive()  
      boolean isBatchMessageCompatibleVersion()  
      protected boolean isHandshakeCompleted()  
      boolean isPreciseDispatcherFlowControl()  
      boolean isWritable()  
      org.apache.pulsar.common.protocol.ByteBufPair newMessageAndIntercept​(long consumerId, long ledgerId, long entryId, int partition, int redeliveryCount, io.netty.buffer.ByteBuf metadataAndPayload, long[] ackSet, java.lang.String topic, long epoch)  
      io.netty.util.concurrent.Promise<java.lang.Void> newPromise()  
      void removedConsumer​(Consumer consumer)  
      void removedProducer​(Producer producer)  
      protected void setAuthRole​(java.lang.String authRole)  
      void startSendOperation​(Producer producer, int msgSize, int numMessages)  
      • 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, handleAckResponse, handleActiveConsumerChange, handleAddPartitionToTxnResponse, handleAddSubscriptionToTxnResponse, handleAuthChallenge, handleConnected, handleConsumerStatsResponse, handleEndTxnOnPartitionResponse, handleEndTxnOnSubscriptionResponse, handleEndTxnResponse, handleError, handleGetLastMessageIdSuccess, handleGetOrCreateSchemaResponse, handleGetSchemaResponse, handleGetTopicsOfNamespaceSuccess, handleLookupResponse, handleMessage, handleNewTxnResponse, handlePartitionResponse, handleProducerSuccess, handleReachedEndOfTopic, handleSendError, handleSendReceipt, handleSuccess, handleTcClientConnectResponse
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelReadComplete, channelRegistered, channelUnregistered, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Constructor Detail

      • ServerCnx

        public ServerCnx​(PulsarService pulsar,
                         java.lang.String listenerName)
    • 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
      • 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
      • channelWritabilityChanged

        public void channelWritabilityChanged​(io.netty.channel.ChannelHandlerContext ctx)
                                       throws java.lang.Exception
        Specified by:
        channelWritabilityChanged in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelWritabilityChanged in class io.netty.channel.ChannelInboundHandlerAdapter
        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
      • handleLookup

        protected void handleLookup​(org.apache.pulsar.common.api.proto.CommandLookupTopic lookup)
        Overrides:
        handleLookup in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handlePartitionMetadataRequest

        protected void handlePartitionMetadataRequest​(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadata partitionMetadata)
        Overrides:
        handlePartitionMetadataRequest in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleConsumerStats

        protected void handleConsumerStats​(org.apache.pulsar.common.api.proto.CommandConsumerStats commandConsumerStats)
        Overrides:
        handleConsumerStats in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleConnect

        protected void handleConnect​(org.apache.pulsar.common.api.proto.CommandConnect connect)
        Overrides:
        handleConnect in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleAuthResponse

        protected void handleAuthResponse​(org.apache.pulsar.common.api.proto.CommandAuthResponse authResponse)
        Overrides:
        handleAuthResponse in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleSubscribe

        protected void handleSubscribe​(org.apache.pulsar.common.api.proto.CommandSubscribe subscribe)
        Overrides:
        handleSubscribe in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleProducer

        protected void handleProducer​(org.apache.pulsar.common.api.proto.CommandProducer cmdProducer)
        Overrides:
        handleProducer in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleSend

        protected void handleSend​(org.apache.pulsar.common.api.proto.CommandSend send,
                                  io.netty.buffer.ByteBuf headersAndPayload)
        Overrides:
        handleSend in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleAck

        protected void handleAck​(org.apache.pulsar.common.api.proto.CommandAck ack)
        Overrides:
        handleAck in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleFlow

        protected void handleFlow​(org.apache.pulsar.common.api.proto.CommandFlow flow)
        Overrides:
        handleFlow in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleRedeliverUnacknowledged

        protected void handleRedeliverUnacknowledged​(org.apache.pulsar.common.api.proto.CommandRedeliverUnacknowledgedMessages redeliver)
        Overrides:
        handleRedeliverUnacknowledged in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleUnsubscribe

        protected void handleUnsubscribe​(org.apache.pulsar.common.api.proto.CommandUnsubscribe unsubscribe)
        Overrides:
        handleUnsubscribe in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleSeek

        protected void handleSeek​(org.apache.pulsar.common.api.proto.CommandSeek seek)
        Overrides:
        handleSeek in class org.apache.pulsar.common.protocol.PulsarDecoder
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • 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
      • handleGetLastMessageId

        protected void handleGetLastMessageId​(org.apache.pulsar.common.api.proto.CommandGetLastMessageId getLastMessageId)
        Overrides:
        handleGetLastMessageId in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleGetTopicsOfNamespace

        protected void handleGetTopicsOfNamespace​(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace commandGetTopicsOfNamespace)
        Overrides:
        handleGetTopicsOfNamespace in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleGetSchema

        protected void handleGetSchema​(org.apache.pulsar.common.api.proto.CommandGetSchema commandGetSchema)
        Overrides:
        handleGetSchema in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleGetOrCreateSchema

        protected void handleGetOrCreateSchema​(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchema commandGetOrCreateSchema)
        Overrides:
        handleGetOrCreateSchema in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleTcClientConnectRequest

        protected void handleTcClientConnectRequest​(org.apache.pulsar.common.api.proto.CommandTcClientConnectRequest command)
        Overrides:
        handleTcClientConnectRequest in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleNewTxn

        protected void handleNewTxn​(org.apache.pulsar.common.api.proto.CommandNewTxn command)
        Overrides:
        handleNewTxn in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleAddPartitionToTxn

        protected void handleAddPartitionToTxn​(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxn command)
        Overrides:
        handleAddPartitionToTxn in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleEndTxn

        protected void handleEndTxn​(org.apache.pulsar.common.api.proto.CommandEndTxn command)
        Overrides:
        handleEndTxn in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleEndTxnOnPartition

        protected void handleEndTxnOnPartition​(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartition command)
        Overrides:
        handleEndTxnOnPartition in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleEndTxnOnSubscription

        protected void handleEndTxnOnSubscription​(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscription command)
        Overrides:
        handleEndTxnOnSubscription in class org.apache.pulsar.common.protocol.PulsarDecoder
      • handleAddSubscriptionToTxn

        protected void handleAddSubscriptionToTxn​(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxn command)
        Overrides:
        handleAddSubscriptionToTxn in class org.apache.pulsar.common.protocol.PulsarDecoder
      • isHandshakeCompleted

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

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

        protected void interceptCommand​(org.apache.pulsar.common.api.proto.BaseCommand command)
                                 throws org.apache.pulsar.common.intercept.InterceptException
        Overrides:
        interceptCommand in class org.apache.pulsar.common.protocol.PulsarDecoder
        Throws:
        org.apache.pulsar.common.intercept.InterceptException
      • close

        protected void close()
        It closes the connection with client which triggers channelInactive() which clears all producers and consumers from connection-map.
      • startSendOperation

        public void startSendOperation​(Producer producer,
                                       int msgSize,
                                       int numMessages)
      • completedSendOperation

        public void completedSendOperation​(boolean isNonPersistentTopic,
                                           int msgSize)
        Specified by:
        completedSendOperation in interface TransportCnx
      • newMessageAndIntercept

        public org.apache.pulsar.common.protocol.ByteBufPair newMessageAndIntercept​(long consumerId,
                                                                                    long ledgerId,
                                                                                    long entryId,
                                                                                    int partition,
                                                                                    int redeliveryCount,
                                                                                    io.netty.buffer.ByteBuf metadataAndPayload,
                                                                                    long[] ackSet,
                                                                                    java.lang.String topic,
                                                                                    long epoch)
      • getState

        public org.apache.pulsar.broker.service.ServerCnx.State getState()
        Helper method for testability.
        Returns:
        the connection state
      • getRemoteAddress

        public java.net.SocketAddress getRemoteAddress()
      • getRole

        public java.lang.String getRole()
      • newPromise

        public io.netty.util.concurrent.Promise<java.lang.Void> newPromise()
        Specified by:
        newPromise in interface TransportCnx
      • getHAProxyMessage

        public io.netty.handler.codec.haproxy.HAProxyMessage getHAProxyMessage()
        Specified by:
        getHAProxyMessage in interface TransportCnx
      • getAuthState

        public org.apache.pulsar.broker.authentication.AuthenticationState getAuthState()
      • getAuthenticationData

        public org.apache.pulsar.broker.authentication.AuthenticationDataSource getAuthenticationData()
        Specified by:
        getAuthenticationData in interface TransportCnx
      • getPrincipal

        public java.lang.String getPrincipal()
      • getAuthenticationProvider

        public org.apache.pulsar.broker.authentication.AuthenticationProvider getAuthenticationProvider()
      • getAuthRole

        public java.lang.String getAuthRole()
        Description copied from interface: TransportCnx
        The security role for this connection.
        Specified by:
        getAuthRole in interface TransportCnx
        Returns:
        the role
      • getAuthMethod

        public java.lang.String getAuthMethod()
      • getConsumers

        public org.apache.pulsar.common.util.collections.ConcurrentLongHashMap<java.util.concurrent.CompletableFuture<Consumer>> getConsumers()
      • getProducers

        public org.apache.pulsar.common.util.collections.ConcurrentLongHashMap<java.util.concurrent.CompletableFuture<Producer>> getProducers()
      • execute

        public void execute​(java.lang.Runnable runnable)
        Specified by:
        execute in interface TransportCnx
      • hasProducers

        public boolean hasProducers()
      • getOriginalPrincipal

        protected java.lang.String getOriginalPrincipal()
      • getAuthData

        protected org.apache.pulsar.broker.authentication.AuthenticationDataSource getAuthData()
      • getOriginalAuthData

        protected org.apache.pulsar.broker.authentication.AuthenticationDataSource getOriginalAuthData()
      • getOriginalAuthState

        protected org.apache.pulsar.broker.authentication.AuthenticationState getOriginalAuthState()
      • setAuthRole

        protected void setAuthRole​(java.lang.String authRole)