Class QuicSession

All Implemented Interfaces:
Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
Direct Known Subclasses:
ClientQuicSession, ServerQuicSession

public abstract class QuicSession extends ContainerLifeCycle

Represents a logical connection with a remote peer, identified by a QUIC connection ID.

Each QuicSession maintains a number of QUIC streams, identified by their QUIC stream ID; Each QUIC stream is wrapped in an EndPoint, namely QuicStreamEndPoint.

Bytes received from a QuicConnection in process(SocketAddress, ByteBuffer) are passed to Quiche for processing; in turn, Quiche produces a list of QUIC stream IDs that have pending I/O events, either read-ready or write-ready.

On the receive side, a QuicSession fans-out to multiple QuicStreamEndPoints.

On the send side, many QuicStreamEndPoints fan-in to a QuicSession.

See Also:
  • Constructor Details

  • Method Details

    • doStart

      protected void doStart() throws Exception
      Description copied from class: ContainerLifeCycle
      Starts the managed lifecycle beans in the order they were added.
      Overrides:
      doStart in class ContainerLifeCycle
      Throws:
      AbstractLifeCycle.StopException - If thrown, the lifecycle will immediately be stopped.
      Exception - If there was a problem starting. Will cause a transition to FAILED state
    • doStop

      protected void doStop() throws Exception
      Description copied from class: ContainerLifeCycle
      Stops the managed lifecycle beans in the reverse order they were added.
      Overrides:
      doStop in class ContainerLifeCycle
      Throws:
      Exception - If there was a problem stopping. Will cause a transition to FAILED state
    • shutdown

      public CompletableFuture<Void> shutdown()
    • getExecutor

      public Executor getExecutor()
    • getScheduler

      public Scheduler getScheduler()
    • getByteBufferPool

      public ByteBufferPool getByteBufferPool()
    • getProtocolSession

      public ProtocolSession getProtocolSession()
    • getMaxLocalStreams

      public int getMaxLocalStreams()
    • getNegotiatedProtocol

      public String getNegotiatedProtocol()
    • getQuicConnection

      public QuicConnection getQuicConnection()
    • getQuicStreamEndPoints

      public Collection<QuicStreamEndPoint> getQuicStreamEndPoints()
    • getRemoteCloseInfo

      public CloseInfo getRemoteCloseInfo()
    • getIdleTimeout

      public long getIdleTimeout()
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
    • onIdleTimeout

      public boolean onIdleTimeout()
    • onFailure

      public void onFailure(Throwable failure)
    • newStreamId

      public long newStreamId(StreamType streamType)
      Parameters:
      streamType - the stream type
      Returns:
      a new stream ID for the given type
    • fill

      public int fill(long streamId, ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • flush

      public int flush(long streamId, ByteBuffer buffer, boolean last) throws IOException
      Throws:
      IOException
    • isFinished

      public boolean isFinished(long streamId)
    • getWindowCapacity

      public long getWindowCapacity()
    • getWindowCapacity

      public long getWindowCapacity(long streamId) throws IOException
      Throws:
      IOException
    • shutdownInput

      public void shutdownInput(long streamId, long error) throws IOException
      Throws:
      IOException
    • shutdownOutput

      public void shutdownOutput(long streamId, long error) throws IOException
      Throws:
      IOException
    • remove

      public void remove(QuicStreamEndPoint endPoint, Throwable failure)
    • getLocalAddress

      public SocketAddress getLocalAddress()
    • getRemoteAddress

      public SocketAddress getRemoteAddress()
    • isConnectionEstablished

      public boolean isConnectionEstablished()
    • getConnectionId

      public org.eclipse.jetty.quic.quiche.QuicheConnectionId getConnectionId()
    • setConnectionId

      public void setConnectionId(org.eclipse.jetty.quic.quiche.QuicheConnectionId quicheConnectionId)
    • process

      public Runnable process(SocketAddress remoteAddress, ByteBuffer cipherBufferIn) throws IOException
      Throws:
      IOException
    • pollTask

      protected Runnable pollTask()
    • createProtocolSession

      protected abstract ProtocolSession createProtocolSession()
    • validateNewlyEstablishedConnection

      protected abstract boolean validateNewlyEstablishedConnection()
      Returns:
      true if the connection is valid, false otherwise.
    • newConnection

      public abstract Connection newConnection(QuicStreamEndPoint endPoint)
    • flush

      public void flush()
    • getOrCreateStreamEndPoint

      public QuicStreamEndPoint getOrCreateStreamEndPoint(long streamId, Consumer<QuicStreamEndPoint> consumer)
    • inwardClose

      public void inwardClose(long error, String reason)
    • outwardClose

      public void outwardClose(long error, String reason)
    • getPeerCertificates

      public X509Certificate[] getPeerCertificates()

      Returns the peer certificates chain.

      Due to current Quiche C API limitations (that the Rust version does not have), only the last certificate in the chain is returned. This may change in the future when the C APIs are aligned to the Rust APIs.

      Returns:
      the peer certificates chain (currently only the last certificate in the chain)
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Description copied from interface: Dumpable
      Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
      Specified by:
      dump in interface Dumpable
      Overrides:
      dump in class ContainerLifeCycle
      Parameters:
      out - The appendable to dump to
      indent - The indent to apply after any new lines.
      Throws:
      IOException - if unable to write to Appendable
    • toString

      public String toString()
      Overrides:
      toString in class AbstractLifeCycle