List of usage examples for org.apache.http.impl.client.cache CachingHttpClients custom
public static CachingHttpClientBuilder custom()
From source file:ch.ledcom.jpreseed.web.JPreseedWeb.java
@Bean public DownloaderFactory downloaderFactory() { CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(MAX_CACHE_ENTRIES) .setMaxObjectSize(MAX_OBJECT_SIZE).build(); RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT) .setSocketTimeout(SOCKET_TIMEOUT).build(); return new DownloaderFactory(CachingHttpClients.custom().setCacheConfig(cacheConfig) .setDefaultRequestConfig(requestConfig).build()); }
From source file:ch.ledcom.jpreseed.cli.JPreseed.java
private static JPreseed initialize() { CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(MAX_CACHE_ENTRIES) .setMaxObjectSize(MAX_OBJECT_SIZE).build(); RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT) .setSocketTimeout(SOCKET_TIMEOUT).build(); DownloaderFactory downloaderFactory = new DownloaderFactory(CachingHttpClients.custom() .setCacheConfig(cacheConfig).setDefaultRequestConfig(requestConfig).build()); return new JPreseed(downloaderFactory, new UsbCreator()); }
From source file:org.brutusin.rpc.client.http.HttpEndpoint.java
public HttpEndpoint(URI endpoint, Config cfg, HttpClientContextFactory clientContextFactory) { if (endpoint == null) { throw new IllegalArgumentException("Endpoint is required"); }/*from ww w .j a va 2 s . c om*/ if (cfg == null) { cfg = new ConfigurationBuilder().build(); } CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(cfg.getMaxCacheEntries()) .setMaxObjectSize(cfg.getMaxCacheObjectSize()).build(); RequestConfig requestConfig = RequestConfig.custom() .setConnectTimeout(1000 * cfg.getConnectTimeOutSeconds()) .setSocketTimeout(1000 * cfg.getSocketTimeOutSeconds()).build(); PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); cm.setMaxTotal(cfg.getMaxConections()); this.endpoint = endpoint; this.httpClient = CachingHttpClients.custom().setCacheConfig(cacheConfig) .setDefaultRequestConfig(requestConfig).setRetryHandler(new StandardHttpRequestRetryHandler()) .setConnectionManager(cm).build(); this.clientContextFactory = clientContextFactory; initPingThread(cfg.getPingSeconds()); }
From source file:it.tidalwave.bluemarine2.downloader.impl.DefaultDownloader.java
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @PostConstruct/* ww w . ja va2s. c om*/ /* VisibleForTesting */ void initialize() { connectionManager = new PoolingHttpClientConnectionManager(); connectionManager.setMaxTotal(200); connectionManager.setDefaultMaxPerRoute(20); cacheConfig = CacheConfig.custom().setAllow303Caching(true).setMaxCacheEntries(Integer.MAX_VALUE) .setMaxObjectSize(Integer.MAX_VALUE).setSharedCache(false).setHeuristicCachingEnabled(true).build(); httpClient = CachingHttpClients.custom().setHttpCacheStorage(cacheStorage).setCacheConfig(cacheConfig) .setRedirectStrategy(dontFollowRedirect).setUserAgent("blueMarine (fabrizio.giudici@tidalwave.it)") .setDefaultHeaders(Arrays.asList(new BasicHeader("Accept", "application/n3"))) .setConnectionManager(connectionManager).addInterceptorFirst(killCacheHeaders) // FIXME: only if explicitly configured .build(); }
From source file:org.lokra.seaweedfs.core.Connection.java
/** * Start up polls for core leader./*from ww w.j a va 2 s . c o m*/ */ void startup() { final RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(this.connectionTimeout) .build(); if (this.enableFileStreamCache) { if (this.fileStreamCacheStorage == null) { final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(this.fileStreamCacheEntries) .setMaxObjectSize(this.fileStreamCacheSize).setHeuristicCachingEnabled(true) .setHeuristicCoefficient(0.8f).build(); this.httpClient = CachingHttpClients.custom().setCacheConfig(cacheConfig) .setConnectionManager(this.clientConnectionManager).setDefaultRequestConfig(requestConfig) .build(); } else { this.httpClient = CachingHttpClients.custom().setHttpCacheStorage(this.fileStreamCacheStorage) .setConnectionManager(this.clientConnectionManager).setDefaultRequestConfig(requestConfig) .build(); } } else { this.httpClient = HttpClients.custom().setConnectionManager(this.clientConnectionManager) .setDefaultRequestConfig(requestConfig).build(); } initCache(); this.pollClusterStatusThread.updateSystemStatus(true, true); this.pollClusterStatusThread.start(); this.idleConnectionMonitorThread.start(); log.info("seaweedfs master server connection is startup"); }