public class CheckRequestAggregator
extends java.lang.Object
CheckRequests.| Modifier and Type | Field and Description |
|---|---|
static int |
NON_CACHING
The flush interval returned by
getFlushIntervalMillis() when an instance is
configured to be non-caching. |
| Constructor and Description |
|---|
CheckRequestAggregator(java.lang.String serviceName,
CheckAggregationOptions options)
Constructor.
|
CheckRequestAggregator(java.lang.String serviceName,
CheckAggregationOptions options,
java.util.Map<java.lang.String,com.google.api.MetricDescriptor.MetricKind> kinds)
Constructor.
|
CheckRequestAggregator(java.lang.String serviceName,
CheckAggregationOptions options,
java.util.Map<java.lang.String,com.google.api.MetricDescriptor.MetricKind> kinds,
com.google.common.base.Ticker ticker)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addResponse(com.google.api.servicecontrol.v1.CheckRequest req,
com.google.api.servicecontrol.v1.CheckResponse resp)
Adds the response from sending
req to this instances cache. |
com.google.api.servicecontrol.v1.CheckResponse |
check(com.google.api.servicecontrol.v1.CheckRequest req)
Determine if a cached response corresponds to
req. |
void |
clear()
Clears this instances cache of aggregated operations.
|
com.google.api.servicecontrol.v1.CheckRequest[] |
flush()
Flushes this instance's cache.
|
int |
getFlushIntervalMillis() |
java.lang.String |
getServiceName() |
static com.google.common.hash.HashCode |
sign(com.google.api.servicecontrol.v1.CheckRequest value)
Obtains the
HashCode for the contents of value. |
public static final int NON_CACHING
getFlushIntervalMillis() when an instance is
configured to be non-caching.public CheckRequestAggregator(java.lang.String serviceName,
CheckAggregationOptions options,
@Nullable
java.util.Map<java.lang.String,com.google.api.MetricDescriptor.MetricKind> kinds,
@Nullable
com.google.common.base.Ticker ticker)
serviceName - the service whose CheckRequests are being aggregatedoptions - configures this instance's caching behaviorkinds - specifies the MetricDescriptor.MetricKind for specific metric namesticker - the time source used to determine expiration. When not specified, this defaults
to Ticker.systemTicker()public CheckRequestAggregator(java.lang.String serviceName,
CheckAggregationOptions options,
@Nullable
java.util.Map<java.lang.String,com.google.api.MetricDescriptor.MetricKind> kinds)
serviceName - the service whose CheckRequests are being aggregatedoptions - configures this instances caching behaviorkinds - specifies the MetricDescriptor.MetricKind for specific metric namespublic CheckRequestAggregator(java.lang.String serviceName,
CheckAggregationOptions options)
serviceName - the service whose CheckRequests are being aggregatedoptions - configures this instances caching behaviorpublic int getFlushIntervalMillis()
flush()public java.lang.String getServiceName()
CheckRequests are being aggregatedpublic void clear()
public com.google.api.servicecontrol.v1.CheckRequest[] flush()
getFlushIntervalMillis()
milliseconds, and send the results to the check service.public void addResponse(com.google.api.servicecontrol.v1.CheckRequest req,
com.google.api.servicecontrol.v1.CheckResponse resp)
req to this instances cache.req - a CheckRequestresp - the response from sending CheckResponse@Nullable public com.google.api.servicecontrol.v1.CheckResponse check(com.google.api.servicecontrol.v1.CheckRequest req)
req.
Determine if there are cache hits for the request in this instance as follows:
Not in the Cache If req is not in the cache, it returns null,
to indicate that the caller should send the request.
Cache Hit, the response has errors When a cached response has errors, it's
assumed that req, would fail as well, so the cached response is returned. However, the
first request after the check interval has elapsed should be sent to the server to refresh the
response - until its response is received, the subsequent reqs should still return the failed
response.
Cache Hit, the response passed When the cached response has no errors, it's
assumed that the req would pass as well, so the response is return, with quota tracking
updated so that it matches that in req.req - a request to be sent to the service control serviceCheckResponse if an applicable one is cached by this instance, otherwise
nullpublic static com.google.common.hash.HashCode sign(com.google.api.servicecontrol.v1.CheckRequest value)
HashCode for the contents of value.value - a CheckRequest to be signedHashCode corresponding to value