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

public final Class QuicSenderStreamImpl

extends AbstractQuicStream
implements QuicSenderStream
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.quic.streams.QuicSenderStream, jdk.internal.net.http.quic.streams.QuicStream
Imports
java.io.IOException, java.lang.invoke.MethodHandles, .MethodHandles.Lookup, .VarHandle, java.nio.ByteBuffer, java.util.Set, jdk.internal.net.http.common.Log, .Logger, .SequentialScheduler, .Utils, jdk.internal.net.http.quic.QuicConnectionImpl, .TerminationCause

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
QuicSenderStreamImpl.QuicStreamWriterImpl

The stream internal implementation of a QuicStreamWriter.

private class
QuicSenderStreamImpl.StreamWriterQueueImpl

A concrete implementation of the StreamWriterQueue for this stream.

Field Summary

Modifier and TypeField and Description
private final String
private final Logger
private volatile long
private final QuicSenderStreamImpl.StreamWriterQueueImpl
private volatile QuicSenderStream.SendingStreamState
private volatile boolean
private volatile QuicSenderStreamImpl.QuicStreamWriterImpl

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the number of bytes that are available for sending, subject to flow control
available
()

Returns the number of bytes that are available for sending, subject to flow control.

pack-priv void
public QuicStreamWriter
connectWriter(SequentialScheduler scheduler)

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.connectWriter.

Connects a writer to the sending end of this stream.

public boolean

Returns:

true if the state was switched to DATA_RECVD as a result of this method invocation
dataAcknowledged
(long
the final size acknowledged
finalSize
)

Called when the packet containing the final STREAM frame for this stream has been acknowledged.

public long
dataSent()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.dataSent.

Returns the amount of data that has been sent.

pack-priv String
public void
disconnectWriter(QuicStreamWriter writer)

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.disconnectWriter.

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

public boolean

Returns:

true if sending is blocked due to flow control
isBlocked
()

Whether the sending is blocked due to flow control.

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.

private boolean
private boolean
private boolean
private boolean
private boolean
private void
public ByteBuffer

Returns:

a ByteBuffer containing at most maxBytes remaining bytes.
poll
(int
the maximum number of bytes to poll for sending
maxBytes
)

Polls at most maxBytes from the StreamWriterQueue of this stream.

public void
reset(long errorCode)

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.reset.

Abruptly closes the writing side of a stream by sending a RESET_STREAM frame.

public boolean

Returns:

true if the state was switched to RESET_RECVD as a result of this method invocation
resetAcknowledged
(long
the final size acknowledged
finalSize
)

Called when the packet containing the RESET_STREAM frame for this stream has been acknowledged.

public void
resetSent()

Called by QuicConnectionStreams after a RESET_STREAM frame has been sent

private QuicSenderStream.SendingStreamState

Returns:

the state before switching to SEND.
sending
(boolean
whether there will be no further data submitted by the producer.
last
)

Called when some data is submitted (or offered) by the producer.

public QuicSenderStream.SendingStreamState
sendingState()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.sendingState.

Returns the sending state of the stream.

private void
setErrorCode(long code)

public long

Returns:

the new limit that has been finalized for max stream data. This new limit may or may not have been increased to the proposed newLimit.
setMaxStreamData
(final long
the proposed new max stream data
newLimit
)

Called to set the max stream data for this stream.

public long
sndErrorCode()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.sndErrorCode.

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

public QuicStream.StreamState
state()

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

Returns the combined stream state.

public boolean
public void
stopSendingReceived(long
the error code
errorCode
)

Called when a STOP_SENDING frame is received from the peer

public long

Returns:

the size of this stream, if known
streamSize
()

Returns the size of this stream, if known.

private boolean
switchSendingState(QuicSenderStream.SendingStreamState
the new state, according to the StreamWriterQueue.
newState
)

Called when the StreamWriterQueue implementation notifies of a state change.

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

Called when the connection is closed locally

private static long
validateStreamId(QuicConnectionImpl connection, long streamId)

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

Field Detail

