Package org.jgroups.util
Class CreditMap
java.lang.Object
org.jgroups.util.CreditMap
Maintains credits for senders, when credits fall below 0, a sender blocks until new credits have been received.
- Author:
- Bela Ban
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()protected longNeeds to be called with lock heldlongprotected booleandecrement(long credits) booleandecrement(long credits, long timeout) Decrements credits bytes from all.protected voiddecrementAndAdd(Address member, long new_credits) Decrements credits bytes from all elements and add new_credits to member (if non null).protected voidlonggetMembersWithCreditsLessThan(long min_credits) getMembersWithInsufficientCredits(long credit_needed) longintlongkeys()putIfAbsent(Address key) voidvoidtoString()
-
Field Details
-
max_credits
protected final long max_credits -
credits
-
min_credits
protected long min_credits -
accumulated_credits
protected long accumulated_credits -
lock
-
credits_available
-
num_blockings
protected int num_blockings -
total_block_time
protected long total_block_time
-
-
Constructor Details
-
CreditMap
public CreditMap(long max_credits)
-
-
Method Details
-
getAccumulatedCredits
public long getAccumulatedCredits() -
getMinCredits
public long getMinCredits() -
getNumBlockings
public int getNumBlockings() -
getTotalBlockTime
public long getTotalBlockTime() -
keys
-
get
-
remove
-
putIfAbsent
-
getMembersWithInsufficientCredits
-
getMembersWithCreditsLessThan
-
decrement
public boolean decrement(long credits, long timeout) Decrements credits bytes from all. Returns true if successful, or false if not. Blocks for timeout ms (if greater than 0).- Parameters:
credits- Number of bytes to decrement from all memberstimeout- Number of milliseconds to wait until more credits have been received- Returns:
- True if decrementing credits bytes succeeded, false otherwise
-
replenish
-
replenishAll
public void replenishAll() -
clear
public void clear() -
toString
-
decrement
protected boolean decrement(long credits) -
computeLowestCredit
protected long computeLowestCredit()Needs to be called with lock held -
computeLowestCreditWithAccumulated
public long computeLowestCreditWithAccumulated() -
decrementAndAdd
Decrements credits bytes from all elements and add new_credits to member (if non null). The lowest credit needs to be greater than min_credits. Needs to be called with lock held- Parameters:
member- The member to which new_credits are added. NOP if nullnew_credits- Number of bytes to add to member. NOP if 0.
-
flushAccumulatedCredits
protected void flushAccumulatedCredits()
-