@Override public void run() { channel.config().setAutoRead(true); } };
public void doResume() { chctx.channel().config().setAutoRead(true); }
/** * Release the Read suspension */ void releaseReadSuspended(ChannelHandlerContext ctx) { Channel channel = ctx.channel(); channel.attr(READ_SUSPENDED).set(false); channel.config().setAutoRead(true); }
@Override public void run() { channel.config().setAutoRead(true); } };
public void doPause() { chctx.channel().config().setAutoRead(false); }
/** * Disables auto read for a netty channel. * * @param channel the netty channel */ public static void disableAutoRead(Channel channel) { channel.config().setAutoRead(false); }
/** * Release the Read suspension */ void releaseReadSuspended(ChannelHandlerContext ctx) { Channel channel = ctx.channel(); channel.attr(READ_SUSPENDED).set(false); channel.config().setAutoRead(true); }
@Override public void run() { channel.config().setAutoRead(true); } };
@Override public final void setAutoRead(boolean autoRead) { channel.config().setAutoRead(autoRead); }
public void inc(int numProducedBytes) { final int oldValue = getAndAdd(numProducedBytes); if (oldValue <= highWatermark && oldValue + numProducedBytes > highWatermark) { // Just went above high watermark if (cfg != null) { cfg.setAutoRead(false); numDeferredReads++; suspended = true; } } }
public void dec(int numConsumedBytes) { final int oldValue = getAndAdd(-numConsumedBytes); if (oldValue > lowWatermark && oldValue - numConsumedBytes <= lowWatermark) { // Just went below high watermark if (cfg != null) { cfg.setAutoRead(true); suspended = false; } } }
@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); } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { try { if (evt == NettyServerCnxn.AutoReadEvent.ENABLE) { LOG.debug("Received AutoReadEvent.ENABLE"); NettyServerCnxn cnxn = ctx.channel().attr(CONNECTION_ATTRIBUTE).get(); // TODO(ilyam): Not sure if cnxn can be null here. It becomes null if channelInactive() // or exceptionCaught() trigger, but it's unclear to me if userEventTriggered() can run // after either of those. Check for null just to be safe ... if (cnxn != null) { cnxn.processQueuedBuffer(); } ctx.channel().config().setAutoRead(true); } else if (evt == NettyServerCnxn.AutoReadEvent.DISABLE) { LOG.debug("Received AutoReadEvent.DISABLE"); ctx.channel().config().setAutoRead(false); } } finally { ReferenceCountUtil.release(evt); } }
@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); } }
@Override public void resume() { ChannelConfig config = ctx.channel().config(); if (!config.isAutoRead()) { config.setAutoRead(true); } }
@Override public void pause() { ChannelConfig config = ctx.channel().config(); if (config.isAutoRead()) { config.setAutoRead(false); } }
@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); } }
private void checkLimitsOnDequeue( BoltConnection connection ) { Channel channel = connection.channel(); if ( queueSize <= lowWatermark && !channel.config().isAutoRead() ) { if ( log != null ) { log.warn( "Channel [%s]: consumed messages on the worker queue below %d, auto-read is being enabled.", channel.remoteAddress(), lowWatermark ); } channel.config().setAutoRead( true ); } }
private void checkLimitsOnEnqueue( BoltConnection connection ) { Channel channel = connection.channel(); if ( queueSize > highWatermark && channel.config().isAutoRead() ) { if ( log != null ) { log.warn( "Channel [%s]: client produced %d messages on the worker queue, auto-read is being disabled.", channel.remoteAddress(), queueSize ); } channel.config().setAutoRead( false ); } }
/** * Enables auto read for a netty channel. * * @param channel the netty channel */ public static void enableAutoRead(Channel channel) { if (!channel.config().isAutoRead()) { channel.config().setAutoRead(true); channel.read(); } }