dbgTagback to summary
private final String dbgTag
debugback to summary
private final Logger debug
errorCodeback to summary
private volatile long errorCode
queueback to summary
private final QuicSenderStreamImpl.StreamWriterQueueImpl queue
sendingStateback to summary
private volatile QuicSenderStream.SendingStreamState sendingState
stopSendingReceivedback to summary
private volatile boolean stopSendingReceived
writerback to summary
private volatile QuicSenderStreamImpl.QuicStreamWriterImpl writer

Constructor Detail

QuicSenderStreamImplback to summary
pack-priv QuicSenderStreamImpl(QuicConnectionImpl connection, long streamId)

Method Detail

availableback to summary
public long available()

Returns the number of bytes that are available for sending, subject to flow control.

Implementation Specification

This method does not return more than what flow control for this stream would allow at the time the method is called.

Implementation Note

If the sender part is not finished initializing the default implementation of this method will return 0.

Returns:long

the number of bytes that are available for sending, subject to flow control

checkOpenedback to summary
pack-priv void checkOpened() throws IOException
connectWriterback to summary
public QuicStreamWriter connectWriter(SequentialScheduler scheduler)

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.connectWriter.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.connectWriter.

Connects a writer to the sending end of this stream.

Annotations
@Override
dataAcknowledgedback to summary
public boolean dataAcknowledged(long finalSize)

Called when the packet containing the final STREAM frame for this stream has been acknowledged.

Parameters
finalSize:long

the final size acknowledged

Returns:boolean

true if the state was switched to DATA_RECVD as a result of this method invocation

dataSentback to summary
public long dataSent()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.dataSent.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.dataSent.

Returns the amount of data that has been sent.

Annotations
@Override
dbgTagback to summary
pack-priv String dbgTag()
disconnectWriterback to summary
public void disconnectWriter(QuicStreamWriter writer)

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.disconnectWriter.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.disconnectWriter.

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

Annotations
@Override
isBlockedback to summary
public boolean isBlocked()

Whether the sending is blocked due to flow control.

Returns:boolean

true if sending is blocked due to flow control

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
markDataRecvdback to summary
private boolean markDataRecvd()
markDataSentback to summary
private boolean markDataSent()
markResetRecvdback to summary
private boolean markResetRecvd()
markResetSentback to summary
private boolean markResetSent()
markSendingback to summary
private boolean markSending()
notifyTerminalStateback to summary
private void notifyTerminalState(QuicSenderStream.SendingStreamState state)
pollback to summary
public ByteBuffer poll(int maxBytes)

Polls at most maxBytes from the StreamWriterQueue of this stream. The semantics are equivalent to that of StreamWriterQueue#poll(int)

Parameters
maxBytes:int

the maximum number of bytes to poll for sending

Returns:ByteBuffer

a ByteBuffer containing at most maxBytes remaining bytes.

resetback to summary
public void reset(long errorCode) throws IOException

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.reset.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.reset.

Abruptly closes the writing side of a stream by sending a RESET_STREAM frame.

Annotations
@Override
resetAcknowledgedback to summary
public boolean resetAcknowledged(long finalSize)

Called when the packet containing the RESET_STREAM frame for this stream has been acknowledged.

Parameters
finalSize:long

the final size acknowledged

Returns:boolean

true if the state was switched to RESET_RECVD as a result of this method invocation

resetSentback to summary
public void resetSent()

Called by QuicConnectionStreams after a RESET_STREAM frame has been sent

sendingback to summary
private QuicSenderStream.SendingStreamState sending(boolean last)

Called when some data is submitted (or offered) by the producer. If the stream is in the READY state, this will switch the sending state to SEND.

Implementation Note

The parameter last is ignored at this stage. switchSendingState(SendingStreamState.DATA_SENT) will be called later on when the last piece of data has been pushed downstream.

Parameters
last:boolean

whether there will be no further data submitted by the producer.

Returns:QuicSenderStream.SendingStreamState

the state before switching to SEND.

sendingStateback to summary
public QuicSenderStream.SendingStreamState sendingState()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.sendingState.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.sendingState.

Returns the sending state of the stream.

Annotations
@Override
setErrorCodeback to summary
private void setErrorCode(long code)
setMaxStreamDataback to summary
public long setMaxStreamData(final long newLimit)

