Class FeatureNegotiatingHandler
java.lang.Object
com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
com.couchbase.client.core.io.netty.kv.FeatureNegotiatingHandler
- All Implemented Interfaces:
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
@Internal
public class FeatureNegotiatingHandler
extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
The
FeatureNegotiatingHandler is responsible for sending the KV "hello" command
and to handshake enabled features on both sides.
If we get any response from the server, we'll take it. If the server returns a non-successful response we will report that, but move on with no negotiated features. If the server returns more features than we asked for, we'll only use the subset and not more (and report the abnormal condition).
- Since:
- 2.0.0
-
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 -
Constructor Summary
ConstructorsConstructorDescriptionFeatureNegotiatingHandler(EndpointContext endpointContext, Set<ServerFeature> features) Creates a newFeatureNegotiatingHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) As soon as the channel is active start sending the hello request but also schedule a timeout properly.voidchannelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg) As soon as we get a response, turn it into a list of negotiated server features.voidconnect(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise) Intercepts the connect process inside the pipeline to only propagate either success or failure if the hello process is completed either way.voidexceptionCaught(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Throwable cause) If there is an exception raised while we are waiting for our connect phase to complete, the error should be propagated as a cause up the pipeline.Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
bind, close, deregister, disconnect, flush, read, writeMethods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods 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
-
Constructor Details
-
FeatureNegotiatingHandler
Creates a newFeatureNegotiatingHandler.- Parameters:
endpointContext- the core context used to refer to values like the core id.features- the list of features that should be negotiated from the client side.
-
-
Method Details
-
connect
public void connect(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise) Intercepts the connect process inside the pipeline to only propagate either success or failure if the hello process is completed either way.Note that if no feature is to negotiate we can bail out right away.
- Specified by:
connectin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler- Overrides:
connectin classcom.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler- Parameters:
ctx- theChannelHandlerContextfor which the connect operation is made.remoteAddress- theSocketAddressto which it should connect.localAddress- theSocketAddresswhich is used as source on connect.promise- theChannelPromiseto notify once the operation completes.
-
channelActive
public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) As soon as the channel is active start sending the hello request but also schedule a timeout properly.- Specified by:
channelActivein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- theChannelHandlerContextfor which the channel active operation is made.
-
channelRead
public void channelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg) As soon as we get a response, turn it into a list of negotiated server features.Since the server might respond with a non-success status code, this case is handled and we would move on without any negotiated features but make sure the proper event is raised.
- Specified by:
channelReadin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- theChannelHandlerContextfor which the channel read operation is made.msg- the incoming msg that needs to be parsed.
-
exceptionCaught
public void exceptionCaught(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Throwable cause) If there is an exception raised while we are waiting for our connect phase to complete, the error should be propagated as a cause up the pipeline.One reason for example could be TLS problems that need to be surfaced up the stack properly.
- Specified by:
exceptionCaughtin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the channel handler context.cause- the cause of the problem.
-