PendingBytesTracker Class — netty Architecture
Architecture documentation for the PendingBytesTracker class in PendingBytesTracker.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c794d9b2_4fb7_4205_6925_1d8b5283ecaa["PendingBytesTracker"] 7793aa4b_3621_52e5_beda_95a5097c5c3d["PendingBytesTracker.java"] c794d9b2_4fb7_4205_6925_1d8b5283ecaa -->|defined in| 7793aa4b_3621_52e5_beda_95a5097c5c3d 75b6e222_3608_64f9_9650_6fbcc5123a0a["PendingBytesTracker()"] c794d9b2_4fb7_4205_6925_1d8b5283ecaa -->|method| 75b6e222_3608_64f9_9650_6fbcc5123a0a 2825d738_3bb5_a82f_37c5_91815225f609["size()"] c794d9b2_4fb7_4205_6925_1d8b5283ecaa -->|method| 2825d738_3bb5_a82f_37c5_91815225f609 8275e226_a52d_5427_8bfb_d8f34ecfde7e["incrementPendingOutboundBytes()"] c794d9b2_4fb7_4205_6925_1d8b5283ecaa -->|method| 8275e226_a52d_5427_8bfb_d8f34ecfde7e df0b6a77_f274_e4d8_8227_329f7f155db6["decrementPendingOutboundBytes()"] c794d9b2_4fb7_4205_6925_1d8b5283ecaa -->|method| df0b6a77_f274_e4d8_8227_329f7f155db6
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/PendingBytesTracker.java lines 20–104
abstract class PendingBytesTracker implements MessageSizeEstimator.Handle {
private final MessageSizeEstimator.Handle estimatorHandle;
private PendingBytesTracker(MessageSizeEstimator.Handle estimatorHandle) {
this.estimatorHandle = ObjectUtil.checkNotNull(estimatorHandle, "estimatorHandle");
}
@Override
public final int size(Object msg) {
return estimatorHandle.size(msg);
}
public abstract void incrementPendingOutboundBytes(long bytes);
public abstract void decrementPendingOutboundBytes(long bytes);
static PendingBytesTracker newTracker(Channel channel) {
if (channel.pipeline() instanceof DefaultChannelPipeline) {
return new DefaultChannelPipelinePendingBytesTracker((DefaultChannelPipeline) channel.pipeline());
} else {
ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
MessageSizeEstimator.Handle handle = channel.config().getMessageSizeEstimator().newHandle();
// We need to guard against null as channel.unsafe().outboundBuffer() may returned null
// if the channel was already closed when constructing the PendingBytesTracker.
// See https://github.com/netty/netty/issues/3967
return buffer == null ?
new NoopPendingBytesTracker(handle) : new ChannelOutboundBufferPendingBytesTracker(buffer, handle);
}
}
private static final class DefaultChannelPipelinePendingBytesTracker extends PendingBytesTracker {
private final DefaultChannelPipeline pipeline;
DefaultChannelPipelinePendingBytesTracker(DefaultChannelPipeline pipeline) {
super(pipeline.estimatorHandle());
this.pipeline = pipeline;
}
@Override
public void incrementPendingOutboundBytes(long bytes) {
pipeline.incrementPendingOutboundBytes(bytes);
}
@Override
public void decrementPendingOutboundBytes(long bytes) {
pipeline.decrementPendingOutboundBytes(bytes);
}
}
private static final class ChannelOutboundBufferPendingBytesTracker extends PendingBytesTracker {
private final ChannelOutboundBuffer buffer;
ChannelOutboundBufferPendingBytesTracker(
ChannelOutboundBuffer buffer, MessageSizeEstimator.Handle estimatorHandle) {
super(estimatorHandle);
this.buffer = buffer;
}
@Override
public void incrementPendingOutboundBytes(long bytes) {
buffer.incrementPendingOutboundBytes(bytes);
}
@Override
public void decrementPendingOutboundBytes(long bytes) {
buffer.decrementPendingOutboundBytes(bytes);
}
}
private static final class NoopPendingBytesTracker extends PendingBytesTracker {
NoopPendingBytesTracker(MessageSizeEstimator.Handle estimatorHandle) {
super(estimatorHandle);
}
@Override
public void incrementPendingOutboundBytes(long bytes) {
// Noop
}
@Override
public void decrementPendingOutboundBytes(long bytes) {
Source
Frequently Asked Questions
What is the PendingBytesTracker class?
PendingBytesTracker is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/PendingBytesTracker.java.
Where is PendingBytesTracker defined?
PendingBytesTracker is defined in transport/src/main/java/io/netty/channel/PendingBytesTracker.java at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free