org.apache.brooklyn.util.time.Time.timeRemaining()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中org.apache.brooklyn.util.time.Time.timeRemaining()方法的一些代码示例,展示了Time.timeRemaining()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.timeRemaining()方法的具体详情如下:
包路径:org.apache.brooklyn.util.time.Time
类名称:Time
方法名:timeRemaining

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), "");
}

相关文章