protected void addHttp1Handlers(ChannelPipeline pipeline) { pipeline.addLast(HTTP_CODEC_HANDLER_NAME, createHttpServerCodec()); pipeline.addLast(new Http1ConnectionCloseHandler(connCloseDelay)); pipeline.addLast("conn_expiry_handler", new Http1ConnectionExpiryHandler(maxRequestsPerConnection, maxRequestsPerConnectionInBrownout, connectionExpiry)); }
@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. }
protected void closeChannel(ChannelHandlerContext ctx, ConnectionCloseType evt, ChannelPromise promise) { switch (evt) { case DELAYED_GRACEFUL: gracefully(ctx, promise); break; case GRACEFUL: gracefully(ctx, promise); break; case IMMEDIATE: immediately(ctx, promise); break; default: throw new IllegalArgumentException("Unknown ConnectionCloseEvent type! - " + String.valueOf(evt)); } }
protected void immediately(ChannelHandlerContext ctx, ChannelPromise promise) { if (isAlreadyClosing(ctx)) { promise.setSuccess(); return; } if (ctx.channel().isActive()) { ctx.close(promise); } else { promise.setSuccess(); } }
protected void gracefully(ChannelHandlerContext ctx, ChannelPromise promise) if (isAlreadyClosing(ctx)) { promise.setSuccess(); return;
protected void closeChannel(ChannelHandlerContext ctx, ConnectionCloseType evt, ChannelPromise promise) { switch (evt) { case DELAYED_GRACEFUL: gracefully(ctx, promise); break; case GRACEFUL: gracefully(ctx, promise); break; case IMMEDIATE: immediately(ctx, promise); break; default: throw new IllegalArgumentException("Unknown ConnectionCloseEvent type! - " + String.valueOf(evt)); } }
protected void immediately(ChannelHandlerContext ctx, ChannelPromise promise) { if (isAlreadyClosing(ctx)) { promise.setSuccess(); return; } if (ctx.channel().isActive()) { ctx.close(promise); } else { promise.setSuccess(); } }
protected void addHttp1Handlers(ChannelPipeline pipeline) { pipeline.addLast(HTTP_CODEC_HANDLER_NAME, createHttpServerCodec()); pipeline.addLast(new Http1ConnectionCloseHandler(connCloseDelay)); pipeline.addLast("conn_expiry_handler", new Http1ConnectionExpiryHandler(maxRequestsPerConnection, maxRequestsPerConnectionInBrownout, connectionExpiry)); }
@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. }
protected void closeChannel(ChannelHandlerContext ctx, ConnectionCloseType evt, ChannelPromise promise) { switch (evt) { case DELAYED_GRACEFUL: gracefully(ctx, promise); break; case GRACEFUL: gracefully(ctx, promise); break; case IMMEDIATE: immediately(ctx, promise); break; default: throw new IllegalArgumentException("Unknown ConnectionCloseEvent type! - " + String.valueOf(evt)); } }
protected void gracefully(ChannelHandlerContext ctx, ChannelPromise promise) if (isAlreadyClosing(ctx)) { promise.setSuccess(); return;
protected void addHttp1Handlers(ChannelPipeline pipeline) { pipeline.addLast(HTTP_CODEC_HANDLER_NAME, createHttpServerCodec()); pipeline.addLast(new Http1ConnectionCloseHandler(connCloseDelay)); pipeline.addLast("conn_expiry_handler", new Http1ConnectionExpiryHandler(maxRequestsPerConnection, maxRequestsPerConnectionInBrownout, connectionExpiry)); }
@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. }
protected void immediately(ChannelHandlerContext ctx, ChannelPromise promise) { if (isAlreadyClosing(ctx)) { promise.setSuccess(); return; } if (ctx.channel().isActive()) { ctx.close(promise); } else { promise.setSuccess(); } }
protected void gracefully(ChannelHandlerContext ctx, ChannelPromise promise) if (isAlreadyClosing(ctx)) { promise.setSuccess(); return;