Class ConnThrottler


  • class ConnThrottler
    extends Object
    Count how often something happens with a particular peer and all peers. This offers basic DOS protection but is not a complete solution. This is a little different from the one in streaming, in that the ban time is different from the check time, and we keep a separate map of throttled peers with individual time stamps. The streaming version is lightweight but "sloppy" since it uses a single time bucket for all.
    Since:
    0.9.9
    • Constructor Detail

      • ConnThrottler

        public ConnThrottler​(int max,
                             int totalMax,
                             long period,
                             long throttlePeriod,
                             long totalThrottlePeriod,
                             String action,
                             Log log)
    • Method Detail

      • start

        public void start()
      • stop

        public void stop()
      • updateLimits

        public void updateLimits​(int max,
                                 int totalMax,
                                 long checkPeriod,
                                 long throttlePeriod,
                                 long totalThrottlePeriod)
      • shouldThrottle

        public boolean shouldThrottle​(Hash h)
        Checks both individual and total. Increments before checking.
      • clear

        public void clear()
        start over