use of com.couchbase.client.core.io.IoContext in project couchbase-jvm-clients by couchbase.
the class ErrorMapLoadingHandler method channelActive.
@Override
public void channelActive(final ChannelHandlerContext ctx) {
ioContext = new IoContext(endpointContext, ctx.channel().localAddress(), ctx.channel().remoteAddress(), endpointContext.bucket());
ctx.executor().schedule(() -> {
if (!interceptedConnectPromise.isDone()) {
ConnectTimings.stop(ctx.channel(), this.getClass(), true);
interceptedConnectPromise.tryFailure(new TimeoutException("KV Error Map loading timed out after " + timeout.toMillis() + "ms"));
}
}, timeout.toNanos(), TimeUnit.NANOSECONDS);
ConnectTimings.start(ctx.channel(), this.getClass());
ctx.writeAndFlush(buildErrorMapRequest(ctx));
// Fire the channel active immediately so the upper handler in the pipeline gets a chance to
// pipeline its request before the response of this one arrives. This helps speeding up the
// bootstrap sequence.
ctx.fireChannelActive();
}
use of com.couchbase.client.core.io.IoContext in project couchbase-jvm-clients by couchbase.
the class FeatureNegotiatingHandler method channelActive.
/**
* As soon as the channel is active start sending the hello request but also schedule
* a timeout properly.
*
* @param ctx the {@link ChannelHandlerContext} for which the channel active operation is made.
*/
@Override
public void channelActive(final ChannelHandlerContext ctx) {
ioContext = new IoContext(endpointContext, ctx.channel().localAddress(), ctx.channel().remoteAddress(), endpointContext.bucket());
ctx.executor().schedule(() -> {
if (!interceptedConnectPromise.isDone()) {
ConnectTimings.stop(ctx.channel(), this.getClass(), true);
interceptedConnectPromise.tryFailure(new TimeoutException("KV Feature Negotiation timed out after " + timeout.toMillis() + "ms"));
}
}, timeout.toNanos(), TimeUnit.NANOSECONDS);
ConnectTimings.start(ctx.channel(), this.getClass());
ctx.writeAndFlush(buildHelloRequest(ctx));
// Fire the channel active immediately so the upper handler in the pipeline gets a chance to
// pipeline its request before the response of this one arrives. This helps speeding up the
// bootstrap sequence.
ctx.fireChannelActive();
}
use of com.couchbase.client.core.io.IoContext in project couchbase-jvm-clients by couchbase.
the class ChunkedMessageHandler method channelActive.
@Override
public void channelActive(final ChannelHandlerContext ctx) {
remoteHost = endpoint.remoteHostname() + ":" + endpoint.remotePort();
ioContext = new IoContext(endpointContext, ctx.channel().localAddress(), ctx.channel().remoteAddress(), endpointContext.bucket());
ctx.fireChannelActive();
}
use of com.couchbase.client.core.io.IoContext in project couchbase-jvm-clients by couchbase.
the class ManagerMessageHandler method channelActive.
@Override
public void channelActive(final ChannelHandlerContext ctx) {
ioContext = new IoContext(coreContext, ctx.channel().localAddress(), ctx.channel().remoteAddress(), Optional.empty());
remoteHost = endpoint.remoteHostname() + ":" + endpoint.remotePort();
currentContent = ctx.alloc().buffer();
ctx.fireChannelActive();
}
use of com.couchbase.client.core.io.IoContext in project couchbase-jvm-clients by couchbase.
the class KeyValueMessageHandler method handleNotMyVbucket.
/**
* Helper method to handle a "not my vbucket" response.
*
* @param request the request to retry.
* @param response the response to extract the config from, potentially.
*/
private void handleNotMyVbucket(final KeyValueRequest<Response> request, final ByteBuf response) {
request.indicateRejectedWithNotMyVbucket();
eventBus.publish(new NotMyVbucketReceivedEvent(ioContext, request.partition()));
final String origin = request.context().lastDispatchedTo() != null ? request.context().lastDispatchedTo().hostname() : null;
RetryOrchestrator.maybeRetry(ioContext, request, RetryReason.KV_NOT_MY_VBUCKET);
body(response).map(b -> b.toString(UTF_8).trim()).filter(c -> c.startsWith("{")).ifPresent(c -> ioContext.core().configurationProvider().proposeBucketConfig(new ProposedBucketConfigContext(request.bucket(), c, origin)));
}
Aggregations