Class HTTP2Session
- All Implemented Interfaces:
Session,ISession,Parser.Listener,org.eclipse.jetty.util.component.Container,org.eclipse.jetty.util.component.Destroyable,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.util.component.Dumpable.DumpableContainer,org.eclipse.jetty.util.component.LifeCycle
- Direct Known Subclasses:
HTTP2ClientSession,HTTP2ServerSession
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classprivate classprivate classprivate classThe HTTP/2 specification requires that stream ids are monotonically increasing, see RFC 7540, 5.1.1.Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.http2.parser.Parser.Listener
Parser.Listener.Adapter, Parser.Listener.WrapperNested classes/interfaces inherited from interface org.eclipse.jetty.http2.api.Session
Session.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicLongprivate final org.eclipse.jetty.io.EndPointprivate final FlowControlStrategyprivate final HTTP2Flusherprivate final Generatorprivate intprivate final AtomicIntegerprivate final Session.Listenerprivate final AtomicIntegerprivate final AtomicIntegerprivate static final org.eclipse.jetty.util.log.Loggerprivate intprivate intprivate intprivate final Parserprivate booleanprivate final AtomicIntegerprivate final org.eclipse.jetty.util.AtomicBiIntegerprivate final org.eclipse.jetty.util.thread.Schedulerprivate final AtomicIntegerprivate longprivate final ConcurrentMap<Integer, IStream> private final AtomicLongprivate final AtomicLongprivate final HTTP2Session.StreamsStateprivate intFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
ConstructorsConstructorDescriptionHTTP2Session(org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId) Deprecated.HTTP2Session(org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.EndPoint endPoint, Parser parser, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleanInvoked internally and by applications to send a GO_AWAY frame to the other peer.private voidprivate voidprotected IStreamcreateLocalStream(int streamId, org.eclipse.jetty.util.Promise<Stream> promise) protected IStreamcreateRemoteStream(int streamId) voidEnqueues the given DATA frame to be written to the connection.voidprotected voiddoStop()voiddump(Appendable out, String indent) private voidfailStream(Stream stream, int error, String reason, Throwable failure, org.eclipse.jetty.util.Callback callback) private voidfailStreams(Predicate<IStream> matcher, String reason, boolean reset) private voidframe(HTTP2Flusher.Entry entry, boolean flush) voidEnqueues the given frames to be written to the connection.longorg.eclipse.jetty.io.EndPointintprotected intintintintintintgetStream(int streamId) Retrieves the stream with the givenstreamId.intlonglonglongintbooleangoAway(GoAwayFrame frame, org.eclipse.jetty.util.Callback callback) protected static booleanisClientStream(int streamId) booleanisClosed()booleanprivate booleanisLocalStream(int streamId) protected booleanisLocalStreamClosed(int streamId) booleanprotected booleanisRemoteStreamClosed(int streamId) private booleanisStreamClosed(int streamId) private HTTP2Flusher.Entryprivate GoAwayFramenewGoAwayFrame(int lastRemoteStreamId, int error, String reason) private GoAwayFramenewGoAwayFrame(int error, String reason) protected IStreamnewStream(int streamId, boolean local) voidnewStream(HeadersFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener) Sends the given HEADERSframeto create a newStream.voidnewStream(IStream.FrameList frames, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener) Sends the given list of frames to create a newStream.private voidnotIdle()protected voidnotifyClose(Session session, GoAwayFrame frame, org.eclipse.jetty.util.Callback callback) protected voidnotifyFailure(Session session, Throwable failure, org.eclipse.jetty.util.Callback callback) protected voidnotifyGoAway(Session session, GoAwayFrame frame) protected voidnotifyHeaders(IStream stream, HeadersFrame frame) protected booleannotifyIdleTimeout(Session session) protected Stream.ListenernotifyNewStream(Stream stream, HeadersFrame frame) protected voidnotifyPing(Session session, PingFrame frame) protected voidnotifyReset(Session session, ResetFrame frame) protected voidnotifySettings(Session session, SettingsFrame frame) voidonConnectionFailure(int error, String reason) voidvoidCallback method invoked when a DATA frame is received.private voidvoidonFlushed(long bytes) Callback method invoked when bytes are flushed to the network.voidCallback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.voidonGoAway(GoAwayFrame frame) This method is called when receiving a GO_AWAY from the other peer.abstract voidonHeaders(HeadersFrame frame) booleanThis method is invoked when the idle timeout expires.voidvoidonPriority(PriorityFrame frame) voidonReset(ResetFrame frame) protected voidprivate voidonSessionFailure(int error, String reason, org.eclipse.jetty.util.Callback callback) voidonSettings(SettingsFrame frame) voidonSettings(SettingsFrame frame, boolean reply) voidThis method is called when the TCP FIN is received from the remote peer.private voidonStreamClosed(IStream stream) private voidonStreamCreated(int streamId) private voidonStreamDestroyed(int streamId) voidonStreamFailure(int streamId, int error, String reason) protected final voidonStreamOpened(IStream stream) voidonWindowUpdate(WindowUpdateFrame frame) voidonWindowUpdate(IStream stream, WindowUpdateFrame frame) Callback method invoked when a WINDOW_UPDATE frame has been received.(package private) voidonWriteFailure(Throwable failure) voidSends the given PINGframe.intpriority(PriorityFrame frame, org.eclipse.jetty.util.Callback callback) Sends the given PRIORITYframe.voidpush(IStream stream, org.eclipse.jetty.util.Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener) Enqueues the given PUSH_PROMISE frame to be written to the connection.booleanremoveStream(IStream stream) Removes the givenstream.(package private) voidreset(IStream stream, ResetFrame frame, org.eclipse.jetty.util.Callback callback) voidsetInitialSessionRecvWindow(int initialSessionRecvWindow) voidsetMaxEncoderTableCapacity(int maxEncoderTableCapacity) voidsetMaxLocalStreams(int maxLocalStreams) voidsetMaxRemoteStreams(int maxRemoteStreams) voidsetStreamIdleTimeout(long streamIdleTimeout) voidsettings(SettingsFrame frame, org.eclipse.jetty.util.Callback callback) Sends the given SETTINGSframeto configure the session.voidsetWriteThreshold(int writeThreshold) private voidprivate ThrowabletoString()protected voidupdateLastRemoteStreamId(int streamId) intupdateRecvWindow(int delta) Updates the session receive window by the givendelta.intupdateSendWindow(int delta) Updates the session send window by the givendelta.(package private) voidupdateStreamCount(boolean local, int deltaStreams, int deltaClosing) 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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface org.eclipse.jetty.http2.parser.Parser.Listener
onPushPromise
-
Field Details
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG -
streams
-
streamsOpened
-
streamsClosed
-
streamsState
-
localStreamIds
-
lastRemoteStreamId
-
localStreamCount
-
remoteStreamCount
private final org.eclipse.jetty.util.AtomicBiInteger remoteStreamCount -
sendWindow
-
recvWindow
-
bytesWritten
-
scheduler
private final org.eclipse.jetty.util.thread.Scheduler scheduler -
endPoint
private final org.eclipse.jetty.io.EndPoint endPoint -
parser
-
generator
-
listener
-
flowControl
-
flusher
-
maxLocalStreams
private int maxLocalStreams -
maxRemoteStreams
private int maxRemoteStreams -
streamIdleTimeout
private long streamIdleTimeout -
initialSessionRecvWindow
private int initialSessionRecvWindow -
writeThreshold
private int writeThreshold -
maxEncoderTableCapacity
private int maxEncoderTableCapacity -
pushEnabled
private boolean pushEnabled
-
-
Constructor Details
-
HTTP2Session
@Deprecated public HTTP2Session(org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId) Deprecated. -
HTTP2Session
public HTTP2Session(org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.EndPoint endPoint, Parser parser, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
-
-
Method Details
-
doStop
- Overrides:
doStopin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
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 org.eclipse.jetty.io.EndPoint getEndPoint() -
getParser
-
getGenerator
-
getBytesWritten
public long getBytesWritten()- Specified by:
getBytesWrittenin interfaceISession- Returns:
- the number of bytes written by this session
-
onData
- Specified by:
onDatain interfaceParser.Listener
-
onData
Description copied from interface:ISessionCallback method invoked when a DATA frame is received.
-
isStreamClosed
private boolean isStreamClosed(int streamId) -
isLocalStream
private boolean isLocalStream(int streamId) -
isLocalStreamClosed
protected boolean isLocalStreamClosed(int streamId) -
isRemoteStreamClosed
protected boolean isRemoteStreamClosed(int streamId) -
onHeaders
- Specified by:
onHeadersin interfaceParser.Listener
-
onPriority
- Specified by:
onPriorityin interfaceParser.Listener
-
onReset
- Specified by:
onResetin interfaceParser.Listener
-
onResetForUnknownStream
-
onSettings
- Specified by:
onSettingsin interfaceParser.Listener
-
onSettings
-
configure
-
onPing
- Specified by:
onPingin interfaceParser.Listener
-
onGoAway
This method is called when receiving a GO_AWAY from the other peer.
- Specified by:
onGoAwayin interfaceParser.Listener- Parameters:
frame- the GO_AWAY frame that has been received.- See Also:
-
onWindowUpdate
- Specified by:
onWindowUpdatein interfaceParser.Listener
-
onWindowUpdate
Description copied from interface:ISessionCallback method invoked when a WINDOW_UPDATE frame has been received.
- Specified by:
onWindowUpdatein 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
- Specified by:
onStreamFailurein interfaceParser.Listener
-
onConnectionFailure
- Specified by:
onConnectionFailurein interfaceParser.Listener
-
onSessionFailure
-
onWriteFailure
-
abort
-
onFailure
-
failStreams
-
failStream
-
toFailure
-
newStream
public void newStream(HeadersFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener) Description copied from interface:SessionSends the given HEADERS
frameto create a newStream. -
newStream
public void newStream(IStream.FrameList frames, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener) Description copied from interface:ISessionSends the given list of frames to create a new
Stream. -
priority
Description copied from interface:SessionSends the given PRIORITY
frame.If the
framereferences astreamIdthat does not exist (for example0), then a newstreamIdwill be allocated, to support unused anchor streams that act as parent for other streams. -
push
public void push(IStream stream, org.eclipse.jetty.util.Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener) Description copied from interface:ISessionEnqueues 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
Description copied from interface:SessionSends the given SETTINGS
frameto configure the session. -
ping
Description copied from interface:SessionSends the given PING
frame.PING frames may be used to test the connection integrity and to measure round-trip time.
-
reset
-
close
Invoked internally and by applications to send a GO_AWAY frame to the other peer.
-
goAway
-
newGoAwayFrame
-
newGoAwayFrame
-
isClosed
public boolean isClosed() -
getCloseState
-
control
-
frames
public void frames(IStream stream, List<? extends Frame> frames, org.eclipse.jetty.util.Callback callback) Description copied from interface:ISessionEnqueues the given frames to be written to the connection.
-
newEntry
private HTTP2Flusher.Entry newEntry(Frame frame, IStream stream, org.eclipse.jetty.util.Callback callback) -
data
Description copied from interface:ISessionEnqueues the given DATA frame to be written to the connection.
-
frame
-
createLocalStream
-
createRemoteStream
-
updateStreamCount
void updateStreamCount(boolean local, int deltaStreams, int deltaClosing) -
newStream
-
removeStream
Description copied from interface:ISessionRemoves the given
stream.- Specified by:
removeStreamin interfaceISession- Parameters:
stream- the stream to remove- Returns:
- whether the stream was removed
-
getStreams
- Specified by:
getStreamsin interfaceSession- Returns:
- a snapshot of all the streams currently belonging to this session
-
getStreamCount
@ManagedAttribute("The number of active streams") public int getStreamCount() -
getStream
Description copied from interface:SessionRetrieves 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:ISessionUpdates the session send window by the given
delta.- Specified by:
updateSendWindowin 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:ISessionUpdates the session receive window by the given
delta.- Specified by:
updateRecvWindowin 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:
isPushEnabledin 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:
onShutdownin interfaceISession- See Also:
-
onIdleTimeout
public boolean onIdleTimeout()This method is invoked when the idle timeout expires.
- Specified by:
onIdleTimeoutin interfaceISession- Returns:
- true if the session should be closed, false otherwise
- See Also:
-
notIdle
private void notIdle() -
onFrame
Description copied from interface:ISessionCallback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.
-
onStreamCreated
private void onStreamCreated(int streamId) -
onStreamOpened
-
onStreamClosed
-
onStreamDestroyed
private void onStreamDestroyed(int streamId) -
onFlushed
Description copied from interface:ISessionCallback method invoked when bytes are flushed to the network.
- Specified by:
onFlushedin interfaceISession- Parameters:
bytes- the number of bytes flushed to the network- Throws:
IOException- if the flush should fail
-
terminate
-
disconnect
public void disconnect() -
isDisconnected
public boolean isDisconnected() -
getLastRemoteStreamId
protected int getLastRemoteStreamId() -
updateLastRemoteStreamId
protected void updateLastRemoteStreamId(int streamId) -
notifyNewStream
-
notifySettings
-
notifyPing
-
notifyReset
-
notifyGoAway
-
notifyClose
protected void notifyClose(Session session, GoAwayFrame frame, org.eclipse.jetty.util.Callback callback) -
notifyIdleTimeout
-
notifyFailure
-
notifyHeaders
-
isClientStream
protected static boolean isClientStream(int streamId) -
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Overrides:
dumpin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
IOException
-
toString
- Overrides:
toStringin classorg.eclipse.jetty.util.component.AbstractLifeCycle
-