Interface IoHandlerContext

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      boolean canBlock()
      Returns true if blocking for IO is allowed or if we should try to do a non-blocking request for IO to be ready.
      long deadlineNanos()
      Returns the absolute point in time at which the next closest scheduled task should run or -1 if nothing is scheduled to run.
      long delayNanos​(long currentTimeNanos)
      Returns the amount of time left until the scheduled task with the closest deadline should run.
      default void reportActiveIoTime​(long activeNanos)
      Reports the amount of time in nanoseconds that was spent actively processing I/O events.
      default boolean shouldReportActiveIoTime()
      Returns true if the I/O handler should measure and report its active I/O time.
    • Method Detail

      • canBlock

        boolean canBlock()
        Returns true if blocking for IO is allowed or if we should try to do a non-blocking request for IO to be ready.
        Returns:
        true if allowed, false otherwise.
      • delayNanos

        long delayNanos​(long currentTimeNanos)
        Returns the amount of time left until the scheduled task with the closest deadline should run.
        Parameters:
        currentTimeNanos - the current nanos.
        Returns:
        nanos
      • deadlineNanos

        long deadlineNanos()
        Returns the absolute point in time at which the next closest scheduled task should run or -1 if nothing is scheduled to run.
        Returns:
        deadline.
      • reportActiveIoTime

        default void reportActiveIoTime​(long activeNanos)
        Reports the amount of time in nanoseconds that was spent actively processing I/O events.

        This metric is needed for the dynamic, utilization-based auto-scaling feature in MultithreadEventExecutorGroup. The reported time allows the auto-scaler to accurately measure the I/O workload of an event loop.

        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 not include time spent blocking or waiting for I/O (e.g., in an epoll_wait) call.

        The default implementation of this method is a no-op. Failing to override it in an IoHandlerContext that supports auto-scaling will result in the I/O utilization being perceived as zero.

        Parameters:
        activeNanos - The duration in nanoseconds of active, non-blocking I/O work.
      • shouldReportActiveIoTime

        default boolean shouldReportActiveIoTime()
        Returns 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 System.nanoTime() when the feature is not in use.
        Returns:
        true if active I/O time should be reported, false otherwise.