use of java.util.concurrent.TimeUnit in project elasticsearch by elastic.
the class RecoverySettingsDynamicUpdateTests method testInternalLongActionTimeout.
public void testInternalLongActionTimeout() {
long duration = between(1, 1000);
TimeUnit timeUnit = randomFrom(TimeUnit.MILLISECONDS, TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS);
clusterSettings.applySettings(Settings.builder().put(RecoverySettings.INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT_SETTING.getKey(), duration, timeUnit).build());
assertEquals(new TimeValue(duration, timeUnit), recoverySettings.internalActionLongTimeout());
}
use of java.util.concurrent.TimeUnit in project elasticsearch by elastic.
the class RecoverySettingsDynamicUpdateTests method testRetryDelayNetwork.
public void testRetryDelayNetwork() {
long duration = between(1, 1000);
TimeUnit timeUnit = randomFrom(TimeUnit.MILLISECONDS, TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS);
clusterSettings.applySettings(Settings.builder().put(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK_SETTING.getKey(), duration, timeUnit).build());
assertEquals(new TimeValue(duration, timeUnit), recoverySettings.retryDelayNetwork());
}
use of java.util.concurrent.TimeUnit in project elasticsearch by elastic.
the class WorkingBulkByScrollTaskTests method testDelayNeverNegative.
public void testDelayNeverNegative() throws IOException {
// Thread pool that returns a ScheduledFuture that claims to have a negative delay
ThreadPool threadPool = new TestThreadPool("test") {
public ScheduledFuture<?> schedule(TimeValue delay, String name, Runnable command) {
return new ScheduledFuture<Void>() {
@Override
public long getDelay(TimeUnit unit) {
return -1;
}
@Override
public int compareTo(Delayed o) {
throw new UnsupportedOperationException();
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
throw new UnsupportedOperationException();
}
@Override
public boolean isCancelled() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDone() {
throw new UnsupportedOperationException();
}
@Override
public Void get() throws InterruptedException, ExecutionException {
throw new UnsupportedOperationException();
}
@Override
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
throw new UnsupportedOperationException();
}
};
}
};
try {
// Have the task use the thread pool to delay a task that does nothing
task.delayPrepareBulkRequest(threadPool, timeValueSeconds(0), 1, new AbstractRunnable() {
@Override
protected void doRun() throws Exception {
}
@Override
public void onFailure(Exception e) {
throw new UnsupportedOperationException();
}
});
// Even though the future returns a negative delay we just return 0 because the time is up.
assertEquals(timeValueSeconds(0), task.getStatus().getThrottledUntil());
} finally {
threadPool.shutdown();
}
}
use of java.util.concurrent.TimeUnit in project hive by apache.
the class HouseKeeperServiceBase method start.
@Override
public void start(HiveConf hiveConf) throws Exception {
this.hiveConf = hiveConf;
HiveTxnManager mgr = TxnManagerFactory.getTxnManagerFactory().getTxnManager(hiveConf);
if (!mgr.supportsAcid()) {
LOG.info(this.getClass().getName() + " not started since " + mgr.getClass().getName() + " does not support Acid.");
//there are no transactions in this case
return;
}
pool = Executors.newScheduledThreadPool(1, new ThreadFactory() {
private final AtomicInteger threadCounter = new AtomicInteger();
@Override
public Thread newThread(Runnable r) {
return new Thread(r, HouseKeeperServiceBase.this.getClass().getName() + "-" + threadCounter.getAndIncrement());
}
});
TimeUnit tu = TimeUnit.MILLISECONDS;
pool.scheduleAtFixedRate(getScheduedAction(hiveConf, isAliveCounter), getStartDelayMs(), getIntervalMs(), tu);
LOG.info("Started " + this.getClass().getName() + " with delay/interval = " + getStartDelayMs() + "/" + getIntervalMs() + " " + tu);
}
use of java.util.concurrent.TimeUnit in project buck by facebook.
the class NetworkStatsKeeper method scheduleDownloadSpeedCalculation.
private void scheduleDownloadSpeedCalculation() {
long calculationInterval = DOWNLOAD_SPEED_CALCULATION_INTERVAL.toMillis();
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
@SuppressWarnings("unused") ScheduledFuture<?> unused = scheduler.scheduleAtFixedRate(this::calculateDownloadSpeedInLastInterval, /* initialDelay */
calculationInterval, /* period */
calculationInterval, timeUnit);
}
Aggregations