ChunkedWriteHandler Class — netty Architecture
Architecture documentation for the ChunkedWriteHandler class in ChunkedWriteHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1e2ef44e_6c44_8584_e44f_ddda636afcfc["ChunkedWriteHandler"] 34e7ab8e_83ca_bc6f_0639_6de9a80f2e92["ChunkedWriteHandler.java"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|defined in| 34e7ab8e_83ca_bc6f_0639_6de9a80f2e92 b452c9e3_b2e6_e974_faf0_f79e56d56f31["ChunkedWriteHandler()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| b452c9e3_b2e6_e974_faf0_f79e56d56f31 efa9902f_a95f_6452_f3cd_2cf326c0b0dd["allocateQueue()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| efa9902f_a95f_6452_f3cd_2cf326c0b0dd 59e2cd7c_239b_2a62_529d_0c2d9e0ea412["queueIsEmpty()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 59e2cd7c_239b_2a62_529d_0c2d9e0ea412 9340847a_ea51_79db_8ecb_e40bf9696424["handlerAdded()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 9340847a_ea51_79db_8ecb_e40bf9696424 45bb37e1_092c_fe4b_5902_ebc8bbf2c033["resumeTransfer()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 45bb37e1_092c_fe4b_5902_ebc8bbf2c033 046072d4_e093_33e5_660c_bf415febf6ae["resumeTransfer0()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 046072d4_e093_33e5_660c_bf415febf6ae 8772a3c8_0f59_0a18_cfc7_49c932daeefd["write()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 8772a3c8_0f59_0a18_cfc7_49c932daeefd ca4aff08_0ab6_b222_41eb_bfd962af48d1["flush()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| ca4aff08_0ab6_b222_41eb_bfd962af48d1 e145c761_5751_60ec_c348_80f23ae93f51["channelInactive()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| e145c761_5751_60ec_c348_80f23ae93f51 28421229_489e_cc1d_e4c9_95eb3986af20["channelWritabilityChanged()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 28421229_489e_cc1d_e4c9_95eb3986af20 5e77e506_0716_aa80_bbd5_9ae4fe677c28["discard()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 5e77e506_0716_aa80_bbd5_9ae4fe677c28 fea31415_af69_2ea8_b80b_97ecc8e7b566["doFlush()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| fea31415_af69_2ea8_b80b_97ecc8e7b566 12066d6b_de59_74be_d499_8c490cf6271c["handleEndOfInputFuture()"] 1e2ef44e_6c44_8584_e44f_ddda636afcfc -->|method| 12066d6b_de59_74be_d499_8c490cf6271c
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java lines 70–393
public class ChunkedWriteHandler extends ChannelDuplexHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(ChunkedWriteHandler.class);
private Queue<PendingWrite> queue;
private volatile ChannelHandlerContext ctx;
public ChunkedWriteHandler() {
}
/**
* @deprecated use {@link #ChunkedWriteHandler()}
*/
@Deprecated
public ChunkedWriteHandler(int maxPendingWrites) {
checkPositive(maxPendingWrites, "maxPendingWrites");
}
private void allocateQueue() {
if (queue == null) {
queue = new ArrayDeque<PendingWrite>();
}
}
private boolean queueIsEmpty() {
return queue == null || queue.isEmpty();
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
}
/**
* Continues to fetch the chunks from the input.
*/
public void resumeTransfer() {
final ChannelHandlerContext ctx = this.ctx;
if (ctx == null) {
return;
}
if (ctx.executor().inEventLoop()) {
resumeTransfer0(ctx);
} else {
// let the transfer resume on the next event loop round
ctx.executor().execute(new Runnable() {
@Override
public void run() {
resumeTransfer0(ctx);
}
});
}
}
private void resumeTransfer0(ChannelHandlerContext ctx) {
try {
doFlush(ctx);
} catch (Exception e) {
logger.warn("Unexpected exception while sending chunks.", e);
}
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (!queueIsEmpty() || msg instanceof ChunkedInput) {
allocateQueue();
queue.add(new PendingWrite(msg, promise));
} else {
ctx.write(msg, promise);
}
}
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
doFlush(ctx);
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
Source
Frequently Asked Questions
What is the ChunkedWriteHandler class?
ChunkedWriteHandler is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java.
Where is ChunkedWriteHandler defined?
ChunkedWriteHandler is defined in handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java at line 70.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free