public class DcpMessageHandler extends io.netty.channel.ChannelInboundHandlerAdapter implements DcpRequestDispatcher
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx)
Fails all the promises in the
outstandingRequests queue when the
channel becomes inactive. |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
Reads server responses and uses them to fulfill promises returned by
sendRequest(io.netty.buffer.ByteBuf). |
io.netty.util.concurrent.Future<DcpResponse> |
sendRequest(io.netty.buffer.ByteBuf request)
Assigns a value to the request's
opaque field and writes
the message to the channel. |
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
Close dead connection in response to idle event from IdleStateHandler.
|
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtensureNotSharable, handlerAdded, handlerRemoved, isSharablepublic void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface io.netty.channel.ChannelInboundHandlerchannelActive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
outstandingRequests queue when the
channel becomes inactive.
Netty always invokes this method in the event loop thread. To ensure
this method never runs concurrently with unsafeSendRequest(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, io.netty.util.concurrent.Promise<com.couchbase.client.dcp.transport.netty.DcpResponse>),
we only call that method in the event loop thread as well.
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic io.netty.util.concurrent.Future<DcpResponse> sendRequest(io.netty.buffer.ByteBuf request)
DcpRequestDispatcheropaque field and writes
the message to the channel. Returns a Future that is completed
when the response is received or the channel is closed.
If the response is received, the Future is always considered successful regardless of the status code returned by the server; the caller is responsible for inspecting the status code.
If the channel is not currently active, or if the channel is closed
before the response is received, the Future fails with
NotConnectedException as the cause.
Callers are responsible for releasing the ByteBuf from successful
Futures. This is true even if a call to Future.get or
Future.await times out, in which case the caller should add
a listener to release the buffer when the Future eventually completes.
Listeners are invoked by the channel's event loop thread, so they should return quickly.
Callers may wish to use the type alias DcpResponseListener
when adding listeners.
sendRequest in interface DcpRequestDispatcherpublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
sendRequest(io.netty.buffer.ByteBuf).
Dispatches other incoming messages to either the data or the control feeds.
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
userEventTriggered in interface io.netty.channel.ChannelInboundHandleruserEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionCopyright © 2021 Couchbase, Inc.. All rights reserved.