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

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

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

Time.sleep介绍

[英]sleep which propagates Interrupted as unchecked
[中]不受控制地传播的睡眠

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override public void run() {
  LOG.debug("Deferring scanner for {} until management context initialisation complete", DynamicMultiGroupImpl.this);
  while (!isRebindComplete()) {
    Time.sleep(100); // avoid thrashing
  }
  LOG.debug("Connecting scanner for {}", DynamicMultiGroupImpl.this);
  connectScanner();
}
private boolean isRebindComplete() {

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override public void run() {
    Time.sleep(Duration.ONE_MINUTE);
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override public String call() {
    Time.sleep(pauseTime);
    return val;
  }
});

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override public T call() throws Exception {
    Time.sleep(delay);
    return result;
  }
})

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
  public Sensor<?> call() throws Exception {
    if (delay) Time.sleep(Duration.FIVE_SECONDS);
    return TestApplication.MY_ATTRIBUTE;
  }
});

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
  public String call() { 
    Time.sleep(timeout); 
    return result; 
  }}
).build();

代码示例来源:origin: org.apache.brooklyn/brooklyn-test-support

public static double getProcessCpuTime(Duration period) {
  Stopwatch stopwatch = Stopwatch.createStarted();
  long prevCpuTime = getProcessCpuTime();
  if (prevCpuTime==-1) {
    return -1;
  }
  Time.sleep(period);
  long currentCpuTime = getProcessCpuTime();
  long elapsedTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
  return (elapsedTime > 0) ? ((double)currentCpuTime-prevCpuTime) / TimeUnit.MILLISECONDS.toNanos(elapsedTime) : -1;
}

代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-mesos

@Override public void run() {
  LOG.debug("Deferring scanner for {} until management context initialisation complete", MesosFrameworkImpl.this);
  while (!isRebindComplete()) {
    Time.sleep(100); // avoid thrashing
  }
  LOG.debug("Connecting scanner for {}", MesosFrameworkImpl.this);
  connectSensors();
}
private boolean isRebindComplete() {

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
public void sleepEffector(Duration duration) {
  if (LOG.isTraceEnabled()) LOG.trace("In sleepEffector for {}", this);
  callHistory.add("sleepEffector");
  Time.sleep(duration);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Override
public void closePortForwarding(NodeMetadata node, int targetPort, HostAndPort publicHostAndPort, Protocol protocol) {
  calls.add(ImmutableList.of("close", System.currentTimeMillis(), node, targetPort, publicHostAndPort, protocol));
  Time.sleep(sleepBeforeReturning);
}
public void assertClosedEquals(Iterable<? extends HostAndPort> expected) {

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
  public void run() {
    while (submitCount.get() > counter.get() + 5000) {
      LOG.info("delaying because "+submitCount.get()+" submitted and only "+counter.get()+" run");
      Time.sleep(500);
    }
    executionManager.submit(MutableMap.of("tags", ImmutableList.of("singlethreaded")), work); 
    submitCount.incrementAndGet();
  }})
.completionLatch(completionLatch));

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testSocketResultIgnoredIfGracePeriodExpiresAfterFirstResultAvailable() {
  reachabilityResults.put(socket1, false);
  reachabilityResults.put(socket2, true);
  // Override the default test grace period.
  finder = new ReachableSocketFinder(socketTester, Duration.ZERO);
  final Iterable<HostAndPort> actual = finder.findOpenSocketsOnNode(ImmutableList.of(socket1, socket2), TIMEOUT);
  // Sleep through the grace period.
  Time.sleep(50);
  reachabilityResults.put(socket1, true);
  assertEquals(actual, ImmutableList.of(socket2));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override public void onEvent(SensorEvent<Integer> event) {
  data.add(event.getValue());
  Time.sleep((int)(20*Math.random()));
  log.info("Thread "+Thread.currentThread()+" notify on subscription received for "+event.getValue()+", data is "+data);
  latch.countDown();
}});

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
  server = initializeServer();
  initVars();
  Time.sleep(DELAY_FOR_SERVER_TO_SETTLE);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base

protected boolean tryCheckStartService() {
  if (getServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("/etc/init.d/"+getServiceName()+" status").runAsRoot()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (service "+getServiceName()+")");
  }
  return true;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base

protected boolean tryCheckStartWindowsService() {
  if (getWindowsServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("sc query \""+getWindowsServiceName()+"\" | find \"RUNNING\"").runAsCommand()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (windowsService "+getWindowsServiceName()+")");
  }
  return true;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-cm-chef

protected boolean tryCheckStartService() {
  if (getServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("/etc/init.d/"+getServiceName()+" status").runAsRoot()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (service "+getServiceName()+")");
  }
  return true;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
  public void stop() {
    try {
      if (getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH).countDown();
      if (getConfig(SHUTDOWN_DELAY) != null) Time.sleep(getConfig(SHUTDOWN_DELAY));
      if (getConfig(SHUTDOWN_LATCH) != null) getConfig(SHUTDOWN_LATCH).await();
      super.stop();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw Throwables.propagate(e);
    }
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

Thread t = new Thread() { @Override public void run() {
  if (staggerStart!=null) Time.sleep(staggerStart.multiply(Math.random()));
  n.ha.start(HighAvailabilityMode.AUTO);
  n.ha.setPollPeriod(Duration.millis(20));
} };
spawned.add(t);

代码示例来源:origin: org.apache.brooklyn/brooklyn-policy

private void stopWithoutLock() {
  running = false;
  Time.sleep(getDelay());
  sensors().set(SERVICE_UP, false);
}

相关文章