Class IdleConnectionHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.apache.tinkerpop.gremlin.driver.handler.IdleConnectionHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

public class IdleConnectionHandler extends io.netty.channel.ChannelDuplexHandler
Detects IdleStateEvents and closes the channel with the goal of releasing pooled connections that have not been used in a while. An idle event that fires while a request is in flight is ignored so that idleTimeout only reaps connections that are idle in the pool between requests; bounding a stalled in-flight response is the responsibility of the per-request readTimeout (ReadTimeoutHandler). This keeps the two timeouts from overlapping on the in-flight window.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final io.netty.util.AttributeKey<io.netty.handler.timeout.IdleStateEvent>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)
    Detects if an IdleStateEvent has occurred and closes the channel, unless a request is currently in flight, in which case the event is ignored and the channel is left to the per-request read timeout.

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read, write

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Field Details

    • IDLE_STATE_EVENT

      public static final io.netty.util.AttributeKey<io.netty.handler.timeout.IdleStateEvent> IDLE_STATE_EVENT
  • Constructor Details

    • IdleConnectionHandler

      public IdleConnectionHandler(BooleanSupplier requestInFlight)
  • Method Details

    • userEventTriggered

      public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)
      Detects if an IdleStateEvent has occurred and closes the channel, unless a request is currently in flight, in which case the event is ignored and the channel is left to the per-request read timeout.
      Specified by:
      userEventTriggered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter