GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec.http2
  • Http2MultiplexCodec

This view

  • Original page
  • New address

GeezerVison is showing netty.io — Http2MultiplexCodec (Netty API Reference (4.1.141.Final))

Class Http2MultiplexCodec

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.http2.Http2ConnectionHandler
io.netty.handler.codec.http2.Http2FrameCodec
io.netty.handler.codec.http2.Http2MultiplexCodec
All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler, Http2LifecycleManager

@Deprecated public class Http2MultiplexCodec extends Http2FrameCodec
Deprecated.
use Http2FrameCodecBuilder together with Http2MultiplexHandler.
An HTTP/2 handler that creates child channels for each stream.

When a new stream is created, a new Channel is created for it. Applications send and receive Http2StreamFrames on the created channel. ByteBufs cannot be processed by the channel; all writes that reach the head of the pipeline must be an instance of Http2StreamFrame. Writes that reach the head of the pipeline are processed directly by this handler and cannot be intercepted.

The child channel will be notified of user events that impact the stream, such as Http2GoAwayFrame and Http2ResetFrame, as soon as they occur. Although Http2GoAwayFrame and Http2ResetFrame signify that the remote is ignoring further communication, closing of the channel is delayed until any inbound queue is drained with Channel.read(), which follows the default behavior of channels in Netty. Applications are free to close the channel in response to such events if they don't have use for any queued messages. Any connection level events like Http2SettingsFrame and Http2GoAwayFrame will be processed internally and also propagated down the pipeline for other handlers to act on.

Outbound streams are supported via the Http2StreamChannelBootstrap.

ChannelConfig.setMaxMessagesPerRead(int) and ChannelConfig.setAutoRead(boolean) are supported.

Reference Counting

Some Http2StreamFrames implement the ReferenceCounted interface, as they carry reference counted objects (e.g. ByteBufs). The multiplex codec will call ReferenceCounted.retain() before propagating a reference counted object through the pipeline, and thus an application handler needs to release such an object after having consumed it. For more information on reference counting take a look at https://netty.io/wiki/reference-counted-objects.html

Channel Events

A child channel becomes active as soon as it is registered to an EventLoop. Therefore, an active channel does not map to an active HTTP/2 stream immediately. Only once a Http2HeadersFrame has been successfully sent or received, does the channel map to an active HTTP/2 stream. In case it is not possible to open a new HTTP/2 stream (i.e. due to the maximum number of active streams being exceeded), the child channel receives an exception indicating the cause and is closed immediately thereafter.

Writability and Flow Control

