Search in sources :

Example 6 with TimeUnit

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();
}
Also used : Locale(java.util.Locale) ConsoleReporter(com.codahale.metrics.ConsoleReporter) TimeUnit(java.util.concurrent.TimeUnit)

Example 7 with TimeUnit

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);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HiveTxnManager(org.apache.hadoop.hive.ql.lockmgr.HiveTxnManager) TimeUnit(java.util.concurrent.TimeUnit)

Example 8 with TimeUnit

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;
        }
    };
}
Also used : CachedData(net.spy.memcached.CachedData) Future(java.util.concurrent.Future) OperationFuture(net.spy.memcached.internal.OperationFuture) BulkFuture(net.spy.memcached.internal.BulkFuture) TimeUnit(java.util.concurrent.TimeUnit)

Example 9 with TimeUnit

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();
        }
    };
}
Also used : CachedData(net.spy.memcached.CachedData) TimeUnit(java.util.concurrent.TimeUnit) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) BulkGetCompletionListener(net.spy.memcached.internal.BulkGetCompletionListener) BulkFuture(net.spy.memcached.internal.BulkFuture)

Example 10 with TimeUnit

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);
}
Also used : TimeUnit(java.util.concurrent.TimeUnit)

Aggregations

TimeUnit (java.util.concurrent.TimeUnit)190 Test (org.junit.Test)28 ExecutionException (java.util.concurrent.ExecutionException)16 IOException (java.io.IOException)11 TimeoutException (java.util.concurrent.TimeoutException)11 Future (java.util.concurrent.Future)10 HashMap (java.util.HashMap)7 TimeSpec (com.linkedin.thirdeye.api.TimeSpec)6 ArrayList (java.util.ArrayList)6 TimeValue (org.elasticsearch.common.unit.TimeValue)6 DataType (com.linkedin.pinot.common.data.FieldSpec.DataType)5 File (java.io.File)5 HashSet (java.util.HashSet)5 Matcher (java.util.regex.Matcher)5 WaitUntilGatewaySenderFlushedCoordinatorJUnitTest (org.apache.geode.internal.cache.wan.WaitUntilGatewaySenderFlushedCoordinatorJUnitTest)5 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)5 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)4 GwtIncompatible (com.google.common.annotations.GwtIncompatible)3 RestException (com.linkedin.r2.message.rest.RestException)3 Map (java.util.Map)3