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:org.openspaces.admin.internal.pu.statistics.StatisticsObjectList.java

private Double getDeltaPerTimeunit(TimeUnit timeUnit) {
    if (notNumberClass != null) {
        throw new ClassCastException(notNumberClass + " cannot be cast to a Number");
    }// ww  w.  j  a v a  2  s.co m
    if (values.size() < 2) {
        return null;
    }

    Long timeWindowInTimeunit = timeUnit.convert(lastTimeStampMillis - firstTimeStampMillis,
            TimeUnit.MILLISECONDS);
    double lastValue = ((Number) last).doubleValue();
    double firstValue = ((Number) first).doubleValue();

    double deltaValuePerTimeunit = (lastValue - firstValue) / timeWindowInTimeunit;

    if (logger.isDebugEnabled()) {
        logger.debug("deltaValuePer" + timeUnit.toString() + "(" + toString() + ")=" + "(" + lastValue + "-"
                + firstValue + ")/" + timeWindowInTimeunit + "=" + deltaValuePerTimeunit);
    }
    return deltaValuePerTimeunit;
}

From source file:org.apache.hadoop.hbase.thrift2.client.ThriftTable.java

@Override
public long getRpcTimeout(TimeUnit unit) {
    return unit.convert(operationTimeout, TimeUnit.MILLISECONDS);
}

From source file:org.apache.hadoop.hbase.thrift2.client.ThriftTable.java

@Override
public long getReadRpcTimeout(TimeUnit unit) {
    return unit.convert(operationTimeout, TimeUnit.MILLISECONDS);
}

From source file:org.apache.hadoop.hbase.thrift2.client.ThriftTable.java

@Override
public long getWriteRpcTimeout(TimeUnit unit) {
    return unit.convert(operationTimeout, TimeUnit.MILLISECONDS);
}

From source file:org.apache.hadoop.hbase.thrift2.client.ThriftTable.java

@Override
public long getOperationTimeout(TimeUnit unit) {
    return unit.convert(operationTimeout, TimeUnit.MILLISECONDS);
}

From source file:com.netflix.simianarmy.basic.sniper.BasicSniperMonkey.java

/**
 * Instantiates a new basic sniper monkey.
 * @param ctx/*  w  ww .  ja  v  a 2s  . co m*/
 *            the ctx
 */
public BasicSniperMonkey(SniperMonkey.Context ctx) {
    super(ctx);

    this.cfg = ctx.configuration();
    this.monkeyCalendar = ctx.calendar();

    Calendar open = monkeyCalendar.now();
    Calendar close = monkeyCalendar.now();
    open.set(Calendar.HOUR, monkeyCalendar.openHour());
    close.set(Calendar.HOUR, monkeyCalendar.closeHour());

    TimeUnit freqUnit = ctx.scheduler().frequencyUnit();
    long units = freqUnit.convert(close.getTimeInMillis() - open.getTimeInMillis(), TimeUnit.MILLISECONDS);
    runsPerDay = units / ctx.scheduler().frequency();

    privateKey = this.cfg.getStr("simianarmy.sniper.privateKey");
    user = this.cfg.getStr("simianarmy.sniper.user");
    process = this.cfg.getStr("simianarmy.sniper.process");
}

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

@Override
public long getSchedulingPeriod(final TimeUnit timeUnit) {
    return timeUnit.convert(schedulingNanos.get(), TimeUnit.NANOSECONDS);
}

From source file:com.netflix.simianarmy.basic.chaos.BasicChaosMonkey.java

/**
 * Instantiates a new basic chaos monkey.
 * @param ctx/* w ww. ja  v a  2s . co  m*/
 *            the ctx
 */
public BasicChaosMonkey(ChaosMonkey.Context ctx) {
    super(ctx);

    this.cfg = ctx.configuration();
    this.monkeyCalendar = ctx.calendar();

    Calendar open = monkeyCalendar.now();
    Calendar close = monkeyCalendar.now();
    open.set(Calendar.HOUR, monkeyCalendar.openHour());
    close.set(Calendar.HOUR, monkeyCalendar.closeHour());

    allChaosTypes = Lists.newArrayList();
    allChaosTypes.add(new ShutdownInstanceChaosType(cfg));
    allChaosTypes.add(new BlockAllNetworkTrafficChaosType(cfg));
    allChaosTypes.add(new DetachVolumesChaosType(cfg));
    allChaosTypes.add(new BurnCpuChaosType(cfg));
    allChaosTypes.add(new BurnIoChaosType(cfg));
    allChaosTypes.add(new KillProcessesChaosType(cfg));
    allChaosTypes.add(new NullRouteChaosType(cfg));
    allChaosTypes.add(new FailEc2ChaosType(cfg));
    allChaosTypes.add(new FailDnsChaosType(cfg));
    allChaosTypes.add(new FailDynamoDbChaosType(cfg));
    allChaosTypes.add(new FailS3ChaosType(cfg));
    allChaosTypes.add(new FillDiskChaosType(cfg));
    allChaosTypes.add(new NetworkCorruptionChaosType(cfg));
    allChaosTypes.add(new NetworkLatencyChaosType(cfg));
    allChaosTypes.add(new NetworkLossChaosType(cfg));

    TimeUnit freqUnit = ctx.scheduler().frequencyUnit();
    if (TimeUnit.DAYS == freqUnit) {
        runsPerDay = ctx.scheduler().frequency();
    } else {
        long units = freqUnit.convert(close.getTimeInMillis() - open.getTimeInMillis(), TimeUnit.MILLISECONDS);
        runsPerDay = units / ctx.scheduler().frequency();
    }
}

From source file:voldemort.client.ClientConfig.java

public int getSocketTimeout(TimeUnit unit) {
    return toInt(unit.convert(socketTimeoutMs, TimeUnit.MILLISECONDS));
}

From source file:voldemort.client.ClientConfig.java

public int getRoutingTimeout(TimeUnit unit) {
    return toInt(unit.convert(routingTimeoutMs, TimeUnit.MILLISECONDS));
}