Class ServerCnx

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.broker.service.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
  • Constructor Details

  • 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
    • 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
    • channelWritabilityChanged

      public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelWritabilityChanged in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelWritabilityChanged in class io.netty.channel.ChannelInboundHandlerAdapter
      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
    • 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(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class 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
    • handleCommandWatchTopicList

      protected void handleCommandWatchTopicList(org.apache.pulsar.common.api.proto.CommandWatchTopicList commandWatchTopicList)
      Overrides:
      handleCommandWatchTopicList in class org.apache.pulsar.common.protocol.PulsarDecoder
    • handleCommandWatchTopicListClose

      protected void handleCommandWatchTopicListClose(org.apache.pulsar.common.api.proto.CommandWatchTopicListClose commandWatchTopicListClose)
      Overrides:
      handleCommandWatchTopicListClose 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
    • closeProducer

      public void closeProducer(Producer producer)
      Specified by:
      closeProducer in interface TransportCnx
    • closeConsumer

      public void closeConsumer(Consumer consumer)
      Specified by:
      closeConsumer in interface TransportCnx
    • close

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

      public SocketAddress clientAddress()
      Specified by:
      clientAddress in interface TransportCnx
    • removedConsumer

      public void removedConsumer(Consumer consumer)
      Specified by:
      removedConsumer in interface TransportCnx
    • removedProducer

      public void removedProducer(Producer producer)
      Specified by:
      removedProducer in interface TransportCnx
    • isActive

      public boolean isActive()
      Specified by:
      isActive in interface TransportCnx
    • isWritable

      public boolean isWritable()
      Specified by:
      isWritable in interface TransportCnx
    • startSendOperation

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

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

      public void enableCnxAutoRead()
      Specified by:
      enableCnxAutoRead in interface TransportCnx
    • disableCnxAutoRead

      public void disableCnxAutoRead()
      Specified by:
      disableCnxAutoRead in interface TransportCnx
    • cancelPublishRateLimiting

      public void cancelPublishRateLimiting()
      Specified by:
      cancelPublishRateLimiting in interface TransportCnx
    • cancelPublishBufferLimiting

      public void cancelPublishBufferLimiting()
      Specified by:
      cancelPublishBufferLimiting 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, String topic, long epoch)
    • getState

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

      public SocketAddress getRemoteAddress()
    • getBrokerService

      public BrokerService getBrokerService()
      Specified by:
      getBrokerService in interface TransportCnx
    • getRole

      public String getRole()
    • newPromise

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

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

      public boolean hasHAProxyMessage()
      Specified by:
      hasHAProxyMessage in interface TransportCnx
    • isBatchMessageCompatibleVersion

      public boolean isBatchMessageCompatibleVersion()
      Specified by:
      isBatchMessageCompatibleVersion in interface TransportCnx
    • getClientVersion

      public String getClientVersion()
      Specified by:
      getClientVersion in interface TransportCnx
    • isPreciseDispatcherFlowControl

      public boolean isPreciseDispatcherFlowControl()
      Specified by:
      isPreciseDispatcherFlowControl 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 String getPrincipal()
    • getAuthenticationProvider

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

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

      public String getAuthMethod()
    • getConsumers

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

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

      public PulsarCommandSender getCommandSender()
      Specified by:
      getCommandSender in interface TransportCnx
    • execute

      public void execute(Runnable runnable)
      Specified by:
      execute in interface TransportCnx
    • clientSourceAddress

      public String clientSourceAddress()
      Specified by:
      clientSourceAddress in interface TransportCnx
    • hasProducers

      public boolean hasProducers()
    • getOriginalPrincipal

      protected 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(String authRole)