Developing lightweight computation at the DSG edge

Commit 6d49bdfc authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-assign] Add the minMons flag to specify redundancy



The assignation's redundancy was hardcoded, use a flag instead.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent d159cfd2
......@@ -67,6 +67,11 @@ var idHelp = "Numeric ID of this monitoring instance"
// IDts holds a timestamp
var IDts = "0_ts"
// minMons defines the minimum number of monitors a deviced must be assigned to
// so that it is considered to have enough redundancy
var minMons = 4
var minMonsHelp = "Minimum number of monitors to assign to each device"
// maxDevs defines the default maximum number of nodes a monitor is assigned to
var maxDevs = 1000
var maxDevsHelp = "Maximum number of devices to monitor"
......@@ -148,6 +153,7 @@ func initializeFlags() {
dbPortPtr := flag.Int("db_port", dbPort, dbPortHelp)
idInt, _ := strconv.ParseInt(ID, 10, 32)
idPtr := flag.Int("id", int(idInt), idHelp)
minMonsPtr := flag.Int("minMons", minMons, minMonsHelp)
maxDevsPtr := flag.Int("maxDevs", maxDevs, maxDevsHelp)
devsCheckIntervalPtr := flag.Int("devsCheckInterval", devsCheckInterval, devsCheckIntervalHelp)
reassignIntervalPtr := flag.Int("reassignInterval", reassignInterval, reassignIntervalHelp)
......@@ -176,6 +182,11 @@ func initializeFlags() {
maxDevs = *maxDevsPtr
}
//Minimum monitors per device
if *minMonsPtr > 0 {
minMons = *minMonsPtr
}
//Timers for tickers (intervals)
if *devsCheckIntervalPtr > 0 {
devsCheckInterval = *devsCheckIntervalPtr
......@@ -416,7 +427,7 @@ func reassignDevs() {
//Create a list with all the unassigned devices
var unassignedDevices []cnml.DeviceIpv4sGraphserver
for _, v := range cnmlDevices {
if (!isDeviceInAssignationSlice(v.ID, globalAssign) || len(globalAssign[posDeviceInAssignationSlice(v.ID, globalAssign)].MonitorID) < 1) && !isDeviceInAssignationSlice(v.ID, localAssign) {
if (!isDeviceInAssignationSlice(v.ID, globalAssign) || len(globalAssign[posDeviceInAssignationSlice(v.ID, globalAssign)].MonitorID) < minMons) && !isDeviceInAssignationSlice(v.ID, localAssign) {
unassignedDevices = append(unassignedDevices, v)
}
}
......
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