Top Description Inners Methods
io.netty.handler.codec.http2

public Interface StreamByteDistributor

Known Direct Implementers
io.netty.handler.codec.http2.UniformStreamByteDistributor, io.netty.handler.codec.http2.WeightedFairQueueByteDistributor
Annotations
@UnstableApi
Imports
io.netty.util.internal.UnstableApi

An object (used by remote flow control) that is responsible for distributing the bytes to be written across the streams in the connection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
StreamByteDistributor.StreamState

State information for the stream, indicating the number of bytes that are currently streamable.

public static interface
StreamByteDistributor.Writer

Object that performs the writing of the bytes that have been allocated for a stream.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if there are still streamable bytes that have not yet been written, otherwise false.
distribute
(int
the maximum number of bytes to write.
maxBytes
,
StreamByteDistributor.Writer writer)

Distributes up to maxBytes to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes.

public void
updateDependencyTree(int
The stream identifier associated with the child stream.
childStreamId
,
int
The stream identifier associated with the parent stream. May be 0, to make childStreamId and immediate child of the connection.
parentStreamId
,
short
The weight which is used relative to other child streams for parentStreamId. This value must be between 1 and 256 (inclusive).
weight
,
boolean
If childStreamId should be the exclusive dependency of parentStreamId.
exclusive
)

Explicitly update the dependency tree.

public void
updateStreamableBytes(StreamByteDistributor.StreamState state)

Called when the streamable bytes for a stream has changed.

Method Detail

distributeback to summary
public boolean distribute(int maxBytes, StreamByteDistributor.Writer writer) throws Http2Exception

Distributes up to maxBytes to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes. Criteria for traversing streams is undefined and it is up to the implementation to determine when to stop at a given stream.

The streamable bytes are not automatically updated by calling this method. It is up to the caller to indicate the number of bytes streamable after the write by calling updateStreamableBytes(StreamState).

Parameters
maxBytes:int

the maximum number of bytes to write.

Returns:boolean

true if there are still streamable bytes that have not yet been written, otherwise false.

Exceptions
Http2Exception:
If an internal exception occurs and internal connection state would otherwise be corrupted.
updateDependencyTreeback to summary
public void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)

Explicitly update the dependency tree. This method is called independently of stream state changes.

Parameters
childStreamId:int

The stream identifier associated with the child stream.

parentStreamId:int

The stream identifier associated with the parent stream. May be 0, to make childStreamId and immediate child of the connection.

weight:short

The weight which is used relative to other child streams for parentStreamId. This value must be between 1 and 256 (inclusive).

exclusive:boolean

If childStreamId should be the exclusive dependency of parentStreamId.

updateStreamableBytesback to summary
public void updateStreamableBytes(StreamByteDistributor.StreamState state)

Called when the streamable bytes for a stream has changed. Until this method is called for the first time for a give stream, the stream is assumed to have no streamable bytes.

io.netty.handler.codec.http2 back to summary

public Interface StreamByteDistributor.StreamState

Known Direct Implementers
io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController.FlowState

State information for the stream, indicating the number of bytes that are currently streamable. This is provided to the updateStreamableBytes(StreamState) method.

Method Summary

Modifier and TypeMethod and Description
public boolean
hasFrame()

Indicates whether or not there are frames pending for this stream.

public long

Returns:

The amount of bytes this stream has pending to send.
pendingBytes
()

Get the amount of bytes this stream has pending to send.

public Http2Stream
stream()

Gets the stream this state is associated with.

public int

Returns:

the size of the stream's flow control window.
windowSize
()

The size (in bytes) of the stream's flow control window.

Method Detail

hasFrameback to summary
public boolean hasFrame()

Indicates whether or not there are frames pending for this stream.

pendingBytesback to summary
public long pendingBytes()

Get the amount of bytes this stream has pending to send. The actual amount written must not exceed windowSize()!

Returns:long

The amount of bytes this stream has pending to send.

See Also
Http2CodecUtil#streamableBytes(StreamState)
streamback to summary
public Http2Stream stream()

Gets the stream this state is associated with.

windowSizeback to summary
public int windowSize()

The size (in bytes) of the stream's flow control window. The amount written must not exceed this amount!

A StreamByteDistributor needs to know the stream's window size in order to avoid allocating bytes if the window size is negative. The window size being 0 may also be significant to determine when if an stream has been given a chance to write an empty frame, and also enables optimizations like not writing empty frames in some situations (don't write headers until data can also be written).

Returns:int

the size of the stream's flow control window.

See Also
Http2CodecUtil#streamableBytes(StreamState)
io.netty.handler.codec.http2 back to summary

public Interface StreamByteDistributor.Writer

Known Direct Implementers
io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController.WritabilityMonitor

Object that performs the writing of the bytes that have been allocated for a stream.

Method Summary

Modifier and TypeMethod and Description
public void
write(Http2Stream
the stream for which to perform the write.
stream
,
int
the number of bytes to write.
numBytes
)

Writes the allocated bytes for this stream.

Method Detail

writeback to summary
public void write(Http2Stream stream, int numBytes)

Writes the allocated bytes for this stream.

Any Throwable thrown from this method is considered a programming error. A GOAWAY frame will be sent and the will be connection closed.

Parameters
stream:Http2Stream

the stream for which to perform the write.

numBytes:int

the number of bytes to write.