当前位置: 首页>>代码示例>>Java>>正文


Java ResourceWeights.setWeight方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights.setWeight方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceWeights.setWeight方法的具体用法?Java ResourceWeights.setWeight怎么用?Java ResourceWeights.setWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights的用法示例。


在下文中一共展示了ResourceWeights.setWeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateShares

import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights; //导入方法依赖的package包/类
/**
 * Calculates and orders a resource's share of a pool in terms of two vectors.
 * The shares vector contains, for each resource, the fraction of the pool that
 * it takes up.  The resourceOrder vector contains an ordering of resources
 * by largest share.  So if resource=<10 MB, 5 CPU>, and pool=<100 MB, 10 CPU>,
 * shares will be [.1, .5] and resourceOrder will be [CPU, MEMORY].
 */
void calculateShares(Resource resource, Resource pool,
    ResourceWeights shares, ResourceType[] resourceOrder, ResourceWeights weights) {
  shares.setWeight(MEMORY, (float)resource.getMemory() /
      (pool.getMemory() * weights.getWeight(MEMORY)));
  shares.setWeight(CPU, (float)resource.getVirtualCores() /
      (pool.getVirtualCores() * weights.getWeight(CPU)));
  // sort order vector by resource share
  if (resourceOrder != null) {
    if (shares.getWeight(MEMORY) > shares.getWeight(CPU)) {
      resourceOrder[0] = MEMORY;
      resourceOrder[1] = CPU;
    } else  {
      resourceOrder[0] = CPU;
      resourceOrder[1] = MEMORY;
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:25,代码来源:DominantResourceFairnessPolicy.java

示例2: calculateShares

import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights; //导入方法依赖的package包/类
/**
 * Calculates and orders a resource's share of a pool in terms of two vectors.
 * The shares vector contains, for each resource, the fraction of the pool that
 * it takes up.  The resourceOrder vector contains an ordering of resources
 * by largest share.  So if resource=<10 MB, 5 CPU>, and pool=<100 MB, 10 CPU>,
 * shares will be [.1, .5] and resourceOrder will be [CPU, MEMORY].
 */
void calculateShares(Resource resource, Resource pool,
    ResourceWeights shares, ResourceType[] resourceOrder, ResourceWeights weights) {
  shares.setWeight(MEMORY, (float)resource.getMemorySize() /
      (pool.getMemorySize() * weights.getWeight(MEMORY)));
  shares.setWeight(CPU, (float)resource.getVirtualCores() /
      (pool.getVirtualCores() * weights.getWeight(CPU)));
  // sort order vector by resource share
  if (resourceOrder != null) {
    if (shares.getWeight(MEMORY) > shares.getWeight(CPU)) {
      resourceOrder[0] = MEMORY;
      resourceOrder[1] = CPU;
      resourceOrder[2] = GPU;
    } else  {
      resourceOrder[0] = CPU;
      resourceOrder[1] = MEMORY;
      resourceOrder[2] = GPU;
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:27,代码来源:DominantResourceFairnessPolicy.java

示例3: getAppWeight

import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights; //导入方法依赖的package包/类
public synchronized ResourceWeights getAppWeight(FSAppAttempt app) {
  double weight = 1.0;
  if (sizeBasedWeight) {
    // Set weight based on current memory demand
    weight = Math.log1p(app.getDemand().getMemory()) / Math.log(2);
  }
  weight *= app.getPriority().getPriority();
  if (weightAdjuster != null) {
    // Run weight through the user-supplied weightAdjuster
    weight = weightAdjuster.adjustWeight(app, weight);
  }
  ResourceWeights resourceWeights = app.getResourceWeights();
  resourceWeights.setWeight((float)weight);
  return resourceWeights;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:FairScheduler.java

示例4: calculateShares

import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights; //导入方法依赖的package包/类
/**
 * Calculates and orders a resource's share of a pool in terms of two vectors.
 * The shares vector contains, for each resource, the fraction of the pool that
 * it takes up.  The resourceOrder vector contains an ordering of resources
 * by largest share.  So if resource=<10 MB, 5 CPU>, and pool=<100 MB, 10 CPU>,
 * shares will be [.1, .5] and resourceOrder will be [CPU, MEMORY].
 */
void calculateShares(Resource resource, Resource pool,
    ResourceWeights shares, ResourceType[] resourceOrder, ResourceWeights weights) {
  shares.setWeight(MEMORY, (float)resource.getMemory() /
      (pool.getMemory() * weights.getWeight(MEMORY)));
  shares.setWeight(CPU, (float)resource.getVirtualCores() /
      (pool.getVirtualCores() * weights.getWeight(CPU)));
  shares.setWeight(GPU, (float)resource.getGPUCores() /
          (pool.getGPUCores() * weights.getWeight(GPU)));
  // sort order vector by resource share
  if (resourceOrder != null) {
    if (shares.getWeight(MEMORY) > shares.getWeight(CPU) && shares.getWeight(CPU) > shares.getWeight(GPU)) {
      resourceOrder[0] = MEMORY;
      resourceOrder[1] = CPU;
      resourceOrder[2] = GPU;
    } else if (shares.getWeight(MEMORY) > shares.getWeight(GPU) && shares.getWeight(GPU) > shares.getWeight(CPU)) {
      resourceOrder[0] = MEMORY;
      resourceOrder[1] = GPU;
      resourceOrder[2] = CPU;
    } else if (shares.getWeight(CPU) > shares.getWeight(MEMORY) && shares.getWeight(MEMORY) > shares.getWeight(GPU)) {
      resourceOrder[0] = CPU;
      resourceOrder[1] = MEMORY;
      resourceOrder[2] = GPU;
    } else if (shares.getWeight(CPU) > shares.getWeight(GPU) && shares.getWeight(GPU) > shares.getWeight(MEMORY)) {
      resourceOrder[0] = CPU;
      resourceOrder[1] = GPU;
      resourceOrder[2] = MEMORY;
    } else if (shares.getWeight(GPU) > shares.getWeight(CPU) && shares.getWeight(CPU) > shares.getWeight(MEMORY)) {
      resourceOrder[0] = GPU;
      resourceOrder[1] = CPU;
      resourceOrder[2] = MEMORY;
    } else if (shares.getWeight(GPU) > shares.getWeight(MEMORY) && shares.getWeight(MEMORY) > shares.getWeight(CPU)) {
      resourceOrder[0] = GPU;
      resourceOrder[1] = MEMORY;
      resourceOrder[2] = CPU;
    }
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:45,代码来源:DominantResourceFairnessPolicy.java

示例5: getAppWeight

import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights; //导入方法依赖的package包/类
public synchronized ResourceWeights getAppWeight(FSAppAttempt app) {
  double weight = 1.0;
  if (sizeBasedWeight) {
    // Set weight based on current memory demand
    weight = Math.log1p(app.getDemand().getMemorySize()) / Math.log(2);
  }
  weight *= app.getPriority().getPriority();
  if (weightAdjuster != null) {
    // Run weight through the user-supplied weightAdjuster
    weight = weightAdjuster.adjustWeight(app, weight);
  }
  ResourceWeights resourceWeights = app.getResourceWeights();
  resourceWeights.setWeight((float)weight);
  return resourceWeights;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:16,代码来源:FairScheduler.java

示例6: calculateShares

import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights; //导入方法依赖的package包/类
/**
 * Calculates and orders a resource's share of a pool in terms of two vectors.
 * The shares vector contains, for each resource, the fraction of the pool that
 * it takes up.  The resourceOrder vector contains an ordering of resources
 * by largest share.  So if resource=<10 MB, 5 CPU>, and pool=<100 MB, 10 CPU>,
 * shares will be [.1, .5] and resourceOrder will be [CPU, MEMORY].
 */
void calculateShares(Resource resource, Resource pool,
    ResourceWeights shares, ResourceType[] resourceOrder, ResourceWeights weights) {
  shares.setWeight(MEMORY, (float)resource.getMemory() /
      (pool.getMemory() * weights.getWeight(MEMORY)));
  shares.setWeight(CPU, (float)resource.getVirtualCores() /
      (pool.getVirtualCores() * weights.getWeight(CPU)));
  shares.setWeight(GPU, (float) resource.getGpuCores() /
      (pool.getGpuCores() * weights.getWeight(GPU)));
  // sort order vector by resource share
  if (resourceOrder != null) {
    int position = 0;

    resourceOrder[0] = MEMORY;
    position ++;

    if (position == 0) {
      resourceOrder[0] = CPU;
    } else {
      if (shares.getWeight(MEMORY) >= shares.getWeight(CPU)) {
        resourceOrder[1] = CPU;
      } else {
        resourceOrder[0] = CPU;
        resourceOrder[1] = MEMORY;
      }
    }
    position ++;

    int startIndex = 0;
    while (startIndex < position) {
      if (shares.getWeight(GPU) >=
          shares.getWeight(resourceOrder[startIndex])) {
        break;
      }
      startIndex ++;
    }
    for (int i = position; i > startIndex; i --) {
      resourceOrder[i] = resourceOrder[i-1];
    }
    resourceOrder[startIndex] = GPU;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:DominantResourceFairnessPolicy.java


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