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

public final Class UniformStreamByteDistributor

extends Object
implements StreamByteDistributor
Class Inheritance
All Implemented Interfaces
io.netty.handler.codec.http2.StreamByteDistributor
Annotations
@UnstableApi
Imports
io.netty.util.internal.UnstableApi, java.util.ArrayDeque, .Deque

A StreamByteDistributor that ignores stream priority and uniformly allocates bytes to all streams. This class uses a minimum chunk size that will be allocated to each stream. While fewer streams may be written to in each call to distribute(int, Writer), doing this should improve the goodput on each written stream.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
UniformStreamByteDistributor.State

The remote flow control state for a single stream.

Field Summary

Modifier and TypeField and Description
private int
minAllocationChunk

The minimum number of bytes that we will attempt to allocate to a stream.

private final Deque<UniformStreamByteDistributor.State>
private final Http2Connection.PropertyKey
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
distribute(int
the maximum number of bytes to write.
maxBytes
,
StreamByteDistributor.Writer writer)

Implements io.netty.handler.codec.http2.StreamByteDistributor.distribute.

Distributes up to maxBytes to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes.
public void
minAllocationChunk(int
the minimum number of bytes that will be allocated to each stream. Must be > 0.
minAllocationChunk
)

Sets the minimum allocation chunk that will be allocated to each stream.

private UniformStreamByteDistributor.State
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
)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateDependencyTree.

Explicitly update the dependency tree.
public void
updateStreamableBytes(StreamByteDistributor.StreamState streamState)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateStreamableBytes.

Called when the streamable bytes for a stream has changed.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

minAllocationChunkback to summary
private int minAllocationChunk

The minimum number of bytes that we will attempt to allocate to a stream. This is to help improve goodput on a per-stream basis.

queueback to summary
private final Deque<UniformStreamByteDistributor.State> queue
stateKeyback to summary
private final Http2Connection.PropertyKey stateKey
totalStreamableBytesback to summary
private long totalStreamableBytes

Constructor Detail

UniformStreamByteDistributorback to summary
public UniformStreamByteDistributor(Http2Connection connection)

Method Detail

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

Implements io.netty.handler.codec.http2.StreamByteDistributor.distribute.

Doc from io.netty.handler.codec.http2.StreamByteDistributor.distribute.

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.

Annotations
@Override
Exceptions
Http2Exception:
If an internal exception occurs and internal connection state would otherwise be corrupted.
minAllocationChunkback to summary
public void minAllocationChunk(int minAllocationChunk)

Sets the minimum allocation chunk that will be allocated to each stream. Defaults to 1KiB.

Parameters
minAllocationChunk:int

the minimum number of bytes that will be allocated to each stream. Must be > 0.

stateback to summary
private UniformStreamByteDistributor.State state(Http2Stream stream)
updateDependencyTreeback to summary
public void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateDependencyTree.

Doc from io.netty.handler.codec.http2.StreamByteDistributor.updateDependencyTree.

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.

Annotations
@Override
updateStreamableBytesback to summary
public void updateStreamableBytes(StreamByteDistributor.StreamState streamState)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateStreamableBytes.

Doc from io.netty.handler.codec.http2.StreamByteDistributor.updateStreamableBytes.

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.

Annotations
@Override
io.netty.handler.codec.http2 back to summary

private final Class UniformStreamByteDistributor.State

extends Object
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.UniformStreamByteDistributor.State

The remote flow control state for a single stream.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv final Http2Stream
pack-priv int
pack-priv boolean
pack-priv boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
pack-priv void
pack-priv void
updateStreamableBytes(int newStreamableBytes, boolean hasFrame, int windowSize)

pack-priv void
write(int numBytes, StreamByteDistributor.Writer writer)

Write any allocated bytes for the given stream and updates the streamable bytes, assuming all of the bytes will be written.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enqueuedback to summary
pack-priv boolean enqueued
streamback to summary
pack-priv final Http2Stream stream
streamableBytesback to summary
pack-priv int streamableBytes
windowNegativeback to summary
pack-priv boolean windowNegative
writingback to summary
pack-priv boolean writing

Constructor Detail

Stateback to summary
pack-priv State(Http2Stream stream)

Method Detail

addToQueueback to summary
pack-priv void addToQueue()
closeback to summary
pack-priv void close()
removeFromQueueback to summary
pack-priv void removeFromQueue()
updateStreamableBytesback to summary
pack-priv void updateStreamableBytes(int newStreamableBytes, boolean hasFrame, int windowSize)
writeback to summary
pack-priv void write(int numBytes, StreamByteDistributor.Writer writer) throws Http2Exception

Write any allocated bytes for the given stream and updates the streamable bytes, assuming all of the bytes will be written.