• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TwillRunResources类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createRunningContainers

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private RunningContainers createRunningContainers(ContainerId appMasterContainerId,
                                                  String appMasterHost) throws Exception {
  int containerMemoryMB = Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_MEMORY_MB));

  // We can't get the -Xmx easily, so just recompute the -Xmx in the same way that the client does
  int maxHeapMemoryMB = Resources.computeMaxHeapSize(containerMemoryMB,
                                                     twillRuntimeSpec.getAMReservedMemory(),
                                                     twillRuntimeSpec.getAMMinHeapRatio());
  TwillRunResources appMasterResources = new DefaultTwillRunResources(
    0,
    appMasterContainerId.toString(),
    Integer.parseInt(System.getenv(EnvKeys.YARN_CONTAINER_VIRTUAL_CORES)),
    containerMemoryMB,
    maxHeapMemoryMB,
    appMasterHost, null);
  String appId = appMasterContainerId.getApplicationAttemptId().getApplicationId().toString();
  return new RunningContainers(twillRuntimeSpec, appId, appMasterResources, zkClient, applicationLocation,
                               twillSpec.getRunnables(), eventHandler);
}
 
开发者ID:apache,项目名称:twill,代码行数:20,代码来源:ApplicationMasterService.java


示例2: RunningContainers

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
RunningContainers(TwillRuntimeSpecification twillRuntimeSpec, String appId, TwillRunResources appMasterResources,
                  ZKClient zookeeperClient, Location applicationLocation,
                  Map<String, RuntimeSpecification> runnables,
                  EventHandler eventHandler) {
  containers = HashBasedTable.create();
  runnableInstances = Maps.newHashMap();
  completedContainerCount = Maps.newHashMap();
  startSequence = Lists.newLinkedList();
  containerLock = new ReentrantLock();
  containerChange = containerLock.newCondition();
  resourceReport = new DefaultResourceReport(appId, appMasterResources);
  zkClient = zookeeperClient;
  containerStats = HashMultimap.create();
  this.applicationLocation = applicationLocation;
  this.runnableNames = runnables.keySet();
  this.logLevels = new TreeMap<>();
  this.maxRetries = Maps.newHashMap(twillRuntimeSpec.getMaxRetries());
  this.numRetries = Maps.newHashMap();
  this.eventHandler = eventHandler;
}
 
开发者ID:apache,项目名称:twill,代码行数:21,代码来源:RunningContainers.java


示例3: waitForDebugPort

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private boolean waitForDebugPort(TwillController controller, String runnable, int timeLimit)
  throws InterruptedException {
  long millis = 0;
  while (millis < 1000 * timeLimit) {
    ResourceReport report = controller.getResourceReport();
    if (report == null || report.getRunnableResources(runnable) == null) {
      continue;
    }
    for (TwillRunResources resources : report.getRunnableResources(runnable)) {
      if (resources.getDebugPort() != null) {
        return true;
      }
    }
    TimeUnit.MILLISECONDS.sleep(100);
    millis += 100;
  }
  return false;
}
 
开发者ID:apache,项目名称:twill,代码行数:19,代码来源:DebugTestRun.java


示例4: waitForLogLevel

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private boolean waitForLogLevel(TwillController controller, String runnable, long timeout,
                                TimeUnit timeoutUnit, @Nullable LogEntry.Level expected) throws InterruptedException {

  Stopwatch stopwatch = new Stopwatch();
  stopwatch.start();
  do {
    ResourceReport report = controller.getResourceReport();
    if (report == null || report.getRunnableResources(runnable) == null) {
      continue;
    }
    for (TwillRunResources resources : report.getRunnableResources(runnable)) {
      LogEntry.Level level = resources.getLogLevels().get(Logger.ROOT_LOGGER_NAME);
      if (expected == level) {
         return true;
      }
    }
    TimeUnit.MILLISECONDS.sleep(100);
  } while (stopwatch.elapsedTime(timeoutUnit) < timeout);

  return false;
}
 
开发者ID:apache,项目名称:twill,代码行数:22,代码来源:LogLevelTestRun.java


