Developing lightweight computation at the DSG edge

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

[monitor-assign] Split policy 2 into 2 and 3


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 4313705c
......@@ -198,6 +198,8 @@ func initializeFlags() {
}
if *maxMonsPtr >= minMons {
maxMons = *maxMonsPtr
} else {
maxMons = minMons + 1
}
//Timers for tickers (intervals)
......@@ -221,9 +223,15 @@ func initializeFlags() {
}
//Policy
if *policyPtr >= 1 && *policyPtr <= 2 {
if *policyPtr >= 1 && *policyPtr <= 3 {
policy = *policyPtr
}
// Policy 2 reuses code from policy 3
if policy == 2 {
policy = 3
maxMons = 32767
}
}
// Get the global devices list from AntidoteDB
......@@ -517,8 +525,12 @@ func reassignDevs() {
fmt.Println("Not assigning any new device.")
}
case 2:
// Policy #2: The monitoring server self-assigns those network devices that
// Policy #2 is the same one as policy #3, but setting maxMons to "infinite"
// (actually to 32767) during the initialize() phase.
// case 2:
case 3:
// Policy #3: The monitoring server self-assigns those network devices that
// have the least monitoring devices already assigned. Devices are picked
// randomly, from those with less monitors, until the server reaches its
// maximum number of monitored devices specified by the maxDevs parameter.
......@@ -536,7 +548,7 @@ func reassignDevs() {
var unassignedDevices []cnml.DeviceIpv4sGraphserver
for leastMons <= maxMons && len(unassignedDevices) == 0 {
for leastMons < maxMons && len(unassignedDevices) == 0 {
for _, v := range cnmlDevices {
if !isDeviceInAssignationSlice(v.ID, globalAssign) || (!isDeviceInAssignationSlice(v.ID, localAssign) && len(globalAssign[posDeviceInAssignationSlice(v.ID, globalAssign)].MonitorID) < leastMons) {
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