Class HTTP2Session
- All Implemented Interfaces:
Session
,Parser.Listener
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
- Direct Known Subclasses:
HTTP2ClientSession
,HTTP2ServerSession
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
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.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.api.Session
Session.Listener
-
Field Summary
-
Constructor Summary
ConstructorDescriptionHTTP2Session
(Scheduler scheduler, EndPoint endPoint, Parser parser, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
boolean
Invoked internally and by applications to send a GO_AWAY frame to the other peer.protected HTTP2Stream
createLocalStream
(int streamId, MetaData.Request request, Consumer<Throwable> failFn) protected HTTP2Stream
createRemoteStream
(int streamId, MetaData.Request request) void
data
(HTTP2Stream stream, DataFrame frame, Callback callback) void
protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.void
frames
(HTTP2Stream stream, List<? extends Frame> frames, Callback callback) long
int
protected int
int
int
int
int
int
int
getStream
(int streamId) Retrieves the stream with the givenstreamId
.int
long
long
long
int
boolean
goAway
(GoAwayFrame frame, Callback callback) protected static boolean
isClientStream
(int streamId) boolean
isClosed()
boolean
boolean
protected boolean
isLocalStreamClosed
(int streamId) boolean
protected boolean
isRemoteStreamClosed
(int streamId) protected HTTP2Stream
newStream
(int streamId, MetaData.Request request, boolean local) void
newStream
(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener) Sends the given HEADERSframe
to create a newStream
.void
newStream
(HTTP2Stream.FrameList frames, Promise<Stream> promise, Stream.Listener listener) newUpgradeStream
(HeadersFrame frame, Stream.Listener listener, Consumer<Throwable> failFn) Creates a new stream allocating a stream id if the given HEADERS frame does not have one.protected void
notifyClose
(Session session, GoAwayFrame frame, Callback callback) protected void
notifyFailure
(Session session, Throwable failure, Callback callback) protected void
notifyGoAway
(Session session, GoAwayFrame 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, String reason) void
onData
(Stream.Data data) void
void
void
onGoAway
(GoAwayFrame frame) This method is called when receiving a GO_AWAY from the other peer.abstract void
onHeaders
(HeadersFrame frame) boolean
This method is invoked when the idle timeout expires.void
void
onPriority
(PriorityFrame frame) void
onReset
(ResetFrame frame) protected void
void
onSettings
(SettingsFrame frame) void
onSettings
(SettingsFrame frame, boolean reply) void
This method is called when the TCP FIN is received from the remote peer.void
onStreamFailure
(int streamId, int error, String reason) protected final void
onStreamOpened
(Stream stream) void
onWindowUpdate
(WindowUpdateFrame frame) void
onWindowUpdate
(HTTP2Stream stream, WindowUpdateFrame frame) void
onWriteFailure
(Throwable failure) void
Sends the given PINGframe
.int
priority
(PriorityFrame frame, Callback callback) Sends the given PRIORITYframe
.void
push
(Stream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener) boolean
removeStream
(Stream stream) void
setConnectProtocolEnabled
(boolean connectProtocolEnabled) void
setInitialSessionRecvWindow
(int initialSessionRecvWindow) void
setMaxEncoderTableCapacity
(int maxEncoderTableCapacity) void
setMaxLocalStreams
(int maxLocalStreams) void
setMaxRemoteStreams
(int maxRemoteStreams) void
setMaxTotalLocalStreams
(int maxTotalLocalStreams) void
setStreamIdleTimeout
(long streamIdleTimeout) void
settings
(SettingsFrame frame, Callback callback) Sends the given SETTINGSframe
to configure the session.void
setWriteThreshold
(int writeThreshold) shutdown()
Gracefully closes the session, returning aCompletableFuture
that is completed when all the streams currently being processed are completed.toString()
protected void
updateLastRemoteStreamId
(int streamId) int
updateRecvWindow
(int delta) int
updateSendWindow
(int delta) Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, 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.Container
getCachedBeans, getEventListeners
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 Details
-
HTTP2Session
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Parser parser, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
-
-
Method Details
-
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classContainerLifeCycle
- Throws:
Exception
- If there was a problem stopping. Will cause a transition to FAILED state
-
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
-
setMaxLocalStreams
public void setMaxLocalStreams(int maxLocalStreams) -
getMaxTotalLocalStreams
@ManagedAttribute("The maximum number of local streams that can be opened") public int getMaxTotalLocalStreams() -
setMaxTotalLocalStreams
public void setMaxTotalLocalStreams(int maxTotalLocalStreams) -
getMaxRemoteStreams
@ManagedAttribute("The maximum number of concurrent remote streams") public int getMaxRemoteStreams() -
setMaxRemoteStreams
public void setMaxRemoteStreams(int maxRemoteStreams) -
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
-
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
-
getParser
-
getGenerator
-
getBytesWritten
public long getBytesWritten() -
onData
- Specified by:
onData
in interfaceParser.Listener
-
onData
-
isLocalStreamClosed
protected boolean isLocalStreamClosed(int streamId) -
isRemoteStreamClosed
protected boolean isRemoteStreamClosed(int streamId) -
onHeaders
- Specified by:
onHeaders
in interfaceParser.Listener
-
onPriority
- Specified by:
onPriority
in interfaceParser.Listener
-
onReset
- Specified by:
onReset
in interfaceParser.Listener
-
onResetForUnknownStream
-
onSettings
- Specified by:
onSettings
in interfaceParser.Listener
-
onSettings
-
onPing
- Specified by:
onPing
in interfaceParser.Listener
-
onGoAway
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:
-
onWindowUpdate
- Specified by:
onWindowUpdate
in interfaceParser.Listener
-
onWindowUpdate
-
onStreamFailure
- Specified by:
onStreamFailure
in interfaceParser.Listener
-
onConnectionFailure
- Specified by:
onConnectionFailure
in interfaceParser.Listener
-
onWriteFailure
-
abort
-
newStream
Description copied from interface:Session
Sends the given HEADERS
frame
to create a newStream
. -
newStream
public void newStream(HTTP2Stream.FrameList frames, Promise<Stream> promise, Stream.Listener listener) -
newUpgradeStream
public Stream newUpgradeStream(HeadersFrame frame, Stream.Listener listener, Consumer<Throwable> failFn) Creates a new stream allocating a stream id if the given HEADERS frame does not have one.
- Parameters:
frame
- the HEADERS frame that triggered the stream creation allocated stream id, or null if not interested in the modified headers framelistener
- the listener that gets notified of stream events
-
newStream
-
priority
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(Stream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener) -
settings
Description copied from interface:Session
Sends the given SETTINGS
frame
to configure the session. -
ping
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
Invoked internally and by applications to send a GO_AWAY frame to the other peer.
-
shutdown
Description copied from interface:Session
Gracefully closes the session, returning a
CompletableFuture
that is completed when all the streams currently being processed are completed.Implementation is idempotent, i.e. calling this method a second time or concurrently results in a no-operation.
-
goAway
-
isClosed
public boolean isClosed() -
getCloseState
-
frames
-
data
-
createLocalStream
protected HTTP2Stream createLocalStream(int streamId, MetaData.Request request, Consumer<Throwable> failFn) -
createRemoteStream
-
removeStream
-
getStreams
- Specified by:
getStreams
in interfaceSession
- Returns:
- a snapshot of all the streams currently belonging to this session
-
getStreamCount
-
getStream
Description copied from interface:Session
Retrieves the stream with the given
streamId
. -
getLocalAddress
- Specified by:
getLocalAddress
in interfaceSession
- Returns:
- the local network address this session is bound to,
or
null
if this session is not bound to a network address
-
getLocalSocketAddress
- Specified by:
getLocalSocketAddress
in interfaceSession
- Returns:
- the local network address this session is bound to,
or
null
if this session is not bound to a network address
-
getRemoteAddress
- Specified by:
getRemoteAddress
in interfaceSession
- Returns:
- the remote network address this session is connected to,
or
null
if this session is not connected to a network address
-
getRemoteSocketAddress
- Specified by:
getRemoteSocketAddress
in interfaceSession
- Returns:
- the remote network address this session is connected to,
or
null
if this session is not connected to a network address
-
getSendWindow
-
getRecvWindow
@ManagedAttribute(value="The flow control receive window", readonly=true) public int getRecvWindow() -
updateSendWindow
public int updateSendWindow(int delta) -
updateRecvWindow
public int updateRecvWindow(int delta) -
isPushEnabled
@ManagedAttribute(value="Whether HTTP/2 push is enabled", readonly=true) public boolean isPushEnabled()- Specified by:
isPushEnabled
in interfaceSession
- Returns:
- whether the push functionality is enabled
-
isConnectProtocolEnabled
@ManagedAttribute(value="Whether CONNECT requests supports a protocol", readonly=true) public boolean isConnectProtocolEnabled() -
setConnectProtocolEnabled
public void setConnectProtocolEnabled(boolean connectProtocolEnabled) -
onShutdown
public void onShutdown()This method is called when the TCP FIN is received from the remote peer.
-
onIdleTimeout
public boolean onIdleTimeout()This method is invoked when the idle timeout expires.
- Returns:
- true if the session should be closed, false otherwise
- See Also:
-
onFrame
-
onStreamOpened
-
disconnect
public void disconnect() -
isDisconnected
public boolean isDisconnected() -
getLastRemoteStreamId
protected int getLastRemoteStreamId() -
updateLastRemoteStreamId
protected void updateLastRemoteStreamId(int streamId) -
notifyNewStream
-
notifySettings
-
notifyPing
-
notifyReset
-
notifyGoAway
-
notifyClose
-
notifyIdleTimeout
-
notifyFailure
-
isClientStream
protected static boolean isClientStream(int streamId) -
dump
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:
IOException
- if unable to write to Appendable
-
toString
- Overrides:
toString
in classAbstractLifeCycle
-