Class HTTP2Stream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Stream, IStream, org.eclipse.jetty.util.Attachable, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.thread.Invocable

    public class HTTP2Stream
    extends org.eclipse.jetty.io.IdleTimeout
    implements IStream, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.component.Dumpable
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Callback

        org.eclipse.jetty.util.Callback.Completable, org.eclipse.jetty.util.Callback.Completing, org.eclipse.jetty.util.Callback.Nested
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

        org.eclipse.jetty.util.component.Dumpable.DumpableContainer
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable

        org.eclipse.jetty.util.thread.Invocable.InvocationType
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicReference<java.lang.Object> attachment  
      private java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object>> attributes  
      private java.util.concurrent.atomic.AtomicReference<CloseState> closeState  
      private boolean committed  
      private long dataLength  
      private java.lang.Throwable failure  
      private Stream.Listener listener  
      private boolean local  
      private boolean localReset  
      private static org.eclipse.jetty.util.log.Logger LOG  
      private java.util.concurrent.atomic.AtomicInteger recvWindow  
      private boolean remoteReset  
      private org.eclipse.jetty.util.Callback sendCallback  
      private java.util.concurrent.atomic.AtomicInteger sendWindow  
      private ISession session  
      private int streamId  
      private long timeStamp  
      • Fields inherited from interface org.eclipse.jetty.util.Callback

        NOOP
      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
      • Fields inherited from interface org.eclipse.jetty.util.thread.Invocable

        __nonBlocking
    • Constructor Summary

      Constructors 
      Constructor Description
      HTTP2Stream​(org.eclipse.jetty.util.thread.Scheduler scheduler, ISession session, int streamId, boolean local)  
    • Field Detail

      • LOG

        private static final org.eclipse.jetty.util.log.Logger LOG
      • attachment

        private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> attachment
      • attributes

        private final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object>> attributes
      • closeState

        private final java.util.concurrent.atomic.AtomicReference<CloseState> closeState
      • sendWindow

        private final java.util.concurrent.atomic.AtomicInteger sendWindow
      • recvWindow

        private final java.util.concurrent.atomic.AtomicInteger recvWindow
      • timeStamp

        private final long timeStamp
      • session

        private final ISession session
      • streamId

        private final int streamId
      • local

        private final boolean local
      • sendCallback

        private org.eclipse.jetty.util.Callback sendCallback
      • failure

        private java.lang.Throwable failure
      • localReset

        private boolean localReset
      • remoteReset

        private boolean remoteReset
      • dataLength

        private long dataLength
      • committed

        private boolean committed
    • Constructor Detail

      • HTTP2Stream

        public HTTP2Stream​(org.eclipse.jetty.util.thread.Scheduler scheduler,
                           ISession session,
                           int streamId,
                           boolean local)
    • Method Detail

      • getId

        public int getId()
        Specified by:
        getId in interface Stream
        Returns:
        the stream unique id
      • getAttachment

        public java.lang.Object getAttachment()
        Specified by:
        getAttachment in interface org.eclipse.jetty.util.Attachable
      • setAttachment

        public void setAttachment​(java.lang.Object attachment)
        Specified by:
        setAttachment in interface org.eclipse.jetty.util.Attachable
      • isLocal

        public boolean isLocal()
        Specified by:
        isLocal in interface IStream
        Returns:
        whether this stream is local or remote
      • send

        public void send​(IStream.FrameList frameList,
                         org.eclipse.jetty.util.Callback callback)
        Description copied from interface: IStream

        Sends the given list of frames.

        Typically used to send HTTP headers along with content and possibly trailers.

        Specified by:
        send in interface IStream
        Parameters:
        frameList - the list of frames to send
        callback - the callback that gets notified when the frames have been sent
      • headers

        public void headers​(HeadersFrame frame,
                            org.eclipse.jetty.util.Callback callback)
        Description copied from interface: Stream

        Sends the given HEADERS frame.

        Typically used to send an HTTP response or to send the HTTP response trailers.

        Specified by:
        headers in interface Stream
        Parameters:
        frame - the HEADERS frame to send
        callback - the callback that gets notified when the frame has been sent
      • push

        public void push​(PushPromiseFrame frame,
                         org.eclipse.jetty.util.Promise<Stream> promise,
                         Stream.Listener listener)
        Description copied from interface: Stream

        Sends the given PUSH_PROMISE frame.

        Specified by:
        push in interface Stream
        Parameters:
        frame - the PUSH_PROMISE frame to send
        promise - the promise that gets notified of the pushed stream creation
        listener - the listener that gets notified of stream events
      • data

        public void data​(DataFrame frame,
                         org.eclipse.jetty.util.Callback callback)
        Description copied from interface: Stream

        Sends the given DATA frame.

        Specified by:
        data in interface Stream
        Parameters:
        frame - the DATA frame to send
        callback - the callback that gets notified when the frame has been sent
      • reset

        public void reset​(ResetFrame frame,
                          org.eclipse.jetty.util.Callback callback)
        Description copied from interface: Stream

        Sends the given RST_STREAM frame.

        Specified by:
        reset in interface Stream
        Parameters:
        frame - the RST_FRAME to send
        callback - the callback that gets notified when the frame has been sent
      • startWrite

        private boolean startWrite​(org.eclipse.jetty.util.Callback callback)
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String key)
        Specified by:
        getAttribute in interface Stream
        Parameters:
        key - the attribute key
        Returns:
        an arbitrary object associated with the given key to this stream or null if no object can be found for the given key.
        See Also:
        Stream.setAttribute(String, Object)
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String key)
        Specified by:
        removeAttribute in interface Stream
        Parameters:
        key - the attribute key
        Returns:
        the arbitrary object associated with the given key to this stream
        See Also:
        Stream.setAttribute(String, Object)
      • isReset

        public boolean isReset()
        Specified by:
        isReset in interface Stream
        Returns:
        whether this stream has been reset
      • isFailed

        private boolean isFailed()
      • isClosed

        public boolean isClosed()
        Specified by:
        isClosed in interface Stream
        Returns:
        whether this stream is closed, both locally and remotely.
      • isLocallyClosed

        public boolean isLocallyClosed()
      • isCommitted

        public boolean isCommitted()
        Specified by:
        isCommitted in interface IStream
        Returns:
        whether bytes for this stream have been sent to the remote peer.
        See Also:
        IStream.commit()
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in class org.eclipse.jetty.io.IdleTimeout
      • onIdleExpired

        protected void onIdleExpired​(java.util.concurrent.TimeoutException timeout)
        Specified by:
        onIdleExpired in class org.eclipse.jetty.io.IdleTimeout
      • attributes

        private java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object> attributes()
      • process

        public void process​(Frame frame,
                            org.eclipse.jetty.util.Callback callback)
        Description copied from interface: IStream

        Processes the given frame, belonging to this stream.

        Specified by:
        process in interface IStream
        Parameters:
        frame - the frame to process
        callback - the callback to complete when frame has been processed
      • onNewStream

        private void onNewStream​(org.eclipse.jetty.util.Callback callback)
      • onHeaders

        private void onHeaders​(HeadersFrame frame,
                               org.eclipse.jetty.util.Callback callback)
      • onData

        private void onData​(DataFrame frame,
                            org.eclipse.jetty.util.Callback callback)
      • onReset

        private void onReset​(ResetFrame frame,
                             org.eclipse.jetty.util.Callback callback)
      • onPush

        private void onPush​(PushPromiseFrame frame,
                            org.eclipse.jetty.util.Callback callback)
      • onWindowUpdate

        private void onWindowUpdate​(WindowUpdateFrame frame,
                                    org.eclipse.jetty.util.Callback callback)
      • onFailure

        private void onFailure​(FailureFrame frame,
                               org.eclipse.jetty.util.Callback callback)
      • updateClose

        public boolean updateClose​(boolean update,
                                   CloseState.Event event)
        Description copied from interface: IStream

        Updates the close state of this stream.

        Specified by:
        updateClose in interface IStream
        Parameters:
        update - whether to update the close state
        event - the event that caused the close state update
        Returns:
        whether the stream has been fully closed by this invocation
      • updateCloseAfterReceived

        private boolean updateCloseAfterReceived()
      • updateCloseBeforeSend

        private boolean updateCloseBeforeSend()
      • updateCloseAfterSend

        private boolean updateCloseAfterSend()
      • getSendWindow

        public int getSendWindow()
      • getRecvWindow

        public int getRecvWindow()
      • updateSendWindow

        public int updateSendWindow​(int delta)
        Description copied from interface: IStream

        Updates the stream send window by the given delta.

        Specified by:
        updateSendWindow in interface IStream
        Parameters:
        delta - the delta value (positive or negative) to add to the stream send window
        Returns:
        the previous value of the stream send window
      • updateRecvWindow

        public int updateRecvWindow​(int delta)
        Description copied from interface: IStream

        Updates the stream receive window by the given delta.

        Specified by:
        updateRecvWindow in interface IStream
        Parameters:
        delta - the delta value (positive or negative) to add to the stream receive window
        Returns:
        the previous value of the stream receive window
      • close

        public void close()
        Description copied from interface: IStream

        Forcibly closes this stream.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface IStream
      • onClose

        public void onClose()
        Overrides:
        onClose in class org.eclipse.jetty.io.IdleTimeout
      • updateStreamCount

        private void updateStreamCount​(int deltaStream,
                                       int deltaClosing)
      • succeeded

        public void succeeded()
        Specified by:
        succeeded in interface org.eclipse.jetty.util.Callback
      • failed

        public void failed​(java.lang.Throwable x)
        Specified by:
        failed in interface org.eclipse.jetty.util.Callback
      • getInvocationType

        public org.eclipse.jetty.util.thread.Invocable.InvocationType getInvocationType()
        Specified by:
        getInvocationType in interface org.eclipse.jetty.util.thread.Invocable
      • endWrite

        private org.eclipse.jetty.util.Callback endWrite()
      • notifyNewStream

        private void notifyNewStream​(Stream stream)
      • notifyData

        private void notifyData​(Stream stream,
                                DataFrame frame,
                                org.eclipse.jetty.util.Callback callback)
      • notifyReset

        private void notifyReset​(Stream stream,
                                 ResetFrame frame,
                                 org.eclipse.jetty.util.Callback callback)
      • notifyIdleTimeout

        private boolean notifyIdleTimeout​(Stream stream,
                                          java.lang.Throwable failure)
      • notifyFailure

        private void notifyFailure​(Stream stream,
                                   FailureFrame frame,
                                   org.eclipse.jetty.util.Callback callback)
      • notifyClosed

        private void notifyClosed​(Stream stream)
      • dump

        public java.lang.String dump()
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object