Scheduler now has a first fit algorithm based on memory, cpu, and watts. Watts need to be set by the user but should be calculated through heuristics. Framework now also works by having a set of tasks and launching them.
This commit is contained in:
parent
6b76e45d6d
commit
bc5e959ade
6 changed files with 142 additions and 83 deletions
33
task.go
Normal file
33
task.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
CPU float64 `json: "cpu"`
|
||||
RAM float64 `json: "ram"`
|
||||
Watts float64 `json: "watts"`
|
||||
Image string `json: "image"`
|
||||
CMD string `json: "cmd"`
|
||||
Instances int `default 1, json: "inst"`
|
||||
}
|
||||
|
||||
func TasksFromJSON(uri string) ([]Task, error) {
|
||||
|
||||
var tasks []Task
|
||||
|
||||
file, err := os.Open(uri)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error opening file")
|
||||
}
|
||||
|
||||
err = json.NewDecoder(file).Decode(&tasks)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error unmarshalling")
|
||||
}
|
||||
|
||||
return tasks, nil
|
||||
}
|
Reference in a new issue