Added a HostMismatch(...) in offerUtils that checks whether a task's host requirement matches the host corresponding to the offer. Made sure all schedulers call takeOffer(...) that is defined in each scheduler, to maintain consistency.
This commit is contained in:
parent
aabdd716dd
commit
6c62b5326f
20 changed files with 175 additions and 239 deletions
|
@ -12,21 +12,22 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (*BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, totalCPU, totalRAM,
|
||||||
|
totalWatts float64, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
// Does the task fit
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.Watts))) &&
|
||||||
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +153,6 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offer_cpu, offer_ram, offer_watts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
|
@ -161,19 +160,14 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || offer_watts >= (totalWatts+task.Watts)) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, task) {
|
||||||
(offer_cpu >= (totalCPU + task.CPU)) &&
|
|
||||||
(offer_ram >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += task.Watts
|
totalWatts += task.Watts
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -258,13 +257,8 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
partialLoad := 0.0
|
partialLoad := 0.0
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {continue}
|
||||||
// Don't take offer if it doens't match our task's host requirement.
|
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
|
|
|
@ -12,21 +12,19 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (*BinPackSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BinPackSortedWatts) takeOffer(offer *mesos.Offer, totalCPU, totalRAM, totalWatts float64, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.Watts))) &&
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +139,6 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offer_cpu, offer_ram, offer_watts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
|
@ -150,19 +146,14 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || offer_watts >= (totalWatts+task.Watts)) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, task) {
|
||||||
(offer_cpu >= (totalCPU + task.CPU)) &&
|
|
||||||
(offer_ram >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += task.Watts
|
totalWatts += task.Watts
|
||||||
|
|
|
@ -26,6 +26,20 @@ BinPacking has the most effect when co-scheduling of tasks is increased. Large t
|
||||||
co-scheduling them has a great impact on the total power utilization.
|
co-scheduling them has a great impact on the total power utilization.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
func (s *BottomHeavy) takeOffer(offer *mesos.Offer, totalCPU, totalRAM, totalWatts,
|
||||||
|
wattsToConsider float64, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + wattsToConsider))) &&
|
||||||
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// electronScheduler implements the Scheduler interface
|
// electronScheduler implements the Scheduler interface
|
||||||
type BottomHeavy struct {
|
type BottomHeavy struct {
|
||||||
base // Type embedded to inherit common functions
|
base // Type embedded to inherit common functions
|
||||||
|
@ -162,7 +176,6 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
totalRAM := 0.0
|
totalRAM := 0.0
|
||||||
|
@ -179,9 +192,7 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver)
|
||||||
if !s.ignoreWatts {
|
if !s.ignoreWatts {
|
||||||
wattsToConsider = task.ClassToWatts[powerClass]
|
wattsToConsider = task.ClassToWatts[powerClass]
|
||||||
}
|
}
|
||||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + wattsToConsider))) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, wattsToConsider, task) {
|
||||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (totalRAM + task.RAM)) {
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += wattsToConsider
|
totalWatts += wattsToConsider
|
||||||
totalCPU += task.CPU
|
totalCPU += task.CPU
|
||||||
|
|
|
@ -12,21 +12,19 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (*BPMaxMinWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPMaxMinWatts) takeOffer(offer *mesos.Offer, totalCPU, totalRAM, totalWatts float64, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.Watts))) &&
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,12 +133,8 @@ func (s *BPMaxMinWatts) CheckFit(i int,
|
||||||
totalRAM *float64,
|
totalRAM *float64,
|
||||||
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
if s.takeOffer(offer, *totalCPU, *totalRAM, *totalWatts, task) {
|
||||||
(offerCPU >= (*totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (*totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
*totalWatts += task.Watts
|
*totalWatts += task.Watts
|
||||||
*totalCPU += task.CPU
|
*totalCPU += task.CPU
|
||||||
|
@ -198,12 +192,9 @@ func (s *BPMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers []*m
|
||||||
for i := len(s.tasks) - 1; i >= 0; i-- {
|
for i := len(s.tasks) - 1; i >= 0; i-- {
|
||||||
|
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this so index doesn't need to be passed
|
// TODO: Fix this so index doesn't need to be passed
|
||||||
|
@ -219,12 +210,9 @@ func (s *BPMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers []*m
|
||||||
// Pack the rest of the offer with the smallest tasks
|
// Pack the rest of the offer with the smallest tasks
|
||||||
for i, task := range s.tasks {
|
for i, task := range s.tasks {
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
|
|
|
@ -16,22 +16,21 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *BPMaxMinPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPMaxMinPistonCapping) takeOffer(offer *mesos.Offer, totalCPU, totalRAM, totalWatts float64, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
// Does the task fit
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
||||||
|
(offerCPU >= (*totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (*totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,12 +223,8 @@ func (s *BPMaxMinPistonCapping) CheckFit(i int,
|
||||||
totalWatts *float64,
|
totalWatts *float64,
|
||||||
partialLoad *float64) (bool, *mesos.TaskInfo) {
|
partialLoad *float64) (bool, *mesos.TaskInfo) {
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
if s.takeOffer(offer, *totalCPU, *totalRAM, *totalWatts, 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 {
|
||||||
|
@ -297,12 +292,9 @@ func (s *BPMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
for i := len(s.tasks) - 1; i >= 0; i-- {
|
for i := len(s.tasks) - 1; i >= 0; i-- {
|
||||||
|
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this so index doesn't need to be passed
|
// TODO: Fix this so index doesn't need to be passed
|
||||||
|
@ -318,12 +310,9 @@ func (s *BPMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
// Pack the rest of the offer with the smallest tasks
|
// Pack the rest of the offer with the smallest tasks
|
||||||
for i, task := range s.tasks {
|
for i, task := range s.tasks {
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
|
|
|
@ -16,21 +16,21 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *BPMaxMinProacCC) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPMaxMinProacCC) takeOffer(offer *mesos.Offer, totalCPU, totalRAM, totalWatts float64, task def.Task) bool {
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
// Does the task fit
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
||||||
|
(offerCPU >= (*totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (*totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,12 +248,8 @@ func (s *BPMaxMinProacCC) CheckFit(i int,
|
||||||
totalRAM *float64,
|
totalRAM *float64,
|
||||||
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
if s.takeOffer(offer, *totalCPU, *totalRAM, *totalWatts, task) {
|
||||||
(offerCPU >= (*totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (*totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
// Capping the cluster if haven't yet started
|
// Capping the cluster if haven't yet started
|
||||||
if !s.isCapping {
|
if !s.isCapping {
|
||||||
|
@ -347,12 +343,9 @@ func (s *BPMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
for i := len(s.tasks) - 1; i >= 0; i-- {
|
for i := len(s.tasks) - 1; i >= 0; i-- {
|
||||||
|
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this so index doesn't need to be passed
|
// TODO: Fix this so index doesn't need to be passed
|
||||||
|
@ -368,12 +361,9 @@ func (s *BPMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
// Pack the rest of the offer with the smallest tasks
|
// Pack the rest of the offer with the smallest tasks
|
||||||
for i, task := range s.tasks {
|
for i, task := range s.tasks {
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
|
|
|
@ -12,21 +12,20 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (*BPSWClassMapWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPSWClassMapWatts) takeOffer(offer *mesos.Offer, totalCPU, totalRAM,
|
||||||
|
totalWatts float64, powerClass string, task def.Task) bool {
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +140,6 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
|
@ -150,12 +147,9 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
|
@ -163,9 +157,7 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
// OR lazy evaluation. If ignore watts is set to true, second statement won't
|
// OR lazy evaluation. If ignore watts is set to true, second statement won't
|
||||||
// be evaluated.
|
// be evaluated.
|
||||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, powerClass, task) {
|
||||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
fmt.Println("Watts being used: ", task.ClassToWatts[powerClass])
|
fmt.Println("Watts being used: ", task.ClassToWatts[powerClass])
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
|
|
|
@ -16,21 +16,21 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *BPSWClassMapWattsPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPSWClassMapWattsPistonCapping) takeOffer(offer *mesos.Offer, totalCPU, totalRAM,
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
totalWatts float64, powerClass string, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
//TODO: Insert watts calculation here instead of taking them as a parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,8 +240,6 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
|
@ -251,12 +249,9 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
partialLoad := 0.0
|
partialLoad := 0.0
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
|
@ -264,9 +259,7 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
// OR lazy evaluation. If ignoreWatts is set to true, second statement won't
|
// OR lazy evaluation. If ignoreWatts is set to true, second statement won't
|
||||||
// be evaluated
|
// be evaluated
|
||||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, powerClass, 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 {
|
||||||
|
|
|
@ -16,21 +16,21 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (*BPSWClassMapWattsProacCC) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPSWClassMapWattsProacCC) takeOffer(offer *mesos.Offer, totalCPU, totalRAM,
|
||||||
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
totalWatts float64, powerClass string, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// TODO: Insert watts calculation here instead of taking them as parameter
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
||||||
if cpus >= task.CPU && mem >= task.RAM && watts >= task.Watts {
|
(offerCPU >= (totalCPU + task.CPU)) &&
|
||||||
|
(offerRAM >= (totalRAM + task.RAM)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,20 +278,15 @@ func (s *BPSWClassMapWattsProacCC) ResourceOffers(driver sched.SchedulerDriver,
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
totalRAM := 0.0
|
totalRAM := 0.0
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer it it doesn't match our task's host requirement.
|
continue
|
||||||
if strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *task.Instances > 0 {
|
for *task.Instances > 0 {
|
||||||
|
@ -299,9 +294,7 @@ func (s *BPSWClassMapWattsProacCC) ResourceOffers(driver sched.SchedulerDriver,
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
// OR Lazy evaluation. If ignore watts is set to true, second statement won't
|
// OR Lazy evaluation. If ignore watts is set to true, second statement won't
|
||||||
// be evaluated.
|
// be evaluated.
|
||||||
if (s.ignoreWatts || (offerWatts >= (totalWatts + task.ClassToWatts[powerClass]))) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, powerClass, task) {
|
||||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
// Capping the cluster if haven't yet started
|
// Capping the cluster if haven't yet started
|
||||||
if !s.isCapping {
|
if !s.isCapping {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
sched "github.com/mesos/mesos-go/scheduler"
|
sched "github.com/mesos/mesos-go/scheduler"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -146,12 +145,9 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -158,12 +157,9 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
|
|
|
@ -12,10 +12,22 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Decides if to take an offer or not
|
||||||
|
func (s *FirstFitSortedWattsClassMapWatts) takeOffer(offer *mesos.Offer, powerClass string, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
// Decision to take the offer or not
|
||||||
|
if (s.ignoreWatts || (offerWatts >= task.ClassToWatts[powerClass])) &&
|
||||||
|
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// electron scheduler implements the Scheduler interface
|
// electron scheduler implements the Scheduler interface
|
||||||
type FirstFitSortedWattsClassMapWatts struct {
|
type FirstFitSortedWattsClassMapWatts struct {
|
||||||
base // Type embedded to inherit common features.
|
base // Type embedded to inherit common features.
|
||||||
|
@ -126,26 +138,20 @@ func (s *FirstFitSortedWattsClassMapWatts) ResourceOffers(driver sched.Scheduler
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
// First fit strategy
|
// First fit strategy
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doens't match our task's host requirement.
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieving the powerClass from the offer
|
// retrieving the powerClass from the offer
|
||||||
powerClass := offerUtils.PowerClass(offer)
|
powerClass := offerUtils.PowerClass(offer)
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
if (s.ignoreWatts || (offerWatts >= task.ClassToWatts[powerClass])) &&
|
if s.takeOffer(offer, powerClass, task) {
|
||||||
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
|
||||||
fmt.Println("Watts being used: ", task.ClassToWatts[powerClass])
|
fmt.Println("Watts being used: ", task.ClassToWatts[powerClass])
|
||||||
log.Println("Co-Located with: ")
|
log.Println("Co-Located with: ")
|
||||||
coLocated(s.running[offer.GetSlaveId().GoString()])
|
coLocated(s.running[offer.GetSlaveId().GoString()])
|
||||||
|
|
|
@ -16,11 +16,23 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Decides if to take an offer or not
|
||||||
|
func (s *FirstFitSortedWattsClassMapWattsProacCC) takeOffer(offer *mesos.Offer, powerClass string, task def.Task) bool {
|
||||||
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
|
//TODO: Insert watts calculation here instead of taking them as a parameter
|
||||||
|
// Decision to take the offer or not
|
||||||
|
if (s.ignoreWatts || (offerWatts >= task.ClassToWatts[powerClass])) &&
|
||||||
|
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// electron scheduler implements the Scheduler interface
|
// electron scheduler implements the Scheduler interface
|
||||||
type FirstFitSortedWattsClassMapWattsProacCC struct {
|
type FirstFitSortedWattsClassMapWattsProacCC struct {
|
||||||
base // Type embedded to inherit common features.
|
base // Type embedded to inherit common features.
|
||||||
|
@ -264,26 +276,20 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) ResourceOffers(driver sched.Sc
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
|
|
||||||
// First fit strategy
|
// First fit strategy
|
||||||
offerTaken := false
|
offerTaken := false
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doens't match our task's host requirement.
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieving the powerClass for the offer
|
// retrieving the powerClass for the offer
|
||||||
powerClass := offerUtils.PowerClass(offer)
|
powerClass := offerUtils.PowerClass(offer)
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
if (s.ignoreWatts || (offerWatts >= task.ClassToWatts[powerClass])) &&
|
if s.takeOffer(offer, powerClass, task) {
|
||||||
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
|
||||||
|
|
||||||
// Capping the cluster if haven't yet started
|
// Capping the cluster if haven't yet started
|
||||||
if !s.isCapping {
|
if !s.isCapping {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -161,12 +160,9 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -149,12 +148,9 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
sched "github.com/mesos/mesos-go/scheduler"
|
sched "github.com/mesos/mesos-go/scheduler"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -140,12 +139,9 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
|
|
||||||
// Check host if it exists
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if task.Host != "" {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
// Don't take offer if it doesn't match our task's host requirement
|
continue
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
|
|
|
@ -15,16 +15,15 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (_ *ProactiveClusterwideCapFCFS) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *ProactiveClusterwideCapFCFS) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
offer_cpu, offer_mem, offer_watts := offerUtils.OfferAgg(offer)
|
offer_cpu, offer_mem, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
if offer_cpu >= task.CPU && offer_mem >= task.RAM && offer_watts >= task.Watts {
|
if offer_cpu >= task.CPU && offer_mem >= task.RAM && (s.ignoreWatts || (offer_watts >= task.Watts)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -279,8 +278,8 @@ func (s *ProactiveClusterwideCapFCFS) ResourceOffers(driver sched.SchedulerDrive
|
||||||
|
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Don't take offer if it doesn't match our task's host requirement.
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,15 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decides if to taken an offer or not
|
// Decides if to taken an offer or not
|
||||||
func (_ *ProactiveClusterwideCapRanked) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *ProactiveClusterwideCapRanked) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
offer_cpu, offer_mem, offer_watts := offerUtils.OfferAgg(offer)
|
offer_cpu, offer_mem, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
if offer_cpu >= task.CPU && offer_mem >= task.RAM && offer_watts >= task.Watts {
|
if offer_cpu >= task.CPU && offer_mem >= task.RAM && (s.ignoreWatts || (offer_watts >= task.Watts)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -303,8 +302,8 @@ func (s *ProactiveClusterwideCapRanked) ResourceOffers(driver sched.SchedulerDri
|
||||||
|
|
||||||
for i := 0; i < len(s.tasks); i++ {
|
for i := 0; i < len(s.tasks); i++ {
|
||||||
task := s.tasks[i]
|
task := s.tasks[i]
|
||||||
// Don't take offer if it doesn't match our task's host requirement.
|
// Don't take offer if it doesn't match our task's host requirement
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
if offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package offerUtils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
|
func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
|
||||||
|
@ -32,6 +33,8 @@ func PowerClass(offer *mesos.Offer) string {
|
||||||
return powerClass
|
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
|
type OffersSorter []*mesos.Offer
|
||||||
|
|
||||||
func (offersSorter OffersSorter) Len() int {
|
func (offersSorter OffersSorter) Len() int {
|
||||||
|
@ -49,3 +52,11 @@ func (offersSorter OffersSorter) Less(i, j int) bool {
|
||||||
cpu2, _, _ := OfferAgg(offersSorter[j])
|
cpu2, _, _ := OfferAgg(offersSorter[j])
|
||||||
return cpu1 <= cpu2
|
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
|
||||||
|
}
|
||||||
|
|
Reference in a new issue