private static ScheduledThreadPoolExecutor createThreadPoolFromCacheConfig( final CacheConfig cacheConfig) { final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor( cacheConfig.getAsynchronousWorkersMax()); scheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); return scheduledThreadPoolExecutor; }
private AsynchronousValidator makeAsynchronousValidator( CacheConfig config) { if (config.getAsynchronousWorkersMax() > 0) { return new AsynchronousValidator(this, config); } return null; }
private AsynchronousValidator makeAsynchronousValidator( final CacheConfig config) { if (config.getAsynchronousWorkersMax() > 0) { return new AsynchronousValidator(this, config); } return null; }
/** * Uses a {@link java.util.concurrent.ThreadPoolExecutor} which is configured according to the * given {@link CacheConfig}. * @param cacheConfig specifies thread pool settings. See * {@link CacheConfig#getAsynchronousWorkersMax()}, * {@link CacheConfig#getAsynchronousWorkersCore()}, * {@link CacheConfig#getAsynchronousWorkerIdleLifetimeSecs()}, * and {@link CacheConfig#getRevalidationQueueSize()}. */ public ImmediateSchedulingStrategy(final CacheConfig cacheConfig) { this(new ThreadPoolExecutor( cacheConfig.getAsynchronousWorkersCore(), cacheConfig.getAsynchronousWorkersMax(), cacheConfig.getAsynchronousWorkerIdleLifetimeSecs(), TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(cacheConfig.getRevalidationQueueSize())) ); }
/** * Create AsynchronousValidator which will make revalidation requests * using the supplied {@link CachingHttpClient}, and * a {@link ThreadPoolExecutor} generated according to the thread * pool settings provided in the given {@link CacheConfig}. * @param cachingClient used to execute asynchronous requests * @param config specifies thread pool settings. See * {@link CacheConfig#getAsynchronousWorkersMax()}, * {@link CacheConfig#getAsynchronousWorkersCore()}, * {@link CacheConfig#getAsynchronousWorkerIdleLifetimeSecs()}, * and {@link CacheConfig#getRevalidationQueueSize()}. */ public AsynchronousValidator(final CachingHttpClient cachingClient, final CacheConfig config) { this(cachingClient, new ThreadPoolExecutor(config.getAsynchronousWorkersCore(), config.getAsynchronousWorkersMax(), config.getAsynchronousWorkerIdleLifetimeSecs(), TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(config.getRevalidationQueueSize())) ); }
/** * Create AsynchronousValidator which will make revalidation requests * using the supplied {@link CachingHttpClient}, and * a {@link ThreadPoolExecutor} generated according to the thread * pool settings provided in the given {@link CacheConfig}. * @param cachingClient used to execute asynchronous requests * @param config specifies thread pool settings. See * {@link CacheConfig#getAsynchronousWorkersMax()}, * {@link CacheConfig#getAsynchronousWorkersCore()}, * {@link CacheConfig#getAsynchronousWorkerIdleLifetimeSecs()}, * and {@link CacheConfig#getRevalidationQueueSize()}. */ public AsynchronousValidator(CachingHttpClient cachingClient, CacheConfig config) { this(cachingClient, new ThreadPoolExecutor(config.getAsynchronousWorkersCore(), config.getAsynchronousWorkersMax(), config.getAsynchronousWorkerIdleLifetimeSecs(), TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(config.getRevalidationQueueSize())) ); }
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; }
public static Builder copy(final CacheConfig config) { Args.notNull(config, "Cache config"); return new Builder() .setMaxObjectSize(config.getMaxObjectSize()) .setMaxCacheEntries(config.getMaxCacheEntries()) .setMaxUpdateRetries(config.getMaxUpdateRetries()) .setHeuristicCachingEnabled(config.isHeuristicCachingEnabled()) .setHeuristicCoefficient(config.getHeuristicCoefficient()) .setHeuristicDefaultLifetime(config.getHeuristicDefaultLifetime()) .setSharedCache(config.isSharedCache()) .setAsynchronousWorkersMax(config.getAsynchronousWorkersMax()) .setAsynchronousWorkersCore(config.getAsynchronousWorkersCore()) .setAsynchronousWorkerIdleLifetimeSecs(config.getAsynchronousWorkerIdleLifetimeSecs()) .setRevalidationQueueSize(config.getRevalidationQueueSize()) .setNeverCacheHTTP10ResponsesWithQueryString(config.isNeverCacheHTTP10ResponsesWithQuery()); }