public class CreditMap
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected long |
accumulated_credits |
protected java.util.Map<Address,java.lang.Long> |
credits |
protected java.util.concurrent.locks.Condition |
credits_available |
protected java.util.concurrent.locks.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() |
java.lang.Long |
get(Address member) |
long |
getAccumulatedCredits() |
java.util.List<Tuple<Address,java.lang.Long>> |
getMembersWithCreditsLessThan(long min_credits) |
java.util.List<Address> |
getMembersWithInsufficientCredits(long credit_needed) |
long |
getMinCredits() |
int |
getNumBlockings() |
long |
getTotalBlockTime() |
java.util.Set<Address> |
keys() |
java.lang.Long |
putIfAbsent(Address key) |
java.lang.Long |
remove(Address key) |
void |
replenish(Address sender,
long new_credits) |
void |
replenishAll() |
java.lang.String |
toString() |
protected final long max_credits
protected final java.util.Map<Address,java.lang.Long> credits
protected long min_credits
protected long accumulated_credits
protected final java.util.concurrent.locks.Lock lock
protected final java.util.concurrent.locks.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 java.util.Set<Address> keys()
public java.lang.Long get(Address member)
public java.lang.Long remove(Address key)
public java.lang.Long putIfAbsent(Address key)
public java.util.List<Address> getMembersWithInsufficientCredits(long credit_needed)
public java.util.List<Tuple<Address,java.lang.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()
public java.lang.String toString()
toString
in class java.lang.Object
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 ? 1998-2009 Bela Ban / Red Hat. All Rights Reserved.