Package org.eclipse.jetty.http2
Class HTTP2Stream
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.http2.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
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.IStream
IStream.FrameList
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.api.Stream
Stream.Listener
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<java.lang.Object>attachmentprivate java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object>>attributesprivate java.util.concurrent.atomic.AtomicReference<CloseState>closeStateprivate booleancommittedprivate longdataLengthprivate java.lang.Throwablefailureprivate Stream.Listenerlistenerprivate booleanlocalprivate booleanlocalResetprivate static org.eclipse.jetty.util.log.LoggerLOGprivate java.util.concurrent.atomic.AtomicIntegerrecvWindowprivate booleanremoteResetprivate org.eclipse.jetty.util.CallbacksendCallbackprivate java.util.concurrent.atomic.AtomicIntegersendWindowprivate ISessionsessionprivate intstreamIdprivate longtimeStamp
-
Constructor Summary
Constructors Constructor Description HTTP2Stream(org.eclipse.jetty.util.thread.Scheduler scheduler, ISession session, int streamId, boolean local)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object>attributes()voidclose()Forcibly closes this stream.voidcommit()Marks this stream as committed.voiddata(DataFrame frame, org.eclipse.jetty.util.Callback callback)Sends the given DATAframe.java.lang.Stringdump()voiddump(java.lang.Appendable out, java.lang.String indent)private org.eclipse.jetty.util.CallbackendWrite()voidfailed(java.lang.Throwable x)java.lang.ObjectgetAttachment()java.lang.ObjectgetAttribute(java.lang.String key)intgetId()org.eclipse.jetty.util.thread.Invocable.InvocationTypegetInvocationType()Stream.ListenergetListener()intgetRecvWindow()intgetSendWindow()ISessiongetSession()voidheaders(HeadersFrame frame, org.eclipse.jetty.util.Callback callback)Sends the given HEADERSframe.booleanisClosed()booleanisCommitted()private booleanisFailed()booleanisLocal()booleanisLocallyClosed()booleanisOpen()booleanisRemotelyClosed()booleanisReset()booleanisResetOrFailed()private voidnotifyClosed(Stream stream)private voidnotifyData(Stream stream, DataFrame frame, org.eclipse.jetty.util.Callback callback)private voidnotifyFailure(Stream stream, FailureFrame frame, org.eclipse.jetty.util.Callback callback)private booleannotifyIdleTimeout(Stream stream, java.lang.Throwable failure)private voidnotifyNewStream(Stream stream)private voidnotifyReset(Stream stream, ResetFrame frame, org.eclipse.jetty.util.Callback callback)voidonClose()private voidonData(DataFrame frame, org.eclipse.jetty.util.Callback callback)private voidonFailure(FailureFrame frame, org.eclipse.jetty.util.Callback callback)private voidonHeaders(HeadersFrame frame, org.eclipse.jetty.util.Callback callback)protected voidonIdleExpired(java.util.concurrent.TimeoutException timeout)private voidonNewStream(org.eclipse.jetty.util.Callback callback)private voidonPush(PushPromiseFrame frame, org.eclipse.jetty.util.Callback callback)private voidonReset(ResetFrame frame, org.eclipse.jetty.util.Callback callback)private voidonWindowUpdate(WindowUpdateFrame frame, org.eclipse.jetty.util.Callback callback)voidprocess(Frame frame, org.eclipse.jetty.util.Callback callback)Processes the givenframe, belonging to this stream.voidpush(PushPromiseFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener)Sends the given PUSH_PROMISEframe.java.lang.ObjectremoveAttribute(java.lang.String key)voidreset(ResetFrame frame, org.eclipse.jetty.util.Callback callback)Sends the given RST_STREAMframe.voidsend(IStream.FrameList frameList, org.eclipse.jetty.util.Callback callback)Sends the given list of frames.voidsetAttachment(java.lang.Object attachment)voidsetAttribute(java.lang.String key, java.lang.Object value)voidsetListener(Stream.Listener listener)private booleanstartWrite(org.eclipse.jetty.util.Callback callback)voidsucceeded()java.lang.StringtoString()booleanupdateClose(boolean update, CloseState.Event event)Updates the close state of this stream.private booleanupdateCloseAfterReceived()private booleanupdateCloseAfterSend()private booleanupdateCloseBeforeSend()intupdateRecvWindow(int delta)Updates the stream receive window by the givendelta.intupdateSendWindow(int delta)Updates the stream send window by the givendelta.private voidupdateStreamCount(int deltaStream, int deltaClosing)-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getScheduler, notIdle, onOpen, setIdleTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.http2.api.Stream
getIdleTimeout, setIdleTimeout
-
-
-
-
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
-
listener
private Stream.Listener listener
-
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
-
getAttachment
public java.lang.Object getAttachment()
- Specified by:
getAttachmentin interfaceorg.eclipse.jetty.util.Attachable
-
setAttachment
public void setAttachment(java.lang.Object attachment)
- Specified by:
setAttachmentin interfaceorg.eclipse.jetty.util.Attachable
-
isLocal
public boolean isLocal()
-
getSession
public ISession getSession()
- Specified by:
getSessionin interfaceIStream- Specified by:
getSessionin interfaceStream- Returns:
- the session this stream is associated to
-
send
public void send(IStream.FrameList frameList, org.eclipse.jetty.util.Callback callback)
Description copied from interface:IStreamSends the given list of frames.
Typically used to send HTTP headers along with content and possibly trailers.
-
headers
public void headers(HeadersFrame frame, org.eclipse.jetty.util.Callback callback)
Description copied from interface:StreamSends the given HEADERS
frame.Typically used to send an HTTP response or to send the HTTP response trailers.
-
push
public void push(PushPromiseFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener)
Description copied from interface:StreamSends the given PUSH_PROMISE
frame.
-
data
public void data(DataFrame frame, org.eclipse.jetty.util.Callback callback)
Description copied from interface:StreamSends the given DATA
frame.
-
reset
public void reset(ResetFrame frame, org.eclipse.jetty.util.Callback callback)
Description copied from interface:StreamSends the given RST_STREAM
frame.
-
startWrite
private boolean startWrite(org.eclipse.jetty.util.Callback callback)
-
getAttribute
public java.lang.Object getAttribute(java.lang.String key)
- Specified by:
getAttributein interfaceStream- 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)
-
setAttribute
public void setAttribute(java.lang.String key, java.lang.Object value)- Specified by:
setAttributein interfaceStream- Parameters:
key- the attribute keyvalue- an arbitrary object to associate with the given key to this stream- See Also:
Stream.getAttribute(String),Stream.removeAttribute(String)
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String key)
- Specified by:
removeAttributein interfaceStream- 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()
-
isFailed
private boolean isFailed()
-
isResetOrFailed
public boolean isResetOrFailed()
- Specified by:
isResetOrFailedin interfaceIStream- Returns:
- whether this stream has been reset (locally or remotely) or has been failed
- See Also:
Stream.isReset(),Stream.Listener.onFailure(Stream, int, String, Throwable, Callback)
-
isClosed
public boolean isClosed()
-
isRemotelyClosed
public boolean isRemotelyClosed()
- Specified by:
isRemotelyClosedin interfaceIStream- Returns:
- whether the stream is closed remotely.
- See Also:
Stream.isClosed()
-
isLocallyClosed
public boolean isLocallyClosed()
-
commit
public void commit()
Description copied from interface:IStreamMarks this stream as committed.- Specified by:
commitin interfaceIStream- See Also:
IStream.isCommitted()
-
isCommitted
public boolean isCommitted()
- Specified by:
isCommittedin interfaceIStream- Returns:
- whether bytes for this stream have been sent to the remote peer.
- See Also:
IStream.commit()
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin classorg.eclipse.jetty.io.IdleTimeout
-
onIdleExpired
protected void onIdleExpired(java.util.concurrent.TimeoutException timeout)
- Specified by:
onIdleExpiredin classorg.eclipse.jetty.io.IdleTimeout
-
attributes
private java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object> attributes()
-
getListener
public Stream.Listener getListener()
- Specified by:
getListenerin interfaceIStream- Returns:
- the
Stream.Listenerassociated with this stream - See Also:
IStream.setListener(Stream.Listener)
-
setListener
public void setListener(Stream.Listener listener)
- Specified by:
setListenerin interfaceIStream- Parameters:
listener- theStream.Listenerassociated with this stream- See Also:
IStream.getListener()
-
process
public void process(Frame frame, org.eclipse.jetty.util.Callback callback)
Description copied from interface:IStreamProcesses the given
frame, belonging to this stream.
-
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:IStreamUpdates the close state of this stream.
- Specified by:
updateClosein interfaceIStream- Parameters:
update- whether to update the close stateevent- 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:IStreamUpdates the stream send window by the given
delta.- Specified by:
updateSendWindowin interfaceIStream- 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:IStreamUpdates the stream receive window by the given
delta.- Specified by:
updateRecvWindowin interfaceIStream- 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:IStreamForcibly closes this stream.
-
onClose
public void onClose()
- Overrides:
onClosein classorg.eclipse.jetty.io.IdleTimeout
-
updateStreamCount
private void updateStreamCount(int deltaStream, int deltaClosing)
-
succeeded
public void succeeded()
- Specified by:
succeededin interfaceorg.eclipse.jetty.util.Callback
-
failed
public void failed(java.lang.Throwable x)
- Specified by:
failedin interfaceorg.eclipse.jetty.util.Callback
-
getInvocationType
public org.eclipse.jetty.util.thread.Invocable.InvocationType getInvocationType()
- Specified by:
getInvocationTypein interfaceorg.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:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-