如何查看App Engine配额?

时间:2011-03-08 07:29:40

标签: java google-app-engine

有没有办法检查Google App Engine配额?我需要使用Java Api检查配额。我该怎么办?

谢谢。

1 个答案:

答案 0 :(得分:4)

查看com.google.appengine.api.quota包。
它为QuotaService接口(带有实现和工厂)提供了几种检查和监控Google App Engine配额的方法。

import com.google.appengine.api.quota.QuotaService;
import com.google.appengine.api.quota.QuotaServiceFactory;

...
QuotaService qs = QuotaServiceFactory.getQuotaService();
long start = qs.getCpuTimeInMegaCycles();
doSomethingExpensive();
long end = qs.getCpuTimeInMegaCycles();
double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start);