private AsynchronousValidator makeAsynchronousValidator( CacheConfig config) { if (config.getAsynchronousWorkersMax() > 0) { return new AsynchronousValidator(this, config); } return null; }
public void run() { try { if (revalidateCacheEntry()) { parent.jobSuccessful(identifier); } else { parent.jobFailed(identifier); } } finally { parent.markComplete(identifier); } }
private HttpResponse revalidateCacheEntry(HttpHost target, HttpRequest request, HttpContext context, HttpCacheEntry entry, Date now) throws ClientProtocolException { log.trace("Revalidating the cache entry"); try { if (asynchRevalidator != null && !staleResponseNotAllowed(request, entry, now) && validityPolicy.mayReturnStaleWhileRevalidating(entry, now)) { final HttpResponse resp = generateCachedResponse(request, context, entry, now); asynchRevalidator.revalidateCacheEntry(target, request, context, entry); return resp; } return revalidateCacheEntry(target, request, context, entry); } catch (IOException ioex) { return handleRevalidationFailure(request, context, entry, now); } catch (ProtocolException e) { throw new ClientProtocolException(e); } }
public void run() { try { cachingClient.revalidateCacheEntry(target, request, context, cacheEntry); } catch (IOException ioe) { log.debug("Asynchronous revalidation failed due to exception: " + ioe); } catch (ProtocolException pe) { log.error("ProtocolException thrown during asynchronous revalidation: " + pe); } finally { parent.markComplete(identifier); } }
log.trace("Serving stale with asynchronous revalidation"); final CloseableHttpResponse resp = generateCachedResponse(request, context, entry, now); asynchRevalidator.revalidateCacheEntry(this, route, request, context, execAware, entry); return resp;
private AsynchronousValidator createAsynchronousRevalidator(final CacheConfig config) { if (config.getAsynchronousWorkersMax() > 0) { final SchedulingStrategy configuredSchedulingStrategy = createSchedulingStrategy(config); final AsynchronousValidator revalidator = new AsynchronousValidator( configuredSchedulingStrategy); addCloseable(revalidator); return revalidator; } return null; }