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:
Pradyumna Kaushik 2017-02-09 22:48:34 -05:00
parent aabdd716dd
commit 6c62b5326f
20 changed files with 175 additions and 239 deletions

View file

@ -2,6 +2,7 @@ package offerUtils
import (
mesos "github.com/mesos/mesos-go/mesosproto"
"strings"
)
func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
@ -32,6 +33,8 @@ func PowerClass(offer *mesos.Offer) string {
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 {
@ -49,3 +52,11 @@ func (offersSorter OffersSorter) Less(i, j int) bool {
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
}