use of java.util.concurrent.TimeUnit in project storm by apache.
the class ConsolePreparableReporter method prepare.
@Override
public void prepare(MetricRegistry metricsRegistry, Map stormConf) {
LOG.debug("Preparing...");
ConsoleReporter.Builder builder = ConsoleReporter.forRegistry(metricsRegistry);
builder.outputTo(System.out);
Locale locale = MetricsUtils.getMetricsReporterLocale(stormConf);
if (locale != null) {
builder.formattedFor(locale);
}
TimeUnit rateUnit = MetricsUtils.getMetricsRateUnit(stormConf);
if (rateUnit != null) {
builder.convertRatesTo(rateUnit);
}
TimeUnit durationUnit = MetricsUtils.getMetricsDurationUnit(stormConf);
if (durationUnit != null) {
builder.convertDurationsTo(durationUnit);
}
reporter = builder.build();
}
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 druid by druid-io.
the class MockMemcachedClient method asyncGet.
@Override
public <T> Future<T> asyncGet(String key, final Transcoder<T> tc) {
CachedData data = theMap.get(key);
final T theValue = data != null ? tc.decode(data) : null;
return new Future<T>() {
@Override
public boolean cancel(boolean b) {
return false;
}
@Override
public boolean isCancelled() {
return false;
}
@Override
public boolean isDone() {
return true;
}
@Override
public T get() throws InterruptedException, ExecutionException {
return theValue;
}
@Override
public T get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
return theValue;
}
};
}
use of java.util.concurrent.TimeUnit in project druid by druid-io.
the class MockMemcachedClient method asyncGetBulk.
@Override
public <T> BulkFuture<Map<String, T>> asyncGetBulk(final Iterator<String> keys, final Transcoder<T> tc) {
return new BulkFuture<Map<String, T>>() {
@Override
public boolean isTimeout() {
return false;
}
@Override
public Map<String, T> getSome(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException {
return get();
}
@Override
public OperationStatus getStatus() {
return null;
}
@Override
public Future<Map<String, T>> addListener(BulkGetCompletionListener bulkGetCompletionListener) {
return null;
}
@Override
public Future<Map<String, T>> removeListener(BulkGetCompletionListener bulkGetCompletionListener) {
return null;
}
@Override
public boolean cancel(boolean b) {
return false;
}
@Override
public boolean isCancelled() {
return false;
}
@Override
public boolean isDone() {
return true;
}
@Override
public Map<String, T> get() throws InterruptedException, ExecutionException {
Map<String, T> retVal = Maps.newHashMap();
while (keys.hasNext()) {
String key = keys.next();
CachedData data = theMap.get(key);
retVal.put(key, data != null ? tc.decode(data) : null);
}
return retVal;
}
@Override
public Map<String, T> get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
return get();
}
};
}
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