Developing lightweight computation at the DSG edge

Commit 0a052624 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-assign] Set an assignation filling time through a variable


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 6c350832
......@@ -77,6 +77,9 @@ var maxDevsHelp = "Maximum number of devices to monitor"
var devsCheckInterval = 5 //60
var devsCheckIntervalHelp = "Interval (in seconds) in which to check for changes in the devices list"
var fillingTime = 30 //60
var fillingTimeHelp = "Interval (in seconds) for filling the local assignation list"
var reassignInterval = 5 //60
var reassignIntervalHelp = "Interval (in seconds) in which to update the local devices assignation list"
......@@ -151,6 +154,7 @@ func initializeFlags() {
minMonsPtr := flag.Int("minMons", minMons, minMonsHelp)
maxDevsPtr := flag.Int("maxDevs", maxDevs, maxDevsHelp)
devsCheckIntervalPtr := flag.Int("devsCheckInterval", devsCheckInterval, devsCheckIntervalHelp)
fillingTimePtr := flag.Int("fillingTime", fillingTime, fillingTimeHelp)
reassignIntervalPtr := flag.Int("reassignInterval", reassignInterval, reassignIntervalHelp)
globalAssignCheckIntervalPtr := flag.Int("globalAssignCheckInterval", globalAssignCheckInterval, globalAssignCheckIntervalHelp)
......@@ -186,6 +190,9 @@ func initializeFlags() {
if *devsCheckIntervalPtr > 0 {
devsCheckInterval = *devsCheckIntervalPtr
}
if *fillingTimePtr > 0 {
fillingTime = *fillingTimePtr
}
if *reassignIntervalPtr > 0 {
reassignInterval = *reassignIntervalPtr
}
......@@ -397,8 +404,7 @@ func reassignDevs() {
if (len(localAssign) < maxDevs) && (len(localAssign) < len(cnmlDevices)) {
// Assign new nodes
fillingTime := 60.0 // Add decimal to force float64 type // Use 60 instead of 3600; be quick and do it in 1 min
toassign := int(math.Min(float64(int(math.Min(math.Min(float64(len(cnmlDevices)), float64(maxDevs))*float64(devsCheckInterval)/fillingTime+1, float64(len(cnmlDevices)-len(localAssign))))), float64(maxDevs-len(localAssign))))
toassign := int(math.Min(float64(int(math.Min(math.Min(float64(len(cnmlDevices)), float64(maxDevs))*float64(devsCheckInterval)/float64(fillingTime)+1, float64(len(cnmlDevices)-len(localAssign))))), float64(maxDevs-len(localAssign))))
fmt.Println("Assigning", toassign, "new devices")
//Create a list with all the unassigned devices
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment