private final class DefaultHttp2Connection.DefaultEndpoint<F extends Http2FlowController> extends java.lang.Object implements Http2Connection.Endpoint<F>
Modifier and Type | Field and Description |
---|---|
private F |
flowController |
private int |
lastStreamKnownByPeer |
private int |
maxActiveStreams |
private int |
maxReservedStreams |
private int |
maxStreams |
private int |
nextReservationStreamId
Used for reservation of stream IDs.
|
private int |
nextStreamIdToCreate
The minimum stream ID allowed when creating the next stream.
|
(package private) int |
numActiveStreams |
(package private) int |
numStreams |
private boolean |
pushToAllowed |
private boolean |
server |
Constructor and Description |
---|
DefaultEndpoint(boolean server,
int maxReservedStreams) |
Modifier and Type | Method and Description |
---|---|
private void |
addStream(DefaultHttp2Connection.DefaultStream stream) |
boolean |
allowPushTo()
This is the SETTINGS_ENABLE_PUSH value sent
from the opposite endpoint.
|
void |
allowPushTo(boolean allow)
This is the SETTINGS_ENABLE_PUSH value sent
from the opposite endpoint.
|
boolean |
canOpenStream()
Indicates whether or a stream created by this endpoint can be opened without violating
Http2Connection.Endpoint.maxActiveStreams() . |
private void |
checkNewStreamAllowed(int streamId,
Http2Stream.State state) |
boolean |
created(Http2Stream stream)
Indicates whether or not this endpoint created the given stream.
|
DefaultHttp2Connection.DefaultStream |
createStream(int streamId,
boolean halfClosed)
Creates a stream initiated by this endpoint.
|
F |
flowController()
Gets the flow controller for this endpoint.
|
void |
flowController(F flowController)
Sets the flow controller for this endpoint.
|
int |
incrementAndGetNextStreamId()
Increment and get the next generated stream id this endpoint.
|
private void |
incrementExpectedStreamId(int streamId) |
private boolean |
isLocal() |
boolean |
isServer()
Indicates whether or not this endpoint is the server-side of the connection.
|
boolean |
isValidStreamId(int streamId)
Indicates whether the given streamId is from the set of IDs used by this endpoint to
create new streams.
|
int |
lastStreamCreated()
Gets the ID of the stream last successfully created by this endpoint.
|
int |
lastStreamKnownByPeer()
If a GOAWAY was received for this endpoint, this will be the last stream ID from the
GOAWAY frame.
|
private void |
lastStreamKnownByPeer(int lastKnownStream) |
int |
maxActiveStreams()
Gets the maximum number of streams (created by this endpoint) that are allowed to be active at
the same time.
|
void |
maxActiveStreams(int maxActiveStreams)
Sets the limit for
SETTINGS_MAX_CONCURRENT_STREAMS . |
boolean |
mayHaveCreatedStream(int streamId)
Indicates whether or not this endpoint may have created the given stream.
|
int |
numActiveStreams()
Gets the number of active streams (i.e.
|
Http2Connection.Endpoint<? extends Http2FlowController> |
opposite()
Gets the
Http2Connection.Endpoint opposite this one. |
DefaultHttp2Connection.DefaultStream |
reservePushStream(int streamId,
Http2Stream parent)
Creates a push stream in the reserved state for this endpoint and notifies all listeners.
|
private void |
updateMaxStreams() |
private final boolean server
private int nextStreamIdToCreate
private int nextReservationStreamId
SETTINGS_MAX_CONCURRENT_STREAMS
, in which case they will reserve stream IDs for each
buffered stream.private int lastStreamKnownByPeer
private boolean pushToAllowed
private F extends Http2FlowController flowController
private int maxStreams
private int maxActiveStreams
private final int maxReservedStreams
int numActiveStreams
int numStreams
public int incrementAndGetNextStreamId()
Http2Connection.Endpoint
incrementAndGetNextStreamId
in interface Http2Connection.Endpoint<F extends Http2FlowController>
private void incrementExpectedStreamId(int streamId)
public boolean isValidStreamId(int streamId)
Http2Connection.Endpoint
isValidStreamId
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public boolean mayHaveCreatedStream(int streamId)
Http2Connection.Endpoint
true
if
Http2Connection.Endpoint.isValidStreamId(int)
and streamId
<= Http2Connection.Endpoint.lastStreamCreated()
.mayHaveCreatedStream
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public boolean canOpenStream()
Http2Connection.Endpoint
Http2Connection.Endpoint.maxActiveStreams()
.canOpenStream
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public DefaultHttp2Connection.DefaultStream createStream(int streamId, boolean halfClosed) throws Http2Exception
Http2Connection.Endpoint
Http2Connection.Endpoint.canOpenStream()
is false
.
The initial state of the stream will be immediately set before notifying Http2Connection.Listener
s. The state
transition is sensitive to halfClosed
and is defined by Http2Stream.open(boolean)
.
createStream
in interface Http2Connection.Endpoint<F extends Http2FlowController>
streamId
- The ID of the streamhalfClosed
- see Http2Stream.open(boolean)
.Http2Exception
Http2Stream.open(boolean)
public boolean created(Http2Stream stream)
Http2Connection.Endpoint
created
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public boolean isServer()
Http2Connection.Endpoint
isServer
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public DefaultHttp2Connection.DefaultStream reservePushStream(int streamId, Http2Stream parent) throws Http2Exception
Http2Connection.Endpoint
OPEN
from the side sending the push
promise.reservePushStream
in interface Http2Connection.Endpoint<F extends Http2FlowController>
streamId
- the ID of the push streamparent
- the parent stream used to initiate the push stream.Http2Exception
private void addStream(DefaultHttp2Connection.DefaultStream stream)
public void allowPushTo(boolean allow)
Http2Connection.Endpoint
SETTINGS
frame.allowPushTo
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public boolean allowPushTo()
Http2Connection.Endpoint
true
for the client endpoint and always false
for a server endpoint.allowPushTo
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public int numActiveStreams()
Http2Connection.Endpoint
OPEN
or HALF CLOSED
) that were created by this
endpoint.numActiveStreams
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public int maxActiveStreams()
Http2Connection.Endpoint
The default value returned by this method must be "unlimited".
maxActiveStreams
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public void maxActiveStreams(int maxActiveStreams)
Http2Connection.Endpoint
SETTINGS_MAX_CONCURRENT_STREAMS
.maxActiveStreams
in interface Http2Connection.Endpoint<F extends Http2FlowController>
maxActiveStreams
- The maximum number of streams (created by this endpoint) that are allowed to be
active at once. This is the
SETTINGS_MAX_CONCURRENT_STREAMS value sent
from the opposite endpoint to restrict stream creation by this endpoint.public int lastStreamCreated()
Http2Connection.Endpoint
lastStreamCreated
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public int lastStreamKnownByPeer()
Http2Connection.Endpoint
-1
.lastStreamKnownByPeer
in interface Http2Connection.Endpoint<F extends Http2FlowController>
private void lastStreamKnownByPeer(int lastKnownStream)
public F flowController()
Http2Connection.Endpoint
flowController
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public void flowController(F flowController)
Http2Connection.Endpoint
flowController
in interface Http2Connection.Endpoint<F extends Http2FlowController>
public Http2Connection.Endpoint<? extends Http2FlowController> opposite()
Http2Connection.Endpoint
Http2Connection.Endpoint
opposite this one.opposite
in interface Http2Connection.Endpoint<F extends Http2FlowController>
private void updateMaxStreams()
private void checkNewStreamAllowed(int streamId, Http2Stream.State state) throws Http2Exception
Http2Exception
private boolean isLocal()