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
Channel handler for the Pulsar client.
Please see PulsarDecoder
javadoc for important details about handle* method
parameter instance lifecycle.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Authentication
protected AuthenticationDataProvider
protected final int
protected String
protected String
protected ClientCnx.State
Fields inherited from class org.apache.pulsar.common.protocol.PulsarHandler
ctx
Fields inherited from class org.apache.pulsar.common.protocol.PulsarDecoder
proxyMessage
-
Constructor Summary
ConstructorDescriptionClientCnx
(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) ClientCnx
(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, int protocolVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
close()
protected void
io.netty.channel.ChannelHandlerContext
ctx()
void
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) long
static PulsarClientException
getPulsarClientException
(ServerError error, String errorMsg) protected void
handleAckResponse
(CommandAckResponse ackResponse) protected void
protected void
protected void
protected void
handleAuthChallenge
(CommandAuthChallenge authChallenge) protected void
handleCloseConsumer
(CommandCloseConsumer closeConsumer) protected void
handleCloseProducer
(CommandCloseProducer closeProducer) protected void
handleCommandWatchTopicListSuccess
(CommandWatchTopicListSuccess commandWatchTopicListSuccess) protected void
handleCommandWatchTopicUpdate
(CommandWatchTopicUpdate commandWatchTopicUpdate) protected void
handleConnected
(CommandConnected connected) protected void
protected void
protected void
protected void
handleError
(CommandError error) protected void
protected void
handleGetOrCreateSchemaResponse
(CommandGetOrCreateSchemaResponse commandGetOrCreateSchemaResponse) protected void
handleGetSchemaResponse
(CommandGetSchemaResponse commandGetSchemaResponse) protected void
protected void
handleLookupResponse
(CommandLookupTopicResponse lookupResult) protected void
handleMessage
(CommandMessage cmdMessage, io.netty.buffer.ByteBuf headersAndPayload) protected void
protected void
protected void
protected void
handleReachedEndOfTopic
(CommandReachedEndOfTopic commandReachedEndOfTopic) protected void
handleSendError
(CommandSendError sendError) protected void
handleSendReceipt
(CommandSendReceipt sendReceipt) protected void
handleSuccess
(CommandSuccess success) protected void
protected void
handleTopicMigrated
(CommandTopicMigrated commandTopicMigrated) boolean
Check client connection is now free.protected boolean
static boolean
newAckForReceipt
(io.netty.buffer.ByteBuf request, long requestId) void
newAckForReceiptWithFuture
(io.netty.buffer.ByteBuf request, long requestId, TimedCompletableFuture<Void> future) protected io.netty.buffer.ByteBuf
newGetTopicsOfNamespace
(io.netty.buffer.ByteBuf request, long requestId) newLookup
(io.netty.buffer.ByteBuf request, long requestId) newWatchTopicList
(BaseCommand commandWatchTopicList, long requestId) newWatchTopicListClose
(BaseCommand commandWatchTopicListClose, long requestId) void
sendGetLastMessageId
(io.netty.buffer.ByteBuf request, long requestId) CompletableFuture<byte[]>
sendGetOrCreateSchema
(io.netty.buffer.ByteBuf request, long requestId) sendGetRawSchema
(io.netty.buffer.ByteBuf request, long requestId) sendGetSchema
(io.netty.buffer.ByteBuf request, long requestId) void
userEventTriggered
(io.netty.channel.ChannelHandlerContext ctx, Object evt) Methods inherited from class org.apache.pulsar.common.protocol.PulsarHandler
cancelKeepAliveTask, getRemoteEndpointProtocolVersion, handlePing, handlePong, messageReceived, sendPing, setRemoteEndpointProtocolVersion
Methods 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, interceptCommand
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
authentication
-
state
-
protocolVersion
protected final int protocolVersion -
proxyToTargetBrokerAddress
-
remoteHostName
-
authenticationDataProvider
-
-
Constructor Details
-
ClientCnx
-
ClientCnx
public ClientCnx(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, int protocolVersion)
-
-
Method Details
-
channelActive
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classPulsarHandler
- Throws:
Exception
-
newConnectCommand
- Throws:
Exception
-
channelInactive
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classPulsarHandler
- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
isKnownException
-
getDuplicatedResponseCount
public long getDuplicatedResponseCount() -
handleConnected
- Overrides:
handleConnected
in classPulsarDecoder
-
handleAuthChallenge
- Overrides:
handleAuthChallenge
in classPulsarDecoder
-
handleSendReceipt
- Overrides:
handleSendReceipt
in classPulsarDecoder
-
handleAckResponse
- Overrides:
handleAckResponse
in classPulsarDecoder
-
handleMessage
- Overrides:
handleMessage
in classPulsarDecoder
-
handleActiveConsumerChange
- Overrides:
handleActiveConsumerChange
in classPulsarDecoder
-
handleSuccess
- Overrides:
handleSuccess
in classPulsarDecoder
-
handleGetLastMessageIdSuccess
- Overrides:
handleGetLastMessageIdSuccess
in classPulsarDecoder
-
handleProducerSuccess
- Overrides:
handleProducerSuccess
in classPulsarDecoder
-
handleLookupResponse
- Overrides:
handleLookupResponse
in classPulsarDecoder
-
handlePartitionResponse
- Overrides:
handlePartitionResponse
in classPulsarDecoder
-
handleReachedEndOfTopic
- Overrides:
handleReachedEndOfTopic
in classPulsarDecoder
-
handleTopicMigrated
- Overrides:
handleTopicMigrated
in classPulsarDecoder
-
handleSendError
- Overrides:
handleSendError
in classPulsarDecoder
-
handleError
- Overrides:
handleError
in classPulsarDecoder
-
handleCloseProducer
- Overrides:
handleCloseProducer
in classPulsarDecoder
-
handleCloseConsumer
- Overrides:
handleCloseConsumer
in classPulsarDecoder
-
isHandshakeCompleted
protected boolean isHandshakeCompleted()- Specified by:
isHandshakeCompleted
in classPulsarHandler
-
newLookup
public CompletableFuture<BinaryProtoLookupService.LookupDataResult> newLookup(io.netty.buffer.ByteBuf request, long requestId) -
newGetTopicsOfNamespace
public CompletableFuture<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
- Overrides:
handleGetTopicsOfNamespaceSuccess
in classPulsarDecoder
-
handleGetSchemaResponse
- Overrides:
handleGetSchemaResponse
in classPulsarDecoder
-
handleGetOrCreateSchemaResponse
protected void handleGetOrCreateSchemaResponse(CommandGetOrCreateSchemaResponse commandGetOrCreateSchemaResponse) - Overrides:
handleGetOrCreateSchemaResponse
in classPulsarDecoder
-
ctx
public io.netty.channel.ChannelHandlerContext ctx() -
sendGetLastMessageId
public CompletableFuture<CommandGetLastMessageIdResponse> sendGetLastMessageId(io.netty.buffer.ByteBuf request, long requestId) -
sendGetSchema
public CompletableFuture<Optional<SchemaInfo>> sendGetSchema(io.netty.buffer.ByteBuf request, long requestId) -
sendGetRawSchema
public CompletableFuture<CommandGetSchemaResponse> sendGetRawSchema(io.netty.buffer.ByteBuf request, long requestId) -
sendGetOrCreateSchema
public CompletableFuture<byte[]> sendGetOrCreateSchema(io.netty.buffer.ByteBuf request, long requestId) -
handleNewTxnResponse
- Overrides:
handleNewTxnResponse
in classPulsarDecoder
-
handleAddPartitionToTxnResponse
- Overrides:
handleAddPartitionToTxnResponse
in classPulsarDecoder
-
handleAddSubscriptionToTxnResponse
- Overrides:
handleAddSubscriptionToTxnResponse
in classPulsarDecoder
-
handleEndTxnOnPartitionResponse
- Overrides:
handleEndTxnOnPartitionResponse
in classPulsarDecoder
-
handleEndTxnOnSubscriptionResponse
- Overrides:
handleEndTxnOnSubscriptionResponse
in classPulsarDecoder
-
handleEndTxnResponse
- Overrides:
handleEndTxnResponse
in classPulsarDecoder
-
handleTcClientConnectResponse
- Overrides:
handleTcClientConnectResponse
in classPulsarDecoder
-
newWatchTopicList
public CompletableFuture<CommandWatchTopicListSuccess> newWatchTopicList(BaseCommand commandWatchTopicList, long requestId) -
newWatchTopicListClose
public CompletableFuture<CommandSuccess> newWatchTopicListClose(BaseCommand commandWatchTopicListClose, long requestId) -
handleCommandWatchTopicListSuccess
protected void handleCommandWatchTopicListSuccess(CommandWatchTopicListSuccess commandWatchTopicListSuccess) - Overrides:
handleCommandWatchTopicListSuccess
in classPulsarDecoder
-
handleCommandWatchTopicUpdate
- Overrides:
handleCommandWatchTopicUpdate
in classPulsarDecoder
-
registerTransactionBufferHandler
-
getPulsarClientException
-
close
public void close() -
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception - Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
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.
-