Class DcpMessageHandler
- All Implemented Interfaces:
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler,DcpRequestDispatcher
- Since:
- 1.0.0
- Author:
- Michael Nitschinger
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler.Sharable -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) Fails all the promises in theoutstandingRequestsqueue when the channel becomes inactive.voidchannelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg) Reads server responses and uses them to fulfill promises returned bysendRequest(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf).com.couchbase.client.core.deps.io.netty.util.concurrent.Future<DcpResponse>sendRequest(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf request) Assigns a value to the request'sopaquefield and writes the message to the channel.voiduserEventTriggered(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object evt) Close dead connection in response to idle event from IdleStateHandler.Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class com.couchbase.client.core.deps.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 com.couchbase.client.core.deps.io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Method Details
-
channelActive
public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) throws Exception - Specified by:
channelActivein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
public void channelInactive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) throws Exception 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(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext, com.couchbase.client.core.deps.io.netty.buffer.ByteBuf, com.couchbase.client.core.deps.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 interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
sendRequest
public com.couchbase.client.core.deps.io.netty.util.concurrent.Future<DcpResponse> sendRequest(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf request) 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
public void channelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception Reads server responses and uses them to fulfill promises returned bysendRequest(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf).Dispatches other incoming messages to either the data or the control feeds.
- Specified by:
channelReadin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception Close dead connection in response to idle event from IdleStateHandler.- Specified by:
userEventTriggeredin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-