scheduling policies pluggable from commandline
This commit is contained in:
parent
051aca4d10
commit
04f24beac5
10 changed files with 216 additions and 121 deletions
76
scheduler.go
76
scheduler.go
|
@ -17,29 +17,63 @@ import (
|
|||
|
||||
var master = flag.String("master", "<mesos-master>:5050", "Location of leading Mesos master")
|
||||
var tasksFile = flag.String("workload", "", "JSON file containing task definitions")
|
||||
var wattsAsAResource = flag.Bool("wattsAsAResource", false, "Enable Watts as a Resource. This allows the usage of the Watts attribute (if present) in the workload definition during offer matching.")
|
||||
var wattsAsAResource = flag.Bool("wattsAsAResource", false, "Enable Watts as a Resource. "+
|
||||
"This allows the usage of the Watts attribute (if present) in the workload definition during offer matching.")
|
||||
var pcplogPrefix = flag.String("logPrefix", "", "Prefix for PCP log file")
|
||||
var hiThreshold = flag.Float64("hiThreshold", 0.0, "Upperbound for Cluster average historical power consumption, beyond which extrema/progressive-extrema would start power-capping")
|
||||
var loThreshold = flag.Float64("loThreshold", 0.0, "Lowerbound for Cluster average historical power consumption, below which extrema/progressive-extrema would stop power-capping")
|
||||
var hiThreshold = flag.Float64("hiThreshold", 0.0, "Upperbound for Cluster average historical power consumption, "+
|
||||
"beyond which extrema/progressive-extrema would start power-capping")
|
||||
var loThreshold = flag.Float64("loThreshold", 0.0, "Lowerbound for Cluster average historical power consumption, "+
|
||||
"below which extrema/progressive-extrema would stop power-capping")
|
||||
var classMapWatts = flag.Bool("classMapWatts", false, "Enable mapping of watts to powerClass of node")
|
||||
var schedPolicyName = flag.String("schedPolicy", "first-fit", "Name of the scheduling policy to be used (default = first-fit).\n "+
|
||||
"Use option -listSchedPolicies to get the names of available scheduling policies")
|
||||
var listSchedPolicies = flag.Bool("listSchedPolicies", false, "Names of the pluaggable scheduling policies.")
|
||||
|
||||
// Short hand args
|
||||
func init() {
|
||||
flag.StringVar(master, "m", "<mesos-master>:5050", "Location of leading Mesos master (shorthand)")
|
||||
flag.StringVar(tasksFile, "w", "", "JSON file containing task definitions (shorthand)")
|
||||
flag.BoolVar(wattsAsAResource, "waar", false, "Enable Watts as a Resource. " +
|
||||
flag.BoolVar(wattsAsAResource, "waar", false, "Enable Watts as a Resource. "+
|
||||
"This allows the usage of the Watts attribute (if present) in the workload definition during offer matching. (shorthand)")
|
||||
flag.StringVar(pcplogPrefix, "p", "", "Prefix for PCP log file (shorthand)")
|
||||
flag.Float64Var(hiThreshold, "ht", 700.0, "Upperbound for Cluster average historical power consumption, " +
|
||||
flag.Float64Var(hiThreshold, "ht", 700.0, "Upperbound for Cluster average historical power consumption, "+
|
||||
"beyond which extrema/progressive-extrema would start power-capping (shorthand)")
|
||||
flag.Float64Var(loThreshold, "lt", 400.0, "Lowerbound for Cluster average historical power consumption, " +
|
||||
flag.Float64Var(loThreshold, "lt", 400.0, "Lowerbound for Cluster average historical power consumption, "+
|
||||
"below which extrema/progressive-extrema would stop power-capping (shorthand)")
|
||||
flag.BoolVar(classMapWatts, "cmw", false, "Enable mapping of watts to powerClass of node (shorthand)")
|
||||
flag.StringVar(schedPolicyName, "sp", "first-fit", "Name of the scheduling policy to be used (default = first-fit).\n "+
|
||||
"Use option -listSchedPolicies to get the names of available scheduling policies (shorthand)")
|
||||
flag.BoolVar(listSchedPolicies, "lsp", false, "Names of the pluaggable scheduling policies. (shorthand)")
|
||||
}
|
||||
|
||||
func listAllSchedulingPolicies() {
|
||||
fmt.Println("Scheduling Policies")
|
||||
fmt.Println("-------------------")
|
||||
for policyName, _ := range schedulers.Schedulers {
|
||||
fmt.Println(policyName)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
// checking to see if we need to just list the pluggable scheduling policies
|
||||
if *listSchedPolicies {
|
||||
listAllSchedulingPolicies()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// If non-default scheduling policy given,
|
||||
// checking if scheduling policyName exists
|
||||
if *schedPolicyName != "first-fit" {
|
||||
if _, ok := schedulers.Schedulers[*schedPolicyName]; !ok {
|
||||
// invalid scheduling policy
|
||||
log.Println("Invalid scheduling policy given. The possible scheduling policies are:")
|
||||
listAllSchedulingPolicies()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if *tasksFile == "" {
|
||||
fmt.Println("No file containing tasks specifiction provided.")
|
||||
os.Exit(1)
|
||||
|
@ -63,7 +97,19 @@ func main() {
|
|||
startTime := time.Now().Format("20060102150405")
|
||||
logPrefix := *pcplogPrefix + "_" + startTime
|
||||
|
||||
scheduler := schedulers.NewFirstFit(tasks, *wattsAsAResource, logPrefix, *classMapWatts)
|
||||
shutdown := make(chan struct{})
|
||||
done := make(chan struct{})
|
||||
pcpLog := make(chan struct{})
|
||||
recordPCP := false
|
||||
scheduler := schedulers.SchedFactory(*schedPolicyName,
|
||||
schedulers.WithTasks(tasks),
|
||||
schedulers.WithWattsAsAResource(*wattsAsAResource),
|
||||
schedulers.WithClassMapWatts(*classMapWatts),
|
||||
schedulers.WithSchedTracePrefix(logPrefix),
|
||||
schedulers.WithRecordPCP(&recordPCP),
|
||||
schedulers.WithShutdown(shutdown),
|
||||
schedulers.WithDone(done),
|
||||
schedulers.WithPCPLog(pcpLog))
|
||||
driver, err := sched.NewMesosSchedulerDriver(sched.DriverConfig{
|
||||
Master: *master,
|
||||
Framework: &mesos.FrameworkInfo{
|
||||
|
@ -77,9 +123,9 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
go pcp.Start(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix)
|
||||
//go pcp.StartPCPLogAndExtremaDynamicCap(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix, *hiThreshold, *loThreshold)
|
||||
//go pcp.StartPCPLogAndProgressiveExtremaCap(scheduler.PCPLog, &scheduler.RecordPCP, logPrefix, *hiThreshold, *loThreshold)
|
||||
go pcp.Start(pcpLog, &recordPCP, logPrefix)
|
||||
//go pcp.StartPCPLogAndExtremaDynamicCap(pcpLog, &recordPCP, logPrefix, *hiThreshold, *loThreshold)
|
||||
//go pcp.StartPCPLogAndProgressiveExtremaCap(pcpLog, &recordPCP, logPrefix, *hiThreshold, *loThreshold)
|
||||
time.Sleep(1 * time.Second) // Take a second between starting PCP log and continuing
|
||||
|
||||
// Attempt to handle SIGINT to not leave pmdumptext running
|
||||
|
@ -89,26 +135,26 @@ func main() {
|
|||
signal.Notify(c, os.Interrupt, os.Kill)
|
||||
s := <-c
|
||||
if s != os.Interrupt {
|
||||
close(scheduler.PCPLog)
|
||||
close(pcpLog)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Received SIGINT...stopping")
|
||||
close(scheduler.Done)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
|
||||
// Signals we have scheduled every task we have
|
||||
select {
|
||||
case <-scheduler.Shutdown:
|
||||
case <-shutdown:
|
||||
//case <-time.After(shutdownTimeout):
|
||||
}
|
||||
|
||||
// All tasks have finished
|
||||
select {
|
||||
case <-scheduler.Done:
|
||||
close(scheduler.PCPLog)
|
||||
case <-done:
|
||||
close(pcpLog)
|
||||
time.Sleep(5 * time.Second) //Wait for PCP to log a few more seconds
|
||||
//case <-time.After(shutdownTimeout):
|
||||
}
|
||||
|
|
Reference in a new issue