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

pack-priv final Class ConnectionTerminatorImpl

extends Object
implements ConnectionTerminator
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.quic.ConnectionTerminator
Imports
java.nio.ByteBuffer, java.time.Duration, java.util.List, .Objects, java.util.concurrent.CompletableFuture, java.util.concurrent.atomic.AtomicReference, java.util.function.Function, .Supplier, jdk.internal.net.http.common.Log, .Logger, .MinimalFuture, jdk.internal.net.http.quic.QuicConnectionImpl.HandshakeFlow, .QuicConnectionImpl.ProtectionRecord, .TerminationCause.AppLayerClose, .TerminationCause.SilentTermination, .TerminationCause.TransportError, jdk.internal.net.http.quic.frames.ConnectionCloseFrame, .QuicFrame, jdk.internal.net.http.quic.packets.QuicPacket, jdk.internal.net.quic.QuicKeyUnavailableException, .QuicTLSEngine.KeySpace, .QuicTransportErrors, .QuicTransportException

Field Summary

Modifier and TypeField and Description
private final QuicConnectionImpl
private final Logger
private final CompletableFuture<TerminationCause>
private final String
private final AtomicReference<TerminationCause>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
appLayerMaxIdle(final Duration maxIdle, final Supplier<Boolean> trafficGenerationCheck)

Implements jdk.internal.net.http.quic.ConnectionTerminator.appLayerMaxIdle.

Instructs the connection terminator that the application layer allows the connection to stay idle for the given maxIdle duration.

private void
private void
private void
drain(final ConnectionCloseFrame incomingFrame)

private void
private void
pack-priv CompletableFuture<TerminationCause>
pack-priv TerminationCause
private void
immediateClose(final ConnectionCloseFrame closeFrame, final QuicTLSEngine.KeySpace keySpace, final TerminationCause terminationCause)

pack-priv void
pack-priv void
pack-priv ByteBuffer

Returns:

the datagram containing the QUIC packet with a CONNECTION_CLOSE frame
makeConnectionCloseDatagram
()

Returns a ByteBuffer which contains an encrypted QUIC packet containing a CONNECTION_CLOSE frame.

private boolean
mark(final int mask, final TerminationCause cause)

public void
markActive()

Implements jdk.internal.net.http.quic.ConnectionTerminator.markActive.

Instructs the connection terminator to consider the connection as active at the present point in time.

private boolean
markClosed(final TerminationCause terminationCause)

private boolean
markClosing(final TerminationCause terminationCause)

private boolean
markDraining(final TerminationCause terminationCause)

private void
pushConnectionCloseFrame(final QuicTLSEngine.KeySpace
the KeySpace to use for sending the packet
keySpace
,
final ConnectionCloseFrame
the CONNECTION_CLOSE frame
frame
)

CONNECTION_CLOSE frame is not congestion controlled (RFC-9002 section 3 and RFC-9000 section 12.4, table 3), nor is it queued or scheduled for sending.

private void
silentTerminate(final TerminationCause.SilentTermination terminationCause)

Called only when the connection is expected to be discarded without being required to inform the peer.

public void
terminate(final TerminationCause cause)

Implements jdk.internal.net.http.quic.ConnectionTerminator.terminate.

Terminates the connection, if not already terminated, with the given cause.

public boolean
tryReserveForUse()

Implements jdk.internal.net.http.quic.ConnectionTerminator.tryReserveForUse.

Returns true if the connection is allowed for use, false otherwise.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
private final QuicConnectionImpl connection
debugback to summary
private final Logger debug
futureTCback to summary
private final CompletableFuture<TerminationCause> futureTC
logTagback to summary
private final String logTag
terminationCauseback to summary
private final AtomicReference<TerminationCause> terminationCause

Constructor Detail

ConnectionTerminatorImplback to summary
pack-priv ConnectionTerminatorImpl(final QuicConnectionImpl connection)

Method Detail

appLayerMaxIdleback to summary
public void appLayerMaxIdle(final Duration maxIdle, final Supplier<Boolean> trafficGenerationCheck)

Implements jdk.internal.net.http.quic.ConnectionTerminator.appLayerMaxIdle.

Doc from jdk.internal.net.http.quic.ConnectionTerminator.appLayerMaxIdle.

Instructs the connection terminator that the application layer allows the connection to stay idle for the given maxIdle duration. If the QUIC layer has negotiated an idle timeout for the connection, that's lower than the application's maxIdle duration, then the connection terminator upon noticing absence of traffic over the connection for certain duration, calls the trafficGenerationCheck to check if the QUIC layer should explicitly generate some traffic to prevent the connection from idle terminating.

When the trafficGenerationCheck is invoked, the application layer must return true only if explicit traffic generation is necessary to keep the connection alive.

