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 ClassesNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.pulsar.client.api.Authenticationprotected org.apache.pulsar.client.api.AuthenticationDataProviderprotected final intprotected Stringprotected Stringprotected ClientCnx.StateFields inherited from class org.apache.pulsar.common.protocol.PulsarHandler
ctxFields inherited from class org.apache.pulsar.common.protocol.PulsarDecoder
proxyMessage -
Constructor Summary
ConstructorsConstructorDescriptionClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, int protocolVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidclose()protected voidio.netty.channel.ChannelHandlerContextctx()voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) static org.apache.pulsar.client.api.PulsarClientExceptiongetPulsarClientException(org.apache.pulsar.common.api.proto.ServerError error, 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 voidhandleCommandWatchTopicListSuccess(org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess commandWatchTopicListSuccess) protected voidhandleCommandWatchTopicUpdate(org.apache.pulsar.common.api.proto.CommandWatchTopicUpdate commandWatchTopicUpdate) 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) booleanCheck client connection is now free.protected booleanstatic booleannewAckForReceipt(io.netty.buffer.ByteBuf request, long requestId) voidnewAckForReceiptWithFuture(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<Void> future) protected io.netty.buffer.ByteBufCompletableFuture<org.apache.pulsar.common.lookup.GetTopicsResult>newGetTopicsOfNamespace(io.netty.buffer.ByteBuf request, long requestId) newLookup(io.netty.buffer.ByteBuf request, long requestId) CompletableFuture<org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess>newWatchTopicList(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicList, long requestId) CompletableFuture<org.apache.pulsar.common.api.proto.CommandSuccess>newWatchTopicListClose(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicListClose, long requestId) voidCompletableFuture<org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse>sendGetLastMessageId(io.netty.buffer.ByteBuf request, long requestId) CompletableFuture<byte[]>sendGetOrCreateSchema(io.netty.buffer.ByteBuf request, long requestId) CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetSchemaResponse>sendGetRawSchema(io.netty.buffer.ByteBuf request, long requestId) CompletableFuture<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, setRemoteEndpointProtocolVersionMethods inherited from class org.apache.pulsar.common.protocol.PulsarDecoder
channelRead, handleAck, handleAddPartitionToTxn, handleAddSubscriptionToTxn, handleAuthResponse, handleCommandWatchTopicList, handleCommandWatchTopicListClose, handleConnect, handleConsumerStats, handleConsumerStatsResponse, handleEndTxn, handleEndTxnOnPartition, handleEndTxnOnSubscription, handleFlow, handleGetLastMessageId, handleGetOrCreateSchema, handleGetSchema, handleGetTopicsOfNamespace, handleLookup, handleNewTxn, handlePartitionMetadataRequest, handleProducer, handleRedeliverUnacknowledged, handleSeek, handleSend, handleSubscribe, handleTcClientConnectRequest, handleUnsubscribe, interceptCommandMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
authentication
protected final org.apache.pulsar.client.api.Authentication authentication -
state
-
protocolVersion
protected final int protocolVersion -
proxyToTargetBrokerAddress
-
remoteHostName
-
authenticationDataProvider
protected org.apache.pulsar.client.api.AuthenticationDataProvider authenticationDataProvider
-
-
Constructor Details
-
ClientCnx
-
ClientCnx
public ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, int protocolVersion)
-
-
Method Details
-
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classorg.apache.pulsar.common.protocol.PulsarHandler- Throws:
Exception
-
newConnectCommand
- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classorg.apache.pulsar.common.protocol.PulsarHandler- 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
-
isKnownException
-
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 CompletableFuture<BinaryProtoLookupService.LookupDataResult> newLookup(io.netty.buffer.ByteBuf request, long requestId) -
newGetTopicsOfNamespace
public CompletableFuture<org.apache.pulsar.common.lookup.GetTopicsResult> newGetTopicsOfNamespace(io.netty.buffer.ByteBuf request, long requestId) -
newAckForReceipt
-
newAckForReceiptWithFuture
public void newAckForReceiptWithFuture(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<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 CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetLastMessageIdResponse> sendGetLastMessageId(io.netty.buffer.ByteBuf request, long requestId) -
sendGetSchema
public CompletableFuture<Optional<org.apache.pulsar.common.schema.SchemaInfo>> sendGetSchema(io.netty.buffer.ByteBuf request, long requestId) -
sendGetRawSchema
public CompletableFuture<org.apache.pulsar.common.api.proto.CommandGetSchemaResponse> sendGetRawSchema(io.netty.buffer.ByteBuf request, long requestId) -
sendGetOrCreateSchema
public 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
-
newWatchTopicList
public CompletableFuture<org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess> newWatchTopicList(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicList, long requestId) -
newWatchTopicListClose
public CompletableFuture<org.apache.pulsar.common.api.proto.CommandSuccess> newWatchTopicListClose(org.apache.pulsar.common.api.proto.BaseCommand commandWatchTopicListClose, long requestId) -
handleCommandWatchTopicListSuccess
protected void handleCommandWatchTopicListSuccess(org.apache.pulsar.common.api.proto.CommandWatchTopicListSuccess commandWatchTopicListSuccess) - Overrides:
handleCommandWatchTopicListSuccessin classorg.apache.pulsar.common.protocol.PulsarDecoder
-
handleCommandWatchTopicUpdate
protected void handleCommandWatchTopicUpdate(org.apache.pulsar.common.api.proto.CommandWatchTopicUpdate commandWatchTopicUpdate) - Overrides:
handleCommandWatchTopicUpdatein classorg.apache.pulsar.common.protocol.PulsarDecoder
-
registerTransactionBufferHandler
-
getPulsarClientException
public static org.apache.pulsar.client.api.PulsarClientException getPulsarClientException(org.apache.pulsar.common.api.proto.ServerError error, String errorMsg) -
close
public void close() -
closeWithException
-
idleCheck
public boolean idleCheck()Check client connection is now free. This method will not change the state to idle.- Returns:
- true if the connection is eligible.
-