当前位置: 首页>>代码示例>>Java>>正文


Java Service.isRunning方法代码示例

本文整理汇总了Java中com.google.common.util.concurrent.Service.isRunning方法的典型用法代码示例。如果您正苦于以下问题:Java Service.isRunning方法的具体用法?Java Service.isRunning怎么用?Java Service.isRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.util.concurrent.Service的用法示例。


在下文中一共展示了Service.isRunning方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: awaitRunning

import com.google.common.util.concurrent.Service; //导入方法依赖的package包/类
/** Returns true if the Guava service entered the RUNNING state within the specified time period. */
private boolean awaitRunning(Service service, long timeoutAt) {
    if (service.isRunning()) {
        return true;
    }
    long waitMillis = timeoutAt - System.currentTimeMillis();
    if (waitMillis <= 0) {
        return false;
    }
    try {
        service.start().get(waitMillis, TimeUnit.MILLISECONDS);
    } catch (Exception e) {
        // Fall through
    }
    return service.isRunning();
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:17,代码来源:OstrichOwnerGroup.java

示例2: stopAll

import com.google.common.util.concurrent.Service; //导入方法依赖的package包/类
private void stopAll() throws Exception {
  Throwable failureCause = null;

  // Stop services in reverse order.
  Iterator<Service> itor = services.descendingIterator();
  while (itor.hasNext()) {
    Service service = itor.next();
    try {
      if (service.isRunning() || service.state() == State.STARTING) {
        service.stopAndWait();
      }
    } catch (UncheckedExecutionException e) {
      // Just catch as we want all services stopped
      if (failureCause == null) {
        failureCause = e.getCause();
      } else {
        // Log for sub-sequence service shutdown error, as only the first failure cause will be thrown.
        LOG.warn("Failed to stop service {}", service, e);
      }
    }
  }

  if (failureCause != null) {
    Throwables.propagateIfPossible(failureCause, Exception.class);
    throw new RuntimeException(failureCause);
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:28,代码来源:CompositeService.java


注:本文中的com.google.common.util.concurrent.Service.isRunning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。