Merged in schedPolSwitchConfigFile (pull request #8)
SchedPolSwitchConfigFile Approved-by: Akash Kothawale <akothaw1@binghamton.edu>
This commit is contained in:
parent
b569bd3060
commit
b877d31cb8
6 changed files with 71 additions and 16 deletions
|
@ -1,7 +1,10 @@
|
|||
package schedulers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
"github.com/pkg/errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Names of different scheduling policies.
|
||||
|
@ -20,12 +23,46 @@ var SchedPolicies map[string]SchedPolicyState = map[string]SchedPolicyState{
|
|||
mm: &MaxMin{},
|
||||
}
|
||||
|
||||
// build the scheduling policy with the options being applied
|
||||
func buildScheduler(s sched.Scheduler, opts ...schedPolicyOption) {
|
||||
// Initialize scheduling policy characteristics using the provided config file.
|
||||
func InitSchedPolicyCharacteristics(schedPoliciesConfigFilename string) error {
|
||||
var schedPolConfig map[string]baseSchedPolicyState
|
||||
if file, err := os.Open(schedPoliciesConfigFilename); err != nil {
|
||||
return errors.Wrap(err, "Error opening file")
|
||||
} else {
|
||||
err := json.NewDecoder(file).Decode(&schedPolConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error unmarshalling")
|
||||
}
|
||||
|
||||
// Initializing.
|
||||
// TODO: Be able to unmarshal a schedPolConfig JSON into any number of scheduling policies.
|
||||
for schedPolName, schedPolState := range SchedPolicies {
|
||||
switch t := schedPolState.(type) {
|
||||
case *FirstFit:
|
||||
t.TaskDistribution = schedPolConfig[schedPolName].TaskDistribution
|
||||
t.VarianceCpuSharePerTask = schedPolConfig[schedPolName].VarianceCpuSharePerTask
|
||||
case *BinPackSortedWatts:
|
||||
t.TaskDistribution = schedPolConfig[schedPolName].TaskDistribution
|
||||
t.VarianceCpuSharePerTask = schedPolConfig[schedPolName].VarianceCpuSharePerTask
|
||||
case *MaxMin:
|
||||
t.TaskDistribution = schedPolConfig[schedPolName].TaskDistribution
|
||||
t.VarianceCpuSharePerTask = schedPolConfig[schedPolName].VarianceCpuSharePerTask
|
||||
case *MaxGreedyMins:
|
||||
t.TaskDistribution = schedPolConfig[schedPolName].TaskDistribution
|
||||
t.VarianceCpuSharePerTask = schedPolConfig[schedPolName].VarianceCpuSharePerTask
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// build the scheduler with the options being applied
|
||||
func buildScheduler(s sched.Scheduler, opts ...schedulerOptions) {
|
||||
s.(ElectronScheduler).init(opts...)
|
||||
}
|
||||
|
||||
func SchedFactory(opts ...schedPolicyOption) sched.Scheduler {
|
||||
func SchedFactory(opts ...schedulerOptions) sched.Scheduler {
|
||||
s := &BaseScheduler{}
|
||||
buildScheduler(s, opts...)
|
||||
return s
|
||||
|
|
Reference in a new issue