APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http.quic.streams

public final Class QuicConnectionStreams

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.time.Duration, java.util.Collections, .HashSet, .List, .Map, .Objects, .Set, java.util.concurrent.CompletableFuture, .ConcurrentHashMap, .ConcurrentLinkedQueue, .ConcurrentMap, .ConcurrentSkipListMap, .Executor, java.util.concurrent.atomic.AtomicLong, java.util.concurrent.locks.Lock, .ReentrantLock, java.util.function.Predicate, java.util.stream.Stream, jdk.internal.net.http.common.Log, .Logger, .MinimalFuture, jdk.internal.net.http.quic.QuicConnectionImpl, .QuicStreamLimitException, .TerminationCause, .QuicTransportParameters, .QuicTransportParameters.ParameterId, jdk.internal.net.http.quic.frames.StreamsBlockedFrame, .MaxStreamDataFrame, .MaxStreamsFrame, .QuicFrame, .ResetStreamFrame, .StopSendingFrame, .StreamDataBlockedFrame, .StreamFrame, jdk.internal.net.quic.QuicTLSEngine, .QuicTLSEngine.KeySpace, .QuicTransportException, .QuicTransportErrors, jdk.internal.net.http.quic.packets.QuicPacketEncoder, jdk.internal.net.http.quic.streams.QuicReceiverStream.ReceivingStreamState, .QuicStream.StreamMode, .QuicStream.StreamState

A helper class to help manage Quic streams in a Quic connection

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
private static class
private static class
private class

Field Summary

Modifier and TypeField and Description
private final AtomicLong
private final QuicConnectionImpl
private final Logger
private final Set<Long>
private final AtomicLong
private final AtomicLong
private final int
private final StreamCreationPermit
private final int
private final int
private final StreamCreationPermit
private static final long
private static final long
private final ConcurrentLinkedQueue<QuicReceiverStream>
private final Lock
private final List<AtomicLong>
private final AtomicLong
private final AtomicLong
private final ConcurrentMap<QuicReceiverStream, QuicFrame>
private final int
private final AtomicLong
private final int
private final AtomicLong
private final QuicConnectionStreams.ReadyStreamCollection
private final ConcurrentMap<QuicSenderStream, Long>
private final Set<Predicate<? super QuicReceiverStream>>
private final QuicConnectionStreams.StreamsContainer
private final AtomicLong

Constructor Summary

AccessConstructor and Description
public
QuicConnectionStreams(QuicConnectionImpl
the connection to which the streams managed by this instance of QuicConnectionStreams belong.
connection
,
Logger debug)

Creates a new instance of QuicConnectionStreams for the given connection.

Method Summary

Modifier and TypeMethod and Description
private void
private long
addMaxStreamsFrame(final List<QuicFrame> frames, final boolean bidi)

public void
addRemoteStreamListener(Predicate<? super QuicReceiverStream>
the listener
streamConsumer
)

Adds a listener that will be invoked when a remote stream is created.

private void
announceStreamsBlocked(final boolean
true if the local endpoint is blocked for bidi streams, false for uni streams
bidi
,
final long
the stream creation limit due to which the local endpoint is currently blocked
blockedOnLimit
)

Runs the APPLICATION space packet transmitter, if necessary, to potentially trigger sending a STREAMS_BLOCKED frame to the peer

private long

Returns:

number of bytes actually added
checkResetAndOtherControls
(List<QuicFrame>
list of frames
frames
,
long
maximum number of bytes that can be added by this method
remaining
)

Checks whether any stream needs to have a STOP_SENDING, RESET_STREAM or any connection control frames like STREAMS_BLOCKED, MAX_STREAMS sent and adds the frame to the list if there's room.

private long

Returns:

size of the added frame, or zero if no frame was added
checkSendControlFrame
(QuicReceiverStreamImpl
the receiver part of the stream
receiver
,
QuicFrame
the frame to send
frame
,
List<QuicFrame>
list of frames
frames
)

Checks whether the given stream is recorded as needing a control frame to be sent, and if so, add that frame to the list

public CompletableFuture<QuicBidiStream>

Returns:

a CompletableFuture whose result on successful completion will return the newly created QuicBidiStream
createNewLocalBidiStream
(final Duration
the maximum duration to wait to acquire a permit for stream creation
timeout
)

Creates a new locally initiated bidirectional stream.

