Class DcpMessageHandler
- All Implemented Interfaces:
DcpRequestDispatcher,io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Since:
- 1.0.0
- Author:
- Michael Nitschinger
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) Fails all the promises in theoutstandingRequestsqueue when the channel becomes inactive.voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) Reads server responses and uses them to fulfill promises returned bysendRequest(io.netty.buffer.ByteBuf).io.netty.util.concurrent.Future<DcpResponse>sendRequest(io.netty.buffer.ByteBuf request) Assigns a value to the request'sopaquefield and writes the message to the channel.voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) Close dead connection in response to idle event from IdleStateHandler.Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods 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
-
Method Details
-
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
Fails all the promises in theoutstandingRequestsqueue 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.- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
sendRequest
Description copied from interface:DcpRequestDispatcherAssigns a value to the request'sopaquefield 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
NotConnectedExceptionas the cause.Callers are responsible for releasing the ByteBuf from successful Futures. This is true even if a call to
Future.getorFuture.awaittimes 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
DcpResponseListenerwhen adding listeners.- Specified by:
sendRequestin interfaceDcpRequestDispatcher
-
channelRead
Reads server responses and uses them to fulfill promises returned bysendRequest(io.netty.buffer.ByteBuf).Dispatches other incoming messages to either the data or the control feeds.
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception Close dead connection in response to idle event from IdleStateHandler.- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-