类 AbstractTokenBucket
java.lang.Object
com.alibaba.csp.sentinel.slots.block.flow.tokenbucket.AbstractTokenBucket
- 所有已实现的接口:
TokenBucket
- 直接已知子类:
DefaultTokenBucket,StrictTokenBucket
- 作者:
- LearningGp
-
字段概要
字段修饰符和类型字段说明protected longNumber of tokens left in the bucketprotected final longprotected final longprotected final longMaximum number of tokens stored in the bucketprotected longTime of next production tokenprotected final longprotected final longNumber of tokens produced per unit of time -
构造器概要
构造器构造器说明AbstractTokenBucket(long unitProduceNum, long maxTokenNum, boolean fullStart, long intervalInMs) -
方法概要
修饰符和类型方法说明protected longcalProducedTokenNum(long currentTimestamp) longvoidrefreshCurrentTokenNum(long currentTimestamp) longbooleantryConsume(long tokenNum) protected voidupdateNextProduceTime(long currentTimestamp)
-
字段详细资料
-
MAX_UNIT_PRODUCE_NUM
protected final long MAX_UNIT_PRODUCE_NUM- 另请参阅:
-
currentTokenNum
protected volatile long currentTokenNumNumber of tokens left in the bucket -
nextProduceTime
protected volatile long nextProduceTimeTime of next production token -
unitProduceNum
protected final long unitProduceNumNumber of tokens produced per unit of time -
maxTokenNum
protected final long maxTokenNumMaximum number of tokens stored in the bucket -
intervalInMs
protected final long intervalInMs -
startTime
protected final long startTime
-
-
构造器详细资料
-
AbstractTokenBucket
public AbstractTokenBucket(long unitProduceNum, long maxTokenNum, boolean fullStart, long intervalInMs)
-
-
方法详细资料
-
tryConsume
public boolean tryConsume(long tokenNum) - 指定者:
tryConsume在接口中TokenBucket
-
refreshCurrentTokenNum
public void refreshCurrentTokenNum(long currentTimestamp) - 指定者:
refreshCurrentTokenNum在接口中TokenBucket
-
calProducedTokenNum
protected long calProducedTokenNum(long currentTimestamp) -
updateNextProduceTime
protected void updateNextProduceTime(long currentTimestamp) -
refreshTokenAndGetCurrentTokenNum
public long refreshTokenAndGetCurrentTokenNum() -
getCurrentTokenNum
public long getCurrentTokenNum()
-