Merged in scheduleOnlySchedWindowTasks (pull request #6)

ScheduleOnlySchedWindowTasks

Approved-by: Akash Kothawale <akothaw1@binghamton.edu>
This commit is contained in:
Pradyumna Kaushik 2018-02-16 21:49:12 +00:00
parent 3d51efc679
commit 85383da550
10 changed files with 103 additions and 112 deletions

View file

@ -26,21 +26,18 @@ func (bsps *baseSchedPolicyState) switchIfNecessary(spc SchedPolicyContext) {
baseSchedRef := spc.(*BaseScheduler)
// Switch scheduling policy only if feature enabled from CLI
if baseSchedRef.schedPolSwitchEnabled {
// Need to recompute schedulWindow 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 })
// Need to recompute size of the scheduling window for the next offer cycle.
// The next scheduling policy will schedule at max schedWindowSize number of tasks.
baseSchedRef.schedWindowSize, baseSchedRef.numTasksInSchedWindow =
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 _, v := range SchedPolicies {
if index == 0 {
spc.SwitchSchedPol(v)
// If switched to a different scheduling policy,
// then setting the numberTasksScheduled to 0.
if v != bsps {
bsps.numTasksScheduled = 0
}
// Resetting the number of tasks scheduled.
bsps.numTasksScheduled = 0
break
}
index--