Pārlūkot izejas kodu

added in-memory

Achilleas Tzenetopoulos 5 gadi atpakaļ
vecāks
revīzija
455f97ff93

+ 14 - 0
kubernetes-v1.15.4/pkg/scheduler/customcache/cache.go

@@ -2,6 +2,8 @@ package customcache
 
 import (
 	"sync"
+
+	"k8s.io/klog"
 )
 
 //var timeout *time.Ticker = time.NewTicker(time.Duration(10 * time.Second))
@@ -129,6 +131,8 @@ func (c *MlabCache) UpdateCache(input map[string]float64, c6res float64, nodenam
 	}
 	c.Mux.Unlock()
 
+	klog.Infof("After cache update")
+	c.printCached(nodename)
 	return nil
 }
 
@@ -139,8 +143,18 @@ func (c *MlabCache) AddAppMetrics(app map[string]float64, nodename string, numCo
 	//TODO
 	// handle c6res addition
 	c.Cache[nodename]["c6res"] -= (1 - app["c6res"]) / float64(100*numCores)
+	if c.Cache[nodename]["c6res"] <= 0 {
+		c.Cache[nodename]["c6res"] = 0.00000001
+	}
 
 	//TODO
 	// handle ipc addition
 	c.Mux.Unlock()
+	klog.Infof("After application metrics addition")
+	c.printCached(nodename)
+}
+
+func (c *MlabCache) printCached(nodename string) {
+	klog.Infof("IPC: %v, Reads: %v,  Writes: %v, C6res: %v", c.Cache[nodename]["ipc"], c.Cache[nodename]["mem_read"],
+		c.Cache[nodename]["mem_write"], c.Cache[nodename]["c6res"])
 }

+ 1 - 0
kubernetes-v1.15.4/pkg/scheduler/scheduler.go

@@ -448,6 +448,7 @@ func (sched *Scheduler) scheduleOne() {
 	select {
 	// clean the cache if 10 seconds are passed
 	case <-timeout.C:
+		klog.Infof("Time to erase")
 		customcache.LabCache.CleanCache()
 	default:
 	}