Package org.apache.pulsar.client.impl
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 classClientCnx.State
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.pulsar.client.api.Authenticationauthenticationprotected org.apache.pulsar.client.api.AuthenticationDataProviderauthenticationDataProviderprotected intprotocolVersionprotected java.lang.StringproxyToTargetBrokerAddressprotected java.lang.StringremoteHostNameprotected ClientCnx.Statestate
-
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidclose()protected voidcloseWithException(java.lang.Throwable e)io.netty.channel.ChannelHandlerContextctx()voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)static org.apache.pulsar.client.api.PulsarClientExceptiongetPulsarClientException(org.apache.pulsar.common.api.proto.ServerError error, java.lang.String errorMsg)protected voidhandleAckResponse(org.apache.pulsar.common.api.proto.CommandAckResponse ackResponse)protected voidhandleActiveConsumerChange(org.apache.pulsar.common.api.proto.CommandActiveConsumerChange change)protected voidhandleAddPartitionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxnResponse command)protected voidhandleAddSubscriptionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxnResponse command)protected voidhandleAuthChallenge(org.apache.pulsar.common.api.proto.CommandAuthChallenge authChallenge)protected voidhandleCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer closeConsumer)protected voidhandleCloseProducer(org.apache.pulsar.common.api.proto.CommandCloseProducer closeProducer)protected voidhandleConnected(org.apache.pulsar.common.api.proto.CommandConnected connected)protected voidhandleEndTxnOnPartitionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartitionResponse command)protected voidhandleEndTxnOnSubscriptionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscriptionResponse command)protected voidhandleEndTxnResponse(org.apache.pulsar.common.api.proto.CommandEndTxnResponse command)protected voidhandleError(org.apache.pulsar.common.api.proto.CommandError error)protected voidhandleGetLastMessageIdSuccess(org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse success)protected voidhandleGetOrCreateSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchemaResponse commandGetOrCreateSchemaResponse)protected voidhandleGetSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetSchemaResponse commandGetSchemaResponse)protected voidhandleGetTopicsOfNamespaceSuccess(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespaceResponse success)protected voidhandleLookupResponse(org.apache.pulsar.common.api.proto.CommandLookupTopicResponse lookupResult)protected voidhandleMessage(org.apache.pulsar.common.api.proto.CommandMessage cmdMessage, io.netty.buffer.ByteBuf headersAndPayload)protected voidhandleNewTxnResponse(org.apache.pulsar.common.api.proto.CommandNewTxnResponse command)protected voidhandlePartitionResponse(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse lookupResult)protected voidhandleProducerSuccess(org.apache.pulsar.common.api.proto.CommandProducerSuccess success)protected voidhandleReachedEndOfTopic(org.apache.pulsar.common.api.proto.CommandReachedEndOfTopic commandReachedEndOfTopic)protected voidhandleSendError(org.apache.pulsar.common.api.proto.CommandSendError sendError)protected voidhandleSendReceipt(org.apache.pulsar.common.api.proto.CommandSendReceipt sendReceipt)protected voidhandleSuccess(org.apache.pulsar.common.api.proto.CommandSuccess success)protected voidhandleTcClientConnectResponse(org.apache.pulsar.common.api.proto.CommandTcClientConnectResponse response)protected booleanisHandshakeCompleted()static booleanisKnownException(java.lang.Throwable t)java.util.concurrent.CompletableFuture<java.lang.Void>newAckForReceipt(io.netty.buffer.ByteBuf request, long requestId)voidnewAckForReceiptWithFuture(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<java.lang.Void> future)protected io.netty.buffer.ByteBufnewConnectCommand()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)voidregisterTransactionBufferHandler(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
-
-
-
-
Field Detail
-
authentication
protected final org.apache.pulsar.client.api.Authentication authentication
-
state
protected ClientCnx.State state
-
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)
-
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:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classorg.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:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classorg.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:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.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:
handleConnectedin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAuthChallenge
protected void handleAuthChallenge(org.apache.pulsar.common.api.proto.CommandAuthChallenge authChallenge)
- Overrides:
handleAuthChallengein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleSendReceipt
protected void handleSendReceipt(org.apache.pulsar.common.api.proto.CommandSendReceipt sendReceipt)
- Overrides:
handleSendReceiptin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAckResponse
protected void handleAckResponse(org.apache.pulsar.common.api.proto.CommandAckResponse ackResponse)
- Overrides:
handleAckResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleMessage
protected void handleMessage(org.apache.pulsar.common.api.proto.CommandMessage cmdMessage, io.netty.buffer.ByteBuf headersAndPayload)- Overrides:
handleMessagein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleActiveConsumerChange
protected void handleActiveConsumerChange(org.apache.pulsar.common.api.proto.CommandActiveConsumerChange change)
- Overrides:
handleActiveConsumerChangein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleSuccess
protected void handleSuccess(org.apache.pulsar.common.api.proto.CommandSuccess success)
- Overrides:
handleSuccessin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetLastMessageIdSuccess
protected void handleGetLastMessageIdSuccess(org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse success)
- Overrides:
handleGetLastMessageIdSuccessin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleProducerSuccess
protected void handleProducerSuccess(org.apache.pulsar.common.api.proto.CommandProducerSuccess success)
- Overrides:
handleProducerSuccessin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleLookupResponse
protected void handleLookupResponse(org.apache.pulsar.common.api.proto.CommandLookupTopicResponse lookupResult)
- Overrides:
handleLookupResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handlePartitionResponse
protected void handlePartitionResponse(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse lookupResult)
- Overrides:
handlePartitionResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleReachedEndOfTopic
protected void handleReachedEndOfTopic(org.apache.pulsar.common.api.proto.CommandReachedEndOfTopic commandReachedEndOfTopic)
- Overrides:
handleReachedEndOfTopicin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleSendError
protected void handleSendError(org.apache.pulsar.common.api.proto.CommandSendError sendError)
- Overrides:
handleSendErrorin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleError
protected void handleError(org.apache.pulsar.common.api.proto.CommandError error)
- Overrides:
handleErrorin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
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
-
isHandshakeCompleted
protected boolean isHandshakeCompleted()
- Specified by:
isHandshakeCompletedin classorg.apache.pulsar.common.protocol.PulsarHandler
-
newLookup
public java.util.concurrent.CompletableFuture<BinaryProtoLookupService.LookupDataResult> newLookup(io.netty.buffer.ByteBuf request, long requestId)
-
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:
handleGetTopicsOfNamespaceSuccessin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetSchemaResponse
protected void handleGetSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetSchemaResponse commandGetSchemaResponse)
- Overrides:
handleGetSchemaResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleGetOrCreateSchemaResponse
protected void handleGetOrCreateSchemaResponse(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchemaResponse commandGetOrCreateSchemaResponse)
- Overrides:
handleGetOrCreateSchemaResponsein classorg.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:
handleNewTxnResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAddPartitionToTxnResponse
protected void handleAddPartitionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxnResponse command)
- Overrides:
handleAddPartitionToTxnResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleAddSubscriptionToTxnResponse
protected void handleAddSubscriptionToTxnResponse(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxnResponse command)
- Overrides:
handleAddSubscriptionToTxnResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleEndTxnOnPartitionResponse
protected void handleEndTxnOnPartitionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartitionResponse command)
- Overrides:
handleEndTxnOnPartitionResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleEndTxnOnSubscriptionResponse
protected void handleEndTxnOnSubscriptionResponse(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscriptionResponse command)
- Overrides:
handleEndTxnOnSubscriptionResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleEndTxnResponse
protected void handleEndTxnResponse(org.apache.pulsar.common.api.proto.CommandEndTxnResponse command)
- Overrides:
handleEndTxnResponsein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleTcClientConnectResponse
protected void handleTcClientConnectResponse(org.apache.pulsar.common.api.proto.CommandTcClientConnectResponse response)
- Overrides:
handleTcClientConnectResponsein classorg.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, java.lang.String errorMsg)
-
close
public void close()
-
closeWithException
protected void closeWithException(java.lang.Throwable e)
-
-