Merged in akash/LogPolicySwitch (pull request #4)

Scheduling Policy Switch Logger

Approved-by: Pradyumna Kaushik <pkaushi1@binghamton.edu>
This commit is contained in:
Akash Kothawale 2018-02-11 13:11:42 +00:00 committed by Pradyumna Kaushik
parent 3fa4a45ca7
commit b1bd21f730
11 changed files with 94 additions and 4 deletions

View file

@ -7,6 +7,7 @@ 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
@ -112,5 +113,18 @@ func (s *BinPackSortedWatts) ConsumeOffers(spc SchedPolicyContext, driver sched.
}
}
s.switchIfNecessary(spc)
// Switch scheduling policy only if feature enabled from CLI
if baseSchedRef.schedPolSwitchEnabled {
// 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--
}
}
}