private CompletableFuture<? extends QuicStream>
createNewLocalStream(final int localType, final QuicStream.StreamMode mode, final Duration timeout)

public CompletableFuture<QuicSenderStream>

Returns:

a CompletableFuture whose result on successful completion will return the newly created QuicSenderStream
createNewLocalUniStream
(final Duration
the maximum duration to wait to acquire a permit for stream creation
timeout
)

Creates a new locally initiated unidirectional stream.

public void
enqueueForSending(long
the stream id of the stream which is ready
streamId
)

This method is called by when a stream has data available for sending.

public final void
enqueueStreamDataBlocked()

If there are any streams in this connection that have been blocked from sending data due to flow control limit on that stream, then this method enqueues a STREAM_DATA_BLOCKED frame to be sent for each such stream.

public QuicStream

Returns:

the stream with the given stream ID if found, null otherwise.
findStream
(long
a stream ID
streamId
)

Finds a stream with the given stream ID. Returns null if no stream with that ID is found.

public QuicStream

Returns:

a remotely initiated stream with the given stream ID. May return null if the stream was already closed.
getOrCreateRemoteStream
(long
the stream ID
streamId
,
long
type of the frame received, used in exceptions
frameType
)

Gets or opens a remotely initiated stream with the given stream ID. Creates all streams with lower IDs if needed.

public boolean

Returns:

true if there is some data to send
hasAvailableData
()

Returns true if there is some data to send.

public final boolean

Returns:

true if there are any streams on this connection which are blocked from sending data due to flow control limit, false otherwise
hasBlockedStreams
()

Returns true if there are any streams on this connection which are blocked from sending data due to flow control limit, false otherwise.

public boolean

Returns:

true if there are control frames to send
hasControlFrames
()

Returns true if there are control frames to send.

public boolean

Returns:

true if the given streamId indicates a local bidirectional stream
isLocalBidi
(long
a stream ID
streamId
)

Returns true if the given streamId indicates a local bidirectional stream.

public boolean

Returns:

true if the given streamId indicates a local unidirectional stream
isLocalUni
(long
a stream ID
streamId
)

Returns true if the given streamId indicates a local unidirectional stream.

public boolean

Returns:

true if the given streamId indicates a stream that has a receiving part
isReceivingStream
(long
a stream ID
streamId
)

Returns true if the given streamId indicates a stream that has a receiving part.

public boolean

Returns:

true if the given streamId indicates a peer initiated bidirectional stream
isRemoteBidi
(long
a stream ID
streamId
)

Returns true if the given streamId indicates a peer initiated bidirectional stream.

public boolean

Returns:

true if the given streamId indicates a peer initiated unidirectional stream
isRemoteUni
(long
a stream ID
streamId
)

Returns true if the given streamId indicates a peer initiated unidirectional stream.

public boolean

Returns:

true if the given streamId indicates a stream that has a sending part
isSendingStream
(long
a stream ID
streamId
)

Returns true if the given streamId indicates a stream that has a sending part.

private void
newInitialLocalParameters(QuicStream
the stream on which parameters might be set
stream
,
QuicTransportParameters
the peer transport parameters
params
)

Called to set initial peer parameters on a stream

private void
newInitialPeerParameters(QuicStream
the stream on which parameters might be set
stream
,
QuicTransportParameters
the peer transport parameters
params
)

Called to set initial peer parameters on a stream

public void
newLocalTransportParameters(final QuicTransportParameters
the new local transport parameters
params
)

Called when new local transport parameters are available

public void
newPeerTransportParameters(final QuicTransportParameters
the new local transport parameters
params
)

Called when new peer transport parameters are available

public long
nextMaxStreamsLimit(final boolean bidi)

public void
notifyTerminalState(long
the id of the stream
streamId
,
QuicStream.StreamState
the terminal state
state
)

Called when the receiving part or the sending part of a stream reaches a terminal state.

public long

Returns:

the next unallocated stream ID that would be expected for a stream of the given type
peekNextStreamId
(int
The stream type, a number in [0..3]
streamType
)

Returns the next unallocated stream ID that would be expected for a stream of the given type.

public void
peerStreamsBlocked(final StreamsBlockedFrame
the STREAMS_BLOCKED frame that was received from the peer
frame
)

Runs the APPLICATION space packet transmitter, if necessary, to potentially trigger sending a MAX_STREAMS frame to the peer, upon receiving the STREAMS_BLOCKED frame from that peer