示例5: waitForInstance

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private void waitForInstance(TwillController controller, String runnable, String yarnInstanceId,
                             long timeout, TimeUnit timeoutUnit) throws InterruptedException, TimeoutException {
  Stopwatch stopwatch = new Stopwatch();
  stopwatch.start();
  do {
    ResourceReport report = controller.getResourceReport();
    if (report != null && report.getRunnableResources(runnable) != null) {
      for (TwillRunResources resources : report.getRunnableResources(runnable)) {
        if (resources.getContainerId().endsWith(yarnInstanceId)) {
          return;
        }
      }
    }
    TimeUnit.SECONDS.sleep(1);
  } while (stopwatch.elapsedTime(timeoutUnit) < timeout);

  throw new TimeoutException("Timeout reached while waiting for runnable " +
                               runnable + " instance " + yarnInstanceId);
}
 
开发者ID:apache,项目名称:twill,代码行数:20,代码来源:RestartRunnableTestRun.java


示例6: validateInstanceIds

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private void validateInstanceIds(String runnable, Set<Integer> instanceIds) {
  ResourceReport resourceReport = getResourceReport();
  if (resourceReport == null) {
    throw new IllegalStateException("Unable to get resource report since application has not started.");
  }
  Collection<TwillRunResources> runnableResources = resourceReport.getRunnableResources(runnable);
  if (runnableResources == null) {
    throw new RuntimeException("Unable to verify run resources for runnable " + runnable);
  }
  Set<Integer> existingInstanceIds = Sets.newHashSet();
  for (TwillRunResources twillRunResources : runnableResources) {
    existingInstanceIds.add(twillRunResources.getInstanceId());
  }
  LOG.info("Existing instance ids: {}", existingInstanceIds);
  for (int instanceId : instanceIds) {
    if (!existingInstanceIds.contains(instanceId)) {
      throw new IllegalArgumentException("Unable to find instance id " + instanceId + " for " + runnable);
    }
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:21,代码来源:AbstractTwillController.java


示例7: serialize

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
@Override
public JsonElement serialize(TwillRunResources src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject json = new JsonObject();

  json.addProperty(CONTAINER_ID, src.getContainerId());
  json.addProperty(INSTANCE_ID, src.getInstanceId());
  json.addProperty(HOST, src.getHost());
  json.addProperty(MEMORY_MB, src.getMemoryMB());
  json.addProperty(MAX_HEAP_MEMORY_MB, src.getMaxHeapMemoryMB());
  json.addProperty(VIRTUAL_CORES, src.getVirtualCores());
  if (src.getDebugPort() != null) {
    json.addProperty(DEBUG_PORT, src.getDebugPort());
  }
  json.add(LOG_LEVELS, context.serialize(src.getLogLevels(),
                                         new TypeToken<Map<String, LogEntry.Level>>() { }.getType()));

  return json;
}
 
开发者ID:apache,项目名称:twill,代码行数:19,代码来源:TwillRunResourcesCodec.java


示例8: deserialize

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
@Override
public TwillRunResources deserialize(JsonElement json, Type typeOfT,
                                         JsonDeserializationContext context) throws JsonParseException {
  JsonObject jsonObj = json.getAsJsonObject();
  Map<String, LogEntry.Level> logLevels =
    context.deserialize(jsonObj.get(LOG_LEVELS), new TypeToken<Map<String, LogEntry.Level>>() { }.getType());
  int memoryMB = jsonObj.get(MEMORY_MB).getAsInt();
  return new DefaultTwillRunResources(
    jsonObj.get(INSTANCE_ID).getAsInt(),
    jsonObj.get(CONTAINER_ID).getAsString(),
    jsonObj.get(VIRTUAL_CORES).getAsInt(),
    memoryMB,
    // For backward compatibility when a newer Twill client re-attached to running app started with older version.
    jsonObj.has(MAX_HEAP_MEMORY_MB) ? jsonObj.get(MAX_HEAP_MEMORY_MB).getAsInt() : memoryMB,
    jsonObj.get(HOST).getAsString(),
    jsonObj.has(DEBUG_PORT) ? jsonObj.get(DEBUG_PORT).getAsInt() : null,
    logLevels);
}
 
开发者ID:apache,项目名称:twill,代码行数:19,代码来源:TwillRunResourcesCodec.java


示例9: reportIsLoading

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
/**
 * Checks to see if the report has loaded.
 * @param report - The {@link ResourceReport} for this Twill Application.
 * @return Return true if the report is null or incomplete.  Return false if the report is completely loaded.
 */
private boolean reportIsLoading(@Nullable final ResourceReport report) {
    if(report == null) {
        return true;
    }

    final String yarnApplicationID = report.getApplicationId();
    final Collection<TwillRunResources> runnableResources = report.getResources().get(PeriodicNotificationTwillRunnable.TWILL_RUNNABLE_NAME);

    if(runnableResources == null || runnableResources.isEmpty()) {
        LOG.info("Received Resource Report for YARN ApplicationID: {}, runnable resources are still loading...", yarnApplicationID);
        return true;
    } else {
        LOG.info("Received Resource Report for YARN ApplicationID: {}, runnable resources are loaded.", yarnApplicationID);
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:PeriodicNotificationTwillRunner.java


示例10: start

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
void start(String runnableName, ContainerInfo containerInfo, TwillContainerLauncher launcher) {
  containerLock.lock();
  try {
    int instanceId = getStartInstanceId(runnableName);
    RunId runId = getRunId(runnableName, instanceId);
    TwillContainerController controller = launcher.start(runId, instanceId,
                                                         TwillContainerMain.class, "$HADOOP_CONF_DIR");
    containers.put(runnableName, containerInfo.getId(), controller);
    TwillRunResources resources = new DynamicTwillRunResources(instanceId,
                                                               containerInfo.getId(),
                                                               containerInfo.getVirtualCores(),
                                                               containerInfo.getMemoryMB(),
                                                               containerInfo.getHost().getHostName(),
                                                               controller);
    resourceReport.addRunResources(runnableName, resources);
    containerStats.put(runnableName, containerInfo);

    if (startSequence.isEmpty() || !runnableName.equals(startSequence.peekLast())) {
      startSequence.addLast(runnableName);
    }
    containerChange.signalAll();

  } finally {
    containerLock.unlock();
  }
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:27,代码来源:RunningContainers.java


示例11: 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


示例12: start

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
/**
 * Start a container for a runnable.
 */
void start(String runnableName, ContainerInfo containerInfo, TwillContainerLauncher launcher) {
  containerLock.lock();
  try {
    int instanceId = getStartInstanceId(runnableName);
    RunId runId = getRunId(runnableName, instanceId);
    TwillContainerController controller = launcher.start(runId, instanceId,
                                                         TwillContainerMain.class, "$HADOOP_CONF_DIR",
                                                         saveLogLevels());
    containers.put(runnableName, containerInfo.getId(), controller);
    TwillRunResources resources = new DynamicTwillRunResources(instanceId,
                                                               containerInfo.getId(),
                                                               containerInfo.getVirtualCores(),
                                                               containerInfo.getMemoryMB(),
                                                               launcher.getMaxHeapMemoryMB(),
                                                               containerInfo.getHost().getHostName(),
                                                               controller);
    resourceReport.addRunResources(runnableName, resources);
    containerStats.put(runnableName, containerInfo);

    if (startSequence.isEmpty() || !runnableName.equals(startSequence.peekLast())) {
      startSequence.addLast(runnableName);
    }
    containerChange.signalAll();       
    // call event handler containerLaunched. 
    eventHandler.containerLaunched(runnableName, instanceId, containerInfo.getId());
  } finally {
    containerLock.unlock();
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:33,代码来源:RunningContainers.java


示例13: getTwillContainersUsed

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private int getTwillContainersUsed(TwillController controller) {
  if (controller.getResourceReport() == null) {
    return 0;
  }

  int count = 1; // 1 for app master container
  ResourceReport resourceReport = controller.getResourceReport();
  for (Collection<TwillRunResources> resources : resourceReport.getResources().values()) {
    count += resources.size();
  }
  return count;
}
 
开发者ID:apache,项目名称:twill,代码行数:13,代码来源:RestartRunnableTestRun.java


示例14: waitForLogLevel

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private void waitForLogLevel(TwillController controller, String runnable, long timeout,
                             TimeUnit timeoutUnit, LogEntry.Level expected,
                             Map<String, LogEntry.Level> expectedArgs) throws InterruptedException {

  Stopwatch stopwatch = new Stopwatch();
  stopwatch.start();
  LogEntry.Level actual = null;
  Map<String, LogEntry.Level> actualArgs = null;
  boolean stopped = false;
  do {
    ResourceReport report = controller.getResourceReport();
    if (report == null || report.getRunnableResources(runnable) == null) {
      continue;
    }
    for (TwillRunResources resources : report.getRunnableResources(runnable)) {
      actual = resources.getLogLevels().get(Logger.ROOT_LOGGER_NAME);
      actualArgs = resources.getLogLevels();
      if (actual != null && actual.equals(expected)) {
        stopped = true;
        break;
      }
    }
    TimeUnit.MILLISECONDS.sleep(100);
  } while (!stopped && stopwatch.elapsedTime(timeoutUnit) < timeout);
  Assert.assertEquals(expected, actual);
  Assert.assertEquals(expectedArgs, actualArgs);
}
 
开发者ID:apache,项目名称:twill,代码行数:28,代码来源:LogLevelChangeTestRun.java


示例15: DefaultResourceReport

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
public DefaultResourceReport(String applicationId, TwillRunResources masterResources,
                             Map<String, Collection<TwillRunResources>> resources, List<String> services) {
  this.applicationId = applicationId;
  this.appMasterResources = masterResources;
  this.usedResources = HashMultimap.create();
  for (Map.Entry<String, Collection<TwillRunResources>> entry : resources.entrySet()) {
    this.usedResources.putAll(entry.getKey(), entry.getValue());
  }
  this.services = new AtomicReference<>(services);
}
 
开发者ID:apache,项目名称:twill,代码行数:11,代码来源:DefaultResourceReport.java


示例16: removeRunnableResources

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
/**
 * Remove the resource corresponding to the given runnable and container.
 *
 * @param runnableName name of runnable.
 * @param containerId container id of the runnable.
 */
public void removeRunnableResources(String runnableName, String containerId) {
  TwillRunResources toRemove = null;
  // could be faster if usedResources was a Table, but that makes returning the
  // report a little more complex, and this does not need to be terribly fast.
  for (TwillRunResources resources : usedResources.get(runnableName)) {
    if (resources.getContainerId().equals(containerId)) {
      toRemove = resources;
      break;
    }
  }
  usedResources.remove(runnableName, toRemove);
}
 
开发者ID:apache,项目名称:twill,代码行数:19,代码来源:DefaultResourceReport.java


示例17: serialize

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
@Override
public JsonElement serialize(ResourceReport src, Type typeOfSrc, JsonSerializationContext context) {
  JsonObject json = new JsonObject();

  json.addProperty("appMasterId", src.getApplicationId());
  json.add("appMasterResources", context.serialize(src.getAppMasterResources(), TwillRunResources.class));
  json.add("runnableResources", context.serialize(
    src.getResources(), new TypeToken<Map<String, Collection<TwillRunResources>>>() { }.getType()));
  json.add("services", context.serialize(
    src.getServices(), new TypeToken<List<String>>() { }.getType()));
  return json;
}
 
开发者ID:apache,项目名称:twill,代码行数:13,代码来源:ResourceReportCodec.java


示例18: deserialize

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
@Override
public ResourceReport deserialize(JsonElement json, Type typeOfT,
                                         JsonDeserializationContext context) throws JsonParseException {
  JsonObject jsonObj = json.getAsJsonObject();
  String appMasterId = jsonObj.get("appMasterId").getAsString();
  TwillRunResources masterResources = context.deserialize(
    jsonObj.get("appMasterResources"), TwillRunResources.class);
  Map<String, Collection<TwillRunResources>> resources = context.deserialize(
    jsonObj.get("runnableResources"), new TypeToken<Map<String, Collection<TwillRunResources>>>() { }.getType());
  List<String> services = context.deserialize(
    jsonObj.get("services"), new TypeToken<List<String>>() { }.getType());

  return new DefaultResourceReport(appMasterId, masterResources, resources, services);
}
 
开发者ID:apache,项目名称:twill,代码行数:15,代码来源:ResourceReportCodec.java


示例19: ResourceReportAdapter

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
private ResourceReportAdapter() {
  gson = new GsonBuilder()
            .serializeNulls()
            .setPrettyPrinting()
            .registerTypeAdapter(TwillRunResources.class, new TwillRunResourcesCodec())
            .registerTypeAdapter(ResourceReport.class, new ResourceReportCodec())
            .create();
}
 
开发者ID:apache,项目名称:twill,代码行数:9,代码来源:ResourceReportAdapter.java


示例20: DefaultResourceReport

import org.apache.twill.api.TwillRunResources; //导入依赖的package包/类
public DefaultResourceReport(String applicationId, TwillRunResources masterResources,
                             Map<String, Collection<TwillRunResources>> resources, List<String> services) {
  this.applicationId = applicationId;
  this.appMasterResources = masterResources;
  this.usedResources = HashMultimap.create();
  for (Map.Entry<String, Collection<TwillRunResources>> entry : resources.entrySet()) {
    this.usedResources.putAll(entry.getKey(), entry.getValue());
  }
  this.services = new AtomicReference<List<String>>(services);
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:11,代码来源:DefaultResourceReport.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CloseHelper类代码示例发布时间:2022-05-22
下一篇:
Java XulListbox类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap