public class CreditMap extends Object
Modifier and Type | Field and Description |
---|---|
protected long |
accumulated_credits |
protected Map<Address,Long> |
credits |
protected Condition |
credits_available |
protected Lock |
lock |
protected long |
max_credits |
protected long |
min_credits |
protected int |
num_blockings |
protected long |
total_block_time |
Constructor and Description |
---|
CreditMap(long max_credits) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
protected long |
computeLowestCredit()
Needs to be called with lock held
|
long |
computeLowestCreditWithAccumulated() |
protected boolean |
decrement(long credits) |
boolean |
decrement(long credits,
long timeout)
Decrements credits bytes from all.
|
protected void |
decrementAndAdd(Address member,
long new_credits)
Decrements credits bytes from all elements and add new_credits to member (if non null).
|
protected void |
flushAccumulatedCredits() |
Long |
get(Address member) |
long |
getAccumulatedCredits() |
List<Tuple<Address,Long>> |
getMembersWithCreditsLessThan(long min_credits) |
List<Address> |
getMembersWithInsufficientCredits(long credit_needed) |
long |
getMinCredits() |
int |
getNumBlockings() |
long |
getTotalBlockTime() |
Set<Address> |
keys() |
Long |
putIfAbsent(Address key) |
Long |
remove(Address key) |
void |
replenish(Address sender,
long new_credits) |
void |
replenishAll() |
String |
toString() |
protected final long max_credits
protected long min_credits
protected long accumulated_credits
protected final Lock lock
protected final Condition credits_available
protected int num_blockings
protected long total_block_time
public long getAccumulatedCredits()
public long getMinCredits()
public int getNumBlockings()
public long getTotalBlockTime()
public List<Address> getMembersWithInsufficientCredits(long credit_needed)
public List<Tuple<Address,Long>> getMembersWithCreditsLessThan(long min_credits)
public boolean decrement(long credits, long timeout)
credits
- Number of bytes to decrement from all memberstimeout
- Number of milliseconds to wait until more credits have been receivedpublic void replenish(Address sender, long new_credits)
public void replenishAll()
public void clear()
protected boolean decrement(long credits)
protected long computeLowestCredit()
public long computeLowestCreditWithAccumulated()
protected void decrementAndAdd(Address member, long new_credits)
member
- The member to which new_credits are added. NOP if nullnew_credits
- Number of bytes to add to member. NOP if 0.protected void flushAccumulatedCredits()
Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.