A child channel observes outbound/remote flow control via the channel's writability. A channel only becomes writable when it maps to an active HTTP/2 stream and the stream's flow control window is greater than zero. A child channel does not know about the connection-level flow control window. ChannelHandlers are free to ignore the channel's writability, in which case the excessive writes will be buffered by the parent channel. It's important to note that only Http2DataFrames are subject to HTTP/2 flow control.
  • Nested Class Summary

    Nested classes/interfaces inherited from class ByteToMessageDecoder

    ByteToMessageDecoder.Cumulator
    Modifier and Type
    Class
    Description
    static interface 
    ByteToMessageDecoder.Cumulator
    Cumulate ByteBufs.

    Nested classes/interfaces inherited from interface ChannelHandler

    ChannelHandler.Sharable
    Modifier and Type
    Interface
    Description
    static @interface 
    ChannelHandler.Sharable
    Indicates that the same instance of the annotated ChannelHandler can be added to one or more ChannelPipelines multiple times without a race condition.
  • Field Summary

    Fields inherited from class Http2FrameCodec

    streamKey
    Modifier and Type
    Field
    Description
    protected final Http2Connection.PropertyKey
    streamKey
     

    Fields inherited from class ByteToMessageDecoder

    COMPOSITE_CUMULATOR, MERGE_CUMULATOR
    Modifier and Type
    Field
    Description
    static final ByteToMessageDecoder.Cumulator
    COMPOSITE_CUMULATOR
    Cumulate ByteBufs by add them to a CompositeByteBuf and so do no memory copy whenever possible.
    static final ByteToMessageDecoder.Cumulator
    MERGE_CUMULATOR
    Cumulate ByteBufs by merge them into one ByteBuf's, using memory copies.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    channelRead(ChannelHandlerContext ctx, Object msg)
    Deprecated.
    Calls ChannelHandlerContext.fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.
    final void
    channelReadComplete(ChannelHandlerContext ctx)
    Deprecated.
    Notifies any child streams of the read completion.
    final void
    channelWritabilityChanged(ChannelHandlerContext ctx)
    Deprecated.
    Calls ChannelHandlerContext.fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    final void
    handlerAdded0(ChannelHandlerContext ctx)
    Deprecated.
     
    final void
    handlerRemoved0(ChannelHandlerContext ctx)
    Deprecated.
    Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.
    void
    onHttpClientUpgrade()
    Deprecated.
    Handles the client-side (cleartext) upgrade from HTTP to HTTP/2.

    Methods inherited from class Http2FrameCodec

    handlerAdded, isGracefulShutdownComplete, newHttp2UnknownFrame, onConnectionError, onStreamError, userEventTriggered, write
    Modifier and Type
    Method
    Description
    final void
    handlerAdded(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    protected final boolean
    isGracefulShutdownComplete()
    Called by the graceful shutdown logic to determine when it is safe to close the connection.
    protected Http2StreamFrame
    newHttp2UnknownFrame(byte frameType, int streamId, Http2Flags flags, ByteBuf payload)
    Create a Http2UnknownFrame.
    protected void
    onConnectionError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, Http2Exception http2Ex)
    Handler for a connection error.
    protected final void
    onStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, Http2Exception.StreamException streamException)
    Exceptions for unknown streams, that is streams that have no Http2FrameStream object attached are simply logged and replied to by sending a RST_STREAM frame.
    final void
    userEventTriggered(ChannelHandlerContext ctx, Object evt)
    Handles the cleartext HTTP upgrade event.
    void
    write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
    Processes all Http2Frames.

    Methods inherited from class Http2ConnectionHandler

    bind, channelActive, channelInactive, close, closeStream, closeStreamLocal, closeStreamRemote, connect, connection, decode, decoder, deregister, disconnect, encoder, exceptionCaught, flush, frameWriter, goAway, gracefulShutdownTimeoutMillis, gracefulShutdownTimeoutMillis, handleServerHeaderDecodeSizeError, onError, onHttpServerUpgrade, read, resetStream
    Modifier and Type
    Method
    Description
    void
    bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
    Called once a bind operation is made.
    void
    channelActive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelInactive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    close(ChannelHandlerContext ctx, ChannelPromise promise)
    Called once a close operation is made.
    void
    closeStream(Http2Stream stream, ChannelFuture future)
    Closes and deactivates the given stream.
    void
    closeStreamLocal(Http2Stream stream, ChannelFuture future)
    Closes the local side of the given stream.
    void
    closeStreamRemote(Http2Stream stream, ChannelFuture future)
    Closes the remote side of the given stream.
    void
    connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
    Called once a connect operation is made.
    Http2Connection
    connection()
     
    protected void
    decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
    Decode the from one ByteBuf to an other.
    Http2ConnectionDecoder
    decoder()
     
    void
    deregister(ChannelHandlerContext ctx, ChannelPromise promise)
    Called once a deregister operation is made from the current registered EventLoop.
    void
    disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
    Called once a disconnect operation is made.
    Http2ConnectionEncoder
    encoder()
     
    void
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Handles Http2Exception objects that were thrown from other handlers.
    void
    flush(ChannelHandlerContext ctx)
    Called once a flush operation is made.
    protected Http2FrameWriter
    frameWriter()
     
    ChannelFuture
    goAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData, ChannelPromise promise)
    Prevents the peer from creating streams and close the connection if errorCode is not Http2Error.NO_ERROR.
    long
    gracefulShutdownTimeoutMillis()
    Get the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.
    void
    gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis)
    Set the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.
    protected void
    handleServerHeaderDecodeSizeError(ChannelHandlerContext ctx, Http2Stream stream)
    Notifies client that this server has received headers that are larger than what it is willing to accept.
    void
    onError(ChannelHandlerContext ctx, boolean outbound, Throwable cause)
    Central handler for all exceptions caught during HTTP/2 processing.
    void
    onHttpServerUpgrade(Http2Settings settings)
    Handles the server-side (cleartext) upgrade from HTTP to HTTP/2.
    void
    read(ChannelHandlerContext ctx)
    Intercepts ChannelHandlerContext.read().
    ChannelFuture
    resetStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)
    Ensure the stream identified by streamId is reset.

    Methods inherited from class ByteToMessageDecoder

    actualReadableBytes, callDecode, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode
    Modifier and Type
    Method
    Description
    protected int
    actualReadableBytes()
    Returns the actual number of readable bytes in the internal cumulative buffer of this decoder.
    protected void
    callDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
    Called once data should be decoded from the given ByteBuf.
    protected void
    decodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
    Is called one last time when the ChannelHandlerContext goes in-active.
    protected final void
    discardSomeReadBytes()
     
    final void
    handlerRemoved(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    protected ByteBuf
    internalBuffer()
    Returns the internal cumulative buffer of this decoder.
    boolean
    isSingleDecode()
    If true then only one message is decoded on each ByteToMessageDecoder.channelRead(ChannelHandlerContext, Object) call.
    void
    setCumulator(ByteToMessageDecoder.Cumulator cumulator)
    Set the ByteToMessageDecoder.Cumulator to use for cumulate the received ByteBufs.
    void
    setDiscardAfterReads(int discardAfterReads)
    Set the number of reads after which ByteBuf.discardSomeReadBytes() are called and so free up memory.
    void
    setSingleDecode(boolean singleDecode)
    If set then only one message is decoded on each ByteToMessageDecoder.channelRead(ChannelHandlerContext, Object) call.

    Methods inherited from class ChannelInboundHandlerAdapter

    channelRegistered, channelUnregistered
    Modifier and Type
    Method
    Description
    void
    channelRegistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelRegistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelUnregistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelUnregistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelHandlerAdapter

    ensureNotSharable, isSharable
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    boolean
    isSharable()
    Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • onHttpClientUpgrade

      public void onHttpClientUpgrade() throws Http2Exception
      Deprecated.
      Description copied from class: Http2ConnectionHandler
      Handles the client-side (cleartext) upgrade from HTTP to HTTP/2. Reserves local stream 1 for the HTTP/2 response.
      Overrides:
      onHttpClientUpgrade in class Http2ConnectionHandler
      Throws:
      Http2Exception
    • handlerAdded0

      public final void handlerAdded0(ChannelHandlerContext ctx) throws Exception
      Deprecated.
      Throws:
      Exception
    • handlerRemoved0

      public final void handlerRemoved0(ChannelHandlerContext ctx) throws Exception
      Deprecated.
      Description copied from class: ByteToMessageDecoder
      Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle events anymore.
      Overrides:
      handlerRemoved0 in class Http2ConnectionHandler
      Throws:
      Exception
    • channelReadComplete

      public final void channelReadComplete(ChannelHandlerContext ctx) throws Exception
      Deprecated.
      Notifies any child streams of the read completion.
      Specified by:
      channelReadComplete in interface ChannelInboundHandler
      Overrides:
      channelReadComplete in class Http2ConnectionHandler
      Throws:
      Exception
    • channelRead

      public final void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
      Deprecated.
      Description copied from class: ChannelInboundHandlerAdapter
      Calls ChannelHandlerContext.fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      channelRead in interface ChannelInboundHandler
      Overrides:
      channelRead in class ByteToMessageDecoder
      Throws:
      Exception
    • channelWritabilityChanged

      public final void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception
      Deprecated.
      Description copied from class: ChannelInboundHandlerAdapter
      Calls ChannelHandlerContext.fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      channelWritabilityChanged in interface ChannelInboundHandler
      Overrides:
      channelWritabilityChanged in class Http2ConnectionHandler
      Throws:
      Exception
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.