public class CreditMap
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
protected long |
accumulated_credits |
protected Average |
avg_block_time |
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 |
构造器和说明 |
---|
CreditMap(long max_credits) |
限定符和类型 | 方法和说明 |
---|---|
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() |
double |
getAverageBlockTime() |
java.util.List<Tuple<Address,java.lang.Long>> |
getMembersWithCreditsLessThan(long min_credits) |
java.util.List<Address> |
getMembersWithInsufficientCredits(long credit_needed) |
long |
getMinCredits() |
int |
getNumBlockings() |
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() |
void |
reset() |
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 final Average avg_block_time
public long getAccumulatedCredits()
public long getMinCredits()
public int getNumBlockings()
public double getAverageBlockTime()
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 void reset()
public java.lang.String toString()
toString
在类中 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()