class AsynchronousValidator
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
private CacheKeyGenerator |
cacheKeyGenerator |
private FailureCache |
failureCache |
private org.apache.commons.logging.Log |
log |
private java.util.Set<java.lang.String> |
queued |
private SchedulingStrategy |
schedulingStrategy |
Constructor and Description |
---|
AsynchronousValidator(CacheConfig config)
Create AsynchronousValidator which will make revalidation requests
using an
ImmediateSchedulingStrategy . |
AsynchronousValidator(SchedulingStrategy schedulingStrategy)
Create AsynchronousValidator which will make revalidation requests
using the supplied
SchedulingStrategy . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
(package private) java.util.Set<java.lang.String> |
getScheduledIdentifiers() |
(package private) void |
jobFailed(java.lang.String identifier)
The revalidation job did fail and thus the number of consecutive failed
attempts will be increased.
|
(package private) void |
jobSuccessful(java.lang.String identifier)
The revalidation job was successful thus the number of consecutive
failed attempts will be reset to zero.
|
(package private) void |
markComplete(java.lang.String identifier)
Removes an identifier from the internal list of revalidation jobs in
progress.
|
void |
revalidateCacheEntry(CachingExec cachingExec,
HttpRoute route,
HttpRequestWrapper request,
HttpClientContext context,
HttpExecutionAware execAware,
HttpCacheEntry entry)
Schedules an asynchronous revalidation
|
private final SchedulingStrategy schedulingStrategy
private final java.util.Set<java.lang.String> queued
private final CacheKeyGenerator cacheKeyGenerator
private final FailureCache failureCache
private final org.apache.commons.logging.Log log
public AsynchronousValidator(CacheConfig config)
ImmediateSchedulingStrategy
. Its thread
pool will be configured according to the given CacheConfig
.config
- specifies thread pool settings. See
CacheConfig.getAsynchronousWorkersMax()
,
CacheConfig.getAsynchronousWorkersCore()
,
CacheConfig.getAsynchronousWorkerIdleLifetimeSecs()
,
and CacheConfig.getRevalidationQueueSize()
.AsynchronousValidator(SchedulingStrategy schedulingStrategy)
SchedulingStrategy
. Closing the validator
will also close the given schedulingStrategy.schedulingStrategy
- used to maintain a pool of worker threads and
schedules when requests are executedpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public void revalidateCacheEntry(CachingExec cachingExec, HttpRoute route, HttpRequestWrapper request, HttpClientContext context, HttpExecutionAware execAware, HttpCacheEntry entry)
void markComplete(java.lang.String identifier)
AsynchronousValidationRequest.run()
once the revalidation is
complete, using the identifier passed in during constructions.identifier
- void jobSuccessful(java.lang.String identifier)
AsynchronousValidationRequest.run()
.identifier
- the revalidation job's unique identifiervoid jobFailed(java.lang.String identifier)
AsynchronousValidationRequest.run()
.identifier
- the revalidation job's unique identifierjava.util.Set<java.lang.String> getScheduledIdentifiers()