Called to set the max stream data for this stream.

API Note

as per RFC 9000, any value less than the current max stream data is ignored

Parameters
newLimit:long

the proposed new max stream data

Returns:long

the new limit that has been finalized for max stream data. This new limit may or may not have been increased to the proposed newLimit.

sndErrorCodeback to summary
public long sndErrorCode()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.sndErrorCode.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.sndErrorCode.

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

Annotations
@Override
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
stopSendingReceivedback to summary
public boolean stopSendingReceived()

Implements jdk.internal.net.http.quic.streams.QuicSenderStream.stopSendingReceived.

Doc from jdk.internal.net.http.quic.streams.QuicSenderStream.stopSendingReceived.

Returns true if STOP_SENDING was received.

Annotations
@Override
stopSendingReceivedback to summary
public void stopSendingReceived(long errorCode)

Called when a STOP_SENDING frame is received from the peer

Parameters
errorCode:long

the error code

streamSizeback to summary
public long streamSize()

Returns the size of this stream, if known.

Implementation Specification

This method returns -1 if the size of the stream is not known.

Returns:long

the size of this stream, if known

switchSendingStateback to summary
private boolean switchSendingState(QuicSenderStream.SendingStreamState newState)

Called when the StreamWriterQueue implementation notifies of a state change.

Parameters
newState:QuicSenderStream.SendingStreamState

the new state, according to the StreamWriterQueue.

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

Called when the connection is closed locally

Parameters
terminationCause:TerminationCause

the termination cause

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

private Class QuicSenderStreamImpl.Handles

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

Field Summary

Modifier and TypeField and Description
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
SENDING_STATEback to summary
pack-priv static final VarHandle SENDING_STATE
WRITERback to summary
pack-priv static final VarHandle WRITER

Constructor Detail

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

private Class QuicSenderStreamImpl.QuicStreamWriterImpl

extends QuicStreamWriter
Class Inheritance

The stream internal implementation of a QuicStreamWriter. Most of the logic is implemented in the StreamWriterQueue, which is subclassed here to provide an implementation of its few abstract methods.

Field Summary

Inherited from jdk.internal.net.http.quic.streams.QuicStreamWriter:
scheduler

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
connected()

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

Returns true if this writer is connected to its stream.

public long
credit()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.credit.

Indicates how many bytes the writer is prepared to received for sending.

public void
queueForWriting(ByteBuffer buffer)

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.queueForWriting.

Queues a ByteBuffer on the writing queue for this stream.

public void
reset(long errorCode)

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.reset.

Abruptly resets the stream.

public void
scheduleForWriting(ByteBuffer buffer, boolean last)

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.scheduleForWriting.

Pushes a ByteBuffer to be scheduled for writing on the stream.

public QuicSenderStream.SendingStreamState
sendingState()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.sendingState.

Returns the sending state of the stream.

public QuicSenderStream
stream()

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

Returns the stream this writer is connected to, or null if this writer isn't currently connected.

pack-priv IOException

Returns:

a new IOException
streamClosedException
()

Compose an exception to throw if data is submitted after the the final data has been sent

pack-priv IOException

Returns:

a new IOException
streamResetException
()

Compose an exception to throw if data is submitted after the stream was reset

pack-priv void
Inherited from jdk.internal.net.http.quic.streams.QuicStreamWriter:
stopSendingReceived

Constructor Detail

QuicStreamWriterImplback to summary
pack-priv QuicStreamWriterImpl(SequentialScheduler scheduler)

Method Detail

checkConnectedback to summary
private void checkConnected()
connectedback to summary
public boolean connected()

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

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

Returns true if this writer is connected to its stream.

Annotations
@Override
creditback to summary
public long credit()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.credit.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.credit.

Indicates how many bytes the writer is prepared to received for sending. When that value grows from 0, and if the queue has no pending data, the scheduler is triggered to elicit more calls to scheduleForWriting(ByteBuffer, boolean).

Annotations
@Override
queueForWritingback to summary
public void queueForWriting(ByteBuffer buffer) throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.queueForWriting.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.queueForWriting.

