Merged in mapTaskDistrToSchedPolWhenSwitching (pull request )

MapTaskDistrToSchedPolWhenSwitching

Approved-by: Akash Kothawale <akothaw1@binghamton.edu>
This commit is contained in:
Pradyumna Kaushik 2018-04-17 20:09:35 +00:00
parent 0f305ab796
commit ae81125110
11 changed files with 255 additions and 65 deletions
schedulers

View file

@ -1,10 +1,12 @@
package schedulers
import (
"bitbucket.org/sunybingcloud/electron/utilities"
"encoding/json"
sched "github.com/mesos/mesos-go/api/v0/scheduler"
"github.com/pkg/errors"
"os"
"sort"
)
// Names of different scheduling policies.
@ -23,6 +25,15 @@ var SchedPolicies map[string]SchedPolicyState = map[string]SchedPolicyState{
mm: &MaxMin{},
}
// Scheduling policies to choose when switching
var schedPoliciesToSwitch map[int]struct {
spName string
sp SchedPolicyState
} = make(map[int]struct {
spName string
sp SchedPolicyState
})
// Initialize scheduling policy characteristics using the provided config file.
func InitSchedPolicyCharacteristics(schedPoliciesConfigFilename string) error {
var schedPolConfig map[string]baseSchedPolicyState
@ -52,6 +63,31 @@ func InitSchedPolicyCharacteristics(schedPoliciesConfigFilename string) error {
t.VarianceCpuSharePerTask = schedPolConfig[schedPolName].VarianceCpuSharePerTask
}
}
// Initialize schedPoliciesToSwitch to allow binary searching for scheduling policy switching.
spInformation := map[string]float64{}
for spName, sp := range SchedPolicies {
spInformation[spName] = sp.GetInfo().taskDist
}
spInformationPairList := utilities.GetPairList(spInformation)
// Sorting spInformationPairList in non-increasing order of taskDist.
sort.SliceStable(spInformationPairList, func(i, j int) bool {
return spInformationPairList[i].Value < spInformationPairList[j].Value
})
// Initializing scheduling policies that are setup for switching.
index := 0
for _, spInformationPair := range spInformationPairList {
if spInformationPair.Value != 0 {
schedPoliciesToSwitch[index] = struct {
spName string
sp SchedPolicyState
}{
spName: spInformationPair.Key,
sp: SchedPolicies[spInformationPair.Key],
}
index++
}
}
}
return nil