Example usage for java.util.concurrent TimeUnit convert

List of usage examples for java.util.concurrent TimeUnit convert

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit convert.

Prototype

public long convert(long sourceDuration, TimeUnit sourceUnit) 

Source Link

Document

Converts the given time duration in the given unit to this unit.

Usage

From source file:voldemort.client.ClientConfig.java

@Deprecated
public int getThreadIdleTime(TimeUnit unit) {
    return toInt(unit.convert(threadIdleMs, TimeUnit.MILLISECONDS));
}

From source file:voldemort.client.ClientConfig.java

/**
 * @deprecated Use {@link #getFailureDetectorBannagePeriod()} instead
 *//* w  ww  .  j  a va  2 s  . c om*/
@Deprecated
public int getNodeBannagePeriod(TimeUnit unit) {
    return toInt(unit.convert(failureDetectorBannagePeriod, TimeUnit.MILLISECONDS));
}

From source file:voldemort.client.ClientConfig.java

public int getConnectionTimeout(TimeUnit unit) {
    return (int) Math.min(unit.convert(connectionTimeoutMs, TimeUnit.MILLISECONDS), Integer.MAX_VALUE);
}

From source file:org.apache.nifi.controller.StandardProcessorNode.java

@Override
public long getRunDuration(final TimeUnit timeUnit) {
    return timeUnit.convert(this.runNanos, TimeUnit.NANOSECONDS);
}

From source file:org.apache.nifi.controller.StandardProcessorNode.java

/**
 * @param timeUnit/*w w  w.  j  a  v  a  2 s.  c o  m*/
 *            determines the unit of time to represent the scheduling
 *            period. If null will be reported in units of
 *            {@link #DEFAULT_SCHEDULING_TIME_UNIT}
 * @return the schedule period that should elapse before subsequent cycles
 *         of this processor's tasks
 */
@Override
public long getSchedulingPeriod(final TimeUnit timeUnit) {
    return timeUnit.convert(schedulingNanos.get(), TimeUnit.NANOSECONDS);
}

From source file:org.apache.cassandra.concurrent.ContinuationsExecutor.java

/**
 * Returns the thread keep-alive time, which is the amount of time that
 * threads in excess of the core pool size may remain idle before being
 * terminated.// w  ww .  ja va2 s .  c o m
 * 
 * @param unit
 *            the desired time unit of the result
 * @return the time limit
 * @see #setKeepAliveTime
 */
public long getKeepAliveTime(TimeUnit unit) {
    return unit.convert(keepAliveTime, TimeUnit.NANOSECONDS);
}

From source file:com.buaa.cfs.conf.Configuration.java

/**
 * Return time duration in the given time unit. Valid units are encoded in properties as suffixes: nanoseconds (ns),
 * microseconds (us), milliseconds (ms), seconds (s), minutes (m), hours (h), and days (d).
 *
 * @param name         Property name//from w  w  w .  j av a  2 s.  c o m
 * @param defaultValue Value returned if no mapping exists.
 * @param unit         Unit to convert the stored property, if it exists.
 *
 * @throws NumberFormatException If the property stripped of its unit is not a number
 */
public long getTimeDuration(String name, long defaultValue, TimeUnit unit) {
    String vStr = get(name);
    if (null == vStr) {
        return defaultValue;
    }
    vStr = vStr.trim();
    ParsedTimeDuration vUnit = ParsedTimeDuration.unitFor(vStr);
    if (null == vUnit) {
        LOG.warn("No unit for " + name + "(" + vStr + ") assuming " + unit);
        vUnit = ParsedTimeDuration.unitFor(unit);
    } else {
        vStr = vStr.substring(0, vStr.lastIndexOf(vUnit.suffix()));
    }
    return unit.convert(Long.parseLong(vStr), vUnit.unit());
}

From source file:org.apache.hadoop.hive.conf.HiveConf.java

public static long toTime(String value, TimeUnit inputUnit, TimeUnit outUnit) {
    String[] parsed = parseNumberFollowedByUnit(value.trim());
    return outUnit.convert(Long.parseLong(parsed[0].trim()), unitFor(parsed[1].trim(), inputUnit));
}