List of usage examples for java.util.concurrent TimeUnit toMillis
public long toMillis(long duration)
From source file:org.scribe.model.ProxyRequest.java
/** * Sets the connect timeout for the underlying {@link HttpURLConnection} * /*from www . j a va2 s.c o m*/ * @param duration duration of the timeout * @param unit unit of time (milliseconds, seconds, etc) */ public void setConnectTimeout(final int duration, final TimeUnit unit) { this.connectTimeout = unit.toMillis(duration); }
From source file:org.apache.geode.geospatial.utils.CachingPutAllMap.java
public void setTimeout(long timeout, TimeUnit timeUnit) { this.timeoutms = timeUnit.toMillis(timeout); }
From source file:org.apache.pulsar.client.impl.ProducerBuilderImpl.java
@Override public ProducerBuilder<T> sendTimeout(int sendTimeout, @NonNull TimeUnit unit) { checkArgument(sendTimeout >= 0, "sendTimeout needs to be >= 0"); conf.setSendTimeoutMs(unit.toMillis(sendTimeout)); return this; }
From source file:com.ponysdk.ui.server.basic.PScript.java
public void executeDeffered(final String js, final int delay, final TimeUnit unit) { final PTerminalScheduledCommand command = new PTerminalScheduledCommand() { @Override/*from w ww. ja va 2s .co m*/ protected void run() { PScript.get().execute(js); } }; command.schedule(unit.toMillis(delay)); }
From source file:org.zenoss.zep.index.impl.BaseEventIndexDaoImpl.java
public void purge(int duration, TimeUnit unit) throws ZepException { if (duration < 0) { throw new IllegalArgumentException("Duration must be >= 0"); }/* w w w . j a v a 2s.c om*/ final Date threshold = new Date(System.currentTimeMillis() - unit.toMillis(duration)); logger.info("Purging events older than {}", threshold); purge(threshold); commit(); }
From source file:com.ponysdk.ui.server.basic.PScript.java
public void executeDeffered(final String js, final ExecutionCallback callback, final int delay, final TimeUnit unit) { final PTerminalScheduledCommand command = new PTerminalScheduledCommand() { @Override/*from w ww .j a va 2 s . c o m*/ protected void run() { PScript.get().execute(js, callback); } }; command.schedule(unit.toMillis(delay)); }
From source file:org.encos.flydown.limiters.cache.impl.RedisRatingCache.java
public long cacheRequest(String evaluationKey, long timeRange, TimeUnit timeRangeUnit) { Date date = new Date(); cacheTemplate.opsForList().rightPush(evaluationKey, date.getTime()); cacheTemplate.expire(evaluationKey, timeRange, timeRangeUnit); log.debug("push({0}, {1}, {2})", evaluationKey, timeRange, timeRangeUnit.name()); return timeRangeUnit.toMillis(timeRange); }
From source file:org.apache.http.impl.conn.BasicClientConnectionManager.java
public void closeIdleConnections(final long idletime, final TimeUnit tunit) { Args.notNull(tunit, "Time unit"); synchronized (this) { assertNotShutdown();//from ww w . ja va2 s. c om long time = tunit.toMillis(idletime); if (time < 0) { time = 0; } final long deadline = System.currentTimeMillis() - time; if (this.poolEntry != null && this.poolEntry.getUpdated() <= deadline) { this.poolEntry.close(); this.poolEntry.getTracker().reset(); } } }
From source file:bear.core.AbstractConsole.java
public AbstractConsole spawn(ExecutorService service, int timeout, TimeUnit unit) { for (MyStreamCopier copier : copiers) { futures.add(copier.spawn(service, System.currentTimeMillis() + unit.toMillis(timeout))); }//from ww w. j a v a2s . c om return this; }
From source file:org.apache.http.impl.conn.tsccm.AbstractConnPool.java
/** * Closes idle connections./* www .j a v a 2s . co m*/ * * @param idletime the time the connections should have been idle * in order to be closed now * @param tunit the unit for the <code>idletime</code> */ public void closeIdleConnections(final long idletime, final TimeUnit tunit) { // idletime can be 0 or negative, no problem there Args.notNull(tunit, "Time unit"); poolLock.lock(); try { idleConnHandler.closeIdleConnections(tunit.toMillis(idletime)); } finally { poolLock.unlock(); } }