private void setupReceiver(int timeoutMs) { AckHandler ackHandler = new AckHandler(timeoutMs); for (Channel ch : datanodeList) { ch.pipeline().addLast( new IdleStateHandler(timeoutMs, timeoutMs / 2, 0, TimeUnit.MILLISECONDS), new ProtobufVarint32FrameDecoder(), new ProtobufDecoder(PipelineAckProto.getDefaultInstance()), ackHandler); ch.config().setAutoRead(true); } }
ctx.channel().config().setAutoRead(false); promise.trySuccess(ctx.channel());
@Override public void run() { channel.config().setAutoRead(true); } };
/** * Release the Read suspension */ void releaseReadSuspended(ChannelHandlerContext ctx) { ctx.attr(READ_SUSPENDED).set(false); ctx.channel().config().setAutoRead(true); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { final ChannelConfig config = ctx.channel().config(); if (config.isAutoRead()) { // stop accept new connections for 1 second to allow the channel to recover // See https://github.com/netty/netty/issues/1328 config.setAutoRead(false); ctx.channel().eventLoop().schedule(enableAutoReadTask, 1, TimeUnit.SECONDS); } // still let the exceptionCaught event flow through the pipeline to give the user // a chance to do something with it ctx.fireExceptionCaught(cause); } }
config.setAutoRead(false); ctx.attr(READ_SUSPENDED).set(true);
config.setAutoRead(false); ctx.attr(READ_SUSPENDED).set(true);
config.setAutoRead(true); ctx.channel().read();