If the application layer wishes to never idle terminate the connection, then a maxIdle duration of Duration.MAX is recommended.

Annotations
@Override
discardConnectionStateback to summary
private void discardConnectionState()
doTerminateback to summary
private void doTerminate(final TerminationCause cause)
drainback to summary
private void drain(final ConnectionCloseFrame incomingFrame)
failHandshakeCFsback to summary
private void failHandshakeCFs()
failHandshakeCFsback to summary
private void failHandshakeCFs(final Throwable cause)
futureTerminationCauseback to summary
pack-priv CompletableFuture<TerminationCause> futureTerminationCause()
getTerminationCauseback to summary
pack-priv TerminationCause getTerminationCause()
immediateCloseback to summary
private void immediateClose(final ConnectionCloseFrame closeFrame, final QuicTLSEngine.KeySpace keySpace, final TerminationCause terminationCause)
incomingConnectionCloseFrameback to summary
pack-priv void incomingConnectionCloseFrame(final ConnectionCloseFrame frame)
incomingStatelessResetback to summary
pack-priv void incomingStatelessReset()
makeConnectionCloseDatagramback to summary
pack-priv ByteBuffer makeConnectionCloseDatagram() throws QuicKeyUnavailableException, QuicTransportException

Returns a ByteBuffer which contains an encrypted QUIC packet containing a CONNECTION_CLOSE frame. The CONNECTION_CLOSE frame will have a frame type of 0x1c and error code of NO_ERROR.

This method should only be invoked when the QuicEndpoint is being closed and the endpoint wants to send out a CONNECTION_CLOSE frame on a best-effort basis (in a fire and forget manner).

Returns:ByteBuffer

the datagram containing the QUIC packet with a CONNECTION_CLOSE frame

markback to summary
private boolean mark(final int mask, final TerminationCause cause)
markActiveback to summary
public void markActive()

Implements jdk.internal.net.http.quic.ConnectionTerminator.markActive.

Doc from jdk.internal.net.http.quic.ConnectionTerminator.markActive.

Instructs the connection terminator to consider the connection as active at the present point in time. The connection terminator will then restart its idle timeout timer from this point in time.

This method must be called when an incoming packet is processed successfully or when an ack-eliciting packet is sent by the local endpoint on the connection.

Annotations
@Override
markClosedback to summary
private boolean markClosed(final TerminationCause terminationCause)
markClosingback to summary
private boolean markClosing(final TerminationCause terminationCause)
markDrainingback to summary
private boolean markDraining(final TerminationCause terminationCause)
pushConnectionCloseFrameback to summary
private void pushConnectionCloseFrame(final QuicTLSEngine.KeySpace keySpace, final ConnectionCloseFrame frame) throws QuicKeyUnavailableException, QuicTransportException

CONNECTION_CLOSE frame is not congestion controlled (RFC-9002 section 3 and RFC-9000 section 12.4, table 3), nor is it queued or scheduled for sending. This method constructs a QuicPacket containing the frame and immediately pushes the datagram through the connection.

Parameters
keySpace:QuicTLSEngine.KeySpace

the KeySpace to use for sending the packet

frame:ConnectionCloseFrame

the CONNECTION_CLOSE frame

Exceptions
QuicKeyUnavailableException:
if the keys for the KeySpace aren't available
QuicTransportException:
for any QUIC transport exception when sending the packet
silentTerminateback to summary
private void silentTerminate(final TerminationCause.SilentTermination terminationCause)

Called only when the connection is expected to be discarded without being required to inform the peer. Discards all state, no CONNECTION_CLOSE is sent, nor does the connection enter closing or discarding state.

terminateback to summary
public void terminate(final TerminationCause cause)

Implements jdk.internal.net.http.quic.ConnectionTerminator.terminate.

Doc from jdk.internal.net.http.quic.ConnectionTerminator.terminate.

Terminates the connection, if not already terminated, with the given cause.

A connection is terminated only once with a TerminationCause. However, this method can be called any number of times. If the connection is not already terminated, then this method does the necessary work to terminate the connection. Any subsequent invocations of this method, after the connection has been terminated, will not change the termination cause of the connection.

Annotations
@Override
tryReserveForUseback to summary
public boolean tryReserveForUse()

Implements jdk.internal.net.http.quic.ConnectionTerminator.tryReserveForUse.

Doc from jdk.internal.net.http.quic.ConnectionTerminator.tryReserveForUse.

Returns true if the connection is allowed for use, false otherwise.

This method is typically called when a connection that has been idle, is about to be used for handling some request. This method allows for co-ordination between the connection usage and the connection terminator to prevent the connection from being idle timed out when it is about to be used for some request. The connection must only be used if this method returns true.

Annotations
@Override
unregisterConnFromEndpointback to summary
private void unregisterConnFromEndpoint()