Top Description Fields Constructors Methods
jdk.internal.net.http

pack-priv final Class WindowController

extends Object
Class Inheritance
Imports
java.lang.System.Logger.Level, java.util.ArrayList, .Map, .HashMap, .Iterator, .LinkedHashMap, .List, java.util.concurrent.locks.ReentrantLock, jdk.internal.net.http.common.Logger, .Utils

A Send Window Flow-Controller that is used to control outgoing Connection and Stream flows, per HTTP/2 connection. A Http2Connection has its own unique single instance of a WindowController that it shares with its Streams. Each stream must acquire the appropriate amount of Send Window from the controller before sending data. WINDOW_UPDATE frames, both connection and stream specific, must notify the controller of their increments. SETTINGS frame's INITIAL_WINDOW_SIZE must notify the controller so that it can adjust the active stream's window size.

Field Summary

Modifier and TypeField and Description
private int
connectionWindowSize

The connection Send Window size.

private final ReentrantLock
pack-priv static final Logger
private static final int
DEFAULT_INITIAL_WINDOW_SIZE

Default initial connection Flow-Control Send Window size, as per HTTP/2.

private final Map<Integer, Map.Entry<Stream<?>, Integer>>
pending

A Map of streams awaiting Send Window.

private final Map<Integer, Integer>
streams

A Map of the active streams, where the key is the stream id, and the value is the stream's Send Window size, which may be negative.

Constructor Summary

AccessConstructor and Description
pack-priv
WindowController()

A Controller with the default initial window size.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
adjustActiveStreams(int adjustAmount)

Adjusts, either increases or decreases, the active streams registered with this controller.

pack-priv int
connectionWindowSize()

Returns the Send Window size for the connection.

pack-priv boolean

Returns:

false if, and only if, the addition of the given amount would cause the Send Window to exceed 2^31-1 (overflow), otherwise true
increaseConnectionWindow
(int amount)

Increases the Send Window size for the connection.

pack-priv boolean

Returns:

false if, and only if, the addition of the given amount would cause the Send Window to exceed 2^31-1 (overflow), otherwise true
increaseStreamWindow
(int amount, int streamid)

Increases the Send Window size for the given stream.

pack-priv void
registerStream(int streamid, int initialStreamWindowSize)

Registers the given stream with this controller.

pack-priv void
removeStream(int streamid)

Removes/De-registers the given stream with this controller.

pack-priv int
streamWindowSize(int streamid)

Returns the Send Window size for the given stream.

pack-priv int
tryAcquire(int requestAmount, int streamid, Stream<?> stream)

Attempts to acquire the requested amount of Send Window for the given stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionWindowSizeback to summary
private int connectionWindowSize

The connection Send Window size.

controllerLockback to summary
private final ReentrantLock controllerLock
debugback to summary
pack-priv static final Logger debug
DEFAULT_INITIAL_WINDOW_SIZEback to summary
private static final int DEFAULT_INITIAL_WINDOW_SIZE

Default initial connection Flow-Control Send Window size, as per HTTP/2.

pendingback to summary
private final Map<Integer, Map.Entry<Stream<?>, Integer>> pending

A Map of streams awaiting Send Window. The key is the stream id. The value is a pair of the Stream ( representing the key's stream id ) and the requested amount of send Window.

streamsback to summary
private final Map<Integer, Integer> streams

A Map of the active streams, where the key is the stream id, and the value is the stream's Send Window size, which may be negative.

Constructor Detail

WindowControllerback to summary
pack-priv WindowController()

A Controller with the default initial window size.

Method Detail

adjustActiveStreamsback to summary
pack-priv void adjustActiveStreams(int adjustAmount)

Adjusts, either increases or decreases, the active streams registered with this controller. May result in a stream's Send Window size becoming negative.

connectionWindowSizeback to summary
pack-priv int connectionWindowSize()

Returns the Send Window size for the connection.

increaseConnectionWindowback to summary
pack-priv boolean increaseConnectionWindow(int amount)

Increases the Send Window size for the connection. A number of awaiting requesters, from unfulfilled tryAcquire requests, may have their stream's Stream#signalWindowUpdate() method scheduled to run ( i.e. awake awaiters ).

Returns:boolean

false if, and only if, the addition of the given amount would cause the Send Window to exceed 2^31-1 (overflow), otherwise true

increaseStreamWindowback to summary
pack-priv boolean increaseStreamWindow(int amount, int streamid)

Increases the Send Window size for the given stream. If the given stream is awaiting window size, from an unfulfilled tryAcquire request, it will have its stream's Stream#signalWindowUpdate() method scheduled to run ( i.e. awoken ).

Returns:boolean

false if, and only if, the addition of the given amount would cause the Send Window to exceed 2^31-1 (overflow), otherwise true

registerStreamback to summary
pack-priv void registerStream(int streamid, int initialStreamWindowSize)

Registers the given stream with this controller.

removeStreamback to summary
pack-priv void removeStream(int streamid)

Removes/De-registers the given stream with this controller.

streamWindowSizeback to summary
pack-priv int streamWindowSize(int streamid)

Returns the Send Window size for the given stream.

tryAcquireback to summary
pack-priv int tryAcquire(int requestAmount, int streamid, Stream<?> stream)

Attempts to acquire the requested amount of Send Window for the given stream. The actual amount of Send Window available may differ from the requested amount. The actual amount, returned by this method, is the minimum of, 1) the requested amount, 2) the stream's Send Window, and 3) the connection's Send Window. A negative or zero value is returned if there's no window available. When the result is negative or zero, this method arranges for the given stream's Stream#signalWindowUpdate() method to be invoke at a later time when the connection and/or stream window's have been increased. The tryAcquire method should then be invoked again to attempt to acquire the available window.