Made classMapWatts a commandLine option where one can enable and disable mapping of watts to powerclasses when accepting offers from Mesos. Removed the schedulers that were created solely for the classMapWatts feature. Retrofitted all schedulers to use the powerClass mapped watts attribute for a task, if classMapWatts has been enabled. Removed unnecessary functions and variables from constants.go. Removed unnecessary functions from utilities/utils.go. Fixed operator precendence issue with takeOffer(...) in some of the schedulers. Added TODO to decouple capping strategies from the schedulers completely. Added TODO to move all the common struct attributes in the schedulers into base.go.
This commit is contained in:
parent
a2b50dd313
commit
fdcb401447
28 changed files with 686 additions and 2094 deletions
29
def/task.go
29
def/task.go
|
@ -2,7 +2,9 @@ package def
|
|||
|
||||
import (
|
||||
"bitbucket.org/sunybingcloud/electron/constants"
|
||||
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||
"encoding/json"
|
||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||
"github.com/pkg/errors"
|
||||
"os"
|
||||
)
|
||||
|
@ -65,6 +67,33 @@ func (tsk *Task) SetTaskID(taskID string) bool {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Determine the watts value to consider for each task.
|
||||
|
||||
This value could either be task.Watts or task.ClassToWatts[<power class>]
|
||||
If task.ClassToWatts is not present, then return task.Watts (this would be for workloads which don't have classMapWatts)
|
||||
*/
|
||||
func WattsToConsider(task Task, classMapWatts bool, offer *mesos.Offer) (float64, error) {
|
||||
if classMapWatts {
|
||||
// checking if ClassToWatts was present in the workload.
|
||||
if task.ClassToWatts != nil {
|
||||
return task.ClassToWatts[offerUtils.PowerClass(offer)], nil
|
||||
} else {
|
||||
// Checking whether task.Watts is 0.0. If yes, then throwing an error.
|
||||
if task.Watts == 0.0 {
|
||||
return task.Watts, errors.New("Configuration error in task. Watts attribute is 0 for " + task.Name)
|
||||
}
|
||||
return task.Watts, nil
|
||||
}
|
||||
} else {
|
||||
// Checking whether task.Watts is 0.0. If yes, then throwing an error.
|
||||
if task.Watts == 0.0 {
|
||||
return task.Watts, errors.New("Configuration error in task. Watts attribute is 0 for " + task.Name)
|
||||
}
|
||||
return task.Watts, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Sorter implements sort.Sort interface to sort tasks by Watts requirement.
|
||||
type WattsSorter []Task
|
||||
|
||||
|
|
Reference in a new issue