From ef8a315e908322a270a58212369534674ed5b5a2 Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Mon, 27 Feb 2017 18:37:53 -0500 Subject: [PATCH 1/2] fixed aggregate check for BinPacking. This had been broken due to a previous merge. --- schedulers/binPackSortedWattsSortedOffers.go | 8 +++++--- schedulers/binpacksortedwatts.go | 7 ++++--- schedulers/bpswMaxMin.go | 8 +++++--- schedulers/bpswMaxMinPistonCapping.go | 8 +++++--- schedulers/bpswMaxMinProacCC.go | 8 +++++--- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/schedulers/binPackSortedWattsSortedOffers.go b/schedulers/binPackSortedWattsSortedOffers.go index e4359de..a1b4e18 100644 --- a/schedulers/binPackSortedWattsSortedOffers.go +++ b/schedulers/binPackSortedWattsSortedOffers.go @@ -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 diff --git a/schedulers/binpacksortedwatts.go b/schedulers/binpacksortedwatts.go index b047373..9ff1c80 100644 --- a/schedulers/binpacksortedwatts.go +++ b/schedulers/binpacksortedwatts.go @@ -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 diff --git a/schedulers/bpswMaxMin.go b/schedulers/bpswMaxMin.go index 73af1db..656048f 100644 --- a/schedulers/bpswMaxMin.go +++ b/schedulers/bpswMaxMin.go @@ -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 diff --git a/schedulers/bpswMaxMinPistonCapping.go b/schedulers/bpswMaxMinPistonCapping.go index fceec50..cf2cdaf 100644 --- a/schedulers/bpswMaxMinPistonCapping.go +++ b/schedulers/bpswMaxMinPistonCapping.go @@ -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 { diff --git a/schedulers/bpswMaxMinProacCC.go b/schedulers/bpswMaxMinProacCC.go index 564134a..963af94 100644 --- a/schedulers/bpswMaxMinProacCC.go +++ b/schedulers/bpswMaxMinProacCC.go @@ -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 { From c18dd0fa70ba9c28d06c7aceaaa4703b46e4a068 Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Mon, 27 Feb 2017 19:03:36 -0500 Subject: [PATCH 2/2] formatted --- schedulers/binPackSortedWattsSortedOffers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedulers/binPackSortedWattsSortedOffers.go b/schedulers/binPackSortedWattsSortedOffers.go index a1b4e18..6cc67bb 100644 --- a/schedulers/binPackSortedWattsSortedOffers.go +++ b/schedulers/binPackSortedWattsSortedOffers.go @@ -27,7 +27,7 @@ func (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def. // Error in determining wattsConsideration log.Fatal(err) } - if (offerCPU >= (totalCPU + task.CPU))&& (offerRAM >= (totalRAM + task.RAM)) && + if (offerCPU >= (totalCPU + task.CPU)) && (offerRAM >= (totalRAM + task.RAM)) && (!s.wattsAsAResource || (offerWatts >= (totalWatts + wattsConsideration))) { return true }