@ManagedObject public abstract class HTTP2Session extends ContainerLifeCycle implements ISession, Parser.Listener
AbstractLifeCycle.AbstractLifeCycleListener
Session.Listener
Parser.Listener.Adapter, Parser.Listener.Wrapper
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Constructor and Description |
---|
HTTP2Session(Scheduler scheduler,
EndPoint endPoint,
Generator generator,
Session.Listener listener,
FlowControlStrategy flowControl,
int initialStreamId) |
Modifier and Type | Method and Description |
---|---|
protected void |
abort(java.lang.Throwable failure) |
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) |
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,
Callback callback,
Frame frame,
Frame... frames)
Enqueues the given frames to be written to the connection.
|
long |
getBytesWritten() |
EndPoint |
getEndPoint() |
FlowControlStrategy |
getFlowControlStrategy() |
Generator |
getGenerator() |
int |
getInitialSessionRecvWindow() |
protected int |
getLastRemoteStreamId() |
int |
getMaxLocalStreams() |
int |
getMaxRemoteStreams() |
int |
getRecvWindow() |
int |
getSendWindow() |
IStream |
getStream(int streamId)
Retrieves the stream with the given
streamId . |
int |
getStreamCount() |
long |
getStreamIdleTimeout() |
java.util.Collection<Stream> |
getStreams() |
int |
getWriteThreshold() |
protected static boolean |
isClientStream(int streamId) |
boolean |
isClosed() |
boolean |
isDisconnected() |
protected boolean |
isLocalStreamClosed(int streamId) |
boolean |
isPushEnabled() |
protected boolean |
isRemoteStreamClosed(int streamId) |
void |
newStream(HeadersFrame frame,
Promise<Stream> promise,
Stream.Listener listener)
Sends the given HEADERS
frame to create a new Stream . |
protected IStream |
newStream(int streamId,
boolean local) |
protected void |
notifyClose(Session session,
GoAwayFrame frame,
Callback callback) |
protected void |
notifyFailure(Session session,
java.lang.Throwable failure,
Callback callback) |
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) |
protected void |
onConnectionFailure(int error,
java.lang.String reason,
Callback callback) |
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 triggers.
|
void |
onPing(PingFrame frame) |
void |
onPriority(PriorityFrame frame) |
void |
onReset(ResetFrame frame) |
protected abstract void |
onResetForUnknownStream(ResetFrame frame) |
void |
onSettings(SettingsFrame frame) |
void |
onSettings(SettingsFrame frame,
boolean reply) |
void |
onShutdown()
A typical close by a remote peer involves a GO_AWAY frame followed by TCP FIN.
|
protected void |
onStreamClosed(IStream stream) |
void |
onStreamFailure(int streamId,
int error,
java.lang.String reason) |
protected void |
onStreamOpened(IStream stream) |
void |
onWindowUpdate(IStream stream,
WindowUpdateFrame frame)
Callback method invoked when a WINDOW_UPDATE frame has been received.
|
void |
onWindowUpdate(WindowUpdateFrame frame) |
void |
ping(PingFrame frame,
Callback callback)
Sends the given PING
frame . |
int |
priority(PriorityFrame frame,
Callback callback)
Sends the given PRIORITY
frame . |
void |
push(IStream stream,
Promise<Stream> promise,
PushPromiseFrame frame,
Stream.Listener listener)
Enqueues the given PUSH_PROMISE frame to be written to the connection.
|
void |
removeStream(IStream stream)
Removes the given
stream . |
protected void |
reset(ResetFrame frame,
Callback callback) |
void |
setInitialSessionRecvWindow(int initialSessionRecvWindow) |
void |
setMaxLocalStreams(int maxLocalStreams) |
void |
setMaxRemoteStreams(int maxRemoteStreams) |
void |
setStreamIdleTimeout(long streamIdleTimeout) |
void |
settings(SettingsFrame frame,
Callback callback)
Sends the given SETTINGS
frame to configure the session. |
void |
setWriteThreshold(int writeThreshold) |
java.lang.String |
toString() |
int |
updateRecvWindow(int delta)
Updates the session receive window by the given
delta . |
int |
updateSendWindow(int delta)
Updates the session send window by the given
delta . |
addBean, 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
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
onPushPromise
dumpObjects, dumpSelf
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
protected void doStop() throws java.lang.Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
java.lang.Exception
@ManagedAttribute(value="The flow control strategy", readonly=true) public FlowControlStrategy getFlowControlStrategy()
public int getMaxLocalStreams()
public void setMaxLocalStreams(int maxLocalStreams)
public int getMaxRemoteStreams()
public void setMaxRemoteStreams(int maxRemoteStreams)
@ManagedAttribute(value="The stream\'s idle timeout") public long getStreamIdleTimeout()
public void setStreamIdleTimeout(long streamIdleTimeout)
@ManagedAttribute(value="The initial size of session\'s flow control receive window") public int getInitialSessionRecvWindow()
public void setInitialSessionRecvWindow(int initialSessionRecvWindow)
public int getWriteThreshold()
public void setWriteThreshold(int writeThreshold)
public EndPoint getEndPoint()
public Generator getGenerator()
public long getBytesWritten()
getBytesWritten
in interface ISession
public void onData(DataFrame frame)
onData
in interface Parser.Listener
public void onData(DataFrame frame, Callback callback)
ISession
Callback method invoked when a DATA frame is received.
protected boolean isLocalStreamClosed(int streamId)
protected boolean isRemoteStreamClosed(int streamId)
public abstract void onHeaders(HeadersFrame frame)
onHeaders
in interface Parser.Listener
public void onPriority(PriorityFrame frame)
onPriority
in interface Parser.Listener
public void onReset(ResetFrame frame)
onReset
in interface Parser.Listener
protected abstract void onResetForUnknownStream(ResetFrame frame)
public void onSettings(SettingsFrame frame)
onSettings
in interface Parser.Listener
public void onSettings(SettingsFrame frame, boolean reply)
public void onPing(PingFrame frame)
onPing
in interface Parser.Listener
public void onGoAway(GoAwayFrame frame)
HTTP2Session.ControlEntry#succeeded()
onGoAway
in interface Parser.Listener
frame
- the GO_AWAY frame that has been received.close(int, String, Callback)
,
onShutdown()
,
onIdleTimeout()
public void onWindowUpdate(WindowUpdateFrame frame)
onWindowUpdate
in interface Parser.Listener
public void onStreamFailure(int streamId, int error, java.lang.String reason)
onStreamFailure
in interface Parser.Listener
public void onConnectionFailure(int error, java.lang.String reason)
onConnectionFailure
in interface Parser.Listener
protected void onConnectionFailure(int error, java.lang.String reason, Callback callback)
public void newStream(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener)
Session
Sends the given HEADERS frame
to create a new Stream
.
public int priority(PriorityFrame frame, Callback callback)
Session
Sends the given PRIORITY frame
.
If the frame
references a streamId
that does not exist
(for example 0
), then a new streamId
will be allocated, to
support unused anchor streams that act as parent for other streams.
public void push(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener)
ISession
Enqueues the given PUSH_PROMISE frame to be written to the connection.
Differently from ISession.frames(IStream, Callback, Frame, Frame...)
, this method
generates atomically the stream id for the pushed stream.
public void settings(SettingsFrame frame, Callback callback)
Session
Sends the given SETTINGS frame
to configure the session.
public void ping(PingFrame frame, Callback callback)
Session
Sends the given PING frame
.
PING frames may be used to test the connection integrity and to measure round-trip time.
protected void reset(ResetFrame frame, Callback callback)
public boolean close(int error, java.lang.String reason, Callback callback)
onShutdown()
.
Otherwise, the idle timeout mechanism will close the connection, see
onIdleTimeout()
.close
in interface Session
error
- the error codereason
- the reasoncallback
- the callback to invoke when the operation is completeonGoAway(GoAwayFrame)
,
onShutdown()
,
onIdleTimeout()
public boolean isClosed()
public void frames(IStream stream, Callback callback, Frame frame, Frame... frames)
ISession
Enqueues the given frames to be written to the connection.
public void data(IStream stream, Callback callback, DataFrame frame)
ISession
Enqueues the given DATA frame to be written to the connection.
protected IStream createLocalStream(int streamId)
protected IStream createRemoteStream(int streamId)
protected IStream newStream(int streamId, boolean local)
public void removeStream(IStream stream)
ISession
Removes the given stream
.
removeStream
in interface ISession
stream
- the stream to removepublic java.util.Collection<Stream> getStreams()
getStreams
in interface Session
@ManagedAttribute(value="The number of active streams") public int getStreamCount()
public IStream getStream(int streamId)
Session
Retrieves the stream with the given streamId
.
@ManagedAttribute(value="The flow control send window", readonly=true) public int getSendWindow()
@ManagedAttribute(value="The flow control receive window", readonly=true) public int getRecvWindow()
public int updateSendWindow(int delta)
ISession
Updates the session send window by the given delta
.
updateSendWindow
in interface ISession
delta
- the delta value (positive or negative) to add to the session send windowpublic int updateRecvWindow(int delta)
ISession
Updates the session receive window by the given delta
.
updateRecvWindow
in interface ISession
delta
- the delta value (positive or negative) to add to the session receive windowpublic void onWindowUpdate(IStream stream, WindowUpdateFrame frame)
ISession
Callback method invoked when a WINDOW_UPDATE frame has been received.
onWindowUpdate
in interface ISession
stream
- the stream the window update belongs to, or null if the window update belongs to the sessionframe
- the WINDOW_UPDATE frame received@ManagedAttribute(value="Whether HTTP/2 push is enabled", readonly=true) public boolean isPushEnabled()
isPushEnabled
in interface ISession
public void onShutdown()
close(int, String, Callback)
.onGoAway(GoAwayFrame)
.onShutdown
in interface ISession
onGoAway(GoAwayFrame)
,
close(int, String, Callback)
,
onIdleTimeout()
public boolean onIdleTimeout()
close(int, String, Callback)
.onGoAway(GoAwayFrame)
.onIdleTimeout
in interface ISession
onGoAway(GoAwayFrame)
,
close(int, String, Callback)
,
onShutdown()
public void onFrame(Frame frame)
ISession
Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.
protected void onStreamOpened(IStream stream)
protected void onStreamClosed(IStream stream)
public void onFlushed(long bytes) throws java.io.IOException
ISession
Callback method invoked when bytes are flushed to the network.
public void disconnect()
protected void abort(java.lang.Throwable failure)
public boolean isDisconnected()
protected int getLastRemoteStreamId()
protected Stream.Listener notifyNewStream(Stream stream, HeadersFrame frame)
protected void notifySettings(Session session, SettingsFrame frame)
protected void notifyReset(Session session, ResetFrame frame)
protected void notifyClose(Session session, GoAwayFrame frame, Callback callback)
protected boolean notifyIdleTimeout(Session session)
protected void notifyFailure(Session session, java.lang.Throwable failure, Callback callback)
protected void notifyHeaders(IStream stream, HeadersFrame frame)
protected static boolean isClientStream(int streamId)
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
Dumpable
dump
in interface Dumpable
dump
in class ContainerLifeCycle
out
- The appendable to dump toindent
- The indent to apply after any new lines.java.io.IOException
- if unable to write to Appendablepublic java.lang.String toString()
toString
in class AbstractLifeCycle
Copyright © 1995–2023 Webtide. All rights reserved.