changed the name of takeOffer(...) to takeOfferBinPack(...) and then created another function called takeOfferFirstFit(...). Made sure that these functions are called instead of inlining code.
This commit is contained in:
parent
1dcf416849
commit
f5ddc56f27
2 changed files with 40 additions and 15 deletions
|
@ -26,7 +26,7 @@ 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,
|
func (s *BottomHeavy) takeOfferBinPack(offer *mesos.Offer, totalCPU, totalRAM, totalWatts,
|
||||||
wattsToConsider float64, task def.Task) bool {
|
wattsToConsider float64, task def.Task) bool {
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
||||||
|
|
||||||
|
@ -40,6 +40,17 @@ func (s *BottomHeavy) takeOffer(offer *mesos.Offer, totalCPU, totalRAM, totalWat
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *BottomHeavy) takeOfferFirstFit(offer *mesos.Offer, wattsConsideration 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 >= wattsConsideration)) &&
|
||||||
|
(offerCPU >= task.CPU) && (offerRAM >= 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
|
||||||
|
@ -199,7 +210,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.takeOffer(offer, totalCPU, totalRAM, totalWatts, wattsConsideration, task) {
|
if s.takeOfferBinPack(offer, totalCPU, totalRAM, totalWatts, wattsConsideration, task) {
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
totalWatts += wattsConsideration
|
totalWatts += wattsConsideration
|
||||||
totalCPU += task.CPU
|
totalCPU += task.CPU
|
||||||
|
@ -245,7 +256,6 @@ func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
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]
|
||||||
|
@ -253,14 +263,10 @@ func (s *BottomHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Error in determining wattsConsideration
|
// Error in determining wattsConsideration
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
} else {
|
|
||||||
// Logging the watts consideration
|
|
||||||
log.Printf("Watts Considered for host[%s], task[%s] = %f\n", *offer.Hostname, task.Name, wattsConsideration)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
if (!s.wattsAsAResource || (offerWatts >= wattsConsideration)) &&
|
if s.takeOfferFirstFit(offer, wattsConsideration, task) {
|
||||||
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
|
||||||
taken = true
|
taken = true
|
||||||
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, task))
|
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, task))
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
|
|
|
@ -26,6 +26,30 @@ This was done to give a little more room for the large tasks (power intensive) f
|
||||||
starvation of power intensive tasks.
|
starvation of power intensive tasks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
func (s *TopHeavy) takeOfferBinPack(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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TopHeavy) takeOfferFirstFit(offer *mesos.Offer, wattsConsideration 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 >= wattsConsideration)) &&
|
||||||
|
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// electronScheduler implements the Scheduler interface
|
// electronScheduler implements the Scheduler interface
|
||||||
type TopHeavy struct {
|
type TopHeavy struct {
|
||||||
base // Type embedded to inherit common functions
|
base // Type embedded to inherit common functions
|
||||||
|
@ -169,7 +193,6 @@ func (s *TopHeavy) 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 +209,7 @@ func (s *TopHeavy) 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.takeOfferBinPack(offer, totalCPU, totalRAM, totalWatts, wattsConsideration, task) {
|
||||||
(offerCPU >= (totalCPU + task.CPU)) &&
|
|
||||||
(offerRAM >= (totalRAM + task.RAM)) {
|
|
||||||
taken = true
|
taken = true
|
||||||
totalWatts += wattsConsideration
|
totalWatts += wattsConsideration
|
||||||
totalCPU += task.CPU
|
totalCPU += task.CPU
|
||||||
|
@ -234,7 +255,6 @@ func (s *TopHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks := []*mesos.TaskInfo{}
|
tasks := []*mesos.TaskInfo{}
|
||||||
offerCPU, offerRAM, offerWatts := offerUtils.OfferAgg(offer)
|
|
||||||
offerTaken := false
|
offerTaken := 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]
|
||||||
|
@ -245,8 +265,7 @@ func (s *TopHeavy) spread(offers []*mesos.Offer, driver sched.SchedulerDriver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decision to take the offer or not
|
// Decision to take the offer or not
|
||||||
if (!s.wattsAsAResource || (offerWatts >= wattsConsideration)) &&
|
if s.takeOfferFirstFit(offer, wattsConsideration, task) {
|
||||||
(offerCPU >= task.CPU) && (offerRAM >= task.RAM) {
|
|
||||||
offerTaken = true
|
offerTaken = true
|
||||||
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, task))
|
tasks = append(tasks, s.createTaskInfoAndLogSchedTrace(offer, task))
|
||||||
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
log.Printf("Starting %s on [%s]\n", task.Name, offer.GetHostname())
|
||||||
|
|
Reference in a new issue