Class QuotaHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
    Direct Known Subclasses:
    QuotaHandler.EppQuotaHandler, QuotaHandler.WhoisQuotaHandler

    public abstract class QuotaHandler
    extends io.netty.channel.ChannelInboundHandlerAdapter
    Handler that checks quota fulfillment and terminates connection if necessary.

    This handler attempts to acquire quota during the first channelRead(io.netty.channel.ChannelHandlerContext, java.lang.Object) operation, not when connection is established. The reason is that the userId used for acquiring quota is not always available when the connection is just open.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  QuotaHandler.EppQuotaHandler
      Quota Handler for EPP protocol.
      static class  QuotaHandler.WhoisQuotaHandler
      Quota Handler for WHOIS protocol.
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

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

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)
      Actions to take when the connection terminates.
      void channelRead​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)  
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, 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
    • Method Detail

      • channelRead

        public void channelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                java.lang.Object msg)
                         throws java.lang.Exception
        Specified by:
        channelRead in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        java.lang.Exception
      • channelInactive

        public abstract void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)
        Actions to take when the connection terminates.

        Depending on the quota type, the handler either returns the tokens, or does nothing.

        Specified by:
        channelInactive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter