@Stability.Internal public class FeatureNegotiatingHandler extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
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).
| Constructor and Description |
|---|
FeatureNegotiatingHandler(EndpointContext endpointContext,
Set<ServerFeature> features)
Creates a new
FeatureNegotiatingHandler. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.
|
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.
|
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.
|
bind, close, deregister, disconnect, flush, read, writechannelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharablepublic FeatureNegotiatingHandler(EndpointContext endpointContext, Set<ServerFeature> features)
FeatureNegotiatingHandler.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.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)
Note that if no feature is to negotiate we can bail out right away.
connect in interface com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandlerconnect in class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandlerctx - the ChannelHandlerContext for which the connect operation is made.remoteAddress - the SocketAddress to which it should connect.localAddress - the SocketAddress which is used as source on connect.promise - the ChannelPromise to notify once the operation completes.public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
channelActive in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerchannelActive in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapterctx - the ChannelHandlerContext for which the channel active operation is made.public void channelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx,
Object msg)
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.
channelRead in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerchannelRead in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapterctx - the ChannelHandlerContext for which the channel read operation is made.msg - the incoming msg that needs to be parsed.public void exceptionCaught(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
One reason for example could be TLS problems that need to be surfaced up the stack properly.
exceptionCaught in interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerexceptionCaught in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerexceptionCaught in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapterctx - the channel handler context.cause - the cause of the problem.Copyright © 2021 Couchbase, Inc.. All rights reserved.