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

public abstract Class PeerUniStreamDispatcher

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.net.http.Http3Connection.Http3StreamDispatcher
Imports
java.io.IOException, java.util.concurrent.CompletableFuture, jdk.internal.net.http.common.Logger, .MinimalFuture, jdk.internal.net.http.http3.Http3Error, jdk.internal.net.http.http3.streams.Http3Streams.StreamType, jdk.internal.net.http.quic.streams.QuicReceiverStream

A class that analyzes the first byte of the stream to figure out where to dispatch it.

Field Summary

Modifier and TypeField and Description
private final CompletableFuture<QuicReceiverStream>
private final QuicStreamIntReader
private final QuicReceiverStream

Constructor Summary

AccessConstructor and Description
protected
PeerUniStreamDispatcher(QuicReceiverStream
a new unidirectional stream opened by the peer
stream
)

Creates a PeerUniStreamDispatcher for the given stream.

Method Summary

Modifier and TypeMethod and Description
protected void
abandon()

This method disconnects the reader, stops the dispatch, and unless the stream type could be decoded and was a reserved type, calls onStreamAbandoned(QuicReceiverStream)

private void
abort(Throwable
the reason for aborting the dispatch
throwable
)

Aborts the dispatch - for instance, if the stream type can't be read, or isn't recognized.

private static QuicReceiverStream
private void
protected abstract Logger

Returns:

the debug logger that should be used
debug
()

Returns the debug logger that should be used.

private void
dispatch(Long result, Throwable error)

public CompletableFuture<QuicReceiverStream>

Returns:

a completable future that will contain the dispatched stream, once dispatched, or a throwable if dispatching the stream failed
dispatchCF
()

Returns a completable future that will contain the dispatched stream, once dispatched, or a throwable if dispatching the stream failed.

private void
protected abstract void
onControlStreamCreated(String
a brief description of the stream for logging purposes
description
,
QuicReceiverStream
the peer control stream
stream
)

Called after disconnecting to handle the peer control stream.

protected abstract void
onDecoderStreamCreated(String
a brief description of the stream for logging purposes
description
,
QuicReceiverStream
the peer decoder stream
stream
)

Called after disconnecting to handle the peer decoder stream.

protected abstract void
onEncoderStreamCreated(String
a brief description of the stream for logging purposes
description
,
QuicReceiverStream
the peer encoder stream
stream
)

Called after disconnecting to handle the peer encoder stream.

protected abstract void
onPushStreamCreated(String
a brief description of the stream for logging purposes
description
,
QuicReceiverStream
a peer initiated push stream
stream
,
long pushId)

Called after disconnecting to handle a peer initiated push stream.

protected void
onReservedStreamType(long
the unrecognized stream type
code
,
QuicReceiverStream
the peer initiated stream
stream
)

Called when a reserved stream type is read off the stream.

protected void
onStreamAbandoned(QuicReceiverStream
a peer initiated stream which was abandoned due to having an unknown type, or which was abandoned due to being reset before being dispatched.
stream
)

Called after disconnecting to abandon a peer initiated stream.

protected void
onUnknownStreamType(long
the unrecognized stream type
code
,
QuicReceiverStream
the peer initiated stream
stream
)

Called when an unrecognized stream type is read off the stream.

private void
pushStream(String description, Http3Streams.StreamType type, long pushId)

private void
private void
private void
protected void
start()

Starts the dispatcher.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cfback to summary
private final CompletableFuture<QuicReceiverStream> cf
readerback to summary
private final QuicStreamIntReader reader
streamback to summary
private final QuicReceiverStream stream

Constructor Detail

PeerUniStreamDispatcherback to summary
protected PeerUniStreamDispatcher(QuicReceiverStream stream)

Creates a PeerUniStreamDispatcher for the given stream.

Parameters
stream:QuicReceiverStream

a new unidirectional stream opened by the peer

Method Detail

abandonback to summary
protected void abandon()

This method disconnects the reader, stops the dispatch, and unless the stream type could be decoded and was a reserved type, calls onStreamAbandoned(QuicReceiverStream)

abortback to summary
private void abort(Throwable throwable)

Aborts the dispatch - for instance, if the stream type can't be read, or isn't recognized.

This method requests the peer to stop sending this stream, and completes the dispatchCF exceptionally with the provided throwable.

Parameters
throwable:Throwable

