gpt4 book ai didi

org.apache.twill.internal.yarn.YarnUtils.getVirtualCores()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 04:23:31 28 4
gpt4 key购买 nike

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

YarnUtils.getVirtualCores介绍

暂无

代码示例

代码示例来源:origin: org.apache.twill/twill-yarn

@Override
 public int getVirtualCores() {
  return YarnUtils.getVirtualCores(container.getResource());
 }
}

代码示例来源:origin: org.apache.twill/twill-yarn

@Override
protected Resource adjustCapability(Resource resource) {
 int cores = YarnUtils.getVirtualCores(resource);
 int updatedCores = Math.max(Math.min(cores, YarnUtils.getVirtualCores(maxCapability)),
               YarnUtils.getVirtualCores(minCapability));
 // Try and set the virtual cores, which older versions of YARN don't support this.
 if (cores != updatedCores && YarnUtils.setVirtualCores(resource, updatedCores)) {
  LOG.info("Adjust virtual cores requirement from {} to {}.", cores, updatedCores);
 }
 int updatedMemory = Math.min(resource.getMemory(), maxCapability.getMemory());
 int minMemory = minCapability.getMemory();
 updatedMemory = (int) Math.ceil(((double) updatedMemory / minMemory)) * minMemory;
 if (resource.getMemory() != updatedMemory) {
  LOG.info("Adjust memory requirement from {} to {} MB.", resource.getMemory(), updatedMemory);
  resource.setMemory(updatedMemory);
 }
 return resource;
}

代码示例来源:origin: cdapio/cdap

private void reportYarnResources() {
 try {
  long totalMemory = 0L;
  long totalVCores = 0L;
  long usedMemory = 0L;
  long usedVCores = 0L;
  for (NodeReport nodeReport : yarnClient.getNodeReports(NodeState.RUNNING)) {
   Resource capability = nodeReport.getCapability();
   Resource used = nodeReport.getUsed();
   totalMemory += capability.getMemory();
   totalVCores += YarnUtils.getVirtualCores(capability);
   usedMemory += used.getMemory();
   usedVCores += YarnUtils.getVirtualCores(used);
  }
  MetricsContext collector = getCollector();
  LOG.trace("YARN Cluster memory total={}MB, used={}MB", totalMemory, usedMemory);
  collector.gauge("resources.total.memory", totalMemory);
  collector.gauge("resources.used.memory", usedMemory);
  collector.gauge("resources.available.memory", totalMemory - usedMemory);
  LOG.trace("YARN Cluster vcores total={}, used={}", totalVCores, usedVCores);
  collector.gauge("resources.total.vcores", totalVCores);
  collector.gauge("resources.used.vcores", usedVCores);
  collector.gauge("resources.available.vcores", totalVCores - usedVCores);
 } catch (Exception e) {
  LOG.warn("Failed to gather YARN NodeReports", e);
 }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

private void reportYarnResources() {
 try {
  long totalMemory = 0L;
  long totalVCores = 0L;
  long usedMemory = 0L;
  long usedVCores = 0L;
  for (NodeReport nodeReport : yarnClient.getNodeReports(NodeState.RUNNING)) {
   Resource capability = nodeReport.getCapability();
   Resource used = nodeReport.getUsed();
   totalMemory += capability.getMemory();
   totalVCores += YarnUtils.getVirtualCores(capability);
   usedMemory += used.getMemory();
   usedVCores += YarnUtils.getVirtualCores(used);
  }
  MetricsContext collector = getCollector();
  LOG.trace("YARN Cluster memory total={}MB, used={}MB", totalMemory, usedMemory);
  collector.gauge("resources.total.memory", totalMemory);
  collector.gauge("resources.used.memory", usedMemory);
  collector.gauge("resources.available.memory", totalMemory - usedMemory);
  LOG.trace("YARN Cluster vcores total={}, used={}", totalVCores, usedVCores);
  collector.gauge("resources.total.vcores", totalVCores);
  collector.gauge("resources.used.vcores", usedVCores);
  collector.gauge("resources.available.vcores", totalVCores - usedVCores);
 } catch (Exception e) {
  LOG.warn("Failed to gather YARN NodeReports", e);
 }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com