Class ConnectionLimitHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.linkedin.alpini.netty4.handlers.ConnectionLimitHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
Direct Known Subclasses:
ConnectionControlHandler

@Sharable public class ConnectionLimitHandler extends io.netty.channel.ChannelInboundHandlerAdapter
  • Nested Class Summary

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

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

    Constructors
    Constructor
    Description
    Construct with a preset connection limit.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    int
    Return the current number of connections.
    int
    Return the current connection limit.
    void
    setConnectionLimit(int limit)
    Set the maximum number of connections.

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    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
  • Constructor Details

    • ConnectionLimitHandler

      public ConnectionLimitHandler(int limit)
      Construct with a preset connection limit.
      Parameters:
      limit - Maximum number of connections.
    • ConnectionLimitHandler

      public ConnectionLimitHandler(IntSupplier limit)
  • Method Details

    • getConnectedCount

      public int getConnectedCount()
      Return the current number of connections.
      Returns:
      number of connections.
    • setConnectionLimit

      public void setConnectionLimit(int limit)
      Set the maximum number of connections.
      Parameters:
      limit - new connection limit.
    • getConnectionLimit

      public int getConnectionLimit()
      Return the current connection limit.
      Returns:
      number of connections.
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Calls ChannelHandlerContext.fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline.

      Sub-classes may override this method to change behavior.

      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx -
      Throws:
      Exception
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Calls ChannelHandlerContext.fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline.

      Sub-classes may override this method to change behavior.

      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx -
      Throws:
      Exception