Class StaticThrottlePolicy

java.lang.Object
com.yahoo.messagebus.StaticThrottlePolicy
All Implemented Interfaces:
ThrottlePolicy
Direct Known Subclasses:
DynamicThrottlePolicy, RateThrottlingPolicy

public class StaticThrottlePolicy extends Object implements ThrottlePolicy
This is an implementation of the ThrottlePolicy that offers static limits to the amount of pending data a SourceSession is allowed to have. You may choose to set a limit to the total number of pending messages (by way of setMaxPendingCount(int)), the total size of pending messages (by way of setMaxPendingSize(long)), or some combination thereof. NOTE: By context, "pending" refers to the number of sent messages that have not been replied to yet.
Author:
Simon Thoresen Hult
  • Constructor Details

    • StaticThrottlePolicy

      public StaticThrottlePolicy()
  • 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
      Parameters:
      message - the message to evaluate
      pendingCount - the current number of pending messages
      Returns:
      true to send the message
    • processMessage

      public void processMessage(Message message)
      Description copied from interface: ThrottlePolicy
      This method is called once for every message that was accepted by ThrottlePolicy.canSend(Message, int) and sent.
      Specified by:
      processMessage in interface ThrottlePolicy
      Parameters:
      message - the message being sent
    • processReply

      public void processReply(Reply reply)
      Description copied from interface: ThrottlePolicy
      This method is called once for every reply that is received.
      Specified by:
      processReply in interface ThrottlePolicy
      Parameters:
      reply - the reply received
    • getMaxPendingCount

      public int getMaxPendingCount()
      Returns the maximum number of pending messages allowed.
      Returns:
      the max limit
    • setMaxPendingCount

      public StaticThrottlePolicy setMaxPendingCount(int maxCount)
      Sets the maximum number of pending messages allowed.
      Parameters:
      maxCount - The max count
      Returns:
      this, to allow chaining
    • getMaxPendingSize

      public long getMaxPendingSize()
      Returns the maximum total size of pending messages allowed.
      Returns:
      The max limit.
    • setMaxPendingSize

      public StaticThrottlePolicy setMaxPendingSize(long maxSize)
      Sets the maximum total size of pending messages allowed. This size is relative to the value returned by Message.getApproxSize().
      Parameters:
      maxSize - The max size.
      Returns:
      This, to allow chaining.
    • getPendingSize

      public long getPendingSize()
      Returns the total size of pending messages.
      Returns:
      The size.