@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { // Close according to the specified close type. ConnectionCloseType type = ConnectionCloseType.fromChannel(ctx.channel()); closeChannel(ctx, type, promise); // Don't pass this event further down the pipeline. }
/** * Note this blocks until all the channels have finished closing. */ public void gracefullyShutdownClientChannels() { LOG.warn("Gracefully shutting down all client channels"); try { List<ChannelFuture> futures = new ArrayList<>(); channels.forEach(channel -> { ConnectionCloseType.setForChannel(channel, ConnectionCloseType.DELAYED_GRACEFUL); ChannelFuture f = channel.pipeline().close(); futures.add(f); }); LOG.warn("Waiting for " + futures.size() + " client channels to be closed."); for (ChannelFuture f : futures) { f.await(); } LOG.warn(futures.size() + " client channels closed."); } catch (InterruptedException ie) { LOG.warn("Interrupted while shutting down client channels"); } } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { // Close according to the specified close type. Channel parent = parentChannel(ctx); ConnectionCloseType type = ConnectionCloseType.fromChannel(parent); closeChannel(ctx, parent, type, promise); // Don't pass this event further down the pipeline. }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (isResponseHeaders(msg)) { // Update the request count attribute for this channel. requestCount++; if (isConnectionExpired(ctx)) { // Flag this channel to be closed after response is written. HttpChannelFlags.CLOSE_AFTER_RESPONSE.set(ctx); // with close of configured type. ConnectionCloseType.setForChannel(ctx.channel(), connectionCloseType); } } super.write(ctx, msg, promise); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { // Close according to the specified close type. ConnectionCloseType type = ConnectionCloseType.fromChannel(ctx.channel()); closeChannel(ctx, type, promise); // Don't pass this event further down the pipeline. }
/** * Note this blocks until all the channels have finished closing. */ public void gracefullyShutdownClientChannels() { LOG.warn("Gracefully shutting down all client channels"); try { List<ChannelFuture> futures = new ArrayList<>(); channels.forEach(channel -> { ConnectionCloseType.setForChannel(channel, ConnectionCloseType.DELAYED_GRACEFUL); ChannelFuture f = channel.pipeline().close(); futures.add(f); }); LOG.warn("Waiting for " + futures.size() + " client channels to be closed."); for (ChannelFuture f : futures) { f.await(); } LOG.warn(futures.size() + " client channels closed."); } catch (InterruptedException ie) { LOG.warn("Interrupted while shutting down client channels"); } } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { // Close according to the specified close type. Channel parent = parentChannel(ctx); ConnectionCloseType type = ConnectionCloseType.fromChannel(parent); closeChannel(ctx, parent, type, promise); // Don't pass this event further down the pipeline. }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (isResponseHeaders(msg)) { // Update the request count attribute for this channel. requestCount++; if (isConnectionExpired(ctx)) { // Flag this channel to be closed after response is written. HttpChannelFlags.CLOSE_AFTER_RESPONSE.set(ctx); // with close of configured type. ConnectionCloseType.setForChannel(ctx.channel(), connectionCloseType); } } super.write(ctx, msg, promise); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { super.write(ctx, msg, promise); // Close the connection immediately after LastContent is written, rather than // waiting until the graceful-delay is up if this flag is set. if (isEndOfRequestResponse(msg)) { if (HttpChannelFlags.CLOSE_AFTER_RESPONSE.get(ctx)) { promise.addListener(future -> { Channel parent = parentChannel(ctx); closeChannel(ctx, parent, ConnectionCloseType.fromChannel(ctx.channel()), ctx.newPromise()); }); } } }
/** * Note this blocks until all the channels have finished closing. */ public void gracefullyShutdownClientChannels() { LOG.warn("Gracefully shutting down all client channels"); try { List<ChannelFuture> futures = new ArrayList<>(); channels.forEach(channel -> { ConnectionCloseType.setForChannel(channel, ConnectionCloseType.DELAYED_GRACEFUL); ChannelFuture f = channel.pipeline().close(); futures.add(f); }); LOG.warn("Waiting for " + futures.size() + " client channels to be closed."); for (ChannelFuture f : futures) { f.await(); } LOG.warn(futures.size() + " client channels closed."); } catch (InterruptedException ie) { LOG.warn("Interrupted while shutting down client channels"); } } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { super.write(ctx, msg, promise); // Close the connection immediately after LastContent is written, rather than // waiting until the graceful-delay is up if this flag is set. if (isEndOfRequestResponse(msg)) { if (HttpChannelFlags.CLOSE_AFTER_RESPONSE.get(ctx)) { promise.addListener(future -> { Channel parent = parentChannel(ctx); closeChannel(ctx, parent, ConnectionCloseType.fromChannel(ctx.channel()), ctx.newPromise()); }); } } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (isResponseHeaders(msg)) { // Update the request count attribute for this channel. requestCount++; if (isConnectionExpired(ctx)) { // Flag this channel to be closed after response is written. HttpChannelFlags.CLOSE_AFTER_RESPONSE.set(ctx); // with close of configured type. ConnectionCloseType.setForChannel(ctx.channel(), connectionCloseType); } } super.write(ctx, msg, promise); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { // Close according to the specified close type. ConnectionCloseType type = ConnectionCloseType.fromChannel(ctx.channel()); closeChannel(ctx, type, promise); // Don't pass this event further down the pipeline. }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { // Close according to the specified close type. Channel parent = parentChannel(ctx); ConnectionCloseType type = ConnectionCloseType.fromChannel(parent); closeChannel(ctx, parent, type, promise); // Don't pass this event further down the pipeline. }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { super.write(ctx, msg, promise); // Close the connection immediately after LastContent is written, rather than // waiting until the graceful-delay is up if this flag is set. if (isEndOfRequestResponse(msg)) { if (HttpChannelFlags.CLOSE_AFTER_RESPONSE.get(ctx)) { promise.addListener(future -> { Channel parent = parentChannel(ctx); closeChannel(ctx, parent, ConnectionCloseType.fromChannel(ctx.channel()), ctx.newPromise()); }); } } }