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

pack-priv final Class QuicReceiverStreamImpl

extends AbstractQuicStream
implements QuicReceiverStream
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.quic.streams.QuicReceiverStream, jdk.internal.net.http.quic.streams.QuicStream
Imports
jdk.internal.net.http.common.Logger, .SequentialScheduler, .Utils, jdk.internal.net.http.quic.OrderedFlow.StreamDataFlow, .QuicConnectionImpl, .TerminationCause, jdk.internal.net.http.quic.frames.ConnectionCloseFrame, .ResetStreamFrame, .StreamDataBlockedFrame, .StreamFrame, jdk.internal.net.quic.QuicTLSEngine, .QuicTransportErrors, .QuicTransportException, java.io.IOException, java.lang.invoke.MethodHandles, .VarHandle, java.nio.ByteBuffer, java.util.concurrent.ConcurrentLinkedQueue

A class that implements the receiver part of a quic stream.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class

Field Summary

Modifier and TypeField and Description
private final OrderedFlow.StreamDataFlow
private final String
private final Logger
private final long
private volatile boolean
private volatile long
private volatile long
private static final int
private volatile long
private volatile long
private static final long
private final ConcurrentLinkedQueue<ByteBuffer>
private volatile long
private volatile QuicReceiverStreamImpl.QuicStreamReaderImpl
private volatile long
private volatile QuicReceiverStream.ReceivingStreamState
private volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv
QuicReceiverStreamImpl(QuicConnectionImpl connection, long streamId)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
private void
checkUpdateState(StreamFrame
received stream frame
streamFrame
)

Checks for error conditions: - max stream data errors - max data errors - final size errors If everything checks OK, updates counters and returns, otherwise throws.

private void
checkUpdateState(ResetStreamFrame
received reset stream frame
resetStreamFrame
)

Checks for error conditions: - max stream data errors - max data errors - final size errors If everything checks OK, updates counters and returns, otherwise throws.

public QuicStreamReader
connectReader(SequentialScheduler scheduler)

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.connectReader.

Connects an unstarted reader to the receiver end of this stream.

public long
dataReceived()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.dataReceived.

Returns the amount of data that has been received so far.

pack-priv String
private void
demand(final long additional)

public void
disconnectReader(QuicStreamReader reader)

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.disconnectReader.

Disconnect the reader, so that a new reader can be connected.

private void
increaseProcessedData(long newProcessed)

Notifies the connection about received data that is no longer buffered.

private void
increaseProcessedDataBy(int diff)

Notifies the connection about received data that is no longer buffered.

public boolean
isDone()

Implements abstract jdk.internal.net.http.quic.streams.AbstractQuicStream.isDone.

Returns true if this stream isn't expecting anything from the peer and can be removed from the streams map.

public boolean
private boolean
private boolean
private boolean
private boolean
private boolean
public long
maxStreamData()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.maxStreamData.

Returns the maximum amount of data that can be received on this stream.

private void
private void
private void
pack-priv void
public void
processIncomingFrame(final StreamFrame
the frame received
streamFrame
)

Receives a QuicFrame from the remote peer.

pack-priv void
processIncomingResetFrame(final ResetStreamFrame
the frame received
resetStreamFrame
)

Receives a QuicFrame from the remote peer.

public long
rcvErrorCode()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.rcvErrorCode.

Returns the error code for this stream, or -1.

public QuicReceiverStream.ReceivingStreamState
receivingState()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.receivingState.

Returns the receiving state of the stream.

public void
requestStopSending(final long errorCode)

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.requestStopSending.

Cancels the reading side of this stream by sending a STOP_SENDING frame.

private void
setErrorCode(long code)

public QuicStream.StreamState
state()

Implements jdk.internal.net.http.quic.streams.QuicStream.state.

Returns the combined stream state.

private static QuicTransportException
streamControlOverflow(StreamFrame
the stream frame that caused the excess
streamFrame
,
long
the value of MAX_STREAM_DATA which was exceeded
maxData
)

Sends a ConnectionCloseFrame due to MAX_STREAM_DATA exceeded for the stream.

private boolean
switchReceivingState(QuicReceiverStream.ReceivingStreamState
the new state.
newState
)

Called when a state change is needed

