Class HTTP2Session
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.http2.HTTP2Session
-
- All Implemented Interfaces:
Session
,ISession
,Parser.Listener
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
- Direct Known Subclasses:
HTTP2ClientSession
,HTTP2ServerSession
@ManagedObject public abstract class HTTP2Session extends ContainerLifeCycle implements ISession, Parser.Listener
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.parser.Parser.Listener
Parser.Listener.Adapter, Parser.Listener.Wrapper
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.api.Session
Session.Listener
-
-
Constructor Summary
Constructors Constructor Description HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
Deprecated.HTTP2Session(Scheduler scheduler, EndPoint endPoint, Parser parser, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
abort(java.lang.String reason, java.lang.Throwable failure, Callback callback)
boolean
close(int error, java.lang.String reason, Callback callback)
Invoked internally and by applications to send a GO_AWAY frame to the other peer.protected IStream
createLocalStream(int streamId, Promise<Stream> promise)
protected IStream
createRemoteStream(int streamId)
void
data(IStream stream, Callback callback, DataFrame frame)
Enqueues the given DATA frame to be written to the connection.void
disconnect()
protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.void
dump(java.lang.Appendable out, java.lang.String indent)
Dump this object (and children) into an Appendable using the provided indent after any new lines.void
frames(IStream stream, java.util.List<? extends Frame> frames, Callback callback)
Enqueues the given frames to be written to the connection.long
getBytesWritten()
CloseState
getCloseState()
EndPoint
getEndPoint()
FlowControlStrategy
getFlowControlStrategy()
Generator
getGenerator()
int
getInitialSessionRecvWindow()
protected int
getLastRemoteStreamId()
int
getMaxEncoderTableCapacity()
int
getMaxLocalStreams()
int
getMaxRemoteStreams()
Parser
getParser()
int
getRecvWindow()
int
getSendWindow()
IStream
getStream(int streamId)
Retrieves the stream with the givenstreamId
.int
getStreamCount()
long
getStreamIdleTimeout()
java.util.Collection<Stream>
getStreams()
long
getStreamsClosed()
long
getStreamsOpened()
int
getWriteThreshold()
boolean
goAway(GoAwayFrame frame, Callback callback)
protected static boolean
isClientStream(int streamId)
boolean
isClosed()
boolean
isDisconnected()
protected boolean
isLocalStreamClosed(int streamId)
boolean
isPushEnabled()
protected boolean
isRemoteStreamClosed(int streamId)
protected IStream
newStream(int streamId, boolean local)
void
newStream(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener)
Sends the given HEADERSframe
to create a newStream
.void
newStream(IStream.FrameList frames, Promise<Stream> promise, Stream.Listener listener)
Sends the given list of frames to create a newStream
.protected void
notifyClose(Session session, GoAwayFrame frame, Callback callback)
protected void
notifyFailure(Session session, java.lang.Throwable failure, Callback callback)
protected void
notifyGoAway(Session session, GoAwayFrame frame)
protected void
notifyHeaders(IStream stream, HeadersFrame frame)
protected boolean
notifyIdleTimeout(Session session)
protected Stream.Listener
notifyNewStream(Stream stream, HeadersFrame frame)
protected void
notifyPing(Session session, PingFrame frame)
protected void
notifyReset(Session session, ResetFrame frame)
protected void
notifySettings(Session session, SettingsFrame frame)
void
onConnectionFailure(int error, java.lang.String reason)
void
onData(DataFrame frame)
void
onData(DataFrame frame, Callback callback)
Callback method invoked when a DATA frame is received.void
onFlushed(long bytes)
Callback method invoked when bytes are flushed to the network.void
onFrame(Frame frame)
Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.void
onGoAway(GoAwayFrame frame)
This method is called when receiving a GO_AWAY from the other peer.abstract void
onHeaders(HeadersFrame frame)
boolean
onIdleTimeout()
This method is invoked when the idle timeout expires.void
onPing(PingFrame frame)
void
onPriority(PriorityFrame frame)
void
onReset(ResetFrame frame)
protected void
onResetForUnknownStream(ResetFrame frame)
void
onSettings(SettingsFrame frame)
void
onSettings(SettingsFrame frame, boolean reply)
void
onShutdown()
This method is called when the TCP FIN is received from the remote peer.void
onStreamFailure(int streamId, int error, java.lang.String reason)
protected void
onStreamOpened(IStream stream)
void
onWindowUpdate(WindowUpdateFrame frame)
void
onWindowUpdate(IStream stream, WindowUpdateFrame frame)
Callback method invoked when a WINDOW_UPDATE frame has been received.void
ping(PingFrame frame, Callback callback)
Sends the given PINGframe
.int
priority(PriorityFrame frame, Callback callback)
Sends the given PRIORITYframe
.void
push(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener)
Enqueues the given PUSH_PROMISE frame to be written to the connection.boolean
removeStream(IStream stream)
Removes the givenstream
.void
setInitialSessionRecvWindow(int initialSessionRecvWindow)
void
setMaxEncoderTableCapacity(int maxEncoderTableCapacity)
void
setMaxLocalStreams(int maxLocalStreams)
void
setMaxRemoteStreams(int maxRemoteStreams)
void
setStreamIdleTimeout(long streamIdleTimeout)
void
settings(SettingsFrame frame, Callback callback)
Sends the given SETTINGSframe
to configure the session.void
setWriteThreshold(int writeThreshold)
java.lang.String
toString()
protected void
updateLastRemoteStreamId(int streamId)
int
updateRecvWindow(int delta)
Updates the session receive window by the givendelta
.int
updateSendWindow(int delta)
Updates the session send window by the givendelta
.-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Methods inherited from interface org.eclipse.jetty.http2.parser.Parser.Listener
onPushPromise
-
-
-
-
Constructor Detail
-
HTTP2Session
@Deprecated public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
Deprecated.
-
HTTP2Session
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Parser parser, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
-
-
Method Detail
-
doStop
protected void doStop() throws java.lang.Exception
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classContainerLifeCycle
- Throws:
java.lang.Exception
-
getFlowControlStrategy
@ManagedAttribute(value="The flow control strategy", readonly=true) public FlowControlStrategy getFlowControlStrategy()
-
getStreamsOpened
@ManagedAttribute(value="The total number of streams opened", readonly=true) public long getStreamsOpened()
-
getStreamsClosed
@ManagedAttribute(value="The total number of streams closed", readonly=true) public long getStreamsClosed()
-
getMaxLocalStreams
@ManagedAttribute("The maximum number of concurrent local streams") public int getMaxLocalStreams()
-
setMaxLocalStreams
public void setMaxLocalStreams(int maxLocalStreams)
-
getMaxRemoteStreams
@ManagedAttribute("The maximum number of concurrent remote streams") public int getMaxRemoteStreams()
-
setMaxRemoteStreams
public void setMaxRemoteStreams(int maxRemoteStreams)
-
getStreamIdleTimeout
@ManagedAttribute("The stream\'s idle timeout") public long getStreamIdleTimeout()
-
setStreamIdleTimeout
public void setStreamIdleTimeout(long streamIdleTimeout)
-
getInitialSessionRecvWindow
@ManagedAttribute("The initial size of session\'s flow control receive window") public int getInitialSessionRecvWindow()
-
setInitialSessionRecvWindow
public void setInitialSessionRecvWindow(int initialSessionRecvWindow)
-
getWriteThreshold
@ManagedAttribute("The number of bytes that trigger a TCP write") public int getWriteThreshold()
-
setWriteThreshold
public void setWriteThreshold(int writeThreshold)
-
getMaxEncoderTableCapacity
@ManagedAttribute("The HPACK encoder dynamic table maximum capacity") public int getMaxEncoderTableCapacity()
-
setMaxEncoderTableCapacity
public void setMaxEncoderTableCapacity(int maxEncoderTableCapacity)
-
getEndPoint
public EndPoint getEndPoint()
-
getParser
public Parser getParser()
-
getGenerator
public Generator getGenerator()
-
getBytesWritten
public long getBytesWritten()
- Specified by:
getBytesWritten
in interfaceISession
- Returns:
- the number of bytes written by this session
-
onData
public void onData(DataFrame frame)
- Specified by:
onData
in interfaceParser.Listener
-
onData
public void onData(DataFrame frame, Callback callback)
Description copied from interface:ISession
Callback method invoked when a DATA frame is received.
-
isLocalStreamClosed
protected boolean isLocalStreamClosed(int streamId)
-
isRemoteStreamClosed
protected boolean isRemoteStreamClosed(int streamId)
-
onHeaders
public abstract void onHeaders(HeadersFrame frame)
- Specified by:
onHeaders
in interfaceParser.Listener
-
onPriority
public void onPriority(PriorityFrame frame)
- Specified by:
onPriority
in interfaceParser.Listener
-
onReset
public void onReset(ResetFrame frame)
- Specified by:
onReset
in interfaceParser.Listener
-
onResetForUnknownStream
protected void onResetForUnknownStream(ResetFrame frame)
-
onSettings
public void onSettings(SettingsFrame frame)
- Specified by:
onSettings
in interfaceParser.Listener
-
onSettings
public void onSettings(SettingsFrame frame, boolean reply)
-
onPing
public void onPing(PingFrame frame)
- Specified by:
onPing
in interfaceParser.Listener
-
onGoAway
public void onGoAway(GoAwayFrame frame)
This method is called when receiving a GO_AWAY from the other peer.
- Specified by:
onGoAway
in interfaceParser.Listener
- Parameters:
frame
- the GO_AWAY frame that has been received.- See Also:
close(int, String, Callback)
,onShutdown()
,onIdleTimeout()
-
onWindowUpdate
public void onWindowUpdate(WindowUpdateFrame frame)
- Specified by:
onWindowUpdate
in interfaceParser.Listener
-
onWindowUpdate
public void onWindowUpdate(IStream stream, WindowUpdateFrame frame)
Description copied from interface:ISession
Callback method invoked when a WINDOW_UPDATE frame has been received.
- Specified by:
onWindowUpdate
in interfaceISession
- Parameters:
stream
- the stream the window update belongs to, or null if the window update belongs to the sessionframe
- the WINDOW_UPDATE frame received
-
onStreamFailure
public void onStreamFailure(int streamId, int error, java.lang.String reason)
- Specified by:
onStreamFailure
in interfaceParser.Listener
-
onConnectionFailure
public void onConnectionFailure(int error, java.lang.String reason)
- Specified by:
onConnectionFailure
in interfaceParser.Listener
-
abort
protected void abort(java.lang.String reason, java.lang.Throwable failure, Callback callback)
-
newStream
public void newStream(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener)
Description copied from interface:Session
Sends the given HEADERS
frame
to create a newStream
.
-
newStream
public void newStream(IStream.FrameList frames, Promise<Stream> promise, Stream.Listener listener)
Description copied from interface:ISession
Sends the given list of frames to create a new
Stream
.
-
priority
public int priority(PriorityFrame frame, Callback callback)
Description copied from interface:Session
Sends the given PRIORITY
frame
.If the
frame
references astreamId
that does not exist (for example0
), then a newstreamId
will be allocated, to support unused anchor streams that act as parent for other streams.
-
push
public void push(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener)
Description copied from interface:ISession
Enqueues the given PUSH_PROMISE frame to be written to the connection.
Differently from
ISession.frames(IStream, List, Callback)
, this method generates atomically the stream id for the pushed stream.
-
settings
public void settings(SettingsFrame frame, Callback callback)
Description copied from interface:Session
Sends the given SETTINGS
frame
to configure the session.
-
ping
public void ping(PingFrame frame, Callback callback)
Description copied from interface:Session
Sends the given PING
frame
.PING frames may be used to test the connection integrity and to measure round-trip time.
-
close
public boolean close(int error, java.lang.String reason, Callback callback)
Invoked internally and by applications to send a GO_AWAY frame to the other peer.
- Specified by:
close
in interfaceSession
- Parameters:
error
- the error codereason
- the reasoncallback
- the callback to invoke when the operation is complete- Returns:
- true if the frame is being sent, false if the session was already closed
- See Also:
onGoAway(GoAwayFrame)
,onShutdown()
,onIdleTimeout()
-
goAway
public boolean goAway(GoAwayFrame frame, Callback callback)
-
isClosed
public boolean isClosed()
-
getCloseState
public CloseState getCloseState()
-
frames
public void frames(IStream stream, java.util.List<? extends Frame> frames, Callback callback)
Description copied from interface:ISession
Enqueues the given frames to be written to the connection.
-
data
public void data(IStream stream, Callback callback, DataFrame frame)
Description copied from interface:ISession
Enqueues the given DATA frame to be written to the connection.
-
createRemoteStream
protected IStream createRemoteStream(int streamId)
-
newStream
protected IStream newStream(int streamId, boolean local)
-
removeStream
public boolean removeStream(IStream stream)
Description copied from interface:ISession
Removes the given
stream
.- Specified by:
removeStream
in interfaceISession
- Parameters:
stream
- the stream to remove- Returns:
- whether the stream was removed
-
getStreams
public java.util.Collection<Stream> getStreams()
- Specified by:
getStreams
in interfaceSession
- Returns:
- a snapshot of all the streams currently belonging to this session
-
getStreamCount
@ManagedAttribute("The number of active streams") public int getStreamCount()
-
getStream
public IStream getStream(int streamId)
Description copied from interface:Session
Retrieves the stream with the given
streamId
.
-
getSendWindow
@ManagedAttribute(value="The flow control send window", readonly=true) public int getSendWindow()
-
getRecvWindow
@ManagedAttribute(value="The flow control receive window", readonly=true) public int getRecvWindow()
-
updateSendWindow
public int updateSendWindow(int delta)
Description copied from interface:ISession
Updates the session send window by the given
delta
.- Specified by:
updateSendWindow
in interfaceISession
- Parameters:
delta
- the delta value (positive or negative) to add to the session send window- Returns:
- the previous value of the session send window
-
updateRecvWindow
public int updateRecvWindow(int delta)
Description copied from interface:ISession
Updates the session receive window by the given
delta
.- Specified by:
updateRecvWindow
in interfaceISession
- Parameters:
delta
- the delta value (positive or negative) to add to the session receive window- Returns:
- the previous value of the session receive window
-
isPushEnabled
@ManagedAttribute(value="Whether HTTP/2 push is enabled", readonly=true) public boolean isPushEnabled()
- Specified by:
isPushEnabled
in interfaceISession
- Returns:
- whether the push functionality is enabled
-
onShutdown
public void onShutdown()
This method is called when the TCP FIN is received from the remote peer.
- Specified by:
onShutdown
in interfaceISession
- See Also:
onGoAway(GoAwayFrame)
,close(int, String, Callback)
,onIdleTimeout()
-
onIdleTimeout
public boolean onIdleTimeout()
This method is invoked when the idle timeout expires.
- Specified by:
onIdleTimeout
in interfaceISession
- Returns:
- true if the session should be closed, false otherwise
- See Also:
onGoAway(GoAwayFrame)
,close(int, String, Callback)
,onShutdown()
-
onFrame
public void onFrame(Frame frame)
Description copied from interface:ISession
Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.
-
onStreamOpened
protected final void onStreamOpened(IStream stream)
-
onFlushed
public void onFlushed(long bytes) throws java.io.IOException
Description copied from interface:ISession
Callback method invoked when bytes are flushed to the network.
-
disconnect
public void disconnect()
-
isDisconnected
public boolean isDisconnected()
-
getLastRemoteStreamId
protected int getLastRemoteStreamId()
-
updateLastRemoteStreamId
protected void updateLastRemoteStreamId(int streamId)
-
notifyNewStream
protected Stream.Listener notifyNewStream(Stream stream, HeadersFrame frame)
-
notifySettings
protected void notifySettings(Session session, SettingsFrame frame)
-
notifyReset
protected void notifyReset(Session session, ResetFrame frame)
-
notifyGoAway
protected void notifyGoAway(Session session, GoAwayFrame frame)
-
notifyClose
protected void notifyClose(Session session, GoAwayFrame frame, Callback callback)
-
notifyIdleTimeout
protected boolean notifyIdleTimeout(Session session)
-
notifyFailure
protected void notifyFailure(Session session, java.lang.Throwable failure, Callback callback)
-
notifyHeaders
protected void notifyHeaders(IStream stream, HeadersFrame frame)
-
isClientStream
protected static boolean isClientStream(int streamId)
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.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 interfaceDumpable
- Overrides:
dump
in classContainerLifeCycle
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
java.io.IOException
- if unable to write to Appendable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractLifeCycle
-
-