Achilleas Tzenetopoulos 5 years ago
parent
commit
d09a286d62

+ 9 - 5
kubernetes-v1.15.4/pkg/scheduler/customcache/cache.go

@@ -5,17 +5,17 @@ import (
 	"time"
 )
 
-var LabCache MlabCache
+var LabCache *MlabCache
 var duration int = 10
 
 type MlabCache struct {
 	Cache   map[string]map[string]float64
 	Mux     sync.Mutex
-	Timeout time.Ticker
+	Timeout *time.Ticker
 }
 
 func init() {
-	LabCache = MlabCache{
+	LabCache = &MlabCache{
 		Cache: map[string]map[string]float64{
 			"kube-01": map[string]float64{
 				"ipc":       -1,
@@ -67,9 +67,13 @@ func init() {
 			},
 		},
 	}
-	LabCache.Timeout = *time.NewTicker(time.Duration(10) * time.Second)
+	LabCache.Timeout = time.NewTicker(time.Duration(10) * time.Second)
 }
 
+// func New() {
+
+// }
+
 // var Τimeout *time.Ticker
 
 func (c *MlabCache) CleanCache() {
@@ -139,7 +143,7 @@ func (c *MlabCache) UpdateCache(input map[string]float64, c6res float64, nodenam
 	}
 
 	// Reset the ticker
-	c.Timeout = *time.NewTicker(time.Duration(duration) * time.Second)
+	c.Timeout = time.NewTicker(time.Duration(duration) * time.Second)
 	//klog.Infof("Reset the Ticker")
 	c.Mux.Unlock()
 

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

@@ -461,6 +461,7 @@ func (sched *Scheduler) scheduleOne() {
 		klog.Infof("Time to erase: %v", time.Now())
 		//customcache.LabCache.Timeout.Stop()
 		customcache.LabCache.CleanCache()
+		klog.Infof("Cache: %v", customcache.LabCache.Cache)
 	default:
 	}