added OffersSorter that implements sort interface to sort offers based on CPU.
This commit is contained in:
parent
477a319688
commit
e60488f965
1 changed files with 18 additions and 0 deletions
|
@ -29,6 +29,24 @@ func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
|
||||||
return cpus, mem, watts
|
return cpus, mem, 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
|
||||||
|
}
|
||||||
|
|
||||||
func coLocated(tasks map[string]bool) {
|
func coLocated(tasks map[string]bool) {
|
||||||
|
|
||||||
for task := range tasks {
|
for task := range tasks {
|
||||||
|
|
Reference in a new issue