Queues a ByteBuffer on the writing queue for this stream. The consumer will not be woken up. More data should be submitted using scheduleForWriting(ByteBuffer, boolean) in order to wake the consumer.

Annotations
@Override
Exceptions
IOException:
if the state of the stream isn't SendingStreamState#READY or SendingStreamState#SEND
resetback to summary
public void reset(long errorCode) throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.reset.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.reset.

Abruptly resets the stream.

Annotations
@Override
scheduleForWritingback to summary
public void scheduleForWriting(ByteBuffer buffer, boolean last) throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.scheduleForWriting.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.scheduleForWriting.

Pushes a ByteBuffer to be scheduled for writing on the stream. The ByteBuffer will be wrapped in a StreamFrame before being sent. Data that cannot be sent due to a lack of flow credit will be buffered.

Annotations
@Override
Exceptions
IOException:
if the state of the stream isn't SendingStreamState#READY or SendingStreamState#SEND
sendingStateback to summary
public QuicSenderStream.SendingStreamState sendingState()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.sendingState.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.sendingState.

Returns the sending state of the stream.

Annotations
@Override
streamback to summary
public QuicSenderStream stream()

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

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

Returns the stream this writer is connected to, or null if this writer isn't currently connected.

Annotations
@Override
streamClosedExceptionback to summary
pack-priv IOException streamClosedException()

Compose an exception to throw if data is submitted after the the final data has been sent

Returns:IOException

a new IOException

streamResetExceptionback to summary
pack-priv IOException streamResetException()

Compose an exception to throw if data is submitted after the stream was reset

Returns:IOException

a new IOException

wakeupWriterback to summary
pack-priv void wakeupWriter()
jdk.internal.net.http.quic.streams back to summary

private final Class QuicSenderStreamImpl.StreamWriterQueueImpl

extends StreamWriterQueue
Class Inheritance

A concrete implementation of the StreamWriterQueue for this stream.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected Logger
protected long
streamId()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.streamId.

Returns the stream id this queue was created for.

protected void
switchState(QuicSenderStream.SendingStreamState state)

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.switchState.

Called to switch the sending state when data has been sent.

protected void
wakeupConsumer()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.wakeupConsumer.

This method is called to wake up the consumer when there is credit and data available for the consumer.

protected void
wakeupProducer()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.wakeupProducer.

This method is called to wake up the producer when there is credit available for the producer.

Inherited from jdk.internal.net.http.quic.streams.StreamWriterQueue:
availablebytesConsumedbytesProducedcloseconsumerBlockedconsumerCreditisConsumerDoneisProducerDonelockmarkResetmaxStreamDatapollproducerBlockedproducerCreditqueuereadyToSendresetByPeersetMaxStreamDatastopSendingstreamSizesubmitunlock

Constructor Detail

StreamWriterQueueImplback to summary
private StreamWriterQueueImpl()

Method Detail

debugback to summary
protected Logger debug()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.debug.

Annotations
@Override
streamIdback to summary
protected long streamId()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.streamId.

Doc from jdk.internal.net.http.quic.streams.StreamWriterQueue.streamId.

Returns the stream id this queue was created for.

Annotations
@Override
switchStateback to summary
protected void switchState(QuicSenderStream.SendingStreamState state)

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.switchState.

Doc from jdk.internal.net.http.quic.streams.StreamWriterQueue.switchState.

Called to switch the sending state when data has been sent.

Annotations
@Override
wakeupConsumerback to summary
protected void wakeupConsumer()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.wakeupConsumer.

Doc from jdk.internal.net.http.quic.streams.StreamWriterQueue.wakeupConsumer.

This method is called to wake up the consumer when there is credit and data available for the consumer.

Annotations
@Override
wakeupProducerback to summary
protected void wakeupProducer()

Implements abstract jdk.internal.net.http.quic.streams.StreamWriterQueue.wakeupProducer.

Doc from jdk.internal.net.http.quic.streams.StreamWriterQueue.wakeupProducer.

This method is called to wake up the producer when there is credit available for the producer.

Annotations
@Override