Nit: Changed variable name 'runningAverageToTotalPowerPercentage' to 'ratios'
This commit is contained in:
parent
b0140a8b93
commit
54a55ec523
1 changed files with 7 additions and 7 deletions
|
@ -89,17 +89,17 @@ func (capper clusterwideCapper) runningAverageOfWatts(tsk *def.Task) float64 {
|
||||||
/*
|
/*
|
||||||
Calculating cap value.
|
Calculating cap value.
|
||||||
|
|
||||||
1. Sorting the values of runningAverageToTotalPowerPercentage in ascending order.
|
1. Sorting the values of ratios ((running average/totalPower) per node) in ascending order.
|
||||||
2. Computing the median of above sorted values.
|
2. Computing the median of above sorted values.
|
||||||
3. The median is now the cap.
|
3. The median is now the cap.
|
||||||
*/
|
*/
|
||||||
func (capper clusterwideCapper) getCap(runningAverageToTotalPowerPercentage map[string]float64) float64 {
|
func (capper clusterwideCapper) getCap(ratios map[string]float64) float64 {
|
||||||
var values []float64
|
var values []float64
|
||||||
// Validation
|
// Validation
|
||||||
if runningAverageToTotalPowerPercentage == nil {
|
if ratios == nil {
|
||||||
return 100.0
|
return 100.0
|
||||||
}
|
}
|
||||||
for _, apower := range runningAverageToTotalPowerPercentage {
|
for _, apower := range ratios {
|
||||||
values = append(values, apower)
|
values = append(values, apower)
|
||||||
}
|
}
|
||||||
// sorting the values in ascending order.
|
// sorting the values in ascending order.
|
||||||
|
@ -339,17 +339,17 @@ func (capper clusterwideCapper) fcfsDetermineCap(totalPower map[string]float64,
|
||||||
// Need to calculate the running average
|
// Need to calculate the running average
|
||||||
runningAverage := capper.runningAverageOfWatts(newTask)
|
runningAverage := capper.runningAverageOfWatts(newTask)
|
||||||
// For each node, calculate the percentage of the running average to the total power.
|
// For each node, calculate the percentage of the running average to the total power.
|
||||||
runningAverageToTotalPowerPercentage := make(map[string]float64)
|
ratios := make(map[string]float64)
|
||||||
for host, tpower := range totalPower {
|
for host, tpower := range totalPower {
|
||||||
if tpower >= runningAverage {
|
if tpower >= runningAverage {
|
||||||
runningAverageToTotalPowerPercentage[host] = (runningAverage / tpower) * 100
|
ratios[host] = (runningAverage / tpower) * 100
|
||||||
} else {
|
} else {
|
||||||
// We don't consider this host for the computation of the cluster wide cap.
|
// We don't consider this host for the computation of the cluster wide cap.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the cluster wide cap value.
|
// Determine the cluster wide cap value.
|
||||||
capValue := capper.getCap(runningAverageToTotalPowerPercentage)
|
capValue := capper.getCap(ratios)
|
||||||
// Need to cap the cluster to this value.
|
// Need to cap the cluster to this value.
|
||||||
return capValue, nil
|
return capValue, nil
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue