Resolved merge conflicts with master
This commit is contained in:
commit
1dcf416849
16 changed files with 79 additions and 140 deletions
|
@ -1,8 +1,18 @@
|
||||||
/*
|
/*
|
||||||
Constants that are used across scripts
|
Constants that are used across scripts
|
||||||
1. The available hosts = stratos-00x (x varies from 1 to 8)
|
1. The available hosts = stratos-00x (x varies from 1 to 8)
|
||||||
|
<<<<<<< HEAD
|
||||||
2. CapMargin = percentage of the requested power to allocate
|
2. CapMargin = percentage of the requested power to allocate
|
||||||
3. ConsiderationWindowSize = number of tasks to consider for computation of the dynamic cap.
|
3. ConsiderationWindowSize = number of tasks to consider for computation of the dynamic cap.
|
||||||
|
=======
|
||||||
|
2. cap_margin = percentage of the requested power to allocate
|
||||||
|
3. power_threshold = overloading factor
|
||||||
|
5. window_size = number of tasks to consider for computation of the dynamic cap.
|
||||||
|
|
||||||
|
Also, exposing functions to update or initialize some of the constants.
|
||||||
|
|
||||||
|
TODO: Clean this up and use Mesos Attributes instead.
|
||||||
|
>>>>>>> a0a3e78041067e5e2f9dc9b5d1e7b6dd001ce1e9
|
||||||
*/
|
*/
|
||||||
package constants
|
package constants
|
||||||
|
|
||||||
|
|
|
@ -12,26 +12,23 @@ 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 (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, 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
|
||||||
|
|
||||||
wattsConsideration, err := def.WattsToConsider(task, s.classMapWatts, offer)
|
wattsConsideration, err := def.WattsToConsider(task, s.classMapWatts, offer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Error in determining wattsConsideration
|
// Error in determining wattsConsideration
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
if offerCPU >= task.CPU && offerRAM >= task.RAM && (!s.wattsAsAResource || (offerWatts >= wattsConsideration)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +163,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
|
||||||
|
@ -180,19 +175,14 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.wattsAsAResource || (offer_watts >= (totalWatts + wattsConsideration))) &&
|
if s.takeOffer(offer, task) {
|
||||||
(offer_cpu >= (totalCPU + task.CPU)) &&
|
|
||||||
(offer_ram >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += wattsConsideration
|
totalWatts += wattsConsideration
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -279,13 +278,8 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ func (s *BinPackSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +152,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
|
||||||
|
@ -168,19 +164,14 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.wattsAsAResource || (offer_watts >= (totalWatts + wattsConsideration))) &&
|
if s.takeOffer(offer, task) {
|
||||||
(offer_cpu >= (totalCPU + task.CPU)) &&
|
|
||||||
(offer_ram >= (totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += wattsConsideration
|
totalWatts += wattsConsideration
|
||||||
|
|
|
@ -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.wattsAsAResource || (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
|
||||||
|
@ -169,7 +183,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
|
||||||
|
@ -186,9 +199,7 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, 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.wattsAsAResource || (offerWatts >= (totalWatts + wattsConsideration))) &&
|
if s.takeOffer(offer, totalCPU, totalRAM, totalWatts, wattsConsideration, task) {
|
||||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (totalRAM + task.RAM)) {
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += wattsConsideration
|
totalWatts += wattsConsideration
|
||||||
totalCPU += task.CPU
|
totalCPU += task.CPU
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ func (s *BPSWMaxMinWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +147,8 @@ func (s *BPSWMaxMinWatts) 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.wattsAsAResource || (offerWatts >= (*totalWatts + wattsConsideration))) &&
|
if s.takeOffer(offer, task) {
|
||||||
(offerCPU >= (*totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (*totalRAM + task.RAM)) {
|
|
||||||
|
|
||||||
*totalWatts += wattsConsideration
|
*totalWatts += wattsConsideration
|
||||||
*totalCPU += task.CPU
|
*totalCPU += task.CPU
|
||||||
|
@ -218,12 +212,9 @@ func (s *BPSWMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -246,12 +237,9 @@ func (s *BPSWMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,7 +16,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -36,7 +35,6 @@ func (s *BPSWMaxMinPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) b
|
||||||
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,12 +237,8 @@ func (s *BPSWMaxMinPistonCapping) 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.wattsAsAResource || (offerWatts >= (*totalWatts + wattsConsideration))) &&
|
if s.takeOffer(offer, 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 {
|
||||||
|
@ -318,12 +312,9 @@ func (s *BPSWMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, o
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -346,12 +337,9 @@ func (s *BPSWMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, o
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,7 +16,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -35,7 +34,6 @@ func (s *BPSWMaxMinProacCC) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
if cpus >= task.CPU && mem >= task.RAM && (!s.wattsAsAResource || (watts >= wattsConsideration)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,12 +260,8 @@ func (s *BPSWMaxMinProacCC) 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.wattsAsAResource || (offerWatts >= (*totalWatts + wattsConsideration))) &&
|
if s.takeOffer(offer, 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 {
|
||||||
|
@ -366,12 +360,9 @@ func (s *BPSWMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
// Error in determining wattsConsideration
|
// Error in determining wattsConsideration
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// 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
|
||||||
|
@ -394,12 +385,9 @@ func (s *BPSWMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -159,12 +158,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
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -293,8 +292,8 @@ func (s *FirstFitProacCC) 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]
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -171,12 +170,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
|
||||||
|
|
|
@ -26,7 +26,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -309,9 +308,8 @@ func (s *FirstFitSortedWattsProacCC) ResourceOffers(driver sched.SchedulerDriver
|
||||||
|
|
||||||
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 offerUtils.HostMismatch(*offer.Hostname, task.Host) {
|
||||||
if !strings.HasPrefix(*offer.Hostname, task.Host) {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -175,12 +174,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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -162,12 +161,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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -152,12 +151,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
|
||||||
|
|
|
@ -33,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 {
|
||||||
|
|
Reference in a new issue