Package org.apache.pulsar.broker.service
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
-
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, remoteAddressFields inherited from class org.apache.pulsar.common.protocol.PulsarDecoder
proxyMessage -
Constructor Summary
ConstructorsConstructorDescriptionServerCnx(PulsarService pulsar) ServerCnx(PulsarService pulsar, String listenerName) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidchannelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) protected voidclose()It closes the connection with client which triggerschannelInactive()which clears all producers and consumers from connection-map.voidcloseConsumer(Consumer consumer) voidcloseProducer(Producer producer) voidcompletedSendOperation(boolean isNonPersistentTopic, int msgSize) io.netty.channel.ChannelHandlerContextctx()voidvoidbooleanvoidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) voidprotected org.apache.pulsar.broker.authentication.AuthenticationDataSourceorg.apache.pulsar.broker.authentication.AuthenticationDataSourceorg.apache.pulsar.broker.authentication.AuthenticationProviderThe security role for this connection.org.apache.pulsar.broker.authentication.AuthenticationStateorg.apache.pulsar.common.util.collections.ConcurrentLongHashMap<CompletableFuture<Consumer>>io.netty.handler.codec.haproxy.HAProxyMessageprotected org.apache.pulsar.broker.authentication.AuthenticationDataSourceprotected org.apache.pulsar.broker.authentication.AuthenticationStateprotected Stringorg.apache.pulsar.common.util.collections.ConcurrentLongHashMap<CompletableFuture<Producer>>getRole()org.apache.pulsar.broker.service.ServerCnx.StategetState()Helper method for testability.protected voidhandleAck(org.apache.pulsar.common.api.proto.CommandAck ack) protected voidhandleAddPartitionToTxn(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxn command) protected voidhandleAddSubscriptionToTxn(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxn command) protected voidhandleAuthResponse(org.apache.pulsar.common.api.proto.CommandAuthResponse authResponse) protected voidhandleCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer closeConsumer) protected voidhandleCloseProducer(org.apache.pulsar.common.api.proto.CommandCloseProducer closeProducer) protected voidhandleCommandWatchTopicList(org.apache.pulsar.common.api.proto.CommandWatchTopicList commandWatchTopicList) protected voidhandleCommandWatchTopicListClose(org.apache.pulsar.common.api.proto.CommandWatchTopicListClose commandWatchTopicListClose) protected voidhandleConnect(org.apache.pulsar.common.api.proto.CommandConnect connect) protected voidhandleConsumerStats(org.apache.pulsar.common.api.proto.CommandConsumerStats commandConsumerStats) protected voidhandleEndTxn(org.apache.pulsar.common.api.proto.CommandEndTxn command) protected voidhandleEndTxnOnPartition(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartition command) protected voidhandleEndTxnOnSubscription(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscription command) protected voidhandleFlow(org.apache.pulsar.common.api.proto.CommandFlow flow) protected voidhandleGetLastMessageId(org.apache.pulsar.common.api.proto.CommandGetLastMessageId getLastMessageId) protected voidhandleGetOrCreateSchema(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchema commandGetOrCreateSchema) protected voidhandleGetSchema(org.apache.pulsar.common.api.proto.CommandGetSchema commandGetSchema) protected voidhandleGetTopicsOfNamespace(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace commandGetTopicsOfNamespace) protected voidhandleLookup(org.apache.pulsar.common.api.proto.CommandLookupTopic lookup) protected voidhandleNewTxn(org.apache.pulsar.common.api.proto.CommandNewTxn command) protected voidhandlePartitionMetadataRequest(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadata partitionMetadata) protected voidhandleProducer(org.apache.pulsar.common.api.proto.CommandProducer cmdProducer) protected voidhandleRedeliverUnacknowledged(org.apache.pulsar.common.api.proto.CommandRedeliverUnacknowledgedMessages redeliver) protected voidhandleSeek(org.apache.pulsar.common.api.proto.CommandSeek seek) protected voidhandleSend(org.apache.pulsar.common.api.proto.CommandSend send, io.netty.buffer.ByteBuf headersAndPayload) protected voidhandleSubscribe(org.apache.pulsar.common.api.proto.CommandSubscribe subscribe) protected voidhandleTcClientConnectRequest(org.apache.pulsar.common.api.proto.CommandTcClientConnectRequest command) protected voidhandleUnsubscribe(org.apache.pulsar.common.api.proto.CommandUnsubscribe unsubscribe) booleaninthashCode()booleanprotected voidinterceptCommand(org.apache.pulsar.common.api.proto.BaseCommand command) booleanisActive()booleanprotected booleanbooleanbooleanorg.apache.pulsar.common.protocol.ByteBufPairnewMessageAndIntercept(long consumerId, long ledgerId, long entryId, int partition, int redeliveryCount, io.netty.buffer.ByteBuf metadataAndPayload, long[] ackSet, String topic, long epoch) io.netty.util.concurrent.Promise<Void>voidremovedConsumer(Consumer consumer) voidremovedProducer(Producer producer) protected voidsetAuthRole(String authRole) voidstartSendOperation(Producer producer, int msgSize, int numMessages) Methods inherited from class org.apache.pulsar.common.protocol.PulsarHandler
cancelKeepAliveTask, getRemoteEndpointProtocolVersion, handlePing, handlePong, messageReceived, setRemoteEndpointProtocolVersionMethods inherited from class org.apache.pulsar.common.protocol.PulsarDecoder
channelRead, handleAckResponse, handleActiveConsumerChange, handleAddPartitionToTxnResponse, handleAddSubscriptionToTxnResponse, handleAuthChallenge, handleCommandWatchTopicListSuccess, handleCommandWatchTopicUpdate, handleConnected, handleConsumerStatsResponse, handleEndTxnOnPartitionResponse, handleEndTxnOnSubscriptionResponse, handleEndTxnResponse, handleError, handleGetLastMessageIdSuccess, handleGetOrCreateSchemaResponse, handleGetSchemaResponse, handleGetTopicsOfNamespaceSuccess, handleLookupResponse, handleMessage, handleNewTxnResponse, handlePartitionResponse, handleProducerSuccess, handleReachedEndOfTopic, handleSendError, handleSendReceipt, handleSuccess, handleTcClientConnectResponseMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
ServerCnx
-
ServerCnx
-
-
Method Details
-
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classorg.apache.pulsar.common.protocol.PulsarHandler- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classorg.apache.pulsar.common.protocol.PulsarHandler- Throws:
Exception
-
channelWritabilityChanged
- Specified by:
channelWritabilityChangedin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelWritabilityChangedin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
handleLookup
protected void handleLookup(org.apache.pulsar.common.api.proto.CommandLookupTopic lookup) - Overrides:
handleLookupin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handlePartitionMetadataRequest
protected void handlePartitionMetadataRequest(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadata partitionMetadata) - Overrides:
handlePartitionMetadataRequestin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleConsumerStats
protected void handleConsumerStats(org.apache.pulsar.common.api.proto.CommandConsumerStats commandConsumerStats) - Overrides:
handleConsumerStatsin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleConnect
protected void handleConnect(org.apache.pulsar.common.api.proto.CommandConnect connect) - Overrides:
handleConnectin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAuthResponse
protected void handleAuthResponse(org.apache.pulsar.common.api.proto.CommandAuthResponse authResponse) - Overrides:
handleAuthResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleSubscribe
protected void handleSubscribe(org.apache.pulsar.common.api.proto.CommandSubscribe subscribe) - Overrides:
handleSubscribein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleProducer
protected void handleProducer(org.apache.pulsar.common.api.proto.CommandProducer cmdProducer) - Overrides:
handleProducerin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleSend
protected void handleSend(org.apache.pulsar.common.api.proto.CommandSend send, io.netty.buffer.ByteBuf headersAndPayload) - Overrides:
handleSendin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAck
protected void handleAck(org.apache.pulsar.common.api.proto.CommandAck ack) - Overrides:
handleAckin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleFlow
protected void handleFlow(org.apache.pulsar.common.api.proto.CommandFlow flow) - Overrides:
handleFlowin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleRedeliverUnacknowledged
protected void handleRedeliverUnacknowledged(org.apache.pulsar.common.api.proto.CommandRedeliverUnacknowledgedMessages redeliver) - Overrides:
handleRedeliverUnacknowledgedin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleUnsubscribe
protected void handleUnsubscribe(org.apache.pulsar.common.api.proto.CommandUnsubscribe unsubscribe) - Overrides:
handleUnsubscribein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleSeek
protected void handleSeek(org.apache.pulsar.common.api.proto.CommandSeek seek) - Overrides:
handleSeekin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
equals
-
hashCode
public int hashCode() -
handleCloseProducer
protected void handleCloseProducer(org.apache.pulsar.common.api.proto.CommandCloseProducer closeProducer) - Overrides:
handleCloseProducerin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleCloseConsumer
protected void handleCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer closeConsumer) - Overrides:
handleCloseConsumerin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetLastMessageId
protected void handleGetLastMessageId(org.apache.pulsar.common.api.proto.CommandGetLastMessageId getLastMessageId) - Overrides:
handleGetLastMessageIdin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetTopicsOfNamespace
protected void handleGetTopicsOfNamespace(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace commandGetTopicsOfNamespace) - Overrides:
handleGetTopicsOfNamespacein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetSchema
protected void handleGetSchema(org.apache.pulsar.common.api.proto.CommandGetSchema commandGetSchema) - Overrides:
handleGetSchemain classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetOrCreateSchema
protected void handleGetOrCreateSchema(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchema commandGetOrCreateSchema) - Overrides:
handleGetOrCreateSchemain classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleTcClientConnectRequest
protected void handleTcClientConnectRequest(org.apache.pulsar.common.api.proto.CommandTcClientConnectRequest command) - Overrides:
handleTcClientConnectRequestin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleNewTxn
protected void handleNewTxn(org.apache.pulsar.common.api.proto.CommandNewTxn command) - Overrides:
handleNewTxnin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAddPartitionToTxn
protected void handleAddPartitionToTxn(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxn command) - Overrides:
handleAddPartitionToTxnin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleEndTxn
protected void handleEndTxn(org.apache.pulsar.common.api.proto.CommandEndTxn command) - Overrides:
handleEndTxnin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleEndTxnOnPartition
protected void handleEndTxnOnPartition(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartition command) - Overrides:
handleEndTxnOnPartitionin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleEndTxnOnSubscription
protected void handleEndTxnOnSubscription(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscription command) - Overrides:
handleEndTxnOnSubscriptionin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAddSubscriptionToTxn
protected void handleAddSubscriptionToTxn(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxn command) - Overrides:
handleAddSubscriptionToTxnin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleCommandWatchTopicList
protected void handleCommandWatchTopicList(org.apache.pulsar.common.api.proto.CommandWatchTopicList commandWatchTopicList) - Overrides:
handleCommandWatchTopicListin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleCommandWatchTopicListClose
protected void handleCommandWatchTopicListClose(org.apache.pulsar.common.api.proto.CommandWatchTopicListClose commandWatchTopicListClose) - Overrides:
handleCommandWatchTopicListClosein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
isHandshakeCompleted
protected boolean isHandshakeCompleted()- Specified by:
isHandshakeCompletedin classorg.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:
interceptCommandin classorg.apache.pulsar.common.protocol.PulsarDecoder- Throws:
org.apache.pulsar.common.intercept.InterceptException
-
closeProducer
- Specified by:
closeProducerin interfaceTransportCnx
-
closeConsumer
- Specified by:
closeConsumerin interfaceTransportCnx
-
close
protected void close()It closes the connection with client which triggerschannelInactive()which clears all producers and consumers from connection-map. -
clientAddress
- Specified by:
clientAddressin interfaceTransportCnx
-
removedConsumer
- Specified by:
removedConsumerin interfaceTransportCnx
-
removedProducer
- Specified by:
removedProducerin interfaceTransportCnx
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceTransportCnx
-
isWritable
public boolean isWritable()- Specified by:
isWritablein interfaceTransportCnx
-
startSendOperation
-
completedSendOperation
public void completedSendOperation(boolean isNonPersistentTopic, int msgSize) - Specified by:
completedSendOperationin interfaceTransportCnx
-
enableCnxAutoRead
public void enableCnxAutoRead()- Specified by:
enableCnxAutoReadin interfaceTransportCnx
-
disableCnxAutoRead
public void disableCnxAutoRead()- Specified by:
disableCnxAutoReadin interfaceTransportCnx
-
cancelPublishRateLimiting
public void cancelPublishRateLimiting()- Specified by:
cancelPublishRateLimitingin interfaceTransportCnx
-
cancelPublishBufferLimiting
public void cancelPublishBufferLimiting()- Specified by:
cancelPublishBufferLimitingin interfaceTransportCnx
-
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
-
getBrokerService
- Specified by:
getBrokerServicein interfaceTransportCnx
-
getRole
-
newPromise
- Specified by:
newPromisein interfaceTransportCnx
-
getHAProxyMessage
public io.netty.handler.codec.haproxy.HAProxyMessage getHAProxyMessage()- Specified by:
getHAProxyMessagein interfaceTransportCnx
-
hasHAProxyMessage
public boolean hasHAProxyMessage()- Specified by:
hasHAProxyMessagein interfaceTransportCnx
-
isBatchMessageCompatibleVersion
public boolean isBatchMessageCompatibleVersion()- Specified by:
isBatchMessageCompatibleVersionin interfaceTransportCnx
-
getClientVersion
- Specified by:
getClientVersionin interfaceTransportCnx
-
isPreciseDispatcherFlowControl
public boolean isPreciseDispatcherFlowControl()- Specified by:
isPreciseDispatcherFlowControlin interfaceTransportCnx
-
getAuthState
public org.apache.pulsar.broker.authentication.AuthenticationState getAuthState() -
getAuthenticationData
public org.apache.pulsar.broker.authentication.AuthenticationDataSource getAuthenticationData()- Specified by:
getAuthenticationDatain interfaceTransportCnx
-
getPrincipal
-
getAuthenticationProvider
public org.apache.pulsar.broker.authentication.AuthenticationProvider getAuthenticationProvider() -
getAuthRole
Description copied from interface:TransportCnxThe security role for this connection.- Specified by:
getAuthRolein interfaceTransportCnx- Returns:
- the role
-
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
- Specified by:
getCommandSenderin interfaceTransportCnx
-
execute
- Specified by:
executein interfaceTransportCnx
-
clientSourceAddress
- Specified by:
clientSourceAddressin interfaceTransportCnx
-
hasProducers
public boolean hasProducers() -
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
-