public interface Quotas
通常的使用场景为: 1. 设定总配额或按资源指定 2. 资源在使用配额时调用 use 3. 资源使用完全释放(归还)配额时使用 refund
| 限定符和类型 | 接口和说明 |
|---|---|
static interface |
Quotas.Governable
可配额控制的项
|
static class |
Quotas.SimpleQuotas
超简的配额控制,总按可用额的2/3计算直至0,默认最大配额为100
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
getCount()
获取正使用的(总)配额
|
int |
getMax()
获取最大值(总配额)
|
int |
getQuota(Quotas.Governable governable,
int concurrent)
指定资源的当前可用配额
|
int |
refund(Object resource)
归还配额
|
int |
use(Quotas.Governable governable,
int concurrent)
使用配额
|
static final Quotas _NoLimit
int getMax()
int getCount()
int getQuota(Quotas.Governable governable, int concurrent)
governable - 受配额控制的资源项concurrent - 资源的并发数(正在使用数)int use(Quotas.Governable governable, int concurrent) throws OverquotaException
governable - 使用配额的资源项concurrent - 资源的并发数(正在使用数)OverquotaException - 若超过配额抛出异常int refund(Object resource)
resource - 要归还配额的资源Copyright © 2022. All rights reserved.