本文整理汇总了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;
}
}
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
}