Merged in fixAggregateResourceCheckForBinPacking (pull request #13)

Fixed aggregate check for BinPacking. This had been broken due to a previous merge.

Approved-by: Renan DelValle
Approved-by: Pradyumna Kaushik
This commit is contained in:
Pradyumna Kaushik 2017-02-28 00:04:53 +00:00
commit 3ea500461d
5 changed files with 24 additions and 15 deletions

View file

@ -16,7 +16,8 @@ import (
)
// Decides if to take an offer or not
func (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
func (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task,
totalCPU, totalRAM, totalWatts float64) bool {
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
@ -26,7 +27,8 @@ func (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.
// Error in determining wattsConsideration
log.Fatal(err)
}
if offerCPU >= task.CPU && offerRAM >= task.RAM && (!s.wattsAsAResource || (offerWatts >= wattsConsideration)) {
if (offerCPU >= (totalCPU + task.CPU)) && (offerRAM >= (totalRAM + task.RAM)) &&
(!s.wattsAsAResource || (offerWatts >= (totalWatts + wattsConsideration))) {
return true
}
return false
@ -161,7 +163,7 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
for *task.Instances > 0 {
// Does the task fit
if s.takeOffer(offer, task) {
if s.takeOffer(offer, task, totalCPU, totalRAM, totalWatts) {
offerTaken = true
totalWatts += wattsConsideration

View file

@ -16,7 +16,7 @@ import (
)
// Decides if to take an offer or not
func (s *BinPackSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
func (s *BinPackSortedWatts) takeOffer(offer *mesos.Offer, task def.Task, totalCPU, totalRAM, totalWatts float64) bool {
cpus, mem, watts := offerUtils.OfferAgg(offer)
@ -27,7 +27,8 @@ func (s *BinPackSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
// Error in determining wattsConsideration
log.Fatal(err)
}
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
if (cpus >= (totalCPU + task.CPU)) && (mem >= (totalRAM + task.RAM)) &&
(!s.wattsAsAResource || (watts >= (totalWatts + wattsConsideration))) {
return true
}
return false
@ -150,7 +151,7 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
for *task.Instances > 0 {
// Does the task fit
if s.takeOffer(offer, task) {
if s.takeOffer(offer, task, totalCPU, totalRAM, totalWatts) {
offerTaken = true
totalWatts += wattsConsideration

View file

@ -16,7 +16,8 @@ import (
)
// Decides if to take an offer or not
func (s *BPSWMaxMinWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
func (s *BPSWMaxMinWatts) takeOffer(offer *mesos.Offer, task def.Task,
totalCPU, totalRAM, totalWatts float64) bool {
cpus, mem, watts := offerUtils.OfferAgg(offer)
@ -27,7 +28,8 @@ func (s *BPSWMaxMinWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
// Error in determining wattsConsideration
log.Fatal(err)
}
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
if (cpus >= (totalCPU + task.CPU)) && (mem >= (totalRAM + task.RAM)) &&
(!s.wattsAsAResource || (watts >= (totalWatts + wattsConsideration))) {
return true
}
return false
@ -128,7 +130,7 @@ func (s *BPSWMaxMinWatts) CheckFit(
totalWatts *float64) (bool, *mesos.TaskInfo) {
// Does the task fit
if s.takeOffer(offer, task) {
if s.takeOffer(offer, task, *totalCPU, *totalRAM, *totalWatts) {
*totalWatts += wattsConsideration
*totalCPU += task.CPU

View file

@ -21,7 +21,8 @@ import (
)
// Decides if to take an offer or not
func (s *BPSWMaxMinPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) bool {
func (s *BPSWMaxMinPistonCapping) takeOffer(offer *mesos.Offer, task def.Task,
totalCPU, totalRAM, totalWatts float64) bool {
cpus, mem, watts := offerUtils.OfferAgg(offer)
@ -32,7 +33,8 @@ func (s *BPSWMaxMinPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) b
// Error in determining wattsConsideration
log.Fatal(err)
}
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
if (cpus >= (totalCPU + task.CPU)) && (mem >= (totalRAM + task.RAM)) &&
(!s.wattsAsAResource || (watts >= (totalWatts + wattsConsideration))) {
return true
}
return false
@ -218,7 +220,7 @@ func (s *BPSWMaxMinPistonCapping) CheckFit(
partialLoad *float64) (bool, *mesos.TaskInfo) {
// Does the task fit
if s.takeOffer(offer, task) {
if s.takeOffer(offer, task, *totalCPU, *totalRAM, *totalWatts) {
// Start piston capping if haven't started yet
if !s.isCapping {

View file

@ -21,7 +21,8 @@ import (
)
// Decides if to take an offer or not
func (s *BPSWMaxMinProacCC) takeOffer(offer *mesos.Offer, task def.Task) bool {
func (s *BPSWMaxMinProacCC) takeOffer(offer *mesos.Offer, task def.Task,
totalCPU, totalRAM, totalWatts float64) bool {
cpus, mem, watts := offerUtils.OfferAgg(offer)
//TODO: Insert watts calculation here instead of taking them as a parameter
@ -31,7 +32,8 @@ func (s *BPSWMaxMinProacCC) takeOffer(offer *mesos.Offer, task def.Task) bool {
// Error in determining wattsConsideration
log.Fatal(err)
}
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
if (cpus >= (totalCPU + task.CPU)) && (mem >= (totalRAM + task.RAM)) &&
(!s.wattsAsAResource || (watts >= (totalWatts + wattsConsideration))) {
return true
}
return false
@ -241,7 +243,7 @@ func (s *BPSWMaxMinProacCC) CheckFit(
totalWatts *float64) (bool, *mesos.TaskInfo) {
// Does the task fit
if s.takeOffer(offer, task) {
if s.takeOffer(offer, task, *totalCPU, *totalRAM, *totalWatts) {
// Capping the cluster if haven't yet started
if !s.isCapping {