Moved the check for fitting tasks into a different function.
This commit is contained in:
parent
2e0ec0cc99
commit
63a7f0acb5
1 changed files with 13 additions and 3 deletions
|
@ -69,6 +69,18 @@ func NewPistonCapper(tasks []def.Task, ignoreWatts bool) *PistonCapper {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check whether task fits the offer or not.
|
||||||
|
func (s *PistonCapper) takeOffer(offerWatts float64, offerCPU float64, offerRAM float64, totalWatts float64, totalCPU float64,
|
||||||
|
totalRAM float64, task def.Task) bool {
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.Watts))) &&
|
||||||
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// mutex
|
// mutex
|
||||||
var mutex sync.Mutex
|
var mutex sync.Mutex
|
||||||
|
|
||||||
|
@ -248,9 +260,7 @@ func (s *PistonCapper) ResourceOffers(driver sched.SchedulerDriver, offers []*me
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.Watts))) &&
|
if s.takeOffer(offerWatts, offerCPU, offerRAM, totalWatts, totalCPU, totalRAM, task) {
|
||||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
// Start piston capping if haven't started yet
|
// Start piston capping if haven't started yet
|
||||||
if !s.isCapping {
|
if !s.isCapping {
|
||||||
|
|
Reference in a new issue