@ManagedObject public abstract class HTTP2Session extends ContainerLifeCycle implements ISession, Parser.Listener
AbstractLifeCycle.AbstractLifeCycleListener
Session.Listener
Parser.Listener.Adapter
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(Throwable failure) |
boolean |
close(int error,
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 |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
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() |
int |
getMaxLocalStreams() |
int |
getMaxRemoteStreams() |
int |
getRecvWindow() |
int |
getSendWindow() |
IStream |
getStream(int streamId)
Retrieves the stream with the given
streamId . |
int |
getStreamCount() |
long |
getStreamIdleTimeout() |
Collection<Stream> |
getStreams() |
boolean |
isClosed() |
boolean |
isDisconnected() |
boolean |
isPushEnabled() |
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) |
protected void |
notifyFailure(Session session,
Throwable failure) |
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(DataFrame frame) |
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) |
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) |
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. |
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, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, 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
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
protected void doStart() throws Exception
ContainerLifeCycle
doStart
in class ContainerLifeCycle
Exception
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
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 EndPoint getEndPoint()
public Generator getGenerator()
public long getBytesWritten()
getBytesWritten
in interface ISession
public void onData(DataFrame frame)
onData
in interface Parser.Listener
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
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()
* In all other cases, we do nothing since other methods are already
performing their actions.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 onConnectionFailure(int error, String reason)
onConnectionFailure
in interface Parser.Listener
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, String reason, Callback callback)
onShutdown()
.
Otherwise, the idle timeout mechanism will close the connection, see
onIdleTimeout()
.
* In all other cases, we do nothing since other methods are already
performing their actions.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 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 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)
.
* REMOTELY_CLOSED: we received the GO_AWAY, and the TCP FIN afterwards, so we
do nothing since the handling of the GO_AWAY will take care of closing the
connection. See onGoAway(GoAwayFrame)
.onShutdown
in interface ISession
onGoAway(GoAwayFrame)
,
close(int, String, Callback)
,
onIdleTimeout()
public boolean onIdleTimeout()
close(int, String, Callback)
.
* LOCALLY_CLOSED: we have sent a GO_AWAY and only shutdown the output, but the
other peer did not close the connection so we never received the TCP FIN, and
therefore we terminate.
* REMOTELY_CLOSED: the other peer sent us a GO_AWAY, we should have queued a
disconnect, but for some reason it was not processed (for example, queue was
stuck because of TCP congestion), therefore we terminate.
See 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 disconnect()
protected void abort(Throwable failure)
public boolean isDisconnected()
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)
protected boolean notifyIdleTimeout(Session session)
Copyright © 1995-2016 Webtide. All Rights Reserved.