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


Java TwillRunResources.getInstanceId方法代码示例

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


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

示例1: equals

import org.apache.twill.api.TwillRunResources; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
  if (!(o instanceof TwillRunResources)) {
    return false;
  }
  TwillRunResources other = (TwillRunResources) o;
  return (instanceId == other.getInstanceId()) &&
    containerId.equals(other.getContainerId()) &&
    host.equals(other.getHost()) &&
    (virtualCores == other.getVirtualCores()) &&
    (memoryMB == other.getMemoryMB());
  // debugPort is ignored here
}
 
开发者ID:apache,项目名称:twill,代码行数:14,代码来源:DefaultTwillRunResources.java

示例2: waitForAfterRestartResourceReport

import org.apache.twill.api.TwillRunResources; //导入方法依赖的package包/类
/**
 *  Need helper method here to wait for getting resource report because {@link TwillController#getResourceReport()}
 *  could return null if the application has not fully started.
 *
 *  This method helps validate restart scenario.
 *
 *  To avoid long sleep if instanceIdToContainerId is passed, then compare the container ids to ones before.
 *  Otherwise just return the valid resource report.
 */
@Nullable
private ResourceReport waitForAfterRestartResourceReport(TwillController controller, String runnable, long timeout,
                                                         TimeUnit timeoutUnit, int numOfResources,
                                                         @Nullable Map<Integer, String> instanceIdToContainerId) {
  Stopwatch stopwatch = new Stopwatch();
  stopwatch.start();
  do {
    ResourceReport report = controller.getResourceReport();
    if (report == null || report.getRunnableResources(runnable) == null) {
      Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
    } else if (report.getRunnableResources(runnable) == null ||
        report.getRunnableResources(runnable).size() != numOfResources) {
      Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
    } else {
      if (instanceIdToContainerId == null) {
        LOG.info("Return resource report without comparing container ids.");
        return report;
      }
      Collection<TwillRunResources> runResources = report.getRunnableResources(runnable);
      boolean isSameContainer = false;
      for (TwillRunResources twillRunResources : runResources) {
        int instanceId = twillRunResources.getInstanceId();
        if (twillRunResources.getContainerId().equals(instanceIdToContainerId.get(instanceId))) {
          // found same container id lets wait again.
          LOG.warn("Found an instance id {} with same container id {} for restart all, let's wait for a while.",
                   instanceId, twillRunResources.getContainerId());
          isSameContainer = true;
          break;
        }
      }
      if (!isSameContainer) {
        LOG.info("Get set of different container ids for restart.");
        return report;
      }
      Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
    }
  } while (stopwatch.elapsedTime(timeoutUnit) < timeout);

  LOG.error("Unable to get different container ids for restart.");
  return null;
}
 
开发者ID:apache,项目名称:twill,代码行数:51,代码来源:EchoServerTestRun.java


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