pack-priv void
terminate(final TerminationCause
the termination cause
terminationCause
)

Called when the connection is closed

private void
updateMaxReceivedData(long
the new max offset - typically obtained by adding the length of a frame to its offset
newMax
,
long
type of frame received
frameType
)

Update the maxReceivedData value, and return the amount by which maxReceivedData was increased.

public void
updateMaxStreamData(long newMaxStreamData)

Update the value of MAX_STREAM_DATA for this stream

private static long
validateStreamId(QuicConnectionImpl connection, long streamId)

Inherited from jdk.internal.net.http.quic.streams.AbstractQuicStream:
connectionisBidirectionalisClientInitiatedisLocalInitiatedisRemoteInitiatedisServerInitiatedmodestreamIdtype

Field Detail

dataFlowback to summary
private final OrderedFlow.StreamDataFlow dataFlow
dbgTagback to summary
private final String dbgTag
debugback to summary
private final Logger debug
desiredBufferSizeback to summary
private final long desiredBufferSize
eofback to summary
private volatile boolean eof
errorCodeback to summary
private volatile long errorCode
knownSizeback to summary
private volatile long knownSize
MAX_SMALL_FRAGMENTSback to summary
private static final int MAX_SMALL_FRAGMENTS
maxReceivedDataback to summary
private volatile long maxReceivedData
maxStreamDataback to summary
private volatile long maxStreamData
MIN_BUFFER_SIZEback to summary
private static final long MIN_BUFFER_SIZE
orderedQueueback to summary
private final ConcurrentLinkedQueue<ByteBuffer> orderedQueue
processedback to summary
private volatile long processed
readerback to summary
private volatile QuicReceiverStreamImpl.QuicStreamReaderImpl reader
receivedback to summary
private volatile long received
receivingStateback to summary
private volatile QuicReceiverStream.ReceivingStreamState receivingState
requestedStopSendingback to summary
private volatile boolean requestedStopSending

Constructor Detail

QuicReceiverStreamImplback to summary
pack-priv QuicReceiverStreamImpl(QuicConnectionImpl connection, long streamId)

Method Detail

checkOpenedback to summary
pack-priv void checkOpened() throws IOException
checkUpdateStateback to summary
private void checkUpdateState(StreamFrame streamFrame) throws QuicTransportException

Checks for error conditions: - max stream data errors - max data errors - final size errors If everything checks OK, updates counters and returns, otherwise throws.

Implementation Note

This method may update counters before throwing. This is OK because we do not expect to use them again in this case.

Parameters
streamFrame:StreamFrame

received stream frame

Exceptions
QuicTransportException:
if frame is invalid
checkUpdateStateback to summary
private void checkUpdateState(ResetStreamFrame resetStreamFrame) throws QuicTransportException

Checks for error conditions: - max stream data errors - max data errors - final size errors If everything checks OK, updates counters and returns, otherwise throws.

Implementation Note

This method may update counters before throwing. This is OK because we do not expect to use them again in this case.

Parameters
resetStreamFrame:ResetStreamFrame

received reset stream frame

Exceptions
QuicTransportException:
if frame is invalid
connectReaderback to summary
public QuicStreamReader connectReader(SequentialScheduler scheduler)

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.connectReader.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.connectReader.

Connects an unstarted reader to the receiver end of this stream.

Annotations
@Override
dataReceivedback to summary
public long dataReceived()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.dataReceived.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.dataReceived.

Returns the amount of data that has been received so far.

Annotations
@Override
dbgTagback to summary
pack-priv String dbgTag()
demandback to summary
private void demand(final long additional)
disconnectReaderback to summary
public void disconnectReader(QuicStreamReader reader)

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.disconnectReader.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.disconnectReader.

Disconnect the reader, so that a new reader can be connected.

Annotations
@Override
increaseProcessedDataback to summary
private void increaseProcessedData(long newProcessed)

Notifies the connection about received data that is no longer buffered.

increaseProcessedDataByback to summary
private void increaseProcessedDataBy(int diff)

Notifies the connection about received data that is no longer buffered.

isDoneback to summary
public boolean isDone()

Implements abstract jdk.internal.net.http.quic.streams.AbstractQuicStream.isDone.

Doc from jdk.internal.net.http.quic.streams.AbstractQuicStream.isDone.

