List of usage examples for java.util.concurrent TimeUnit MILLISECONDS
TimeUnit MILLISECONDS
To view the source code for java.util.concurrent TimeUnit MILLISECONDS.
Click Source Link
From source file:org.sonatype.nexus.apachehttpclient.PoolingClientConnectionManagerMBeanImpl.java
@Override public void closeIdleConnections(final long idleTimeoutInMillis) { connMgr.closeIdleConnections(idleTimeoutInMillis, TimeUnit.MILLISECONDS); }
From source file:com.frostwire.http.HttpClient.java
private static OkHttpClient buildDefaultClient() { OkHttpClient c = new OkHttpClient(); c.setFollowRedirects(true);/*from w w w .j a v a2 s . c om*/ c.setFollowSslRedirects(true); c.setConnectTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); c.setReadTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); c.setWriteTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); c.setHostnameVerifier(buildHostnameVerifier()); c.setSslSocketFactory(buildSSLSocketFactory()); c.interceptors().add(new GzipInterceptor()); return c; }
From source file:org.doxu.g2.gwc.crawler.Crawler.java
public void start() { String startUrl = "http://cache.trillinux.org/g2/bazooka.php"; session.addURL(startUrl);//from w w w .ja va 2 s . com RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(Crawler.CONNECT_TIMEOUT) .setSocketTimeout(Crawler.CONNECT_TIMEOUT).build(); try (CloseableHttpClient httpClient = HttpClients.custom().setUserAgent("doxu/" + Crawler.VERSION) .setDefaultRequestConfig(requestConfig).disableAutomaticRetries().build()) { CrawlerThreadPoolExecutor executor = new CrawlerThreadPoolExecutor(GWC_CRAWLER_THREADS, GWC_CRAWLER_THREADS, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); executor.setListener(new IdleListener() { @Override public void idle() { // If the thread pool is idle and the queue of GWCs to crawl is empty // the crawl of GWCs is complete if (session.peek() == null) { crawlCompletedBarrier.countDown(); } } }); CrawlThreadFactory factory = CrawlThreadFactory.newFactory(session, httpClient); runQueueProcessor(factory, executor); executor.shutdown(); try { executor.awaitTermination(30, TimeUnit.SECONDS); } catch (InterruptedException ex) { Logger.getLogger(Crawler.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(Crawler.class.getName()).log(Level.SEVERE, null, ex); } HostChecker hostChecker = new HostChecker(session); hostChecker.start(); printStats(); System.out.println(session.toXML()); }
From source file:org.openhab.habdroid.util.MyHttpClient.java
public void setTimeout(int timeout) { clientBuilder.readTimeout(timeout, TimeUnit.MILLISECONDS); client = clientBuilder.build(); }
From source file:com.agileEAP.module.cache.memcached.SpyMemcachedClient.java
/** * Set, ??updateTimeout, ?false??./*from w w w . ja va 2 s . c o m*/ */ public boolean safeSet(String key, int expiration, Object value) { Future<Boolean> future = memcachedClient.set(key, expiration, value); try { return future.get(updateTimeout, TimeUnit.MILLISECONDS); } catch (Exception e) { future.cancel(false); } return false; }
From source file:com.baasbox.android.net.OkClient.java
@Override public void init(Context context, BaasBox.Config config) { this.charset = config.httpCharset; mOkHttp.setConnectTimeout(config.httpConnectionTimeout, TimeUnit.MILLISECONDS); mOkHttp.setReadTimeout(config.httpSocketTimeout, TimeUnit.MILLISECONDS); mOkHttp.setFollowSslRedirects(true); }
From source file:cf.service.ServiceGarbageCollector.java
public ServiceGarbageCollector(ScheduledExecutorService executorService, UUID serviceGuid, CloudController cloudController, TokenProvider token, Provisioner provisioner) { this.serviceGuid = serviceGuid; this.cloudController = cloudController; this.token = token; this.provisioner = provisioner; executorService.scheduleWithFixedDelay(new Runnable() { @Override/* w w w . ja va 2 s . c om*/ public void run() { collect(); } }, COLLECTION_RATE, COLLECTION_RATE, TimeUnit.MILLISECONDS); }
From source file:com.netflix.spinnaker.igor.config.GitlabCiConfig.java
public static GitlabCiClient gitlabCiClient(String address, String privateToken, int timeout, ObjectMapper objectMapper) {/* ww w . jav a 2s . co m*/ OkHttpClient client = new OkHttpClient(); client.setReadTimeout(timeout, TimeUnit.MILLISECONDS); //Need this code because without FULL log level, fetching logs will fail. Ref https://github.com/square/retrofit/issues/953. RestAdapter.Log fooLog = message -> { }; return new RestAdapter.Builder().setEndpoint(Endpoints.newFixedEndpoint(address)) .setRequestInterceptor(new GitlabCiHeaders(privateToken)).setClient(new OkClient(client)) .setLog(fooLog).setLogLevel(RestAdapter.LogLevel.FULL) .setConverter(new JacksonConverter(objectMapper)).build().create(GitlabCiClient.class); }
From source file:com.ignorelist.kassandra.steam.scraper.FileCache.java
public FileCache(Path cacheDirectory, CacheLoader<String, ? extends InputStream> valueLoader, TimeUnit expireUnit, long expireDuration) { this(cacheDirectory, valueLoader, TimeUnit.MILLISECONDS.convert(expireDuration, expireUnit)); }
From source file:com.legstar.host.access.PooledHostAccessStrategy.java
/** * An engine, servicing pool of host connections, is assumed to be running * in this VM. Rather than invoking the host directly, we submit a request * asynchronously to the engine and then wait for a reply. * /*from w ww . ja va 2s. c om*/ * @see com.legstar.host.access.HostAccessStrategy#invoke( * com.legstar.messaging.Request) * {@inheritDoc} */ public void invoke(final LegStarRequest request) throws HostAccessStrategyException { long startTime = System.currentTimeMillis(); if (_log.isDebugEnabled()) { _log.debug("Pooled invoke for Request:" + request.getID()); } try { EngineHolder.getEngine().addRequest(request); request.await(mInvokeTimeout, TimeUnit.MILLISECONDS); if (request.getException() != null) { throw new HostAccessStrategyException(request.getException()); } else { if (request.getResponseMessage() == null) { throw new HostAccessStrategyException( "Timed out waiting for a response for Request:" + request.getID()); } } } catch (InterruptedException e) { throw new HostAccessStrategyException(e); } catch (EngineNotStartedException e) { throw new HostAccessStrategyException(e); } if (_log.isDebugEnabled()) { long endTime = System.currentTimeMillis(); _log.debug("Pooled invoke for Request:" + request.getID() + " ended. elapse: " + Long.toString(endTime - startTime) + " ms"); } }