Package com.yahoo.messagebus
Class StaticThrottlePolicy
java.lang.Object
com.yahoo.messagebus.StaticThrottlePolicy
- All Implemented Interfaces:
ThrottlePolicy
- Direct Known Subclasses:
DynamicThrottlePolicy,RateThrottlingPolicy
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether or not the given message can be sent according to the current state of this policy.intReturns the maximum number of pending messages allowed.longReturns the maximum total size of pending messages allowed.longReturns the total size of pending messages.voidprocessMessage(Message message) This method is called once for every message that was accepted byThrottlePolicy.canSend(Message, int)and sent.voidprocessReply(Reply reply) This method is called once for every reply that is received.setMaxPendingCount(int maxCount) Sets the maximum number of pending messages allowed.setMaxPendingSize(long maxSize) Sets the maximum total size of pending messages allowed.
-
Constructor Details
-
StaticThrottlePolicy
public StaticThrottlePolicy()
-
-
Method Details
-
canSend
Description copied from interface:ThrottlePolicyReturns whether or not the given message can be sent according to the current state of this policy.- Specified by:
canSendin interfaceThrottlePolicy- Parameters:
message- the message to evaluatependingCount- the current number of pending messages- Returns:
- true to send the message
-
processMessage
Description copied from interface:ThrottlePolicyThis method is called once for every message that was accepted byThrottlePolicy.canSend(Message, int)and sent.- Specified by:
processMessagein interfaceThrottlePolicy- Parameters:
message- the message being sent
-
processReply
Description copied from interface:ThrottlePolicyThis method is called once for every reply that is received.- Specified by:
processReplyin interfaceThrottlePolicy- Parameters:
reply- the reply received
-
getMaxPendingCount
public int getMaxPendingCount()Returns the maximum number of pending messages allowed.- Returns:
- the max limit
-
setMaxPendingCount
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
Sets the maximum total size of pending messages allowed. This size is relative to the value returned byMessage.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.
-