WritabilityMonitor Class — netty Architecture
Architecture documentation for the WritabilityMonitor class in DefaultHttp2RemoteFlowController.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 095a31fa_5eda_a3b5_9421_f6a5ba1d388c["WritabilityMonitor"] 387ab0e0_5536_b5a6_dd1e_6048c918e522["DefaultHttp2RemoteFlowController.java"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|defined in| 387ab0e0_5536_b5a6_dd1e_6048c918e522 b418b091_1216_530c_9ba3_7c08661c27d1["write()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| b418b091_1216_530c_9ba3_7c08661c27d1 f7bee684_84ef_b88a_9642_52916375da52["channelWritabilityChange()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| f7bee684_84ef_b88a_9642_52916375da52 c7b70004_1a90_09f1_9939_cc705b244d1d["stateCancelled()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| c7b70004_1a90_09f1_9939_cc705b244d1d 0a0c0c02_ed9a_9be0_3aa6_bd10b613b1d0["windowSize()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| 0a0c0c02_ed9a_9be0_3aa6_bd10b613b1d0 11849e18_d9ef_64e9_d508_35c077f67430["incrementWindowSize()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| 11849e18_d9ef_64e9_d508_35c077f67430 32e9eb66_5e13_84c4_008c_4cb17f23fa24["enqueueFrame()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| 32e9eb66_5e13_84c4_008c_4cb17f23fa24 b6fe1448_ec3d_bdd8_459c_eaf0fb563bce["incrementPendingBytes()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| b6fe1448_ec3d_bdd8_459c_eaf0fb563bce df1d8530_f007_6158_5a9b_c0b221ef5241["isWritable()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| df1d8530_f007_6158_5a9b_c0b221ef5241 1b91d5a0_59ed_e138_1c7d_a8c48586e1ad["writePendingBytes()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| 1b91d5a0_59ed_e138_1c7d_a8c48586e1ad 4726301f_0167_8ad7_ccda_f3c46efe04f9["initialWindowSize()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| 4726301f_0167_8ad7_ccda_f3c46efe04f9 f3d43993_1ede_3353_8257_e436049bf804["isWritableConnection()"] 095a31fa_5eda_a3b5_9421_f6a5ba1d388c -->|method| f3d43993_1ede_3353_8257_e436049bf804
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java lines 539–658
private class WritabilityMonitor implements StreamByteDistributor.Writer {
private boolean inWritePendingBytes;
private long totalPendingBytes;
@Override
public final void write(Http2Stream stream, int numBytes) {
state(stream).writeAllocatedBytes(numBytes);
}
/**
* Called when the writability of the underlying channel changes.
* @throws Http2Exception If a write occurs and an exception happens in the write operation.
*/
void channelWritabilityChange() throws Http2Exception { }
/**
* Called when the state is cancelled.
* @param state the state that was cancelled.
*/
void stateCancelled(FlowState state) { }
/**
* Set the initial window size for {@code state}.
* @param state the state to change the initial window size for.
* @param initialWindowSize the size of the window in bytes.
*/
void windowSize(FlowState state, int initialWindowSize) {
state.windowSize(initialWindowSize);
}
/**
* Increment the window size for a particular stream.
* @param state the state associated with the stream whose window is being incremented.
* @param delta The amount to increment by.
* @throws Http2Exception If this operation overflows the window for {@code state}.
*/
void incrementWindowSize(FlowState state, int delta) throws Http2Exception {
state.incrementStreamWindow(delta);
}
/**
* Add a frame to be sent via flow control.
* @param state The state associated with the stream which the {@code frame} is associated with.
* @param frame the frame to enqueue.
* @throws Http2Exception If a writability error occurs.
*/
void enqueueFrame(FlowState state, FlowControlled frame) throws Http2Exception {
state.enqueueFrame(frame);
}
/**
* Increment the total amount of pending bytes for all streams. When any stream's pending bytes changes
* method should be called.
* @param delta The amount to increment by.
*/
final void incrementPendingBytes(int delta) {
totalPendingBytes += delta;
// Notification of writibilty change should be delayed until the end of the top level event.
// This is to ensure the flow controller is more consistent state before calling external listener methods.
}
/**
* Determine if the stream associated with {@code state} is writable.
* @param state The state which is associated with the stream to test writability for.
* @return {@code true} if {@link FlowState#stream()} is writable. {@code false} otherwise.
*/
final boolean isWritable(FlowState state) {
return isWritableConnection() && state.isWritable();
}
final void writePendingBytes() throws Http2Exception {
// Reentry is not permitted during the byte distribution process. It may lead to undesirable distribution of
// bytes and even infinite loops. We protect against reentry and make sure each call has an opportunity to
// cause a distribution to occur. This may be useful for example if the channel's writability changes from
// Writable -> Not Writable (because we are writing) -> Writable (because the user flushed to make more room
// in the channel outbound buffer).
if (inWritePendingBytes) {
return;
}
inWritePendingBytes = true;
Defined In
Source
Frequently Asked Questions
What is the WritabilityMonitor class?
WritabilityMonitor is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java.
Where is WritabilityMonitor defined?
WritabilityMonitor is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java at line 539.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free