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
-
-
Constructor Summary
Constructors Constructor Description ConnectionLimitHandler(int limit)
Construct with a preset connection limit.ConnectionLimitHandler(java.util.function.IntSupplier limit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelActive(io.netty.channel.ChannelHandlerContext ctx)
CallsChannelHandlerContext.fireChannelActive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
channelInactive(io.netty.channel.ChannelHandlerContext ctx)
CallsChannelHandlerContext.fireChannelInactive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.int
getConnectedCount()
Return the current number of connections.int
getConnectionLimit()
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
-
-
-
-
Method Detail
-
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 java.lang.Exception
CallsChannelHandlerContext.fireChannelActive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.Sub-classes may override this method to change behavior.
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Parameters:
ctx
-- Throws:
java.lang.Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
CallsChannelHandlerContext.fireChannelInactive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.Sub-classes may override this method to change behavior.
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Parameters:
ctx
-- Throws:
java.lang.Exception
-
-