APIdia Launch Partner
Top Description Methods
jdk.internal.net.http.quic

public sealed Interface ConnectionTerminator

permits ConnectionTerminatorImpl
Known Direct Implementers
jdk.internal.net.http.quic.ConnectionTerminatorImpl
Imports
java.time.Duration, java.util.function.Supplier

Responsible for managing the connection termination of a QUIC connection

Method Summary

Modifier and TypeMethod and Description
public void
appLayerMaxIdle(Duration
the maximum idle duration of the connection, at the application layer
maxIdle
,
Supplier<Boolean>
the callback that will be invoked by the connection terminator to decide if the QUIC layer should generate any traffic to prevent the connection from idle terminating
trafficGenerationCheck
)

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

public void
markActive()

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

public void
terminate(TerminationCause
the termination cause
cause
)

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

public boolean

Returns:

true if the connection can be used, false otherwise
tryReserveForUse
()

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

Method Detail

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

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.

Parameters
maxIdle:Duration

the maximum idle duration of the connection, at the application layer

trafficGenerationCheck:Supplier<Boolean>

the callback that will be invoked by the connection terminator to decide if the QUIC layer should generate any traffic to prevent the connection from idle terminating

Exceptions
NullPointerException:
if either maxIdle or trafficGenerationCheck is null
IllegalArgumentException:
if maxIdle is negative or zero
markActiveback to summary
public void 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.

terminateback to summary
public void terminate(TerminationCause cause)

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.

Parameters
cause:TerminationCause

the termination cause

tryReserveForUseback to summary
public boolean 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.

Returns:boolean

true if the connection can be used, false otherwise