Merged in scheduleOnlySchedWindowTasks (pull request #6)
ScheduleOnlySchedWindowTasks Approved-by: Akash Kothawale <akothaw1@binghamton.edu>
This commit is contained in:
parent
3d51efc679
commit
85383da550
10 changed files with 103 additions and 112 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
"log"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
// Decides if to take an offer or not
|
||||
|
@ -59,6 +58,7 @@ func (s *MaxMin) CheckFit(
|
|||
|
||||
baseSchedRef.LogSchedTrace(taskToSchedule, offer)
|
||||
*task.Instances--
|
||||
s.numTasksScheduled++
|
||||
|
||||
if *task.Instances <= 0 {
|
||||
// All instances of task have been scheduled, remove it.
|
||||
|
@ -78,7 +78,11 @@ func (s *MaxMin) CheckFit(
|
|||
func (s *MaxMin) ConsumeOffers(spc SchedPolicyContext, driver sched.SchedulerDriver, offers []*mesos.Offer) {
|
||||
log.Println("Max-Min scheduling...")
|
||||
baseSchedRef := spc.(*BaseScheduler)
|
||||
def.SortTasks(baseSchedRef.tasks, def.SortByWatts)
|
||||
if baseSchedRef.schedPolSwitchEnabled {
|
||||
SortNTasks(baseSchedRef.tasks, baseSchedRef.numTasksInSchedWindow, def.SortByWatts)
|
||||
} else {
|
||||
def.SortTasks(baseSchedRef.tasks, def.SortByWatts)
|
||||
}
|
||||
baseSchedRef.LogOffersReceived(offers)
|
||||
|
||||
for _, offer := range offers {
|
||||
|
@ -108,6 +112,14 @@ func (s *MaxMin) ConsumeOffers(spc SchedPolicyContext, driver sched.SchedulerDri
|
|||
var index int
|
||||
start := true // If false then index has changed and need to keep it that way
|
||||
for i := 0; i < len(baseSchedRef.tasks); i++ {
|
||||
// If scheduling policy switching enabled, then
|
||||
// stop scheduling if the #baseSchedRef.schedWindowSize tasks have been scheduled.
|
||||
if baseSchedRef.schedPolSwitchEnabled &&
|
||||
(s.numTasksScheduled >= baseSchedRef.schedWindowSize) {
|
||||
log.Printf("Stopped scheduling... Completed scheduling %d tasks.",
|
||||
s.numTasksScheduled)
|
||||
break // Offers will automatically get declined.
|
||||
}
|
||||
// We need to pick a min task or a max task
|
||||
// depending on the value of direction.
|
||||
if direction && start {
|
||||
|
@ -128,7 +140,6 @@ func (s *MaxMin) ConsumeOffers(spc SchedPolicyContext, driver sched.SchedulerDri
|
|||
continue
|
||||
}
|
||||
|
||||
// TODO: Fix this so index doesn't need to be passed.
|
||||
taken, taskToSchedule := s.CheckFit(spc, index, task, wattsConsideration, offer,
|
||||
&totalCPU, &totalRAM, &totalWatts)
|
||||
|
||||
|
@ -163,22 +174,5 @@ func (s *MaxMin) ConsumeOffers(spc SchedPolicyContext, driver sched.SchedulerDri
|
|||
}
|
||||
}
|
||||
|
||||
// Switch scheduling policy only if feature enabled from CLI
|
||||
if baseSchedRef.schedPolSwitchEnabled {
|
||||
// Need to recompute the schedWindow for the next offer cycle.
|
||||
// The next scheduling policy will schedule at max schedWindow number of tasks.
|
||||
baseSchedRef.curSchedWindow = baseSchedRef.schedWindowResStrategy.Apply(
|
||||
func() interface{} { return baseSchedRef.tasks })
|
||||
// Switching to a random scheduling policy.
|
||||
// TODO: Switch based on some criteria.
|
||||
index := rand.Intn(len(SchedPolicies))
|
||||
for k, v := range SchedPolicies {
|
||||
if index == 0 {
|
||||
baseSchedRef.LogSchedPolicySwitch(k, v)
|
||||
spc.SwitchSchedPol(v)
|
||||
break
|
||||
}
|
||||
index--
|
||||
}
|
||||
}
|
||||
s.switchIfNecessary(spc)
|
||||
}
|
||||
|
|
Reference in a new issue