Package io.netty.handler.codec.http2
Class EspressoHttp2MultiplexHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.http2.Http2ChannelDuplexHandler
io.netty.handler.codec.http2.EspressoHttp2MultiplexHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public final class EspressoHttp2MultiplexHandler
extends io.netty.handler.codec.http2.Http2ChannelDuplexHandler
Forked from Netty's Http2MultiplexHandler (4.1.42)
(https://github.com/netty/netty/blob/4.1/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MultiplexHandler.java)
In HTTP/1.1, the requests from the client are distributed across 48 workers threads of router.
With HTTP/2 there will be only connection between the client -> router, all the requests for a given client are executed on a single I/O worker thread.
If there are less than 48 client to a given router, not all threads will be utilized.
To mitigate this, this rb forks Netty's multiplex handler and registers the child channels on different I/O workers.
This will help distribute the work on to different threads.
Design document - https://iwww.corp.linkedin.com/wiki/cf/pages/viewpage.action?pageId=323757534
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionEspressoHttp2MultiplexHandler(io.netty.channel.ChannelHandler inboundStreamHandler) Creates a new instanceEspressoHttp2MultiplexHandler(io.netty.channel.ChannelHandler inboundStreamHandler, boolean reuseChildChannels, boolean offloadChildChannels) EspressoHttp2MultiplexHandler(io.netty.channel.ChannelHandler inboundStreamHandler, io.netty.channel.ChannelHandler upgradeStreamHandler) Creates a new instance -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) voidchannelReadComplete(io.netty.channel.ChannelHandlerContext ctx) Notifies any child streams of the read completion.voidchannelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Queue<io.netty.handler.codec.http2.EspressoAbstractHttp2StreamChannel>protected voidhandlerAdded0(io.netty.channel.ChannelHandlerContext ctx) protected voidhandlerRemoved0(io.netty.channel.ChannelHandlerContext ctx) voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) Methods inherited from class io.netty.handler.codec.http2.Http2ChannelDuplexHandler
forEachActiveStream, handlerAdded, handlerRemoved, newStreamMethods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read, writeMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregisteredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
EspressoHttp2MultiplexHandler
public EspressoHttp2MultiplexHandler(io.netty.channel.ChannelHandler inboundStreamHandler) Creates a new instance- Parameters:
inboundStreamHandler- theChannelHandlerthat will be added to the { ChannelPipeline} of theChannels created for new inbound streams.
-
EspressoHttp2MultiplexHandler
public EspressoHttp2MultiplexHandler(io.netty.channel.ChannelHandler inboundStreamHandler, io.netty.channel.ChannelHandler upgradeStreamHandler) Creates a new instance- Parameters:
inboundStreamHandler- theChannelHandlerthat will be added to the { ChannelPipeline} of theChannels created for new inbound streams.upgradeStreamHandler- theChannelHandlerthat will be added to the { ChannelPipeline} of the upgradedChannel.
-
EspressoHttp2MultiplexHandler
public EspressoHttp2MultiplexHandler(io.netty.channel.ChannelHandler inboundStreamHandler, boolean reuseChildChannels, boolean offloadChildChannels)
-
-
Method Details
-
getChildChannelPool
-
handlerAdded0
protected void handlerAdded0(io.netty.channel.ChannelHandlerContext ctx) - Overrides:
handlerAdded0in classio.netty.handler.codec.http2.Http2ChannelDuplexHandler
-
handlerRemoved0
protected void handlerRemoved0(io.netty.channel.ChannelHandlerContext ctx) - Overrides:
handlerRemoved0in classio.netty.handler.codec.http2.Http2ChannelDuplexHandler
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelWritabilityChanged
- Specified by:
channelWritabilityChangedin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelWritabilityChangedin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception - Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelReadComplete
Notifies any child streams of the read completion.- Specified by:
channelReadCompletein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadCompletein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-