public void
processIncomingFrame(QuicStream
the stream for which the StreamFrame was received
stream
,
StreamFrame
the stream frame
frame
)

Called when a StreamFrame is received.

public void
processIncomingFrame(QuicStream
the stream for which the ResetStreamFrame was received
stream
,
ResetStreamFrame
the reset stream frame
frame
)

Called when a ResetStreamFrame is received.

public void
public long

Returns:

the total number of stream data bytes packaged in the created frames. This will not exceed the given maxConnectionData.
produceFramesToSend
(QuicPacketEncoder
the QuicPacketEncoder, used if anything is quic version dependent.
encoder
,
long
the cumulated maximum size of all the frames
maxSize
,
long
the maximum number of stream data bytes that can be packaged to respect connection flow control constraints
maxConnectionData
,
List<QuicFrame>
a list of frames in which to add the packaged data
frames
)

Package available data in StreamFrame instances and add them to the provided frames list.

public Stream<? extends QuicStream>

Returns:

a stream of all currently active QuicStream in the connection
quicStreams
()

Returns a stream of all currently active QuicStream in the connection.

pack-priv QuicReceiverStreamImpl

Returns:

the receiver part implementation of the given stream, or null
receiverImpl
(QuicStream
a receiving or bidirectional stream
stream
)

Returns the receiver part implementation of the given stream, or null.

private void
register(long streamId, AbstractQuicStream stream)

public boolean

Returns:

true if the listener was found and removed, false otherwise
removeRemoteStreamListener
(Predicate<? super QuicReceiverStream> streamConsumer)

Removes a listener previously added with addRemoteStreamListener(Predicate)

private void
removeStream(long
the stream id
streamId
,
QuicStream
the stream instance
stream
)

Removes a stream from the stream map after its state has been switched to DATA_RECVD or RESET_RECVD

public void
requestResetStream(long
the id of the stream that should be reset
streamId
,
long
the application error code
errorCode
)

Mark the stream whose ID is encoded in the given ResetStreamFrame as needing a RESET_STREAM frame to be sent.

public void
requestSendMaxStreamData(MaxStreamDataFrame
the MAX_STREAM_DATA frame to send
maxStreamDataFrame
)

Mark the stream whose ID is encoded in the given MaxStreamDataFrame as needing a MAX_STREAM_DATA frame to be sent.

public void
scheduleStopSendingFrame(StopSendingFrame
the STOP_SENDING frame to send
stopSendingFrame
)

Mark the stream whose ID is encoded in the given StopSendingFrame as needing a STOP_SENDING frame to be sent.

pack-priv QuicSenderStreamImpl

Returns:

the sender part implementation of the given stream, or null
senderImpl
(QuicStream
a sending or bidirectional stream
stream
)

Returns the sender part implementation of the given stream, or null.

public void
setMaxStreamData(QuicSenderStream
the stream
stream
,
long
the max data that the peer is willing to accept on this stream
maxStreamData
)

Set max stream data for a stream.

private boolean
shouldSendMaxStreams(final boolean bidi)

public void
stopSendingReceived(QuicSenderStream
the stream for which stop sending was requested by the peer
stream
,
long
the error code
errorCode
)

This method is called when a jdk.internal.net.http.quic.frames.StopSendingFrame is received from the peer.

public void
streamDataSentAcknowledged(StreamFrame
the final STREAM frame
streamFrame
)

Called when the final STREAM frame is acknowledged by the peer.

public void
streamResetAcknowledged(ResetStreamFrame
the RESET_STREAM frame
reset
)

Called when the RESET_STREAM frame is acknowledged by the peer.

public void
terminate(final TerminationCause
the termination cause
terminationCause
)

Called when the connection is closed by the higher level protocol

pack-priv final void
trackBlockedStream(final long
the stream id
streamId
)

Tracks a stream, belonging to this connection, as being blocked from sending data due to flow control limit.

private static boolean
tryIncreaseLimitTo(final AtomicLong limit, final long newLimit)

public boolean
tryIncreaseStreamLimit(final MaxStreamsFrame maxStreamsFrame)

pack-priv final void
untrackBlockedStream(final long
the stream id
streamId
)

Stops tracking a stream, belonging to this connection, that may have been previously tracked as being blocked due to flow control limit.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait