Class RateThrottlingPolicy

  • All Implemented Interfaces:
    ThrottlePolicy

    public class RateThrottlingPolicy
    extends StaticThrottlePolicy
    Throttling policy that throttles sending based on a desired rate. It will block messages if the current rate is higher than desired, but otherwise will respect the static throttle policy's maximum window size. Rate is measured from at most the last 60 seconds.
    • Field Detail

      • log

        public static final java.util.logging.Logger log
    • Constructor Detail

      • RateThrottlingPolicy

        public RateThrottlingPolicy​(double desiredRate)
      • RateThrottlingPolicy

        public RateThrottlingPolicy​(double desiredRate,
                                    com.yahoo.concurrent.Timer timer)
    • Method Detail

      • canSend

        public boolean canSend​(Message message,
                               int pendingCount)
        Description copied from interface: ThrottlePolicy
        Returns whether or not the given message can be sent according to the current state of this policy.
        Specified by:
        canSend in interface ThrottlePolicy
        Overrides:
        canSend in class StaticThrottlePolicy
        Parameters:
        message - the message to evaluate
        pendingCount - the current number of pending messages
        Returns:
        true to send the message