Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      EspressoHttp2MultiplexHandler​(io.netty.channel.ChannelHandler inboundStreamHandler)
      Creates a new instance
      EspressoHttp2MultiplexHandler​(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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)  
      void channelRead​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)  
      void channelReadComplete​(io.netty.channel.ChannelHandlerContext ctx)
      Notifies any child streams of the read completion.
      void channelWritabilityChanged​(io.netty.channel.ChannelHandlerContext ctx)  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)  
      java.util.Queue<io.netty.handler.codec.http2.EspressoAbstractHttp2StreamChannel> getChildChannelPool()  
      protected void handlerAdded0​(io.netty.channel.ChannelHandlerContext ctx)  
      protected void handlerRemoved0​(io.netty.channel.ChannelHandlerContext ctx)  
      void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt)  
      • Methods inherited from class io.netty.handler.codec.http2.Http2ChannelDuplexHandler

        forEachActiveStream, handlerAdded, handlerRemoved, newStream
      • Methods inherited from class io.netty.channel.ChannelDuplexHandler

        bind, close, connect, deregister, disconnect, flush, read, write
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelRegistered, channelUnregistered
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, isSharable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EspressoHttp2MultiplexHandler

        public EspressoHttp2MultiplexHandler​(io.netty.channel.ChannelHandler inboundStreamHandler)
        Creates a new instance
        Parameters:
        inboundStreamHandler - the ChannelHandler that will be added to the { ChannelPipeline} of the Channels created for new inbound streams.
      • EspressoHttp2MultiplexHandler

        public EspressoHttp2MultiplexHandler​(io.netty.channel.ChannelHandler inboundStreamHandler,
                                             io.netty.channel.ChannelHandler upgradeStreamHandler)
        Creates a new instance
        Parameters:
        inboundStreamHandler - the ChannelHandler that will be added to the { ChannelPipeline} of the Channels created for new inbound streams.
        upgradeStreamHandler - the ChannelHandler that will be added to the { ChannelPipeline} of the upgraded Channel.
      • EspressoHttp2MultiplexHandler

        public EspressoHttp2MultiplexHandler​(io.netty.channel.ChannelHandler inboundStreamHandler,
                                             boolean reuseChildChannels,
                                             boolean offloadChildChannels)
    • Method Detail

      • getChildChannelPool

        public java.util.Queue<io.netty.handler.codec.http2.EspressoAbstractHttp2StreamChannel> getChildChannelPool()
      • handlerAdded0

        protected void handlerAdded0​(io.netty.channel.ChannelHandlerContext ctx)
        Overrides:
        handlerAdded0 in class io.netty.handler.codec.http2.Http2ChannelDuplexHandler
      • handlerRemoved0

        protected void handlerRemoved0​(io.netty.channel.ChannelHandlerContext ctx)
        Overrides:
        handlerRemoved0 in class io.netty.handler.codec.http2.Http2ChannelDuplexHandler
      • channelInactive

        public void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)
                             throws java.lang.Exception
        Specified by:
        channelInactive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • channelRead

        public void channelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                java.lang.Object msg)
                         throws java.lang.Exception
        Specified by:
        channelRead in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • channelWritabilityChanged

        public void channelWritabilityChanged​(io.netty.channel.ChannelHandlerContext ctx)
                                       throws java.lang.Exception
        Specified by:
        channelWritabilityChanged in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelWritabilityChanged in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • userEventTriggered

        public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx,
                                       java.lang.Object evt)
                                throws java.lang.Exception
        Specified by:
        userEventTriggered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    java.lang.Throwable cause)
                             throws java.lang.Exception
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • channelReadComplete

        public void channelReadComplete​(io.netty.channel.ChannelHandlerContext ctx)
                                 throws java.lang.Exception
        Notifies any child streams of the read completion.
        Specified by:
        channelReadComplete in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception