Class RateThrottlingPolicy

java.lang.Object
com.yahoo.messagebus.StaticThrottlePolicy
com.yahoo.messagebus.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 Details

    • log

      public static final Logger log
  • Constructor Details

    • RateThrottlingPolicy

      public RateThrottlingPolicy(double desiredRate)
    • RateThrottlingPolicy

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

    • 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