org.apache.hadoop.yarn.util.resource.Resources.multiplyAndRoundUp()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(99)

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

Resources.multiplyAndRoundUp介绍

暂无

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

/**
* Compute the maximum resource AM can use. The value is the result of
* multiplying FairShare and maxAMShare. If FairShare is zero, use
* min(maxShare, available resource) instead to prevent zero value for
* maximum AM resource since it forbids any job running in the queue.
*
* @return the maximum resource AM can use
*/
private Resource computeMaxAMResource() {
 Resource maxResource = Resources.clone(getFairShare());
 if (maxResource.getMemorySize() == 0) {
  maxResource.setMemorySize(
    Math.min(scheduler.getRootQueueMetrics().getAvailableMB(),
         getMaxShare().getMemorySize()));
 }
 if (maxResource.getVirtualCores() == 0) {
  maxResource.setVirtualCores(Math.min(
    scheduler.getRootQueueMetrics().getAvailableVirtualCores(),
    getMaxShare().getVirtualCores()));
 }
 // Round up to allow AM to run when there is only one vcore on the cluster
 return Resources.multiplyAndRoundUp(maxResource, maxAMShare);
}

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

@Test(timeout=10000)
public void testMultipleRoundUp() {
 final double by = 0.5;
 final String memoryErrorMsg = "Invalid memory size.";
 final String vcoreErrorMsg = "Invalid virtual core number.";
 Resource resource = Resources.createResource(1, 1);
 Resource result = Resources.multiplyAndRoundUp(resource, by);
 assertEquals(memoryErrorMsg, result.getMemorySize(), 1);
 assertEquals(vcoreErrorMsg, result.getVirtualCores(), 1);
 resource = Resources.createResource(2, 2);
 result = Resources.multiplyAndRoundUp(resource, by);
 assertEquals(memoryErrorMsg, result.getMemorySize(), 1);
 assertEquals(vcoreErrorMsg, result.getVirtualCores(), 1);
 resource = Resources.createResource(0, 0);
 result = Resources.multiplyAndRoundUp(resource, by);
 assertEquals(memoryErrorMsg, result.getMemorySize(), 0);
 assertEquals(vcoreErrorMsg, result.getVirtualCores(), 0);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

Resource expectedAMResource = Resources.multiplyAndRoundUp(
  queueFSZeroWithMax.getMaxShare(), queueFSZeroWithMax.getMaxAMShare());
assertEquals("QueueFSZeroWithMax's maximum AM resource should be "
expectedAMResource = Resources.multiplyAndRoundUp(
  Resources.createResource(memCapacity - amResource.getMemorySize(),
    cpuCapacity - amResource.getVirtualCores()),
expectedAMResource = Resources.multiplyAndRoundUp(
  queueFSNonZero.getFairShare(), queueFSNonZero.getMaxAMShare());
assertEquals("QueueFSNonZero's maximum AM resource should be "

相关文章