Class ConcurrentThrottler


  • public class ConcurrentThrottler
    extends java.lang.Object
    The implementation enforces a quota of request executions per time unit. It is used by the concurrent scanner to impose cloud servers access quota. Failure to impose quota can cause service denials. If the scanner is stopped, the throttler is closed and all the requesters get permits. But since we closed all the requests are canceled so the requesters will not try to access the server.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcurrentThrottler​(long timeUnitMillis, long quota)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void backOff​(long millisBackOffPeriod)  
      void close()
      Let all the requester pass and cancel the time window timer
      void getPermit()
      Blocked until a permit is granted.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConcurrentThrottler

        public ConcurrentThrottler​(long timeUnitMillis,
                                   long quota)
        Parameters:
        timeUnitMillis - the time window for limiting requests
        quota - the number of requests permitted per time window (-1 for no limit)
    • Method Detail

      • backOff

        public void backOff​(long millisBackOffPeriod)
      • close

        public void close()
        Let all the requester pass and cancel the time window timer
      • getPermit

        public void getPermit()
        Blocked until a permit is granted. Once the throttler is granted, all requester are granted a permit.