123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- package priorities
- import (
- "os"
- "time"
- client "github.com/influxdata/influxdb1-client/v2"
- "gopkg.in/yaml.v2"
- "k8s.io/klog"
- )
- type scorerInput struct {
- metricName string
- metrics map[string]float64
- }
- type Config struct {
- Server struct {
- Port string `yaml:"port"`
- Host string `yaml:"host"`
- } `yaml:"server"`
- Database struct {
- Type string `yaml:"type"`
- Name string `yaml:"name"`
- Username string `yaml:"username"`
- Password string `yaml:"password"`
- } `yaml:"database"`
- MonitoringSpecs struct {
- TimeInterval float32 `yaml:"interval"`
- } `yaml:"monitoring"`
- }
- type Application struct {
- Metrics map[string]float64
- Duration time.Duration
- }
- var Applications = map[string]Application{
- "scikit-lasso": Application{
- Metrics: map[string]float64{
- "ipc": 1.87,
- "mem_read": 0.1753,
- "mem_write": 0.008856,
- "c6res": 0.003058,
- },
- Duration: 69 * time.Second,
- },
- "scikit-ada": Application{
- Metrics: map[string]float64{
- "ipc": 1.10,
- "mem_read": 0.09868,
- "mem_write": 0.00669,
- "c6res": 0,
- },
- Duration: 138 * time.Second,
- },
- "scikit-rfr": Application{
- Metrics: map[string]float64{
- "ipc": 1.25,
- "mem_read": 0.0228,
- "mem_write": 0.00503,
- "c6res": 0,
- },
- Duration: 115 * time.Second,
- },
- "scikit-rfc": Application{
- Metrics: map[string]float64{
- "ipc": 1.802,
- "mem_read": 0.02423,
- "mem_write": 0.010603,
- "c6res": 0,
- },
- Duration: 38 * time.Second,
- },
- "scikit-linregr": Application{
- Metrics: map[string]float64{
- "ipc": 1.9464,
- "mem_read": 0.040475,
- "mem_write": 0.01974,
- "c6res": 0.00928149,
- },
- Duration: 45 * time.Second,
- },
- "scikit-lda": Application{
- Metrics: map[string]float64{
- "ipc": 1.9162,
- "mem_read": 0.0541,
- "mem_write": 0.029381,
- "c6res": 0.003805,
- },
- Duration: 53 * time.Second,
- },
- "cloudsuite-data-serving-client": Application{
- Metrics: map[string]float64{
- "ipc": 0.6619,
- "mem_read": 0,
- "mem_write": 0,
- "c6res": 44.48,
- },
- Duration: 72 * time.Second,
- },
- "cloudsuite-in-memory-analytics": Application{
- Metrics: map[string]float64{
- "ipc": 1.3399,
- "mem_read": 0.0052142,
- "mem_write": 0.61361,
- "c6res": 3.76196,
- },
- Duration: 60 * time.Second,
- },
- "cloudsuite-web-serving-client": Application{
- Metrics: map[string]float64{
- "ipc": 0.6619,
- "mem_read": 0,
- "mem_write": 0,
- "c6res": 44.48,
- },
- Duration: 203 * time.Second,
- },
- "spec-sphinx": Application{
- Metrics: map[string]float64{
- "ipc": 2.035,
- "mem_read": 0.0042372,
- "mem_write": 0.0021131,
- "c6res": 0.07497,
- },
- Duration: 592 * time.Second,
- },
- "spec-cactus": Application{
- Metrics: map[string]float64{
- "ipc": 1.353,
- "mem_read": 0.07105,
- "mem_write": 0.0273161,
- "c6res": 0.0532267,
- },
- Duration: 780 * time.Second,
- },
- "spec-astar": Application{
- Metrics: map[string]float64{
- "ipc": 0.86314,
- "mem_read": 0.0063,
- "mem_write": 0.0032874,
- "c6res": 0.09115,
- },
- Duration: 468 * time.Second,
- },
- "spec-leslie": Application{
- Metrics: map[string]float64{
- "ipc": 1.5225,
- "mem_read": 0.3221,
- "mem_write": 0.1532,
- "c6res": 0.1215,
- },
- Duration: 378 * time.Second,
- },
- }
- var Nodes = map[string]string{
- "kube-01": "e77467ad-636e-4e7e-8bc9-53e46ae51da1",
- "kube-02": "e77467ad-636e-4e7e-8bc9-53e46ae51da1",
- "kube-03": "e77467ad-636e-4e7e-8bc9-53e46ae51da1",
- "kube-04": "e77467ad-636e-4e7e-8bc9-53e46ae51da1",
- "kube-05": "c4766d29-4dc1-11ea-9d98-0242ac110002",
- "kube-06": "c4766d29-4dc1-11ea-9d98-0242ac110002",
- "kube-07": "c4766d29-4dc1-11ea-9d98-0242ac110002",
- "kube-08": "c4766d29-4dc1-11ea-9d98-0242ac110002",
- }
- var links = map[string][]float32{
- "e77467ad-636e-4e7e-8bc9-53e46ae51da1": []float32{3, 10.4},
- "c4766d29-4dc1-11ea-9d98-0242ac110002": []float32{2, 9.6},
- }
- var maxSpeed = map[string]float32{
- "e77467ad-636e-4e7e-8bc9-53e46ae51da1": 2.2,
- "c4766d29-4dc1-11ea-9d98-0242ac110002": 2.0,
- }
- var Sockets = map[string]int{
- "kube-01": 1,
- "kube-02": 0,
- "kube-03": 0,
- "kube-04": 1,
- "kube-05": 0,
- //"kube-06": 1,
- "kube-07": 0,
- "kube-08": 1,
- }
- var Cores = map[string][]int{
- "kube-01": []int{20, 21, 22, 23},
- "kube-02": []int{2, 3, 4, 5, 6, 7, 8, 9},
- "kube-03": []int{40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55},
- "kube-04": []int{24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75},
- "kube-05": []int{0, 1, 2, 3},
- //"kube-06": []int{12, 13, 14, 15, 16, 17, 18, 19},
- "kube-07": []int{4, 5, 6, 7, 8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31},
- "kube-08": []int{20, 21, 22, 23, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47},
- }
- func readFile(cfg *Config, file string) error {
- f, err := os.Open(file)
- if err != nil {
- klog.Infof("Config file for scheduler not found. Error: %v", err)
- return err
- }
- defer f.Close()
- decoder := yaml.NewDecoder(f)
- err = decoder.Decode(&cfg)
- if err != nil {
- klog.Infof("Unable to decode the config file. Error: %v", err)
- return err
- }
- return nil
- }
- func connectToInfluxDB(cfg Config) (client.Client, error) {
- c, err := client.NewHTTPClient(client.HTTPConfig{
- Addr: "http://" + cfg.Server.Host + ":" + cfg.Server.Port + "",
- })
- if err != nil {
- klog.Infof("Error while connecting to InfluxDB: %v ", err.Error())
- return nil, err
- }
- klog.Infof("Connected Successfully to InfluxDB")
- return c, nil
- }
|