IoHandlerContext Type — netty Architecture
Architecture documentation for the IoHandlerContext type/interface in IoHandlerContext.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 20fa981d_ee97_654a_877f_85fa8ce5a7aa["IoHandlerContext"] bafbd103_5970_8399_b71f_26ebc48c3293["IoHandlerContext.java"] 20fa981d_ee97_654a_877f_85fa8ce5a7aa -->|defined in| bafbd103_5970_8399_b71f_26ebc48c3293 style 20fa981d_ee97_654a_877f_85fa8ce5a7aa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/IoHandlerContext.java lines 26–83
public interface IoHandlerContext {
/**
* Returns {@code true} if blocking for IO is allowed or if we should try to do a non-blocking request for IO to be
* ready.
*
* @return {@code true} if allowed, {@code false} otherwise.
*/
boolean canBlock();
/**
* Returns the amount of time left until the scheduled task with the closest deadline should run.
*
* @param currentTimeNanos the current nanos.
* @return nanos
*/
long delayNanos(long currentTimeNanos);
/**
* Returns the absolute point in time at which the next
* closest scheduled task should run or {@code -1} if nothing is scheduled to run.
*
* @return deadline.
*/
long deadlineNanos();
/**
* Reports the amount of time in nanoseconds that was spent actively processing I/O events.
* <p>
* This metric is needed for the dynamic, utilization-based auto-scaling feature
* in {@link MultithreadEventExecutorGroup}. The reported time
* allows the auto-scaler to accurately measure the I/O workload of an event loop.
* <p>
* {@code IoHandler} implementations should measure the time spent in their event processing
* logic and report the duration via this method. This should only include time spent
* actively handling ready I/O events and should <strong>not</strong> include time spent blocking or
* waiting for I/O (e.g., in an {@code epoll_wait}) call.
* <p>
* The default implementation of this method is a no-op. Failing to override it in an
* {@link IoHandlerContext} that supports auto-scaling will result in the I/O utilization
* being perceived as zero.
*
* @param activeNanos The duration in nanoseconds of active, non-blocking I/O work.
*/
default void reportActiveIoTime(long activeNanos) {
// no-op
}
/**
* Returns {@code true} if the I/O handler should measure and report its active I/O time.
* This is used as a guard to avoid the overhead of calling {@link System#nanoTime()}
* when the feature is not in use.
*
* @return {@code true} if active I/O time should be reported, {@code false} otherwise.
*/
default boolean shouldReportActiveIoTime() {
return false;
}
}
Source
Frequently Asked Questions
What is the IoHandlerContext type?
IoHandlerContext is a type/interface in the netty codebase, defined in transport/src/main/java/io/netty/channel/IoHandlerContext.java.
Where is IoHandlerContext defined?
IoHandlerContext is defined in transport/src/main/java/io/netty/channel/IoHandlerContext.java at line 26.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free