本文整理了Java中org.apache.brooklyn.util.time.Time.timeRemaining()
方法的一些代码示例,展示了Time.timeRemaining()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.timeRemaining()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.time.Time
类名称:Time
方法名:timeRemaining
[英]Calculates how long until maxTime has passed since the given startTime. However, maxTime==0 is a special case (e.g. could mean wait forever), so the result is guaranteed to be only 0 if maxTime was 0; otherwise -1 will be returned.
[中]计算从给定的开始时间到maxTime过去的时间。然而,maxTime==0是一种特殊情况(例如,可能意味着永远等待),因此如果maxTime为0,则结果保证仅为0;否则将返回-1。
代码示例来源:origin: org.apache.brooklyn/brooklyn-test-framework
@Override
public Boolean call() throws ExecutionException {
try {
long timeRemaining = Time.timeRemaining(startTime, timeout.toMilliseconds());
Object result = invokeEffector(targetEntity, effector, effectorParams, Duration.millis(timeRemaining));
effectorResult.set(result);
return true;
} catch (TimeoutException e) {
throw new AssertionError("Effector "+effector.getName()+" timed out after "+timeout, e);
}
}})
.limitIterationsTo(iterationLimit)
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testTimeRemaining() {
long gracePeriod = 5000;
long maxTime = 30000;
long now = System.currentTimeMillis();
long remaining = Time.timeRemaining(now, maxTime);
assertOrdered(ImmutableList.<Long>of(maxTime-gracePeriod, remaining, maxTime), "");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testTimeRemainingMaxLong() {
long gracePeriod = 5000;
long maxTime = Long.MAX_VALUE;
long now = System.currentTimeMillis();
long remaining = Time.timeRemaining(now, maxTime);
assertOrdered(ImmutableList.<Long>of(maxTime-gracePeriod, remaining, maxTime), "");
}
内容来源于网络,如有侵权,请联系作者删除!