Returns true if this stream isn't expecting anything from the peer and can be removed from the streams map.

Annotations
@Override
isStopSendingRequestedback to summary
public boolean isStopSendingRequested()

Overrides default jdk.internal.net.http.quic.streams.QuicReceiverStream.isStopSendingRequested.

Annotations
@Override
markDataReadback to summary
private boolean markDataRead()
markDataRecvdback to summary
private boolean markDataRecvd()
markResetReadback to summary
private boolean markResetRead()
markResetRecvdback to summary
private boolean markResetRecvd()
markSizeKnownback to summary
private boolean markSizeKnown()
maxStreamDataback to summary
public long maxStreamData()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.maxStreamData.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.maxStreamData.

Returns the maximum amount of data that can be received on this stream.

Annotations
@Override
notifyTerminalStateback to summary
private void notifyTerminalState(QuicReceiverStream.ReceivingStreamState state)
offerback to summary
private void offer(StreamFrame frame)
offerEofback to summary
private void offerEof()
processIncomingFrameback to summary
pack-priv void processIncomingFrame(final StreamDataBlockedFrame streamDataBlocked)
processIncomingFrameback to summary
public void processIncomingFrame(final StreamFrame streamFrame) throws QuicTransportException

Receives a QuicFrame from the remote peer.

Parameters
streamFrame:StreamFrame

the frame received

processIncomingResetFrameback to summary
pack-priv void processIncomingResetFrame(final ResetStreamFrame resetStreamFrame) throws QuicTransportException

Receives a QuicFrame from the remote peer.

Parameters
resetStreamFrame:ResetStreamFrame

the frame received

rcvErrorCodeback to summary
public long rcvErrorCode()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.rcvErrorCode.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.rcvErrorCode.

Returns the error code for this stream, or -1.

Annotations
@Override
receivingStateback to summary
public QuicReceiverStream.ReceivingStreamState receivingState()

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.receivingState.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.receivingState.

Returns the receiving state of the stream.

Annotations
@Override
requestStopSendingback to summary
public void requestStopSending(final long errorCode)

Implements jdk.internal.net.http.quic.streams.QuicReceiverStream.requestStopSending.

Doc from jdk.internal.net.http.quic.streams.QuicReceiverStream.requestStopSending.

Cancels the reading side of this stream by sending a STOP_SENDING frame.

Annotations
@Override
setErrorCodeback to summary
private void setErrorCode(long code)
stateback to summary
public QuicStream.StreamState state()

Implements jdk.internal.net.http.quic.streams.QuicStream.state.

Doc from jdk.internal.net.http.quic.streams.QuicStream.state.

Returns the combined stream state.

Annotations
@Override
streamControlOverflowback to summary
private static QuicTransportException streamControlOverflow(StreamFrame streamFrame, long maxData) throws QuicTransportException

Sends a ConnectionCloseFrame due to MAX_STREAM_DATA exceeded for the stream.

Parameters
streamFrame:StreamFrame

the stream frame that caused the excess

maxData:long

the value of MAX_STREAM_DATA which was exceeded

switchReceivingStateback to summary
private boolean switchReceivingState(QuicReceiverStream.ReceivingStreamState newState)

Called when a state change is needed

Parameters
newState:QuicReceiverStream.ReceivingStreamState

the new state.

terminateback to summary
pack-priv void terminate(final TerminationCause terminationCause)

Called when the connection is closed

Parameters
terminationCause:TerminationCause

the termination cause

updateMaxReceivedDataback to summary
private void updateMaxReceivedData(long newMax, long frameType) throws QuicTransportException

Update the maxReceivedData value, and return the amount by which maxReceivedData was increased. This method is a no-op and returns 0 if maxReceivedData >= newMax.

Parameters
newMax:long

the new max offset - typically obtained by adding the length of a frame to its offset

frameType:long

type of frame received

Exceptions
QuicTransportException:
if flow control was violated
updateMaxStreamDataback to summary
public void updateMaxStreamData(long newMaxStreamData)

Update the value of MAX_STREAM_DATA for this stream

validateStreamIdback to summary
private static long validateStreamId(QuicConnectionImpl connection, long streamId)
jdk.internal.net.http.quic.streams back to summary

