接口 OccupySupport
- 所有已知子接口:
Node
- 所有已知实现类:
ClusterNode,DefaultNode,EntranceNode,StatisticNode
public interface OccupySupport
- 从以下版本开始:
- 1.5.0
- 作者:
- Eric Zhao
-
方法概要
修饰符和类型方法说明voidaddOccupiedPass(int acquireCount) Add occupied pass request, which represents pass requests that borrow the latter windows' token.voidaddWaitingRequest(long futureTime, int acquireCount) Add request that occupied.doubleGet current occupied pass QPS.longtryOccupyNext(long currentTime, int acquireCount, double threshold) Try to occupy latter time windows' tokens.longwaiting()Get current waiting amount.
-
方法详细资料
-
tryOccupyNext
long tryOccupyNext(long currentTime, int acquireCount, double threshold) Try to occupy latter time windows' tokens. If occupy success, a value less thanoccupyTimeoutinOccupyTimeoutPropertywill be return.Each time we occupy tokens of the future window, current thread should sleep for the corresponding time for smoothing QPS. We can't occupy tokens of the future with unlimited, the sleep time limit is
occupyTimeoutinOccupyTimeoutProperty.- 参数:
currentTime- current time millis.acquireCount- tokens count to acquire.threshold- qps threshold.- 返回:
- time should sleep. Time >=
occupyTimeoutinOccupyTimeoutPropertymeans occupy fail, in this case, the request should be rejected immediately.
-
waiting
long waiting()Get current waiting amount. Useful for debug.- 返回:
- current waiting amount
-
addWaitingRequest
void addWaitingRequest(long futureTime, int acquireCount) Add request that occupied.- 参数:
futureTime- future timestamp that the acquireCount should be added on.acquireCount- tokens count.
-
addOccupiedPass
void addOccupiedPass(int acquireCount) Add occupied pass request, which represents pass requests that borrow the latter windows' token.- 参数:
acquireCount- tokens count.
-
occupiedPassQps
double occupiedPassQps()Get current occupied pass QPS.- 返回:
- current occupied pass QPS
-