From 9365c2e51df2f5613a1e2f041e9d524e31c825de Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:01:29 -0400 Subject: [PATCH 01/23] Changed the Hosts from list to a set of hosts using a map with key as hostname and value as an empty struct --- constants/constants.go | 5 +-- utilities/offerUtils/offerUtils.go | 62 ------------------------------ 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 utilities/offerUtils/offerUtils.go diff --git a/constants/constants.go b/constants/constants.go index 1cc97cf..bb664e8 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -7,10 +7,7 @@ TODO: Clean this up and use Mesos Attributes instead. */ package constants -var Hosts = []string{"stratos-001.cs.binghamton.edu", "stratos-002.cs.binghamton.edu", - "stratos-003.cs.binghamton.edu", "stratos-004.cs.binghamton.edu", - "stratos-005.cs.binghamton.edu", "stratos-006.cs.binghamton.edu", - "stratos-007.cs.binghamton.edu", "stratos-008.cs.binghamton.edu"} +var Hosts = make(map[string]struct{}) /* Classification of the nodes in the cluster based on their Thermal Design Power (TDP). diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go deleted file mode 100644 index 6f5dc81..0000000 --- a/utilities/offerUtils/offerUtils.go +++ /dev/null @@ -1,62 +0,0 @@ -package offerUtils - -import ( - mesos "github.com/mesos/mesos-go/mesosproto" - "strings" -) - -func OfferAgg(offer *mesos.Offer) (float64, float64, float64) { - var cpus, mem, watts float64 - - for _, resource := range offer.Resources { - switch resource.GetName() { - case "cpus": - cpus += *resource.GetScalar().Value - case "mem": - mem += *resource.GetScalar().Value - case "watts": - watts += *resource.GetScalar().Value - } - } - - return cpus, mem, watts -} - -// Determine the power class of the host in the offer -func PowerClass(offer *mesos.Offer) string { - var powerClass string - for _, attr := range offer.GetAttributes() { - if attr.GetName() == "class" { - powerClass = attr.GetText().GetValue() - } - } - return powerClass -} - -// Implements the sort.Sort interface to sort Offers based on CPU. -// TODO: Have a generic sorter that sorts based on a defined requirement (CPU, RAM, DISK or Watts) -type OffersSorter []*mesos.Offer - -func (offersSorter OffersSorter) Len() int { - return len(offersSorter) -} - -func (offersSorter OffersSorter) Swap(i, j int) { - offersSorter[i], offersSorter[j] = offersSorter[j], offersSorter[i] -} - -func (offersSorter OffersSorter) Less(i, j int) bool { - // getting CPU resource availability of offersSorter[i] - cpu1, _, _ := OfferAgg(offersSorter[i]) - // getting CPU resource availability of offersSorter[j] - cpu2, _, _ := OfferAgg(offersSorter[j]) - return cpu1 <= cpu2 -} - -// Is there a mismatch between the task's host requirement and the host corresponding to the offer. -func HostMismatch(offerHost string, taskHost string) bool { - if taskHost != "" && !strings.HasPrefix(offerHost, taskHost) { - return true - } - return false -} From b311ee81f59a55bf0a013279c105690948fe9568 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:03:03 -0400 Subject: [PATCH 02/23] Changed the loop as the Hosts is now a map and not a list and now looping over the keys is required. --- powerCapping/proactiveclusterwidecappers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerCapping/proactiveclusterwidecappers.go b/powerCapping/proactiveclusterwidecappers.go index 3f10d6a..9088b29 100644 --- a/powerCapping/proactiveclusterwidecappers.go +++ b/powerCapping/proactiveclusterwidecappers.go @@ -110,7 +110,7 @@ func (capper ClusterwideCapper) CleverRecap(totalPower map[string]float64, wattsUsages := make(map[string][]float64) hostOfFinishedTask := "" indexOfFinishedTask := -1 - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { wattsUsages[host] = []float64{0.0} } for host, tasks := range taskMonitor { From 26c49d4098b25e2c32bb77931989bb15b92dac94 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:09:51 -0400 Subject: [PATCH 03/23] Restoring offerUtils. Had deleted this by mistake. --- utilities/offerUtils/offerUtils.go | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 utilities/offerUtils/offerUtils.go diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go new file mode 100644 index 0000000..6f5dc81 --- /dev/null +++ b/utilities/offerUtils/offerUtils.go @@ -0,0 +1,62 @@ +package offerUtils + +import ( + mesos "github.com/mesos/mesos-go/mesosproto" + "strings" +) + +func OfferAgg(offer *mesos.Offer) (float64, float64, float64) { + var cpus, mem, watts float64 + + for _, resource := range offer.Resources { + switch resource.GetName() { + case "cpus": + cpus += *resource.GetScalar().Value + case "mem": + mem += *resource.GetScalar().Value + case "watts": + watts += *resource.GetScalar().Value + } + } + + return cpus, mem, watts +} + +// Determine the power class of the host in the offer +func PowerClass(offer *mesos.Offer) string { + var powerClass string + for _, attr := range offer.GetAttributes() { + if attr.GetName() == "class" { + powerClass = attr.GetText().GetValue() + } + } + return powerClass +} + +// Implements the sort.Sort interface to sort Offers based on CPU. +// TODO: Have a generic sorter that sorts based on a defined requirement (CPU, RAM, DISK or Watts) +type OffersSorter []*mesos.Offer + +func (offersSorter OffersSorter) Len() int { + return len(offersSorter) +} + +func (offersSorter OffersSorter) Swap(i, j int) { + offersSorter[i], offersSorter[j] = offersSorter[j], offersSorter[i] +} + +func (offersSorter OffersSorter) Less(i, j int) bool { + // getting CPU resource availability of offersSorter[i] + cpu1, _, _ := OfferAgg(offersSorter[i]) + // getting CPU resource availability of offersSorter[j] + cpu2, _, _ := OfferAgg(offersSorter[j]) + return cpu1 <= cpu2 +} + +// Is there a mismatch between the task's host requirement and the host corresponding to the offer. +func HostMismatch(offerHost string, taskHost string) bool { + if taskHost != "" && !strings.HasPrefix(offerHost, taskHost) { + return true + } + return false +} From 710447cb0d6a876d07e0c9e8c3533216dce3ab3d Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:11:38 -0400 Subject: [PATCH 04/23] Changed the Hosts from being a slice to a map with the key as hostname and value as a struct which would be an empty struct in order to mimic a set --- constants/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants/constants.go b/constants/constants.go index bb664e8..b0c81a3 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -25,7 +25,7 @@ var PowerClasses = map[string]map[string]bool{ "C": map[string]bool{ "stratos-008.cs.binghamton.edu": true, }, - "D": map[string]bool { + "D": map[string]bool{ "stratos-001.cs.binghamton.edu": true, "stratos-002.cs.binghamton.edu": true, "stratos-003.cs.binghamton.edu": true, From f85ed944f48891fa923bb9a6fff8bb09c58fd270 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:13:29 -0400 Subject: [PATCH 05/23] Changed the loop as now we are looping over a map and not a slice. --- def/task.go | 2 +- pcp/logAndProgressiveExtrema.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/def/task.go b/def/task.go index 1b4af97..973021f 100644 --- a/def/task.go +++ b/def/task.go @@ -43,7 +43,7 @@ func TasksFromJSON(uri string) ([]Task, error) { func (tsk *Task) UpdateHost(newHost string) bool { // Validation isCorrectHost := false - for _, existingHost := range constants.Hosts { + for existingHost, _ := range constants.Hosts { if newHost == existingHost { isCorrectHost = true } diff --git a/pcp/logAndProgressiveExtrema.go b/pcp/logAndProgressiveExtrema.go index f708bef..4a2cf56 100644 --- a/pcp/logAndProgressiveExtrema.go +++ b/pcp/logAndProgressiveExtrema.go @@ -3,6 +3,7 @@ package pcp import ( "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/rapl" + "bitbucket.org/sunybingcloud/electron/utilities" "bufio" "container/ring" "log" @@ -14,7 +15,6 @@ import ( "strings" "syscall" "time" - "bitbucket.org/sunybingcloud/electron/utilities" ) func round(num float64) int { @@ -202,7 +202,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, pref // If cannot find any victim, then all nodes have been capped to the maximum and we stop capping at this point. } } - if (!canCapAlreadyCappedVictim) { + if !canCapAlreadyCappedVictim { log.Println("No Victim left to cap.") } } From aed4fd1073d74073737ee5553419b1696bf96065 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:16:05 -0400 Subject: [PATCH 06/23] Retrofitted all schedulers to now pick the hostname from the offer and add it to constants.Hosts --- schedulers/binPackSortedWattsSortedOffers.go | 5 +++++ schedulers/binpackedpistoncapping.go | 4 ++++ schedulers/binpacksortedwatts.go | 5 +++++ schedulers/bottomHeavy.go | 4 ++++ schedulers/bpswMaxMin.go | 5 +++++ schedulers/bpswMaxMinPistonCapping.go | 4 ++++ schedulers/bpswMaxMinProacCC.go | 8 ++++++-- schedulers/firstfit.go | 5 +++++ schedulers/firstfitProacCC.go | 8 ++++++-- schedulers/firstfitSortedOffers.go | 5 +++++ schedulers/firstfitSortedWattsProacCC.go | 8 ++++++-- schedulers/firstfitSortedWattsSortedOffers.go | 5 +++++ schedulers/firstfitsortedwatts.go | 5 +++++ schedulers/firstfitwattsonly.go | 5 +++++ 14 files changed, 70 insertions(+), 6 deletions(-) diff --git a/schedulers/binPackSortedWattsSortedOffers.go b/schedulers/binPackSortedWattsSortedOffers.go index 6cc67bb..93e564a 100644 --- a/schedulers/binPackSortedWattsSortedOffers.go +++ b/schedulers/binPackSortedWattsSortedOffers.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -127,6 +128,10 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/binpackedpistoncapping.go b/schedulers/binpackedpistoncapping.go index 69764a9..3022d6c 100644 --- a/schedulers/binpackedpistoncapping.go +++ b/schedulers/binpackedpistoncapping.go @@ -210,6 +210,10 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off // retrieving the total power for each host in the offers for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } if _, ok := s.totalPower[*offer.Hostname]; !ok { _, _, offerWatts := offerUtils.OfferAgg(offer) s.totalPower[*offer.Hostname] = offerWatts diff --git a/schedulers/binpacksortedwatts.go b/schedulers/binpacksortedwatts.go index 9ff1c80..45d2488 100644 --- a/schedulers/binpacksortedwatts.go +++ b/schedulers/binpacksortedwatts.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -120,6 +121,10 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bottomHeavy.go b/schedulers/bottomHeavy.go index e1b5567..eef8bd6 100644 --- a/schedulers/bottomHeavy.go +++ b/schedulers/bottomHeavy.go @@ -282,6 +282,10 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes offersLightPowerClasses := []*mesos.Offer{} for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMin.go b/schedulers/bpswMaxMin.go index 656048f..940439a 100644 --- a/schedulers/bpswMaxMin.go +++ b/schedulers/bpswMaxMin.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -164,6 +165,10 @@ func (s *BPSWMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers [] log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMinPistonCapping.go b/schedulers/bpswMaxMinPistonCapping.go index 28964fd..4031e88 100644 --- a/schedulers/bpswMaxMinPistonCapping.go +++ b/schedulers/bpswMaxMinPistonCapping.go @@ -261,6 +261,10 @@ func (s *BPSWMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, o log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMinProacCC.go b/schedulers/bpswMaxMinProacCC.go index 8f05596..d80f05f 100644 --- a/schedulers/bpswMaxMinProacCC.go +++ b/schedulers/bpswMaxMinProacCC.go @@ -164,7 +164,7 @@ func (s *BPSWMaxMinProacCC) startCapping() { // updating cap value bpMaxMinProacCCCapValue = bpMaxMinProacCCNewCapValue if bpMaxMinProacCCCapValue > 0.0 { - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { // Rounding cap value to nearest int if err := rapl.Cap(host, "rapl", float64(int(math.Floor(bpMaxMinProacCCCapValue+0.5)))); err != nil { log.Println(err) @@ -190,7 +190,7 @@ func (s *BPSWMaxMinProacCC) startRecapping() { bpMaxMinProacCCMutex.Lock() // If stopped performing cluster-wide capping, then we need to recap. if s.isRecapping && bpMaxMinProacCCRecapValue > 0.0 { - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { // Rounding the recap value to the nearest int if err := rapl.Cap(host, "rapl", float64(int(math.Floor(bpMaxMinProacCCRecapValue+0.5)))); err != nil { log.Println(err) @@ -300,6 +300,10 @@ func (s *BPSWMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers // retrieving the available power for all the hosts in the offers. for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } _, _, offerWatts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offerWatts // setting total power if the first time diff --git a/schedulers/firstfit.go b/schedulers/firstfit.go index 864a208..e07839c 100644 --- a/schedulers/firstfit.go +++ b/schedulers/firstfit.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -119,6 +120,10 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/firstfitProacCC.go b/schedulers/firstfitProacCC.go index 01c163e..51011e5 100644 --- a/schedulers/firstfitProacCC.go +++ b/schedulers/firstfitProacCC.go @@ -164,7 +164,7 @@ func (s *FirstFitProacCC) startCapping() { // Need to cap the cluster to the fcfsCurrentCapValue. fcfsMutex.Lock() if fcfsCurrentCapValue > 0.0 { - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { // Rounding curreCapValue to the nearest int. if err := rapl.Cap(host, "rapl", float64(int(math.Floor(fcfsCurrentCapValue+0.5)))); err != nil { log.Println(err) @@ -188,7 +188,7 @@ func (s *FirstFitProacCC) startRecapping() { fcfsMutex.Lock() // If stopped performing cluster wide capping then we need to explicitly cap the entire cluster. if s.isRecapping && fcfsRecapValue > 0.0 { - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { // Rounding curreCapValue to the nearest int. if err := rapl.Cap(host, "rapl", float64(int(math.Floor(fcfsRecapValue+0.5)))); err != nil { log.Println(err) @@ -233,6 +233,10 @@ func (s *FirstFitProacCC) ResourceOffers(driver sched.SchedulerDriver, offers [] // retrieving the available power for all the hosts in the offers. for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } _, _, offer_watts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offer_watts // setting total power if the first time. diff --git a/schedulers/firstfitSortedOffers.go b/schedulers/firstfitSortedOffers.go index 48a9ec1..a9ab1d8 100644 --- a/schedulers/firstfitSortedOffers.go +++ b/schedulers/firstfitSortedOffers.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -126,6 +127,10 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/firstfitSortedWattsProacCC.go b/schedulers/firstfitSortedWattsProacCC.go index 1792cfd..4173ae6 100644 --- a/schedulers/firstfitSortedWattsProacCC.go +++ b/schedulers/firstfitSortedWattsProacCC.go @@ -177,7 +177,7 @@ func (s *FirstFitSortedWattsProacCC) startCapping() { // Need to cap the cluster to the rankedCurrentCapValue. rankedMutex.Lock() if rankedCurrentCapValue > 0.0 { - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { // Rounding currentCapValue to the nearest int. if err := rapl.Cap(host, "rapl", float64(int(math.Floor(rankedCurrentCapValue+0.5)))); err != nil { log.Println(err) @@ -201,7 +201,7 @@ func (s *FirstFitSortedWattsProacCC) startRecapping() { rankedMutex.Lock() // If stopped performing cluster wide capping then we need to explicitly cap the entire cluster. if s.isRecapping && rankedRecapValue > 0.0 { - for _, host := range constants.Hosts { + for host, _ := range constants.Hosts { // Rounding currentCapValue to the nearest int. if err := rapl.Cap(host, "rapl", float64(int(math.Floor(rankedRecapValue+0.5)))); err != nil { log.Println(err) @@ -246,6 +246,10 @@ func (s *FirstFitSortedWattsProacCC) ResourceOffers(driver sched.SchedulerDriver // retrieving the available power for all the hosts in the offers. for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } _, _, offer_watts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offer_watts // setting total power if the first time. diff --git a/schedulers/firstfitSortedWattsSortedOffers.go b/schedulers/firstfitSortedWattsSortedOffers.go index d473a09..5745ec6 100644 --- a/schedulers/firstfitSortedWattsSortedOffers.go +++ b/schedulers/firstfitSortedWattsSortedOffers.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -128,6 +129,10 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/firstfitsortedwatts.go b/schedulers/firstfitsortedwatts.go index dfb7bed..f19bec0 100644 --- a/schedulers/firstfitsortedwatts.go +++ b/schedulers/firstfitsortedwatts.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -122,6 +123,10 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/firstfitwattsonly.go b/schedulers/firstfitwattsonly.go index e2225ff..f7833b1 100644 --- a/schedulers/firstfitwattsonly.go +++ b/schedulers/firstfitwattsonly.go @@ -1,6 +1,7 @@ package schedulers import ( + "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -112,6 +113,10 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { + if _, ok := constants.Hosts[offer.GetHostname()]; !ok { + log.Printf("New host found. Adding host [%s]", offer.GetHostname()) + constants.Hosts[offer.GetHostname()] = struct{}{} + } select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") From ee94e13d8638362e3e8cfba6aa99132b80c0f145 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 23 Mar 2017 22:25:35 -0400 Subject: [PATCH 07/23] Updated a TODO from the list of TODOs, changed the usage of running electron with Watts as a resource and updated the workload schema --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2e494da..79b433d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ To Do: * Make parameters corresponding to each scheduler configurable (possible to have a config template for each scheduler?) * TODO : Adding type of scheduler to be used, to be picked from a config file, along with it's configurable parameters. * Write test code for each scheduler (This should be after the design change) - * Some of the constants in constants/constants.go can vary based on the environment. + * Populate constants.PowerClasses dynamically. Possible to setup the constants at runtime based on the environment? * Log fix for declining offer -- different reason when insufficient resources as compared to when there are no longer any tasks to schedule. @@ -28,9 +28,9 @@ How to run (Use the --help option to get information about other command-line op `./electron -workload ` -To run electron with ignoreWatts, run the following command, +To run electron with Watts as Resource, run the following command, -`./electron -workload -ignoreWatts` +`./electron -workload -wattsAsAResource` Workload schema: @@ -41,30 +41,31 @@ Workload schema: "name": "minife", "cpu": 3.0, "ram": 4096, - "watts": 50, - "image": "gouravr/minife:v5", - "cmd": "cd src && mpirun -np 1 miniFE.x -nx 100 -ny 100 -nz 100", - "inst": 9, - "class_to_watts" : { - "A": 30.2475289996, - "B": 35.6491229228, - "C": 24.0476734352 - } - + "watts": 63.141, + "class_to_watts": { + "A": 93.062, + "B": 65.552, + "C": 57.897, + "D": 60.729 + }, + "image": "rdelvalle/minife:electron1", + "cmd": "cd src && mpirun -np 3 miniFE.x -nx 100 -ny 100 -nz 100", + "inst": 10 }, { "name": "dgemm", "cpu": 3.0, - "ram": 4096, - "watts": 50, - "image": "gouravr/dgemm:v2", + "ram": 32, + "watts": 85.903, + "class_to_watts": { + "A": 114.789, + "B": 89.133, + "C": 82.672, + "D": 81.944 + }, + "image": "rdelvalle/dgemm:electron1", "cmd": "/./mt-dgemm 1024", - "inst": 9, - "class_to_watts" : { - "A": 35.2475289996, - "B": 25.6491229228, - "C": 29.0476734352 - } + "inst": 10 } ] ``` From ed8799566b424c23f10e559cc5585d5099b717c1 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:25:24 -0400 Subject: [PATCH 08/23] Removed the hardcoded nodes and their powerclasses from the PowerClasses map as now it will populated dynamically --- constants/constants.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/constants/constants.go b/constants/constants.go index b0c81a3..313b620 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -14,24 +14,7 @@ var Hosts = make(map[string]struct{}) The power classes are labelled in the decreasing order of the corresponding TDP, with class A nodes having the highest TDP and class C nodes having the lowest TDP. */ -var PowerClasses = map[string]map[string]bool{ - "A": map[string]bool{ - "stratos-005.cs.binghamton.edu": true, - "stratos-006.cs.binghamton.edu": true, - }, - "B": map[string]bool{ - "stratos-007.cs.binghamton.edu": true, - }, - "C": map[string]bool{ - "stratos-008.cs.binghamton.edu": true, - }, - "D": map[string]bool{ - "stratos-001.cs.binghamton.edu": true, - "stratos-002.cs.binghamton.edu": true, - "stratos-003.cs.binghamton.edu": true, - "stratos-004.cs.binghamton.edu": true, - }, -} +var PowerClasses = make(map[string]map[string]struct{}) /* Margin with respect to the required power for a job. From 841c7d5ee8e6cf3d626aaa9298f61080aee8a5ce Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:27:14 -0400 Subject: [PATCH 09/23] Added AddHostIfNew(..) utility function which is responsible to populate the constants.Hosts and constants.PowerClasses --- utilities/offerUtils/offerUtils.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index 6f5dc81..9d0034a 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -1,8 +1,11 @@ package offerUtils import ( + "bitbucket.org/sunybingcloud/electron/constants" mesos "github.com/mesos/mesos-go/mesosproto" "strings" + "log" + "bitbucket.org/sunybingcloud/electron-archive/utilities/offerUtils" ) func OfferAgg(offer *mesos.Offer) (float64, float64, float64) { @@ -60,3 +63,26 @@ func HostMismatch(offerHost string, taskHost string) bool { } return false } + +// If the host in the offer is a new host, add the host to the set of Hosts and +// register the powerclass of this host. +func AddHostIfNew(offer *mesos.Offer) { + var host = offer.GetHostname() + // If this host is not present in the set of hosts. + if _, ok := constants.Hosts[host]; !ok { + log.Printf("New host found. Adding host [%s]", host) + // Add this host. + constants.Hosts[host] = struct{}{} + // Get the power class of this host. + var class = offerUtils.PowerClass(offer) + log.Printf("Registering the power class of this host [%s] --> [%s]", host, class) + // If this class is a new power class, create a map for this class. + if _, ok := constants.PowerClasses[class]; !ok { + constants.PowerClasses[class] = make(map[string]struct{}) + } + // If the host of this class is not yet present in PowerClasses[class], add it. + if _, ok:= constants.PowerClasses[class][host]; !ok{ + constants.PowerClasses[class][host] = struct{}{} + } + } +} \ No newline at end of file From b4f9a989cb3c0bab68b0855bb5a5ca9de1b8eaed Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:28:49 -0400 Subject: [PATCH 10/23] Retrofitted all the schedulers to now call the offerutils.AddHostIfNew(..) utility function which will dynamically populate the constants.Hosts and constants.PowerClasses. --- schedulers/binPackSortedWattsSortedOffers.go | 6 +----- schedulers/binpackedpistoncapping.go | 5 +---- schedulers/binpacksortedwatts.go | 6 +----- schedulers/bottomHeavy.go | 21 +++++++++++-------- schedulers/bpswMaxMin.go | 6 +----- schedulers/bpswMaxMinPistonCapping.go | 5 +---- schedulers/bpswMaxMinProacCC.go | 5 +---- schedulers/firstfit.go | 6 +----- schedulers/firstfitProacCC.go | 5 +---- schedulers/firstfitSortedOffers.go | 6 +----- schedulers/firstfitSortedWattsProacCC.go | 5 +---- schedulers/firstfitSortedWattsSortedOffers.go | 6 +----- schedulers/firstfitsortedwatts.go | 6 +----- schedulers/firstfitwattsonly.go | 6 +----- schedulers/helpers.go | 2 +- schedulers/topHeavy.go | 16 +++++++++----- 16 files changed, 37 insertions(+), 75 deletions(-) diff --git a/schedulers/binPackSortedWattsSortedOffers.go b/schedulers/binPackSortedWattsSortedOffers.go index 93e564a..e89236f 100644 --- a/schedulers/binPackSortedWattsSortedOffers.go +++ b/schedulers/binPackSortedWattsSortedOffers.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -128,10 +127,7 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/binpackedpistoncapping.go b/schedulers/binpackedpistoncapping.go index 3022d6c..a14e18f 100644 --- a/schedulers/binpackedpistoncapping.go +++ b/schedulers/binpackedpistoncapping.go @@ -210,10 +210,7 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off // retrieving the total power for each host in the offers for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) if _, ok := s.totalPower[*offer.Hostname]; !ok { _, _, offerWatts := offerUtils.OfferAgg(offer) s.totalPower[*offer.Hostname] = offerWatts diff --git a/schedulers/binpacksortedwatts.go b/schedulers/binpacksortedwatts.go index 45d2488..2dd6f5f 100644 --- a/schedulers/binpacksortedwatts.go +++ b/schedulers/binpacksortedwatts.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -121,10 +120,7 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bottomHeavy.go b/schedulers/bottomHeavy.go index eef8bd6..49487fc 100644 --- a/schedulers/bottomHeavy.go +++ b/schedulers/bottomHeavy.go @@ -282,10 +282,7 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes offersLightPowerClasses := []*mesos.Offer{} for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") @@ -296,13 +293,19 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes default: } - if constants.PowerClasses["A"][*offer.Hostname] || - constants.PowerClasses["B"][*offer.Hostname] { + if _, ok := constants.PowerClasses["A"][*offer.Hostname]; ok{ offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) - } else if constants.PowerClasses["C"][*offer.Hostname] || - constants.PowerClasses["D"][*offer.Hostname] { - offersLightPowerClasses = append(offersLightPowerClasses, offer) } + if _, ok := constants.PowerClasses["B"][*offer.Hostname]; ok{ + offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) + } + if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok{ + offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + } + if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok{ + offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + } + } log.Println("Packing Large tasks into ClassAB offers:") diff --git a/schedulers/bpswMaxMin.go b/schedulers/bpswMaxMin.go index 940439a..a176501 100644 --- a/schedulers/bpswMaxMin.go +++ b/schedulers/bpswMaxMin.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -165,10 +164,7 @@ func (s *BPSWMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers [] log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMinPistonCapping.go b/schedulers/bpswMaxMinPistonCapping.go index 4031e88..41c1559 100644 --- a/schedulers/bpswMaxMinPistonCapping.go +++ b/schedulers/bpswMaxMinPistonCapping.go @@ -261,10 +261,7 @@ func (s *BPSWMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, o log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMinProacCC.go b/schedulers/bpswMaxMinProacCC.go index d80f05f..c3f2e90 100644 --- a/schedulers/bpswMaxMinProacCC.go +++ b/schedulers/bpswMaxMinProacCC.go @@ -300,10 +300,7 @@ func (s *BPSWMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers // retrieving the available power for all the hosts in the offers. for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) _, _, offerWatts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offerWatts // setting total power if the first time diff --git a/schedulers/firstfit.go b/schedulers/firstfit.go index e07839c..e0f114d 100644 --- a/schedulers/firstfit.go +++ b/schedulers/firstfit.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -120,10 +119,7 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/firstfitProacCC.go b/schedulers/firstfitProacCC.go index 51011e5..0d4c3d4 100644 --- a/schedulers/firstfitProacCC.go +++ b/schedulers/firstfitProacCC.go @@ -233,10 +233,7 @@ func (s *FirstFitProacCC) ResourceOffers(driver sched.SchedulerDriver, offers [] // retrieving the available power for all the hosts in the offers. for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) _, _, offer_watts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offer_watts // setting total power if the first time. diff --git a/schedulers/firstfitSortedOffers.go b/schedulers/firstfitSortedOffers.go index a9ab1d8..0bcd47a 100644 --- a/schedulers/firstfitSortedOffers.go +++ b/schedulers/firstfitSortedOffers.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -127,10 +126,7 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/firstfitSortedWattsProacCC.go b/schedulers/firstfitSortedWattsProacCC.go index 4173ae6..99524b2 100644 --- a/schedulers/firstfitSortedWattsProacCC.go +++ b/schedulers/firstfitSortedWattsProacCC.go @@ -246,10 +246,7 @@ func (s *FirstFitSortedWattsProacCC) ResourceOffers(driver sched.SchedulerDriver // retrieving the available power for all the hosts in the offers. for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) _, _, offer_watts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offer_watts // setting total power if the first time. diff --git a/schedulers/firstfitSortedWattsSortedOffers.go b/schedulers/firstfitSortedWattsSortedOffers.go index 5745ec6..dd552de 100644 --- a/schedulers/firstfitSortedWattsSortedOffers.go +++ b/schedulers/firstfitSortedWattsSortedOffers.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -129,10 +128,7 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/firstfitsortedwatts.go b/schedulers/firstfitsortedwatts.go index f19bec0..6c6cc24 100644 --- a/schedulers/firstfitsortedwatts.go +++ b/schedulers/firstfitsortedwatts.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -123,10 +122,7 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/firstfitwattsonly.go b/schedulers/firstfitwattsonly.go index f7833b1..5bef674 100644 --- a/schedulers/firstfitwattsonly.go +++ b/schedulers/firstfitwattsonly.go @@ -1,7 +1,6 @@ package schedulers import ( - "bitbucket.org/sunybingcloud/electron/constants" "bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/utilities/mesosUtils" "bitbucket.org/sunybingcloud/electron/utilities/offerUtils" @@ -113,10 +112,7 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - if _, ok := constants.Hosts[offer.GetHostname()]; !ok { - log.Printf("New host found. Adding host [%s]", offer.GetHostname()) - constants.Hosts[offer.GetHostname()] = struct{}{} - } + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/helpers.go b/schedulers/helpers.go index e6ba7fb..1e39c20 100644 --- a/schedulers/helpers.go +++ b/schedulers/helpers.go @@ -18,7 +18,7 @@ func coLocated(tasks map[string]bool) { // Get the powerClass of the given hostname func hostToPowerClass(hostName string) string { for powerClass, hosts := range constants.PowerClasses { - if ok := hosts[hostName]; ok { + if _, ok := hosts[hostName]; ok { return powerClass } } diff --git a/schedulers/topHeavy.go b/schedulers/topHeavy.go index 63c11e0..fbcd093 100644 --- a/schedulers/topHeavy.go +++ b/schedulers/topHeavy.go @@ -281,6 +281,7 @@ func (s *TopHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. offersLightPowerClasses := []*mesos.Offer{} for _, offer := range offers { + offerUtils.AddHostIfNew(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") @@ -291,12 +292,17 @@ func (s *TopHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. default: } - if constants.PowerClasses["A"][*offer.Hostname] || - constants.PowerClasses["B"][*offer.Hostname] { + if _, ok := constants.PowerClasses["A"][*offer.Hostname]; ok{ offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) - } else if constants.PowerClasses["C"][*offer.Hostname] || - constants.PowerClasses["D"][*offer.Hostname] { - offersLightPowerClasses = append(offersLightPowerClasses, offer) + } + if _, ok := constants.PowerClasses["B"][*offer.Hostname]; ok{ + offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) + } + if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok{ + offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + } + if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok{ + offersHeavyPowerClasses = append(offersLightPowerClasses, offer) } } From 10358b418b3687ada8a44ad83c986ab9f815aa4c Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:31:49 -0400 Subject: [PATCH 11/23] Added a space before { --- utilities/offerUtils/offerUtils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index 9d0034a..4e01a19 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -81,7 +81,7 @@ func AddHostIfNew(offer *mesos.Offer) { constants.PowerClasses[class] = make(map[string]struct{}) } // If the host of this class is not yet present in PowerClasses[class], add it. - if _, ok:= constants.PowerClasses[class][host]; !ok{ + if _, ok:= constants.PowerClasses[class][host]; !ok { constants.PowerClasses[class][host] = struct{}{} } } From abc718b55422fecb96e2c133a12692fbaf36e2fa Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:34:17 -0400 Subject: [PATCH 12/23] Performed a git fmt --- schedulers/bottomHeavy.go | 8 ++++---- schedulers/topHeavy.go | 8 ++++---- utilities/offerUtils/offerUtils.go | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/schedulers/bottomHeavy.go b/schedulers/bottomHeavy.go index 49487fc..2f49e59 100644 --- a/schedulers/bottomHeavy.go +++ b/schedulers/bottomHeavy.go @@ -293,16 +293,16 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes default: } - if _, ok := constants.PowerClasses["A"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["A"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) } - if _, ok := constants.PowerClasses["B"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["B"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) } - if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersLightPowerClasses, offer) } - if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersLightPowerClasses, offer) } diff --git a/schedulers/topHeavy.go b/schedulers/topHeavy.go index fbcd093..4c0add7 100644 --- a/schedulers/topHeavy.go +++ b/schedulers/topHeavy.go @@ -292,16 +292,16 @@ func (s *TopHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. default: } - if _, ok := constants.PowerClasses["A"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["A"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) } - if _, ok := constants.PowerClasses["B"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["B"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) } - if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersLightPowerClasses, offer) } - if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok{ + if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok { offersHeavyPowerClasses = append(offersLightPowerClasses, offer) } } diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index 4e01a19..1f4644c 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -1,11 +1,11 @@ package offerUtils import ( + "bitbucket.org/sunybingcloud/electron-archive/utilities/offerUtils" "bitbucket.org/sunybingcloud/electron/constants" mesos "github.com/mesos/mesos-go/mesosproto" - "strings" "log" - "bitbucket.org/sunybingcloud/electron-archive/utilities/offerUtils" + "strings" ) func OfferAgg(offer *mesos.Offer) (float64, float64, float64) { @@ -81,8 +81,8 @@ func AddHostIfNew(offer *mesos.Offer) { constants.PowerClasses[class] = make(map[string]struct{}) } // If the host of this class is not yet present in PowerClasses[class], add it. - if _, ok:= constants.PowerClasses[class][host]; !ok { + if _, ok := constants.PowerClasses[class][host]; !ok { constants.PowerClasses[class][host] = struct{}{} } } -} \ No newline at end of file +} From 6665ff47766cb4d3cb1d71f67ec41b075a557539 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:36:42 -0400 Subject: [PATCH 13/23] Fixed a bug. --- schedulers/bottomHeavy.go | 4 ++-- schedulers/topHeavy.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/schedulers/bottomHeavy.go b/schedulers/bottomHeavy.go index 2f49e59..c3f5198 100644 --- a/schedulers/bottomHeavy.go +++ b/schedulers/bottomHeavy.go @@ -300,10 +300,10 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) } if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok { - offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + offersLightPowerClasses = append(offersLightPowerClasses, offer) } if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok { - offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + offersLightPowerClasses = append(offersLightPowerClasses, offer) } } diff --git a/schedulers/topHeavy.go b/schedulers/topHeavy.go index 4c0add7..da612d7 100644 --- a/schedulers/topHeavy.go +++ b/schedulers/topHeavy.go @@ -299,10 +299,10 @@ func (s *TopHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. offersHeavyPowerClasses = append(offersHeavyPowerClasses, offer) } if _, ok := constants.PowerClasses["C"][*offer.Hostname]; ok { - offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + offersLightPowerClasses = append(offersLightPowerClasses, offer) } if _, ok := constants.PowerClasses["D"][*offer.Hostname]; ok { - offersHeavyPowerClasses = append(offersLightPowerClasses, offer) + offersLightPowerClasses = append(offersLightPowerClasses, offer) } } From 02aa1fac3c1b35c7b291c06f9dfc26e80470a96d Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:40:14 -0400 Subject: [PATCH 14/23] Removed a TODO which is basically this current PR --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 79b433d..2f2566d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ To Do: * Make parameters corresponding to each scheduler configurable (possible to have a config template for each scheduler?) * TODO : Adding type of scheduler to be used, to be picked from a config file, along with it's configurable parameters. * Write test code for each scheduler (This should be after the design change) - * Populate constants.PowerClasses dynamically. Possible to setup the constants at runtime based on the environment? * Log fix for declining offer -- different reason when insufficient resources as compared to when there are no longer any tasks to schedule. From ca247065820a7f6397b3c53d424be5dd0f7380ae Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 16:53:27 -0400 Subject: [PATCH 15/23] Removed the tag TODO from a TODO --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f2566d..fdc4907 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ To Do: * Add ability to use constraints * Running average calculations https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average * Make parameters corresponding to each scheduler configurable (possible to have a config template for each scheduler?) - * TODO : Adding type of scheduler to be used, to be picked from a config file, along with it's configurable parameters. + * Adding type of scheduler to be used, to be picked from a config file, along with it's configurable parameters. * Write test code for each scheduler (This should be after the design change) Possible to setup the constants at runtime based on the environment? * Log fix for declining offer -- different reason when insufficient resources as compared to when there are no From 1915e589cda7a49c34c6a60ad3a8b1bd9570451b Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 17:03:29 -0400 Subject: [PATCH 16/23] Made a tiny change in the logging message in AddHostIfNew(..) function --- utilities/offerUtils/offerUtils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index 1f4644c..cb68ead 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -70,7 +70,7 @@ func AddHostIfNew(offer *mesos.Offer) { var host = offer.GetHostname() // If this host is not present in the set of hosts. if _, ok := constants.Hosts[host]; !ok { - log.Printf("New host found. Adding host [%s]", host) + log.Printf("New host detected. Adding host [%s]", host) // Add this host. constants.Hosts[host] = struct{}{} // Get the power class of this host. From 9546529f80eebbd23d00b489d7f8d120a3182794 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 17:13:21 -0400 Subject: [PATCH 17/23] Corrected a spelling mistake in a print statement --- scheduler.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scheduler.go b/scheduler.go index b21b567..2128309 100644 --- a/scheduler.go +++ b/scheduler.go @@ -43,7 +43,7 @@ func main() { } if *hiThreshold < *loThreshold { - fmt.Println("High threshold is of a lower value than low threhold.") + fmt.Println("High threshold is of a lower value than low threshold.") os.Exit(1) } @@ -74,12 +74,12 @@ func main() { return } - //go pcp.Start(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix) + go pcp.Start(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix) //go pcp.StartPCPLogAndExtremaDynamicCap(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix, *hiThreshold, *loThreshold) - go pcp.StartPCPLogAndProgressiveExtremaCap(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix, *hiThreshold, *loThreshold) + //go pcp.StartPCPLogAndProgressiveExtremaCap(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix, *hiThreshold, *loThreshold) time.Sleep(1 * time.Second) // Take a second between starting PCP log and continuing - // Attempt to handle signint to not leave pmdumptext running + // Attempt to handle SIGINT to not leave pmdumptext running // Catch interrupt go func() { c := make(chan os.Signal, 1) @@ -120,4 +120,4 @@ func main() { log.Printf("Framework stopped with status %s and error: %s\n", status.String(), err.Error()) } log.Println("Exiting...") -} +} \ No newline at end of file From 85b14e125d309eb1a86d6d454362d8787989260e Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 24 Mar 2017 17:28:53 -0400 Subject: [PATCH 18/23] Got rid of commented code --- pcp/pcp.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pcp/pcp.go b/pcp/pcp.go index edc60a9..1498317 100644 --- a/pcp/pcp.go +++ b/pcp/pcp.go @@ -37,15 +37,6 @@ func Start(quit chan struct{}, logging *bool, prefix string) { // Write to logfile logFile.WriteString(scanner.Text() + "\n") - /* - headers := strings.Split(scanner.Text(), ",") - - for _, hostMetric := range headers { - split := strings.Split(hostMetric, ":") - fmt.Printf("Host %s: Metric: %s\n", split[0], split[1]) - } - */ - // Throw away first set of results scanner.Scan() @@ -57,15 +48,7 @@ func Start(quit chan struct{}, logging *bool, prefix string) { logFile.WriteString(scanner.Text() + "\n") } - /* - fmt.Printf("Second: %d\n", seconds) - for i, val := range strings.Split(scanner.Text(), ",") { - fmt.Printf("host metric: %s val: %s\n", headers[i], val) - }*/ - seconds++ - - // fmt.Println("--------------------------------") } }(logging) From 8eddad4e176a00839c2da883b9774b954ba472e3 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 25 Mar 2017 18:05:36 -0400 Subject: [PATCH 19/23] Changed the function name from AddHostIfNew(..) to UpdateEnvironment(..) based on a comment in the PR --- utilities/offerUtils/offerUtils.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index cb68ead..a6013ed 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -66,7 +66,7 @@ func HostMismatch(offerHost string, taskHost string) bool { // If the host in the offer is a new host, add the host to the set of Hosts and // register the powerclass of this host. -func AddHostIfNew(offer *mesos.Offer) { +func UpdateEnvironment(offer *mesos.Offer) { var host = offer.GetHostname() // If this host is not present in the set of hosts. if _, ok := constants.Hosts[host]; !ok { @@ -74,9 +74,9 @@ func AddHostIfNew(offer *mesos.Offer) { // Add this host. constants.Hosts[host] = struct{}{} // Get the power class of this host. - var class = offerUtils.PowerClass(offer) + class := offerUtils.PowerClass(offer) log.Printf("Registering the power class of this host [%s] --> [%s]", host, class) - // If this class is a new power class, create a map for this class. + // If new power class, register the power class. if _, ok := constants.PowerClasses[class]; !ok { constants.PowerClasses[class] = make(map[string]struct{}) } From e01c7b1b1d68498e0c95f247e6795df1b2ff5eba Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 25 Mar 2017 18:06:39 -0400 Subject: [PATCH 20/23] Retrofitted all the schedulers to call UpdateEnvironment(..) function instead of the old named function i.e AddHostIfNew(..) --- schedulers/binPackSortedWattsSortedOffers.go | 2 +- schedulers/binpackedpistoncapping.go | 2 +- schedulers/binpacksortedwatts.go | 2 +- schedulers/bottomHeavy.go | 16 ++++++++-------- schedulers/bpswMaxMin.go | 2 +- schedulers/bpswMaxMinPistonCapping.go | 2 +- schedulers/bpswMaxMinProacCC.go | 2 +- schedulers/firstfit.go | 2 +- schedulers/firstfitProacCC.go | 2 +- schedulers/firstfitSortedOffers.go | 2 +- schedulers/firstfitSortedWattsProacCC.go | 2 +- schedulers/firstfitSortedWattsSortedOffers.go | 2 +- schedulers/firstfitsortedwatts.go | 2 +- schedulers/firstfitwattsonly.go | 2 +- schedulers/topHeavy.go | 6 +++--- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/schedulers/binPackSortedWattsSortedOffers.go b/schedulers/binPackSortedWattsSortedOffers.go index e89236f..8d757fb 100644 --- a/schedulers/binPackSortedWattsSortedOffers.go +++ b/schedulers/binPackSortedWattsSortedOffers.go @@ -127,7 +127,7 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/binpackedpistoncapping.go b/schedulers/binpackedpistoncapping.go index a14e18f..a7ead66 100644 --- a/schedulers/binpackedpistoncapping.go +++ b/schedulers/binpackedpistoncapping.go @@ -210,7 +210,7 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off // retrieving the total power for each host in the offers for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) if _, ok := s.totalPower[*offer.Hostname]; !ok { _, _, offerWatts := offerUtils.OfferAgg(offer) s.totalPower[*offer.Hostname] = offerWatts diff --git a/schedulers/binpacksortedwatts.go b/schedulers/binpacksortedwatts.go index 2dd6f5f..f0c69fa 100644 --- a/schedulers/binpacksortedwatts.go +++ b/schedulers/binpacksortedwatts.go @@ -120,7 +120,7 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bottomHeavy.go b/schedulers/bottomHeavy.go index c3f5198..3d8251e 100644 --- a/schedulers/bottomHeavy.go +++ b/schedulers/bottomHeavy.go @@ -18,12 +18,12 @@ import ( ) /* -Tasks are categorized into small and large tasks based on the watts requirement. -All the small tasks are packed into offers from agents belonging to power class C and power class D, using BinPacking. -All the large tasks are spread among the offers from agents belonging to power class A and power class B, using FirstFit. +Tasks are categorized into small and large tasks based on watts requirements. +All the large tasks are packed into offers from agents belonging to power classes A and B, using Bin-Packing. +All the small tasks are spread among offers from agents belonging to power class C and D, using First-Fit. -BinPacking has the most effect when co-scheduling of tasks is increased. Large tasks typically utilize more resources and hence, - co-scheduling them has a great impact on the total power utilization. +Bin-Packing has the most effect when co-scheduling of tasks is increased. Large tasks typically utilize more resources and hence, +co-scheduling them has a great impact on the total power utilization. */ func (s *BottomHeavy) takeOfferBinPack(offer *mesos.Offer, totalCPU, totalRAM, totalWatts, @@ -159,7 +159,7 @@ func (s *BottomHeavy) createTaskInfoAndLogSchedTrace(offer *mesos.Offer, task de return taskToSchedule } -// Using BinPacking to pack small tasks into this offer. +// Using BinPacking to pack large tasks into the given offers. func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver) { for _, offer := range offers { select { @@ -221,7 +221,7 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver) } } -// Using first fit to spread large tasks into these offers. +// Using First-Fit to spread small tasks among the given offers. func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) { for _, offer := range offers { select { @@ -282,7 +282,7 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes offersLightPowerClasses := []*mesos.Offer{} for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMin.go b/schedulers/bpswMaxMin.go index a176501..60a80ee 100644 --- a/schedulers/bpswMaxMin.go +++ b/schedulers/bpswMaxMin.go @@ -164,7 +164,7 @@ func (s *BPSWMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers [] log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMinPistonCapping.go b/schedulers/bpswMaxMinPistonCapping.go index 41c1559..53a7200 100644 --- a/schedulers/bpswMaxMinPistonCapping.go +++ b/schedulers/bpswMaxMinPistonCapping.go @@ -261,7 +261,7 @@ func (s *BPSWMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, o log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/bpswMaxMinProacCC.go b/schedulers/bpswMaxMinProacCC.go index c3f2e90..a0ac947 100644 --- a/schedulers/bpswMaxMinProacCC.go +++ b/schedulers/bpswMaxMinProacCC.go @@ -300,7 +300,7 @@ func (s *BPSWMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers // retrieving the available power for all the hosts in the offers. for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) _, _, offerWatts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offerWatts // setting total power if the first time diff --git a/schedulers/firstfit.go b/schedulers/firstfit.go index e0f114d..db59e24 100644 --- a/schedulers/firstfit.go +++ b/schedulers/firstfit.go @@ -119,7 +119,7 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/firstfitProacCC.go b/schedulers/firstfitProacCC.go index 0d4c3d4..51a466e 100644 --- a/schedulers/firstfitProacCC.go +++ b/schedulers/firstfitProacCC.go @@ -233,7 +233,7 @@ func (s *FirstFitProacCC) ResourceOffers(driver sched.SchedulerDriver, offers [] // retrieving the available power for all the hosts in the offers. for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) _, _, offer_watts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offer_watts // setting total power if the first time. diff --git a/schedulers/firstfitSortedOffers.go b/schedulers/firstfitSortedOffers.go index 0bcd47a..d3fdb5f 100644 --- a/schedulers/firstfitSortedOffers.go +++ b/schedulers/firstfitSortedOffers.go @@ -126,7 +126,7 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/firstfitSortedWattsProacCC.go b/schedulers/firstfitSortedWattsProacCC.go index 99524b2..2610084 100644 --- a/schedulers/firstfitSortedWattsProacCC.go +++ b/schedulers/firstfitSortedWattsProacCC.go @@ -246,7 +246,7 @@ func (s *FirstFitSortedWattsProacCC) ResourceOffers(driver sched.SchedulerDriver // retrieving the available power for all the hosts in the offers. for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) _, _, offer_watts := offerUtils.OfferAgg(offer) s.availablePower[*offer.Hostname] = offer_watts // setting total power if the first time. diff --git a/schedulers/firstfitSortedWattsSortedOffers.go b/schedulers/firstfitSortedWattsSortedOffers.go index dd552de..b8b1eef 100644 --- a/schedulers/firstfitSortedWattsSortedOffers.go +++ b/schedulers/firstfitSortedWattsSortedOffers.go @@ -128,7 +128,7 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD log.Println("Sorted Offers:") for i := 0; i < len(offers); i++ { offer := offers[i] - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) offerCPU, _, _ := offerUtils.OfferAgg(offer) log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU) } diff --git a/schedulers/firstfitsortedwatts.go b/schedulers/firstfitsortedwatts.go index 6c6cc24..1f71411 100644 --- a/schedulers/firstfitsortedwatts.go +++ b/schedulers/firstfitsortedwatts.go @@ -122,7 +122,7 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/firstfitwattsonly.go b/schedulers/firstfitwattsonly.go index 5bef674..d2b13b6 100644 --- a/schedulers/firstfitwattsonly.go +++ b/schedulers/firstfitwattsonly.go @@ -112,7 +112,7 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers log.Printf("Received %d resource offers", len(offers)) for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") diff --git a/schedulers/topHeavy.go b/schedulers/topHeavy.go index da612d7..1b62336 100644 --- a/schedulers/topHeavy.go +++ b/schedulers/topHeavy.go @@ -19,8 +19,8 @@ import ( /* Tasks are categorized into small and large tasks based on the watts requirement. -All the large tasks are packed into offers from agents belonging to power class A and power class B, using BinPacking. -All the small tasks are spread among the offers from agents belonging to power class C and power class D, using FirstFit. +All the small tasks are packed into offers from agents belonging to power class C and power class D, using BinPacking. +All the large tasks are spread among the offers from agents belonging to power class A and power class B, using FirstFit. This was done to give a little more room for the large tasks (power intensive) for execution and reduce the possibility of starvation of power intensive tasks. @@ -281,7 +281,7 @@ func (s *TopHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos. offersLightPowerClasses := []*mesos.Offer{} for _, offer := range offers { - offerUtils.AddHostIfNew(offer) + offerUtils.UpdateEnvironment(offer) select { case <-s.Shutdown: log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]") From de7e73ff507afb91f9e7f43a044df994e0e9cce6 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 25 Mar 2017 20:27:40 -0400 Subject: [PATCH 21/23] Changed a log message in the UpdateEnvironment(..) func. --- utilities/offerUtils/offerUtils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index a6013ed..f90480e 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -75,7 +75,7 @@ func UpdateEnvironment(offer *mesos.Offer) { constants.Hosts[host] = struct{}{} // Get the power class of this host. class := offerUtils.PowerClass(offer) - log.Printf("Registering the power class of this host [%s] --> [%s]", host, class) + log.Printf("Registering the power class... Host [%s] --> PowerClass [%s]", host, class) // If new power class, register the power class. if _, ok := constants.PowerClasses[class]; !ok { constants.PowerClasses[class] = make(map[string]struct{}) From 34a9c89e45fcbbbc203f9012ae516bd69fd4f7cc Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 25 Mar 2017 20:34:58 -0400 Subject: [PATCH 22/23] Added a TODO regarding handling the powerclass not being configured on a node condition --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fdc4907..b937690 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ To Do: * Make def.Task an interface for further modularization and flexibility. * Convert def#WattsToConsider(...) to be a receiver of def.Task and change the name of it to Watts(...). * Have a generic sorter for task resources instead of having one for each kind of resource. + * Handle Powerclass not configured on a node condition. As of now, an assumption is made that the powerclass is configured + for all the nodes. **Requires [Performance Co-Pilot](http://pcp.io/) tool pmdumptext to be installed on the machine on which electron is launched for logging to work and PCP collector agents installed From 4024f1655e13d5dff7e16259d2d397308057787e Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 25 Mar 2017 20:35:50 -0400 Subject: [PATCH 23/23] Fixed a TODO --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b937690..16a1114 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To Do: * Make def.Task an interface for further modularization and flexibility. * Convert def#WattsToConsider(...) to be a receiver of def.Task and change the name of it to Watts(...). * Have a generic sorter for task resources instead of having one for each kind of resource. - * Handle Powerclass not configured on a node condition. As of now, an assumption is made that the powerclass is configured + * Handle powerclass not configured on a node condition. As of now, an assumption is made that the powerclass is configured for all the nodes. **Requires [Performance Co-Pilot](http://pcp.io/) tool pmdumptext to be installed on the