private final Class QuicReceiverStreamImpl.Handles

extends Object
Class Inheritance
  • java.lang.Object
  • jdk.internal.net.http.quic.streams.QuicReceiverStreamImpl.Handles

Field Summary

Modifier and TypeField and Description
pack-priv static final VarHandle
pack-priv static final VarHandle
pack-priv static final VarHandle
pack-priv static final VarHandle
pack-priv static final VarHandle
pack-priv static final VarHandle

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ERROR_CODEback to summary
pack-priv static final VarHandle ERROR_CODE
MAX_RECEIVED_DATAback to summary
pack-priv static final VarHandle MAX_RECEIVED_DATA
MAX_STREAM_DATAback to summary
pack-priv static final VarHandle MAX_STREAM_DATA
READERback to summary
pack-priv static final VarHandle READER
RECEIVING_STATEback to summary
pack-priv static final VarHandle RECEIVING_STATE
STOP_SENDINGback to summary
pack-priv static final VarHandle STOP_SENDING

Constructor Detail

Handlesback to summary
private Handles()
jdk.internal.net.http.quic.streams back to summary

private final Class QuicReceiverStreamImpl.QuicStreamReaderImpl

extends QuicStreamReader
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
private int
Inherited from jdk.internal.net.http.quic.streams.QuicStreamReader:
EOFscheduler

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
private void
checkReset()

Checks whether the stream was reset and throws an exception if yes.

public boolean
connected()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.connected.

Returns true if this reader is connected to its stream.

public ByteBuffer
peek()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.peek.

Returns the ByteBuffer at the head of the queue, or null if no data is available.

public ByteBuffer
poll()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.poll.

Returns the ByteBuffer at the head of the queue, or null if no data is available.

public QuicReceiverStream.ReceivingStreamState
receivingState()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.receivingState.

Returns the receiving state of the stream.

public void
start()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.start.

Starts the reader.

public boolean
started()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.started.

Returns true if this reader has been started.

public QuicReceiverStream
stream()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.stream.

Returns the stream this reader is connected to, or null if this reader is not currently connected.

private long
pack-priv void
private boolean
wakeupOnStart(int state)

Inherited from jdk.internal.net.http.quic.streams.QuicStreamReader:
isReset

Field Detail

PENDINGback to summary
pack-priv static final int PENDING
STARTEDback to summary
pack-priv static final int STARTED
stateback to summary
private int state

Constructor Detail

QuicStreamReaderImplback to summary
pack-priv QuicStreamReaderImpl(SequentialScheduler scheduler)

Method Detail

checkConnectedback to summary
private void checkConnected()
checkResetback to summary
private void checkReset() throws IOException

Checks whether the stream was reset and throws an exception if yes.

Exceptions
IOException:
if the stream is reset
connectedback to summary
public boolean connected()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.connected.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.connected.

Returns true if this reader is connected to its stream.

Annotations
@Override
peekback to summary
public ByteBuffer peek() throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.peek.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.peek.

Returns the ByteBuffer at the head of the queue, or null if no data is available.

Annotations
@Override
Exceptions
IOException:
if the stream was reset by the peer
pollback to summary
public ByteBuffer poll() throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.poll.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.poll.

Returns the ByteBuffer at the head of the queue, or null if no data is available. . If the end of the stream is reached then EOF is returned.

Annotations
@Override
Exceptions
IOException:
if the stream was closed locally or reset by the peer
receivingStateback to summary
public QuicReceiverStream.ReceivingStreamState receivingState()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.receivingState.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.receivingState.

Returns the receiving state of the stream.

Annotations
@Override
startback to summary
public void start()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.start.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.start.

Starts the reader. The scheduler will not be invoked until the reader is started.

Annotations
@Override
startedback to summary
public boolean started()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.started.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.started.

Returns true if this reader has been started.

Annotations
@Override
streamback to summary
public QuicReceiverStream stream()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamReader.stream.

Doc from jdk.internal.net.http.quic.streams.QuicStreamReader.stream.

Returns the stream this reader is connected to, or null if this reader is not currently connected.

Annotations
@Override
unfulfilledback to summary
private long unfulfilled()
wakeupback to summary
pack-priv void wakeup()
wakeupOnStartback to summary
private boolean wakeupOnStart(int state)