retrofitted to use offerUtils.PowerClass(...) instead of inlining the code in every scheduler. Reduced redundant code. Changed name of newTaskClass in newTask(...) to powerClass.
This commit is contained in:
parent
04d722d20f
commit
3af1d561c2
5 changed files with 35 additions and 59 deletions
|
@ -91,7 +91,7 @@ func NewBPSWClassMapWattsPistonCapping(tasks []def.Task, ignoreWatts bool, sched
|
|||
return s
|
||||
}
|
||||
|
||||
func (s *BPSWClassMapWattsPistonCapping) newTask(offer *mesos.Offer, task def.Task, newTaskClass string) *mesos.TaskInfo {
|
||||
func (s *BPSWClassMapWattsPistonCapping) newTask(offer *mesos.Offer, task def.Task, powerClass string) *mesos.TaskInfo {
|
||||
taskName := fmt.Sprintf("%s-%d", task.Name, *task.Instances)
|
||||
s.tasksCreated++
|
||||
|
||||
|
@ -125,7 +125,7 @@ func (s *BPSWClassMapWattsPistonCapping) newTask(offer *mesos.Offer, task def.Ta
|
|||
}
|
||||
|
||||
if !s.ignoreWatts {
|
||||
resources = append(resources, mesosutil.NewScalarResource("watts", task.ClassToWatts[newTaskClass]))
|
||||
resources = append(resources, mesosutil.NewScalarResource("watts", task.ClassToWatts[powerClass]))
|
||||
}
|
||||
|
||||
return &mesos.TaskInfo{
|
||||
|
@ -260,16 +260,11 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
|||
}
|
||||
|
||||
for *task.Instances > 0 {
|
||||
var nodeClass string
|
||||
for _, attr := range offer.GetAttributes() {
|
||||
if attr.GetName() == "class" {
|
||||
nodeClass = attr.GetText().GetValue()
|
||||
}
|
||||
}
|
||||
powerClass := offerUtils.PowerClass(offer)
|
||||
// Does the task fit
|
||||
// OR lazy evaluation. If ignoreWatts is set to true, second statement won't
|
||||
// be evaluated
|
||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[nodeClass]))) &&
|
||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||
(offerRAM >= (totalRAM + task.RAM)) {
|
||||
|
||||
|
@ -279,14 +274,14 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
|||
s.startCapping()
|
||||
}
|
||||
|
||||
fmt.Println("Watts being used: ", task.ClassToWatts[nodeClass])
|
||||
fmt.Println("Watts being used: ", task.ClassToWatts[powerClass])
|
||||
taken = true
|
||||
totalWatts += task.ClassToWatts[nodeClass]
|
||||
totalWatts += task.ClassToWatts[powerClass]
|
||||
totalCPU += task.CPU
|
||||
totalRAM += task.RAM
|
||||
log.Println("Co-Located with: ")
|
||||
coLocated(s.running[offer.GetSlaveId().GoString()])
|
||||
taskToSchedule := s.newTask(offer, task, nodeClass)
|
||||
taskToSchedule := s.newTask(offer, task, powerClass)
|
||||
tasks = append(tasks, taskToSchedule)
|
||||
|
||||
fmt.Println("Inst: ", *task.Instances)
|
||||
|
|
Reference in a new issue