Class QuicheStream

java.lang.Object
org.eclipse.jetty.quic.common.AbstractStream
org.eclipse.jetty.quic.quiche.QuicheStream
All Implemented Interfaces:
CyclicTimeouts.Expirable, Stream

public class QuicheStream extends AbstractStream
  • Constructor Details

    • QuicheStream

      public QuicheStream(QuicheSession session, long streamId, boolean local)
  • Method Details

    • isClosed

      public boolean isClosed()
      Description copied from interface: Stream

      Returns whether the stream is fully closed, both locally and remotely.

      Returns:
      whether the stream is fully closed
      See Also:
    • isLocallyClosed

      public boolean isLocallyClosed()
      Description copied from interface: Stream

      Returns whether the stream is locally closed.

      A locally closed stream will not send further data.

      A stream becomes locally closed when either it has sent the last data, or issued a Stream.reset(long, Promise.Invocable).

      Returns:
      whether the stream is locally closed
      See Also:
    • isRemotelyClosed

      public boolean isRemotelyClosed()
      Description copied from interface: Stream

      Returns whether the stream is remotely closed.

      A remotely closed stream will not receive further data.

      A stream becomes remotely closed when it has Stream.read() the last data.

      Returns:
      whether the stream is remotely closed
      See Also:
    • getSession

      public QuicheSession getSession()
      Description copied from interface: Stream

      Returns the Session this stream is associated to.

      Returns:
      the Session this stream is associated to
    • read

      public Content.Chunk read()
      Description copied from interface: Stream

      Reads data from this stream, if any.

      The returned Content.Chunk object may be null indicating that the end of the read side of the stream has not yet been reached, which may happen when not all the bytes have been received so far, for example the remote peer did not send them yet, or they are in-flight.

      When the returned Content.Chunk object is not null, the flow control window has been enlarged by the data length. Applications must call, either immediately or later (even asynchronously from a different thread) Retainable.release() to notify the implementation that the bytes have been processed.

      Content.Chunk objects may be stored away for later, asynchronous, processing (for example, to process them only when all of them have been received).

      Once the returned Content.Chunk object indicates that the end of the read side of the stream has been reached, further calls to this method will return a Content.Chunk object with the same indication, although the instance may be different.

      Returns:
      a Content.Chunk object containing the data bytes or a failure, or null if no data bytes are available
      See Also:
    • demand

      public void demand()
      Description copied from interface: Stream

      Demands more data bytes for this stream.

      Calling this method causes Stream.Listener.onDataAvailable(Stream) to be invoked, possibly at a later time, when the stream has data to be read, but also when the stream has reached EOF.

      This method is idempotent: calling it when there already is an outstanding demand to invoke Stream.Listener.onDataAvailable(Stream) is a no-operation.

      The thread invoking this method may invoke directly Stream.Listener.onDataAvailable(Stream), unless another thread that must invoke Stream.Listener.onDataAvailable(Stream) notices the outstanding demand first.

      It is always guaranteed that invoking this method from within onDataAvailable(Stream) will not cause a StackOverflowError.

      See Also:
    • data

      public void data(boolean last, List<ByteBuffer> buffers, Promise.Invocable<Stream> promise)
      Description copied from interface: Stream

      Sends a STREAM frame with the given data bytes and the indication of whether they are the last to be sent.

      Parameters:
      last - whether the data bytes are the last
      buffers - the list of data bytes to send
      promise - the Promise.Invocable that gets notified when the data has been sent
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
      Specified by:
      setIdleTimeout in interface Stream
      Overrides:
      setIdleTimeout in class AbstractStream
    • maxData

      public void maxData(long maxData, Promise.Invocable<Stream> promise)
      Description copied from interface: Stream

      Sends a MAX_STREAM_DATA frame with the new total max data bytes that this peer is willing to receive.

      Parameters:
      maxData - the max data bytes this peer is willing to receive
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • reset

      public void reset(long appErrorCode, Promise.Invocable<Stream> promise)
      Description copied from interface: Stream

      Sends a RESET_STREAM frame, with the given application error code.

      Parameters:
      appErrorCode - the application error code
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • stopSending

      public void stopSending(long appErrorCode, Promise.Invocable<Stream> promise)
      Description copied from interface: Stream

      Sends a STOP_SENDING frame, with the given application error code.

      Parameters:
      appErrorCode - the application error code
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • dataBlocked

      public void dataBlocked(long offset, Promise.Invocable<Stream> promise)
      Description copied from interface: Stream

      Sends a STREAM_DATA_BLOCKED frame, with the given offset.

      Parameters:
      offset - the data offset
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • disconnect

      public void disconnect(long appErrorCode, Throwable failure, Promise.Invocable<Stream> promise)
      Description copied from interface: Stream

      Abruptly terminates this stream with the given error.

      This method removes this stream from its session and then terminates the QUIC stream, via Stream.stopSending(long, Promise.Invocable), and then a Stream.reset(long, Promise.Invocable).

      Parameters:
      appErrorCode - the application error code
      failure - the failure that caused the disconnect of the stream
      promise - the Promise.Invocable that gets notified when the disconnect is completed
    • toString

      public String toString()
      Overrides:
      toString in class AbstractStream