# QuotaService
Date: 2012-02-24

## com.google.appengine.api.quota
Interface QuotaService

    public interface QuotaService

The `QuotaService` provides a way for user code to get access to some server-internal metrics.

Nested Class Summary
`static class` `QuotaService.DataType` Represents all types of data that a QuotaService might be able to provide.

Method Summary
`long` `convertCpuSecondsToMegacycles(double cpuSeconds)` Expresses a value in megaCycles as its approximate equivalent of CPU seconds on a theoretical 1.2 GHz CPU.
`double` `convertMegacyclesToCpuSeconds(long megaCycles)` Expresses a value in megaCycles as its approximate equivalent of CPU seconds on a theoretical 1.2 GHz CPU.
`long` `getApiTimeInMegaCycles()` Measures the duration that the current request has spent so far in API calls, such as making datastore requests or sending out mail.
`long` `getCpuTimeInMegaCycles()` Measures the duration that the current request has spent so far processing the request within the App Engine sandbox.
`boolean` `supports(QuotaService.DataType type)` Tests if the QuotaService can provide a certain kind of data at this point in time.

Method Detail

### supports

    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.

  Parameters:
    `type` - the type of data in question.
  Returns:
    true if the QuotaService can provide such data at this time.
  Throws:
    `java.lang.NullPointerException` - if a null argument is passed into the method.

### getApiTimeInMegaCycles

    long getApiTimeInMegaCycles()

  Measures the duration that the current request has spent so far in API calls, such as making datastore requests or sending out mail.

  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:
    the overall amount spent in API cycles, as returned by the system. Returns 0 if the feature is not supported.

### getCpuTimeInMegaCycles

    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:
    the overall amount spent in CPU cycles, as returned by the system. Returns 0 if the feature is not supported.

### convertMegacyclesToCpuSeconds

    double convertMegacyclesToCpuSeconds(long megaCycles)

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

  Parameters:
    `megaCycles` - the value, in megacycles, to convert.
  Returns:
    a double representing the CPU-seconds the input megacycle value converts to.

### convertCpuSecondsToMegacycles

    long convertCpuSecondsToMegacycles(double cpuSeconds)

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

  Parameters:
    `cpuSeconds` - the value, in cpu seconds, to convert.
  Returns:
    a long representing the megacycles the input CPU-seconds value converts to.