Interface QuotaService (2.0.0)

public interface QuotaService

The QuotaService provides measurement of API and CPU usage during requests.

Methods

convertCpuSecondsToMegacycles(double cpuSeconds)

public abstract long convertCpuSecondsToMegacycles(double cpuSeconds)

Expresses a value in megaCycles as its approximate equivalent of CPU seconds on a theoretical 1.2 GHz CPU.

Parameter
Name Description
cpuSeconds double

the value, in cpu seconds, to convert.

Returns
Type Description
long

a long representing the megacycles the input CPU-seconds value converts to.

convertMegacyclesToCpuSeconds(long megaCycles)

public abstract double convertMegacyclesToCpuSeconds(long megaCycles)

Expresses a value in megaCycles as its approximate equivalent of CPU seconds on a theoretical 1.2 GHz CPU.

Parameter
Name Description
megaCycles long

the value, in megacycles, to convert.

Returns
Type Description
double

a double representing the CPU-seconds the input megacycle value converts to.

getApiTimeInMegaCycles() (deprecated)

public abstract long getApiTimeInMegaCycles()

Deprecated. This value is no longer meaningful.

Returns
Type Description
long

the overall amount spent in API cycles, as returned by the system. Returns 0 if the feature is not supported.

getCpuTimeInMegaCycles()

public abstract long getCpuTimeInMegaCycles()

Measures the duration that the current request has spent so far processing the request within the App Engine sandbox. Note that time spent in API calls will not be added to this value.

The unit the duration is measured is Megacycles. If all instructions were to be executed sequentially on a standard 1.2 GHz 64-bit x86 CPU, 1200 megacycles would equate to one second physical time elapsed.

Returns
Type Description
long

the overall amount spent in CPU cycles, as returned by the system. Returns 0 if the feature is not supported.

supports(QuotaService.DataType type)

public abstract boolean supports(QuotaService.DataType type)

Tests if the QuotaService can provide a certain kind of data at this point in time. Depending on the underlying app server implementation and what state it is in, a QuotaService might not always have access to all categories of data. For example, the dev-appserver might not be able to measure the megacycles of api calls. Trying to access that data would lead to an IllegalStateException, which would then need to be handled. To make it easier to prevent this, it is possible to ask the service if a particular kind of data is supported.

Parameter
Name Description
type QuotaService.DataType

the type of data in question.

Returns
Type Description
boolean

true if the QuotaService can provide such data at this time.