the reason for aborting the dispatch

checkStreamback to summary
private static QuicReceiverStream checkStream(QuicReceiverStream stream)
controlStreamback to summary
private void controlStream(String description, Http3Streams.StreamType type)
debugback to summary
protected abstract Logger debug()

Returns the debug logger that should be used.

Returns:Logger

the debug logger that should be used

dispatchback to summary
private void dispatch(Long result, Throwable error)
dispatchCFback to summary
public CompletableFuture<QuicReceiverStream> dispatchCF()

Returns a completable future that will contain the dispatched stream, once dispatched, or a throwable if dispatching the stream failed.

Returns:CompletableFuture<QuicReceiverStream>

a completable future that will contain the dispatched stream, once dispatched, or a throwable if dispatching the stream failed

dispatchPushStreamback to summary
private void dispatchPushStream(Long result, Throwable error)
onControlStreamCreatedback to summary
protected abstract void onControlStreamCreated(String description, QuicReceiverStream stream)

Called after disconnecting to handle the peer control stream. The stream type has already been read off the stream.

Parameters
description:String

a brief description of the stream for logging purposes

stream:QuicReceiverStream

the peer control stream

onDecoderStreamCreatedback to summary
protected abstract void onDecoderStreamCreated(String description, QuicReceiverStream stream)

Called after disconnecting to handle the peer decoder stream. The stream type has already been read off the stream.

Parameters
description:String

a brief description of the stream for logging purposes

stream:QuicReceiverStream

the peer decoder stream

onEncoderStreamCreatedback to summary
protected abstract void onEncoderStreamCreated(String description, QuicReceiverStream stream)

Called after disconnecting to handle the peer encoder stream. The stream type has already been read off the stream.

Parameters
description:String

a brief description of the stream for logging purposes

stream:QuicReceiverStream

the peer encoder stream

onPushStreamCreatedback to summary
protected abstract void onPushStreamCreated(String description, QuicReceiverStream stream, long pushId)

Called after disconnecting to handle a peer initiated push stream. The stream type has already been read off the stream.

Parameters
description:String

a brief description of the stream for logging purposes

stream:QuicReceiverStream

a peer initiated push stream

onReservedStreamTypeback to summary
protected void onReservedStreamType(long code, QuicReceiverStream stream)

Called when a reserved stream type is read off the stream.

Implementation Specification

The default implementation of this method calls

stream.requestStopSending(Http3Error.H3_STREAM_CREATION_ERROR.code());
stream.requestStopSending(Http3Error.H3_STREAM_CREATION_ERROR.code());
Parameters
code:long

the unrecognized stream type

stream:QuicReceiverStream

the peer initiated stream

onStreamAbandonedback to summary
protected void onStreamAbandoned(QuicReceiverStream stream)

Called after disconnecting to abandon a peer initiated stream.

API Note

A subclass may want to override this method in order to, e.g, emit a QPack Stream Cancellation instruction; See https://www.rfc-editor.org/rfc/rfc9204.html#name-abandonment-of-a-stream

Parameters
stream:QuicReceiverStream

a peer initiated stream which was abandoned due to having an unknown type, or which was abandoned due to being reset before being dispatched.

onUnknownStreamTypeback to summary
protected void onUnknownStreamType(long code, QuicReceiverStream stream)

Called when an unrecognized stream type is read off the stream.

Implementation Specification

The default implementation of this method calls

stream.requestStopSending(Http3Error.H3_STREAM_CREATION_ERROR.code()); abandon();
stream.requestStopSending(Http3Error.H3_STREAM_CREATION_ERROR.code());
abandon();
Parameters
code:long

the unrecognized stream type

stream:QuicReceiverStream

the peer initiated stream

pushStreamback to summary
private void pushStream(String description, Http3Streams.StreamType type, long pushId)
qpackDecoderStreamback to summary
private void qpackDecoderStream(String description, Http3Streams.StreamType type)
qpackEncoderStreamback to summary
private void qpackEncoderStream(String description, Http3Streams.StreamType type)
reservedStreamTypeback to summary
private void reservedStreamType(long code, QuicReceiverStream stream)
startback to summary
protected void start()

Starts the dispatcher.

API Note

The dispatcher should be explicitly started after creating the dispatcher.

unknownStreamTypeback to summary
private void unknownStreamType(long code, QuicReceiverStream stream)