@Test void encodeAndSendErrorMapRequest() { ErrorMapLoadingHandler handler = new ErrorMapLoadingHandler(endpointContext); channel.pipeline().addLast(handler); assertEquals(handler, channel.pipeline().get(ErrorMapLoadingHandler.class)); channel.connect(new InetSocketAddress("1.2.3.4", 1234)); channel.pipeline().fireChannelActive(); channel.runPendingTasks(); ByteBuf writtenRequest = channel.readOutbound(); verifyRequest(writtenRequest, MemcacheProtocol.Opcode.ERROR_MAP.opcode(), false, false, true); assertTrue(ProtocolVerifier.body(writtenRequest).isPresent()); ByteBuf body = ProtocolVerifier.body(writtenRequest).get(); assertEquals(2, body.readableBytes()); assertEquals((short) 1, body.readShort()); ReferenceCountUtil.release(writtenRequest); }
@Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); }
ErrorMapLoadingHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } }
ErrorMapLoadingHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } ErrorMapLoadingHandler(final EndpointContext endpointContext); }
ErrorMapLoadingHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } ErrorMapLoadingHandler(final EndpointContext endpointContext); @Override void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
                      final SocketAddress localAddress, final ChannelPromise promise); @Override void channelActive(final ChannelHandlerContext ctx); @Override void channelRead(final ChannelHandlerContext ctx, final Object msg); }
ErrorMapLoadingHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } ErrorMapLoadingHandler(final EndpointContext endpointContext); @Override void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
                      final SocketAddress localAddress, final ChannelPromise promise); @Override void channelActive(final ChannelHandlerContext ctx); @Override void channelRead(final ChannelHandlerContext ctx, final Object msg);  }