@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof BufferCallEvent) { BufferCallEvent bcEvt = (BufferCallBeforeInitHandler.BufferCallEvent) evt; switch (bcEvt.action) { case FLUSH: for (Call call : id2Call.values()) { ctx.write(call); } break; case FAIL: for (Call call : id2Call.values()) { call.setException(bcEvt.error); } break; } ctx.flush(); ctx.pipeline().remove(this); } else if (evt instanceof CallEvent) { // just remove the call for now until we add other call event other than timeout and cancel. id2Call.remove(((CallEvent) evt).call.id); } else { ctx.fireUserEventTriggered(evt); } } }
private void tryComplete(ChannelHandlerContext ctx) { if (!saslRpcClient.isComplete()) { return; } saslRpcClient.setupSaslHandler(ctx.pipeline()); setCryptoAESOption(); saslPromise.setSuccess(true); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { NettyServerRpcConnection conn = createNettyServerRpcConnection(ctx.channel()); ByteBuffer buf = ByteBuffer.allocate(msg.readableBytes()); msg.readBytes(buf); buf.flip(); if (!conn.processPreamble(buf)) { conn.close(); return; } ChannelPipeline p = ctx.pipeline(); ((NettyRpcFrameDecoder) p.get("frameDecoder")).setConnection(conn); ((NettyRpcServerRequestDecoder) p.get("decoder")).setConnection(conn); p.remove(this); p.remove("preambleDecoder"); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { // read the ConnectionHeaderResponse from server int len = msg.readInt(); byte[] buff = new byte[len]; msg.readBytes(buff); RPCProtos.ConnectionHeaderResponse connectionHeaderResponse = RPCProtos.ConnectionHeaderResponse.parseFrom(buff); // Get the CryptoCipherMeta, update the HBaseSaslRpcClient for Crypto Cipher if (connectionHeaderResponse.hasCryptoCipherMeta()) { CryptoAES cryptoAES = EncryptionUtil.createCryptoAES( connectionHeaderResponse.getCryptoCipherMeta(), conf); // replace the Sasl handler with Crypto AES handler setupCryptoAESHandler(ctx.pipeline(), cryptoAES); } saslPromise.setSuccess(true); }
ChannelPipeline p = ctx.pipeline(); for (ChannelHandler handler; (handler = p.removeLast()) != null;) {
CipherOption cipherOption = getCipherOption(proto, isNegotiatedQopPrivacy(), saslClient); ChannelPipeline p = ctx.pipeline(); while (p.first() != null) { p.removeFirst();
private void tryComplete(ChannelHandlerContext ctx) { if (!saslRpcClient.isComplete()) { return; } saslRpcClient.setupSaslHandler(ctx.pipeline()); setCryptoAESOption(); saslPromise.setSuccess(true); }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof BufferCallEvent) { BufferCallEvent bcEvt = (BufferCallBeforeInitHandler.BufferCallEvent) evt; switch (bcEvt.action) { case FLUSH: for (Call call : id2Call.values()) { ctx.write(call); } break; case FAIL: for (Call call : id2Call.values()) { call.setException(bcEvt.error); } break; } ctx.flush(); ctx.pipeline().remove(this); } else if (evt instanceof CallEvent) { // just remove the call for now until we add other call event other than timeout and cancel. id2Call.remove(((CallEvent) evt).call.id); } else { ctx.fireUserEventTriggered(evt); } } }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { // read the ConnectionHeaderResponse from server int len = msg.readInt(); byte[] buff = new byte[len]; msg.readBytes(buff); RPCProtos.ConnectionHeaderResponse connectionHeaderResponse = RPCProtos.ConnectionHeaderResponse.parseFrom(buff); // Get the CryptoCipherMeta, update the HBaseSaslRpcClient for Crypto Cipher if (connectionHeaderResponse.hasCryptoCipherMeta()) { CryptoAES cryptoAES = EncryptionUtil.createCryptoAES( connectionHeaderResponse.getCryptoCipherMeta(), conf); // replace the Sasl handler with Crypto AES handler setupCryptoAESHandler(ctx.pipeline(), cryptoAES); } saslPromise.setSuccess(true); }
/** * Upgrades to another protocol from HTTP. Removes the {@link Decoder} and {@link Encoder} from * the pipeline. */ @Override public void upgradeFrom(ChannelHandlerContext ctx) { final ChannelPipeline p = ctx.pipeline(); p.remove(this); }
/** * Upgrades to another protocol from HTTP. Removes the {@link HttpRequestDecoder} and * {@link HttpResponseEncoder} from the pipeline. */ @Override public void upgradeFrom(ChannelHandlerContext ctx) { ctx.pipeline().remove(this); }
@Override protected void removeDecoder(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); p.remove(decoderName); }
private static Http2FrameCodec requireHttp2FrameCodec(ChannelHandlerContext ctx) { ChannelHandlerContext frameCodecCtx = ctx.pipeline().context(Http2FrameCodec.class); if (frameCodecCtx == null) { throw new IllegalArgumentException(Http2FrameCodec.class.getSimpleName() + " was not found in the channel pipeline."); } return (Http2FrameCodec) frameCodecCtx.handler(); } }
@Override protected void removeDecoder(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); if (p.context(decoderName) != null) { p.remove(decoderName); } }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); p.addBefore(name, null, codec); }
@Override protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { // Remove ourself and do the actual handshake ctx.pipeline().remove(this); try { finishHandshake(channel, msg); promise.setSuccess(); } catch (Throwable cause) { promise.setFailure(cause); } }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { ctx.pipeline() .addBefore(ctx.name(), null, new PriorKnowledgeHandler()) .addBefore(ctx.name(), null, httpServerCodec) .replace(this, null, httpServerUpgradeHandler); }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); Socks5InitialResponseDecoder decoder = new Socks5InitialResponseDecoder(); p.addBefore(name, null, decoder); decoderName = p.context(decoder).name(); encoderName = decoderName + ".encoder"; p.addBefore(name, encoderName, Socks5ClientEncoder.DEFAULT); }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); Socks4ClientDecoder decoder = new Socks4ClientDecoder(); p.addBefore(name, null, decoder); decoderName = p.context(decoder).name(); encoderName = decoderName + ".encoder"; p.addBefore(name, encoderName, Socks4ClientEncoder.INSTANCE); }