DefaultEndpoint Class — netty Architecture
Architecture documentation for the DefaultEndpoint class in DefaultHttp2Connection.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84["DefaultEndpoint"] c1b91a38_3d50_98cc_116d_1d9e5bc49432["DefaultHttp2Connection.java"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|defined in| c1b91a38_3d50_98cc_116d_1d9e5bc49432 1c3025b8_fb94_d072_6f5e_99925dc74fa1["DefaultEndpoint()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 1c3025b8_fb94_d072_6f5e_99925dc74fa1 55d6bddb_2b89_56fb_23b0_72ee357c6118["incrementAndGetNextStreamId()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 55d6bddb_2b89_56fb_23b0_72ee357c6118 d07008fb_0112_ca84_34c9_1cd022951147["incrementExpectedStreamId()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| d07008fb_0112_ca84_34c9_1cd022951147 36dea6ba_23b3_cc56_baf0_358018c65dc1["isValidStreamId()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 36dea6ba_23b3_cc56_baf0_358018c65dc1 dd504b42_7fd8_c9e4_7833_8863cdffb657["mayHaveCreatedStream()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| dd504b42_7fd8_c9e4_7833_8863cdffb657 88dfd231_33bb_8529_db43_2bb61c56d210["canOpenStream()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 88dfd231_33bb_8529_db43_2bb61c56d210 70d81cb4_4074_f43b_ccc8_18d7b3da8dc5["DefaultStream()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 70d81cb4_4074_f43b_ccc8_18d7b3da8dc5 ba4a95c5_3cfa_ef09_2ce9_5f80920f3313["created()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| ba4a95c5_3cfa_ef09_2ce9_5f80920f3313 df43bd9c_081c_e03f_93ce_d7d1806d1f36["isServer()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| df43bd9c_081c_e03f_93ce_d7d1806d1f36 bdf9e048_5016_bfd6_6f40_02cd1d34b189["addStream()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| bdf9e048_5016_bfd6_6f40_02cd1d34b189 99f1447c_1bfc_d9fe_4cb8_61a3bca25ad5["allowPushTo()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 99f1447c_1bfc_d9fe_4cb8_61a3bca25ad5 e868e239_1a00_7e01_7d0b_97836799873d["numActiveStreams()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| e868e239_1a00_7e01_7d0b_97836799873d 035de25c_29bd_8119_0d8c_a7d33a345a90["maxActiveStreams()"] 4fff0ad9_a79c_4bdb_3e93_54ee4440ca84 -->|method| 035de25c_29bd_8119_0d8c_a7d33a345a90
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java lines 694–950
private final class DefaultEndpoint<F extends Http2FlowController> implements Endpoint<F> {
private final boolean server;
/**
* This is an always increasing sequence number used to hash {@link DefaultStream} instances.
*/
private long lastCreatedStreamIdentity;
/**
* The minimum stream ID allowed when creating the next stream. This only applies at the time the stream is
* created. If the ID of the stream being created is less than this value, stream creation will fail. Upon
* successful creation of a stream, this value is incremented to the next valid stream ID.
*/
private int nextStreamIdToCreate;
/**
* Used for reservation of stream IDs. Stream IDs can be reserved in advance by applications before the streams
* are actually created. For example, applications may choose to buffer stream creation attempts as a way of
* working around {@code SETTINGS_MAX_CONCURRENT_STREAMS}, in which case they will reserve stream IDs for each
* buffered stream.
*/
private int nextReservationStreamId;
private int lastStreamKnownByPeer = -1;
private boolean pushToAllowed;
private F flowController;
private int maxStreams;
private int maxActiveStreams;
private final int maxReservedStreams;
// Fields accessed by inner classes
int numActiveStreams;
int numStreams;
DefaultEndpoint(boolean server, int maxReservedStreams) {
this.lastCreatedStreamIdentity = 0;
this.server = server;
// Determine the starting stream ID for this endpoint. Client-initiated streams
// are odd and server-initiated streams are even. Zero is reserved for the
// connection. Stream 1 is reserved client-initiated stream for responding to an
// upgrade from HTTP 1.1.
if (server) {
nextStreamIdToCreate = 2;
nextReservationStreamId = 0;
} else {
nextStreamIdToCreate = 1;
// For manually created client-side streams, 1 is reserved for HTTP upgrade, so start at 3.
nextReservationStreamId = 1;
}
// Push is disallowed by default for servers and allowed for clients.
pushToAllowed = !server;
maxActiveStreams = MAX_VALUE;
this.maxReservedStreams = checkPositiveOrZero(maxReservedStreams, "maxReservedStreams");
updateMaxStreams();
}
@Override
public int incrementAndGetNextStreamId() {
return nextReservationStreamId >= 0 ? nextReservationStreamId += 2 : nextReservationStreamId;
}
private void incrementExpectedStreamId(int streamId) {
if (streamId > nextReservationStreamId && nextReservationStreamId >= 0) {
nextReservationStreamId = streamId;
}
nextStreamIdToCreate = streamId + 2;
++numStreams;
}
@Override
public boolean isValidStreamId(int streamId) {
return streamId > 0 && server == ((streamId & 1) == 0);
}
@Override
public boolean mayHaveCreatedStream(int streamId) {
return isValidStreamId(streamId) && streamId <= lastStreamCreated();
}
@Override
public boolean canOpenStream() {
return numActiveStreams < maxActiveStreams;
}
Source
Frequently Asked Questions
What is the DefaultEndpoint class?
DefaultEndpoint is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java.
Where is DefaultEndpoint defined?
DefaultEndpoint is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java at line 694.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free