public class LeakBucket extends Bucket
BUCKET_HASH_WHEEL_TIMER, hashWheelTask
Constructor and Description |
---|
LeakBucket(int tokenSize,
int interval)
令牌桶构造函数
|
LeakBucket(int tokenSize,
int interval,
int releaseTime)
令牌桶构造函数
|
Modifier and Type | Method and Description |
---|---|
boolean |
acquire()
获取令牌, 立即返回
|
void |
acquire(int timeout)
获取令牌, 带有时间等待
|
int |
getReleaseTime() |
void |
init(int tokenSize,
int interval,
int releaseTime) |
void |
setReleaseTime(int releaseTime) |
getHashWheelTask, release, setHashWheelTask
public LeakBucket(int tokenSize, int interval, int releaseTime)
tokenSize
- 漏桶的初始数量interval
- 漏桶的新增周期, 每次触发将重置漏桶的数量, 单位: 毫秒releaseTime
- 漏桶失效并自动移除的时间public LeakBucket(int tokenSize, int interval)
tokenSize
- 漏桶的初始数量interval
- 漏桶的新增周期, 每次触发将重置漏桶的数量, 单位: 毫秒public void init(int tokenSize, int interval, int releaseTime)
public int getReleaseTime()
public void setReleaseTime(int releaseTime)
public boolean acquire()
public void acquire(int timeout) throws TimeoutException
acquire
in class Bucket
timeout
- 等待时间TimeoutException
- 超时异常Copyright © 2020 Voovan. All rights reserved.