retrofitted all schedulers to call OfferAgg(...) and OffersSorter from utilities/offerUtils and also to use defaultFilter and longFilter from utilities/mesosUtils
This commit is contained in:
parent
354e89cac7
commit
8581749435
20 changed files with 182 additions and 143 deletions
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -17,7 +19,7 @@ import (
|
||||||
// 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 (*BinPackSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -37,18 +39,18 @@ type BinPackSortedWattsSortedOffers struct {
|
||||||
running map[string]map[string]bool
|
running map[string]map[string]bool
|
||||||
ignoreWatts bool
|
ignoreWatts bool
|
||||||
|
|
||||||
// First set of PCP values are garbage values, signal to logger to start recording when we're
|
// First set of PCP values are garbage values, signal to logger to start recording when we're
|
||||||
// about to schedule a new task
|
// about to schedule a new task
|
||||||
RecordPCP bool
|
RecordPCP bool
|
||||||
|
|
||||||
// This channel is closed when the program receives an interrupt,
|
// This channel is closed when the program receives an interrupt,
|
||||||
// signalling that the program should shut down.
|
// signalling that the program should shut down.
|
||||||
Shutdown chan struct{}
|
Shutdown chan struct{}
|
||||||
// This channel is closed after shutdown is closed, and only when all
|
// This channel is closed after shutdown is closed, and only when all
|
||||||
// outstanding tasks have been cleaned up
|
// outstanding tasks have been cleaned up
|
||||||
Done chan struct{}
|
Done chan struct{}
|
||||||
|
|
||||||
// Controls when to shutdown pcp logging
|
// Controls when to shutdown pcp logging
|
||||||
PCPLog chan struct{}
|
PCPLog chan struct{}
|
||||||
|
|
||||||
schedTrace *log.Logger
|
schedTrace *log.Logger
|
||||||
|
@ -127,13 +129,13 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
log.Printf("Received %d resource offers", len(offers))
|
log.Printf("Received %d resource offers", len(offers))
|
||||||
|
|
||||||
// Sorting the offers
|
// Sorting the offers
|
||||||
sort.Sort(OffersSorter(offers))
|
sort.Sort(offerUtils.OffersSorter(offers))
|
||||||
|
|
||||||
// Printing the sorted offers and the corresponding CPU resource availability
|
// Printing the sorted offers and the corresponding CPU resource availability
|
||||||
log.Println("Sorted Offers:")
|
log.Println("Sorted Offers:")
|
||||||
for i := 0; i < len(offers); i++ {
|
for i := 0; i < len(offers); i++ {
|
||||||
offer := offers[i]
|
offer := offers[i]
|
||||||
offerCPU, _, _ := OfferAgg(offer)
|
offerCPU, _, _ := offerUtils.OfferAgg(offer)
|
||||||
log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU)
|
log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -150,7 +152,7 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offer_cpu, offer_ram, offer_watts := OfferAgg(offer)
|
offer_cpu, offer_ram, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
taken := false
|
taken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
|
@ -203,15 +205,15 @@ func (s *BinPackSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDr
|
||||||
|
|
||||||
if taken {
|
if taken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,4 +236,3 @@ func (s *BinPackSortedWattsSortedOffers) StatusUpdate(driver sched.SchedulerDriv
|
||||||
}
|
}
|
||||||
log.Printf("DONE: Task status [%s] for task [%s]", NameFor(status.State), *status.TaskId.Value)
|
log.Printf("DONE: Task status [%s] for task [%s]", NameFor(status.State), *status.TaskId.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"bitbucket.org/sunybingcloud/electron/constants"
|
"bitbucket.org/sunybingcloud/electron/constants"
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
@ -217,7 +219,7 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
// retrieving the total power for each host in the offers
|
// retrieving the total power for each host in the offers
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
_, _, offer_watts := OfferAgg(offer)
|
_, _, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
s.totalPower[*offer.Hostname] = offer_watts
|
s.totalPower[*offer.Hostname] = offer_watts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +240,7 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -246,7 +248,7 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
}
|
}
|
||||||
|
|
||||||
fitTasks := []*mesos.TaskInfo{}
|
fitTasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
taken := false
|
taken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
|
@ -309,14 +311,14 @@ func (s *BinPackedPistonCapper) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
bpPistonCapValues[*offer.Hostname] += partialLoad
|
bpPistonCapValues[*offer.Hostname] += partialLoad
|
||||||
bpPistonMutex.Unlock()
|
bpPistonMutex.Unlock()
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, fitTasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, fitTasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
// If there was no match for task
|
// If there was no match for task
|
||||||
log.Println("There is not enough resources to launch task: ")
|
log.Println("There is not enough resources to launch task: ")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -17,7 +19,7 @@ import (
|
||||||
// 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 (*BinPackSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -130,7 +132,7 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -139,7 +141,7 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offer_cpu, offer_ram, offer_watts := OfferAgg(offer)
|
offer_cpu, offer_ram, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
taken := false
|
taken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
|
@ -192,15 +194,15 @@ func (s *BinPackSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
|
|
||||||
if taken {
|
if taken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package schedulers
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/constants"
|
"bitbucket.org/sunybingcloud/electron/constants"
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -53,7 +55,7 @@ type BottomHeavy struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New electron scheduler
|
// New electron scheduler
|
||||||
func NewPackBigSpreadSmall(tasks []def.Task, ignoreWatts bool, schedTracePrefix string) *BottomHeavy {
|
func NewBottomHeavy(tasks []def.Task, ignoreWatts bool, schedTracePrefix string) *BottomHeavy {
|
||||||
sort.Sort(def.WattsSorter(tasks))
|
sort.Sort(def.WattsSorter(tasks))
|
||||||
|
|
||||||
logFile, err := os.Create("./" + schedTracePrefix + "_schedTrace.log")
|
logFile, err := os.Create("./" + schedTracePrefix + "_schedTrace.log")
|
||||||
|
@ -163,7 +165,7 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver)
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -171,7 +173,7 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
totalRAM := 0.0
|
totalRAM := 0.0
|
||||||
|
@ -210,14 +212,14 @@ func (s *BottomHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver)
|
||||||
|
|
||||||
if taken {
|
if taken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +230,7 @@ func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -236,7 +238,7 @@ func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
taken := false
|
taken := false
|
||||||
for i := 0; i < len(s.smallTasks); i++ {
|
for i := 0; i < len(s.smallTasks); i++ {
|
||||||
task := s.smallTasks[i]
|
task := s.smallTasks[i]
|
||||||
|
@ -252,7 +254,7 @@ func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver
|
||||||
taken = true
|
taken = true
|
||||||
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, powerClass, task))
|
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, powerClass, task))
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
if *task.Instances <= 0 {
|
if *task.Instances <= 0 {
|
||||||
// All instances of task have been scheduled, remove it
|
// All instances of task have been scheduled, remove it
|
||||||
|
@ -266,10 +268,10 @@ func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver
|
||||||
if !taken {
|
if !taken {
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +290,7 @@ func (s *BottomHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mes
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -17,7 +19,7 @@ import (
|
||||||
// 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 (*BPMaxMinWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -133,7 +135,7 @@ func (s *BPMaxMinWatts) CheckFit(i int,
|
||||||
totalRAM *float64,
|
totalRAM *float64,
|
||||||
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
||||||
|
@ -175,7 +177,7 @@ func (s *BPMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers []*m
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -240,15 +242,15 @@ func (s *BPMaxMinWatts) ResourceOffers(driver sched.SchedulerDriver, offers []*m
|
||||||
|
|
||||||
if offerTaken {
|
if offerTaken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"bitbucket.org/sunybingcloud/electron/constants"
|
"bitbucket.org/sunybingcloud/electron/constants"
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
@ -22,7 +24,7 @@ import (
|
||||||
// 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, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -222,7 +224,7 @@ func (s *BPMaxMinPistonCapping) CheckFit(i int,
|
||||||
totalWatts *float64,
|
totalWatts *float64,
|
||||||
partialLoad *float64) (bool, *mesos.TaskInfo) {
|
partialLoad *float64) (bool, *mesos.TaskInfo) {
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
||||||
|
@ -271,7 +273,7 @@ func (s *BPMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -343,15 +345,15 @@ func (s *BPMaxMinPistonCapping) ResourceOffers(driver sched.SchedulerDriver, off
|
||||||
bpMaxMinPistonCappingCapValues[*offer.Hostname] += partialLoad
|
bpMaxMinPistonCappingCapValues[*offer.Hostname] += partialLoad
|
||||||
bpMaxMinPistonCappingMutex.Unlock()
|
bpMaxMinPistonCappingMutex.Unlock()
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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, task def.Task) bool {
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -246,7 +248,7 @@ func (s *BPMaxMinProacCC) CheckFit(i int,
|
||||||
totalRAM *float64,
|
totalRAM *float64,
|
||||||
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
totalWatts *float64) (bool, *mesos.TaskInfo) {
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// Does the task fit
|
// Does the task fit
|
||||||
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
if (s.ignoreWatts || (offerWatts >= (*totalWatts + task.Watts))) &&
|
||||||
|
@ -308,7 +310,7 @@ func (s *BPMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
|
|
||||||
// retrieving the available power for all the hosts in the offers.
|
// retrieving the available power for all the hosts in the offers.
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
_, _, offerWatts := OfferAgg(offer)
|
_, _, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
s.availablePower[*offer.Hostname] = offerWatts
|
s.availablePower[*offer.Hostname] = offerWatts
|
||||||
// setting total power if the first time
|
// setting total power if the first time
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
|
@ -324,7 +326,7 @@ func (s *BPMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -389,15 +391,15 @@ func (s *BPMaxMinProacCC) ResourceOffers(driver sched.SchedulerDriver, offers []
|
||||||
|
|
||||||
if offerTaken {
|
if offerTaken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,14 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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 (*BPSWClassMapWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -130,7 +132,7 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -139,7 +141,7 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
taken := false
|
taken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
|
@ -201,15 +203,15 @@ func (s *BPSWClassMapWatts) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
|
|
||||||
if taken {
|
if taken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"bitbucket.org/sunybingcloud/electron/constants"
|
"bitbucket.org/sunybingcloud/electron/constants"
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
@ -21,7 +23,7 @@ import (
|
||||||
|
|
||||||
// Decides if to take offer or not
|
// Decides if to take offer or not
|
||||||
func (s *BPSWClassMapWattsPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *BPSWClassMapWattsPistonCapping) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -215,7 +217,7 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
// retrieving the total power for each host in the offers.
|
// retrieving the total power for each host in the offers.
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
_, _, offerWatts := OfferAgg(offer)
|
_, _, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
s.totalPower[*offer.Hostname] = offerWatts
|
s.totalPower[*offer.Hostname] = offerWatts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,7 +231,7 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -238,7 +240,7 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
taken := false
|
taken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
|
@ -312,14 +314,14 @@ func (s *BPSWClassMapWattsPistonCapping) ResourceOffers(driver sched.SchedulerDr
|
||||||
bpswClassMapWattsPistonCapValues[*offer.Hostname] += partialLoad
|
bpswClassMapWattsPistonCapValues[*offer.Hostname] += partialLoad
|
||||||
bpswClassMapWattsPistonMutex.Unlock()
|
bpswClassMapWattsPistonMutex.Unlock()
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
// If there was no match for task
|
// If there was no match for task
|
||||||
log.Println("There is not enough resources to launch task: ")
|
log.Println("There is not enough resources to launch task: ")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
"bitbucket.org/sunybingcloud/electron/pcp"
|
"bitbucket.org/sunybingcloud/electron/pcp"
|
||||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -21,7 +23,7 @@ import (
|
||||||
|
|
||||||
// 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 (*BPSWClassMapWattsProacCC) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// TODO: Insert watts calculation here instead of taking them as parameter
|
// TODO: Insert watts calculation here instead of taking them as parameter
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ func (s *BPSWClassMapWattsProacCC) Disconnected(sched.SchedulerDriver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// go routine to cap the entire cluster in regular intervals of time.
|
// go routine to cap the entire cluster in regular intervals of time.
|
||||||
var bpswClassMapWattsProacCCCapValue = 0.0 // initial value to indicate that we haven't capped the cluster yet.
|
var bpswClassMapWattsProacCCCapValue = 0.0 // initial value to indicate that we haven't capped the cluster yet.
|
||||||
var bpswClassMapWattsProacCCNewCapValue = 0.0 // newly computed cap value
|
var bpswClassMapWattsProacCCNewCapValue = 0.0 // newly computed cap value
|
||||||
func (s *BPSWClassMapWattsProacCC) startCapping() {
|
func (s *BPSWClassMapWattsProacCC) startCapping() {
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -251,7 +253,7 @@ func (s *BPSWClassMapWattsProacCC) ResourceOffers(driver sched.SchedulerDriver,
|
||||||
|
|
||||||
// retrieving the available power for all the hosts in the offers.
|
// retrieving the available power for all the hosts in the offers.
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
_, _, offerWatts := OfferAgg(offer)
|
_, _, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
s.availablePower[*offer.Hostname] = offerWatts
|
s.availablePower[*offer.Hostname] = offerWatts
|
||||||
// setting total power if the first time
|
// setting total power if the first time
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
|
@ -267,7 +269,7 @@ func (s *BPSWClassMapWattsProacCC) ResourceOffers(driver sched.SchedulerDriver,
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -276,7 +278,7 @@ func (s *BPSWClassMapWattsProacCC) ResourceOffers(driver sched.SchedulerDriver,
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
taken := false
|
taken := false
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
|
@ -357,14 +359,14 @@ func (s *BPSWClassMapWattsProacCC) ResourceOffers(driver sched.SchedulerDriver,
|
||||||
|
|
||||||
if taken {
|
if taken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -16,7 +18,7 @@ import (
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *FirstFit) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *FirstFit) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -129,7 +131,7 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -162,7 +164,7 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.
|
||||||
tasks = append(tasks, taskToSchedule)
|
tasks = append(tasks, taskToSchedule)
|
||||||
|
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
|
|
||||||
|
@ -187,10 +189,10 @@ func (s *FirstFit) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -17,7 +19,7 @@ import (
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *FirstFitSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *FirstFitSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -127,13 +129,13 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe
|
||||||
log.Printf("Received %d resource offers", len(offers))
|
log.Printf("Received %d resource offers", len(offers))
|
||||||
|
|
||||||
// Sorting the offers
|
// Sorting the offers
|
||||||
sort.Sort(OffersSorter(offers))
|
sort.Sort(offerUtils.OffersSorter(offers))
|
||||||
|
|
||||||
// Printing the sorted offers and the corresponding CPU resource availability
|
// Printing the sorted offers and the corresponding CPU resource availability
|
||||||
log.Println("Sorted Offers:")
|
log.Println("Sorted Offers:")
|
||||||
for i := 0; i < len(offers); i++ {
|
for i := 0; i < len(offers); i++ {
|
||||||
offer := offers[i]
|
offer := offers[i]
|
||||||
offerCPU, _, _ := OfferAgg(offer)
|
offerCPU, _, _ := offerUtils.OfferAgg(offer)
|
||||||
log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU)
|
log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -174,7 +176,7 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe
|
||||||
tasks = append(tasks, taskToSchedule)
|
tasks = append(tasks, taskToSchedule)
|
||||||
|
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
|
|
||||||
|
@ -199,10 +201,10 @@ func (s *FirstFitSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offe
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -117,14 +119,14 @@ func (s *FirstFitSortedWattsClassMapWatts) ResourceOffers(driver sched.Scheduler
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// First fit strategy
|
// First fit strategy
|
||||||
taken := false
|
taken := false
|
||||||
|
@ -155,7 +157,7 @@ func (s *FirstFitSortedWattsClassMapWatts) ResourceOffers(driver sched.Scheduler
|
||||||
taskToSchedule := s.newTask(offer, task, nodeClass)
|
taskToSchedule := s.newTask(offer, task, nodeClass)
|
||||||
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, []*mesos.TaskInfo{taskToSchedule}, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, []*mesos.TaskInfo{taskToSchedule}, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
fmt.Println("Inst: ", *task.Instances)
|
fmt.Println("Inst: ", *task.Instances)
|
||||||
|
@ -176,10 +178,10 @@ func (s *FirstFitSortedWattsClassMapWatts) ResourceOffers(driver sched.Scheduler
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// electron scheduler implements the Scheduler interface
|
// electron scheduler implements the Scheduler interface
|
||||||
|
@ -239,7 +241,7 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) ResourceOffers(driver sched.Sc
|
||||||
|
|
||||||
// retrieving the available power for all the hosts in the offers.
|
// retrieving the available power for all the hosts in the offers.
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
_, _, offerWatts := OfferAgg(offer)
|
_, _, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
s.availablePower[*offer.Hostname] = offerWatts
|
s.availablePower[*offer.Hostname] = offerWatts
|
||||||
// setting total power if the first time
|
// setting total power if the first time
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
|
@ -255,14 +257,14 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) ResourceOffers(driver sched.Sc
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
// First fit strategy
|
// First fit strategy
|
||||||
taken := false
|
taken := false
|
||||||
|
@ -313,7 +315,7 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) ResourceOffers(driver sched.Sc
|
||||||
taskToSchedule := s.newTask(offer, task, nodeClass)
|
taskToSchedule := s.newTask(offer, task, nodeClass)
|
||||||
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, []*mesos.TaskInfo{taskToSchedule}, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, []*mesos.TaskInfo{taskToSchedule}, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
fmt.Println("Inst: ", *task.Instances)
|
fmt.Println("Inst: ", *task.Instances)
|
||||||
|
@ -337,10 +339,10 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) ResourceOffers(driver sched.Sc
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -17,7 +19,7 @@ import (
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *FirstFitSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *FirstFitSortedWattsSortedOffers) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -128,13 +130,13 @@ func (s *FirstFitSortedWattsSortedOffers) newTask(offer *mesos.Offer, task def.T
|
||||||
|
|
||||||
func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.Offer) {
|
func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.Offer) {
|
||||||
// Sorting the offers
|
// Sorting the offers
|
||||||
sort.Sort(OffersSorter(offers))
|
sort.Sort(offerUtils.OffersSorter(offers))
|
||||||
|
|
||||||
// Printing the sorted offers and the corresponding CPU resource availability
|
// Printing the sorted offers and the corresponding CPU resource availability
|
||||||
log.Println("Sorted Offers:")
|
log.Println("Sorted Offers:")
|
||||||
for i := 0; i < len(offers); i++ {
|
for i := 0; i < len(offers); i++ {
|
||||||
offer := offers[i]
|
offer := offers[i]
|
||||||
offerCPU, _, _ := OfferAgg(offer)
|
offerCPU, _, _ := offerUtils.OfferAgg(offer)
|
||||||
log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU)
|
log.Printf("Offer[%s].CPU = %f\n", offer.GetHostname(), offerCPU)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +146,7 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -177,7 +179,7 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD
|
||||||
tasks = append(tasks, taskToSchedule)
|
tasks = append(tasks, taskToSchedule)
|
||||||
|
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
|
|
||||||
|
@ -201,10 +203,10 @@ func (s *FirstFitSortedWattsSortedOffers) ResourceOffers(driver sched.SchedulerD
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -17,7 +19,7 @@ import (
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (s *FirstFitSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (s *FirstFitSortedWatts) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
cpus, mem, watts := 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
|
||||||
|
|
||||||
|
@ -132,7 +134,7 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -165,7 +167,7 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer
|
||||||
tasks = append(tasks, taskToSchedule)
|
tasks = append(tasks, taskToSchedule)
|
||||||
|
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
|
|
||||||
|
@ -189,10 +191,10 @@ func (s *FirstFitSortedWatts) ResourceOffers(driver sched.SchedulerDriver, offer
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -16,7 +18,7 @@ import (
|
||||||
// Decides if to take an offer or not
|
// Decides if to take an offer or not
|
||||||
func (*FirstFitWattsOnly) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
func (*FirstFitWattsOnly) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
|
|
||||||
_, _, watts := OfferAgg(offer)
|
_, _, 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
|
||||||
|
|
||||||
|
@ -123,7 +125,7 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -156,7 +158,7 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
tasks = append(tasks, taskToSchedule)
|
tasks = append(tasks, taskToSchedule)
|
||||||
|
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
taken = true
|
taken = true
|
||||||
|
|
||||||
|
@ -181,10 +183,10 @@ func (s *FirstFitWattsOnly) ResourceOffers(driver sched.SchedulerDriver, offers
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
if !taken {
|
if !taken {
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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 (_ *ProactiveClusterwideCapFCFS) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
offer_cpu, offer_mem, offer_watts := 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 && offer_watts >= task.Watts {
|
||||||
return true
|
return true
|
||||||
|
@ -240,7 +242,7 @@ func (s *ProactiveClusterwideCapFCFS) ResourceOffers(driver sched.SchedulerDrive
|
||||||
|
|
||||||
// retrieving the available power for all the hosts in the offers.
|
// retrieving the available power for all the hosts in the offers.
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
_, _, offer_watts := OfferAgg(offer)
|
_, _, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
s.availablePower[*offer.Hostname] = offer_watts
|
s.availablePower[*offer.Hostname] = offer_watts
|
||||||
// setting total power if the first time.
|
// setting total power if the first time.
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
|
@ -256,7 +258,7 @@ func (s *ProactiveClusterwideCapFCFS) ResourceOffers(driver sched.SchedulerDrive
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -305,7 +307,7 @@ func (s *ProactiveClusterwideCapFCFS) ResourceOffers(driver sched.SchedulerDrive
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
taskToSchedule := s.newTask(offer, task)
|
taskToSchedule := s.newTask(offer, task)
|
||||||
toSchedule := []*mesos.TaskInfo{taskToSchedule}
|
toSchedule := []*mesos.TaskInfo{taskToSchedule}
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, toSchedule, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, toSchedule, mesosUtils.DefaultFilter)
|
||||||
log.Printf("Inst: %d", *task.Instances)
|
log.Printf("Inst: %d", *task.Instances)
|
||||||
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
||||||
*task.Instances--
|
*task.Instances--
|
||||||
|
@ -331,10 +333,10 @@ func (s *ProactiveClusterwideCapFCFS) ResourceOffers(driver sched.SchedulerDrive
|
||||||
// If no task fit the offer, then declining the offer.
|
// If no task fit the offer, then declining the offer.
|
||||||
if !taken {
|
if !taken {
|
||||||
log.Printf("There is not enough resources to launch a task on Host: %s\n", offer.GetHostname())
|
log.Printf("There is not enough resources to launch a task on Host: %s\n", offer.GetHostname())
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
"bitbucket.org/sunybingcloud/electron/pcp"
|
"bitbucket.org/sunybingcloud/electron/pcp"
|
||||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -31,7 +33,7 @@ import (
|
||||||
|
|
||||||
// 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 (_ *ProactiveClusterwideCapRanked) takeOffer(offer *mesos.Offer, task def.Task) bool {
|
||||||
offer_cpu, offer_mem, offer_watts := 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 && offer_watts >= task.Watts {
|
||||||
return true
|
return true
|
||||||
|
@ -251,7 +253,7 @@ func (s *ProactiveClusterwideCapRanked) ResourceOffers(driver sched.SchedulerDri
|
||||||
|
|
||||||
// retrieving the available power for all the hosts in the offers.
|
// retrieving the available power for all the hosts in the offers.
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
_, _, offer_watts := OfferAgg(offer)
|
_, _, offer_watts := offerUtils.OfferAgg(offer)
|
||||||
s.availablePower[*offer.Hostname] = offer_watts
|
s.availablePower[*offer.Hostname] = offer_watts
|
||||||
// setting total power if the first time.
|
// setting total power if the first time.
|
||||||
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
if _, ok := s.totalPower[*offer.Hostname]; !ok {
|
||||||
|
@ -277,7 +279,7 @@ func (s *ProactiveClusterwideCapRanked) ResourceOffers(driver sched.SchedulerDri
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -328,7 +330,7 @@ func (s *ProactiveClusterwideCapRanked) ResourceOffers(driver sched.SchedulerDri
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
taskToSchedule := s.newTask(offer, task)
|
taskToSchedule := s.newTask(offer, task)
|
||||||
to_schedule := []*mesos.TaskInfo{taskToSchedule}
|
to_schedule := []*mesos.TaskInfo{taskToSchedule}
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, to_schedule, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, to_schedule, mesosUtils.DefaultFilter)
|
||||||
log.Printf("Inst: %d", *task.Instances)
|
log.Printf("Inst: %d", *task.Instances)
|
||||||
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
s.schedTrace.Print(offer.GetHostname() + ":" + taskToSchedule.GetTaskId().GetValue())
|
||||||
*task.Instances--
|
*task.Instances--
|
||||||
|
@ -354,10 +356,10 @@ func (s *ProactiveClusterwideCapRanked) ResourceOffers(driver sched.SchedulerDri
|
||||||
// If no tasks fit the offer, then declining the offer.
|
// If no tasks fit the offer, then declining the offer.
|
||||||
if !taken {
|
if !taken {
|
||||||
log.Printf("There is not enough resources to launch a task on Host: %s\n", offer.GetHostname())
|
log.Printf("There is not enough resources to launch a task on Host: %s\n", offer.GetHostname())
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package schedulers
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/constants"
|
"bitbucket.org/sunybingcloud/electron/constants"
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/mesosUtils"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/utilities/offerUtils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -163,7 +165,7 @@ func (s *TopHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -171,7 +173,7 @@ func (s *TopHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
totalWatts := 0.0
|
totalWatts := 0.0
|
||||||
totalCPU := 0.0
|
totalCPU := 0.0
|
||||||
totalRAM := 0.0
|
totalRAM := 0.0
|
||||||
|
@ -210,14 +212,14 @@ func (s *TopHeavy) pack(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
|
|
||||||
if taken {
|
if taken {
|
||||||
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
log.Printf("Starting on [%s]\n", offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
} else {
|
} else {
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +230,7 @@ func (s *TopHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
@ -236,7 +238,7 @@ func (s *TopHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
taken := false
|
taken := false
|
||||||
for i := 0; i < len(s.largeTasks); i++ {
|
for i := 0; i < len(s.largeTasks); i++ {
|
||||||
task := s.largeTasks[i]
|
task := s.largeTasks[i]
|
||||||
|
@ -252,7 +254,7 @@ func (s *TopHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
taken = true
|
taken = true
|
||||||
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, powerClass, task))
|
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, powerClass, task))
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, defaultFilter)
|
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, mesosUtils.DefaultFilter)
|
||||||
|
|
||||||
if *task.Instances <= 0 {
|
if *task.Instances <= 0 {
|
||||||
// All instances of task have been scheduled, remove it
|
// All instances of task have been scheduled, remove it
|
||||||
|
@ -266,10 +268,10 @@ func (s *TopHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
if !taken {
|
if !taken {
|
||||||
// If there was no match for the task
|
// If there was no match for the task
|
||||||
fmt.Println("There is not enough resources to launch a task:")
|
fmt.Println("There is not enough resources to launch a task:")
|
||||||
cpus, mem, watts := OfferAgg(offer)
|
cpus, mem, watts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
log.Printf("<CPU: %f, RAM: %f, Watts: %f>\n", cpus, mem, watts)
|
||||||
driver.DeclineOffer(offer.Id, defaultFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.DefaultFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +290,7 @@ func (s *TopHeavy) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.
|
||||||
select {
|
select {
|
||||||
case <-s.Shutdown:
|
case <-s.Shutdown:
|
||||||
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
log.Println("Done scheduling tasks: declining offer on [", offer.GetHostname(), "]")
|
||||||
driver.DeclineOffer(offer.Id, longFilter)
|
driver.DeclineOffer(offer.Id, mesosUtils.LongFilter)
|
||||||
|
|
||||||
log.Println("Number of tasks still running: ", s.tasksRunning)
|
log.Println("Number of tasks still running: ", s.tasksRunning)
|
||||||
continue
|
continue
|
||||||
|
|
Reference in a new issue