作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.twill.internal.yarn.YarnUtils.getVirtualCores()
方法的一些代码示例,展示了YarnUtils.getVirtualCores()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarnUtils.getVirtualCores()
方法的具体详情如下:
包路径:org.apache.twill.internal.yarn.YarnUtils
类名称: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);
}
}
本文整理了Java中org.apache.twill.internal.yarn.YarnUtils.getVirtualCores()方法的一些代码示例,展示了YarnUtils.getVirtua
我是一名优秀的程序员,十分优秀!