org.apache.hadoop.yarn.api.records.Resource.getResourceValue()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(73)

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

Resource.getResourceValue介绍

[英]Get the value for a specified resource. No information about the units is returned.
[中]获取指定资源的值。没有返回有关这些单位的信息。

代码示例

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

@Override
public long getResourceValue(String resource) {
 return super.getResourceValue(resource);
}

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

/**
 * Get number of requested GPUs from resource.
 * @param requestedResource requested resource
 * @return #gpus.
 */
public static int getRequestedGpus(Resource requestedResource) {
 try {
  return Long.valueOf(requestedResource.getResourceValue(
    GPU_URI)).intValue();
 } catch (ResourceNotFoundException e) {
  return 0;
 }
}

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

/**
 * Compute the resources assigned to a Schedulable given a particular
 * weight-to-resource ratio w2rRatio.
 */
private static int computeShare(Schedulable sched, double w2rRatio,
  String type) {
 double share = sched.getWeight() * w2rRatio;
 share = Math.max(share, sched.getMinShare().getResourceValue(type));
 share = Math.min(share, sched.getMaxShare().getResourceValue(type));
 return (int) share;
}

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

/**
  * Get the fairshare for the {@link Schedulable} if it is fixed, -1 otherwise.
  *
  * The fairshare is fixed if either the maxShare is 0, weight is 0,
  * or the Schedulable is not active for instantaneous fairshare.
  */
 private static long getFairShareIfFixed(Schedulable sched,
   boolean isSteadyShare, String type) {

  // Check if maxShare is 0
  if (sched.getMaxShare().getResourceValue(type) <= 0) {
   return 0;
  }

  // For instantaneous fairshares, check if queue is active
  if (!isSteadyShare &&
    (sched instanceof FSQueue) && !((FSQueue)sched).isActive()) {
   return 0;
  }

  // Check if weight is 0
  if (sched.getWeight() <= 0) {
   long minShare = sched.getMinShare().getResourceValue(type);
   return (minShare <= 0) ? 0 : minShare;
  }

  return -1;
 }
}

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

long maxShare = sched.getMaxShare().getResourceValue(type);
 totalMaxShare = (int) Math.min(maxShare + (long)totalMaxShare,
   Integer.MAX_VALUE);
long totalResource = Math.max((totalResources.getResourceValue(type) -
  takenResources), 0);
totalResource = Math.min(totalMaxShare, totalResource);

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

containerIdStr);
long deviceCount = requestedResource.getResourceValue(FPGA_URI);
LOG.info(containerIdStr + " requested " + deviceCount + " Intel FPGA(s)");
String ipFilePath = null;

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

cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
Assert.assertEquals(3333L,
  cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
Assert.assertEquals(
  YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
  cs.getMaximumResourceCapability()
    .getResourceValue(ResourceInformation.MEMORY_URI));
Assert.assertEquals(
  YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
  cs.getMaximumAllocation()
    .getResourceValue(ResourceInformation.MEMORY_URI));
Assert.assertEquals(
  YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
  cs.getMaximumResourceCapability()
    .getResourceValue(ResourceInformation.VCORES_URI));
Assert.assertEquals(
  YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
  cs.getMaximumAllocation()
    .getResourceValue(ResourceInformation.VCORES_URI));
  cs.getMaximumResourceCapability().getResourceValue(RESOURCE_1));
Assert.assertEquals(3333L,
  cs.getMaximumAllocation().getResourceValue(RESOURCE_1));
Assert.assertEquals(
  YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
  cs.getMaximumResourceCapability()
    .getResourceValue(ResourceInformation.MEMORY_URI));
Assert.assertEquals(
  YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,

相关文章