Java 8 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Java 8
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Java
8 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Java.
QuotaService (Google App Engine API for Java)
Stay organized with collections
Save and categorize content based on your preferences.
-
-
Nested Class Summary
Nested Classes
Modifier and Type |
Interface and Description |
static class |
QuotaService.DataType
Represents all types of data that a QuotaService might be able to provide.
|
-
-
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
@Deprecated
long getApiTimeInMegaCycles()
Deprecated.
- 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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eQuotaService\u003c/code\u003e interface measures API and CPU usage during requests within the App Engine environment.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to measure CPU time in megacycles, reflecting the duration of request processing within the App Engine sandbox, excluding API call time.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esupports\u003c/code\u003e method tests if the \u003ccode\u003eQuotaService\u003c/code\u003e can currently provide a specific type of data, preventing potential \u003ccode\u003eIllegalStateException\u003c/code\u003e errors.\u003c/p\u003e\n"],["\u003cp\u003eMethods are available to convert between megacycles and approximate CPU seconds based on a theoretical 1.2 GHz CPU.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetApiTimeInMegaCycles\u003c/code\u003e method is deprecated and no longer provides a meaningful measurement.\u003c/p\u003e\n"]]],[],null,["# QuotaService (Google App Engine API for Java)\n\ncom.google.appengine.api.quota\n\nInterface QuotaService\n----------------------\n\n-\n\n *** ** * ** ***\n\n \u003cbr /\u003e\n\n ```\n public interface QuotaService\n ``` \nThe `QuotaService` provides measurement of API and CPU usage during requests. \n-\n -\n\n ### Nested Class Summary\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Summary\n\n-\n -\n\n ### Method Detail\n\n\n -\n\n #### supports\n\n ```\n boolean supports(QuotaService.DataType type)\n ``` \n 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.\n\n Parameters:\n : `type` - the type of data in question.\n\n Returns:\n : true if the QuotaService can provide such data at this time.\n\n Throws:\n : `java.lang.NullPointerException` - if a null argument is passed into\n the method.\n\n\n -\n\n #### getApiTimeInMegaCycles\n\n ```\n @Deprecated\n long getApiTimeInMegaCycles()\n ``` \n Deprecated. This value is no longer meaningful.\n\n Returns:\n : the overall amount spent in API cycles, as returned by the system.\n Returns 0 if the feature is not supported.\n\n\n -\n\n #### getCpuTimeInMegaCycles\n\n ```\n long getCpuTimeInMegaCycles()\n ``` \n 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.\n\n\n The unit the duration is measured is Megacycles. If all instructions\n were to be executed sequentially on a standard 1.2 GHz 64-bit x86 CPU,\n 1200 megacycles would equate to one second physical time elapsed.\n\n Returns:\n : the overall amount spent in CPU cycles, as returned by the system.\n Returns 0 if the feature is not supported.\n\n\n -\n\n #### convertMegacyclesToCpuSeconds\n\n ```\n double convertMegacyclesToCpuSeconds(long megaCycles)\n ``` \n Expresses a value in megaCycles as its approximate equivalent of CPU seconds on a theoretical 1.2 GHz CPU.\n\n Parameters:\n : `megaCycles` - the value, in megacycles, to convert.\n\n Returns:\n : a double representing the CPU-seconds the input megacycle value\n converts to.\n\n\n -\n\n #### convertCpuSecondsToMegacycles\n\n ```\n long convertCpuSecondsToMegacycles(double cpuSeconds)\n ``` \n Expresses a value in megaCycles as its approximate equivalent of CPU seconds on a theoretical 1.2 GHz CPU.\n\n Parameters:\n : `cpuSeconds` - the value, in cpu seconds, to convert.\n\n Returns:\n : a long representing the megacycles the input CPU-seconds value\n converts to."]]