Developing lightweight computation at the DSG edge

Commit a4d5dfb0 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-assign] Add maxMons to policy #2


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 5d2fc158
......@@ -495,23 +495,16 @@ func reassignDevs() {
// Calculate which is the number of least monitors a device has
leastMons := 0
for _, v := range globalAssign {
leastMons = int(math.Max(float64(leastMons), float64(len(v.MonitorID))))
}
for _, v := range cnmlDevices {
if !isDeviceInAssignationSlice(v.ID, globalAssign) {
leastMons = 0
} else {
leastMons = int(math.Min(float64(leastMons), float64(len(globalAssign[posDeviceInAssignationSlice(v.ID, globalAssign)].MonitorID))))
}
}
fmt.Println(leastMons)
var unassignedDevices []cnml.DeviceIpv4sGraphserver
for _, v := range cnmlDevices {
if (!isDeviceInAssignationSlice(v.ID, globalAssign) || len(globalAssign[posDeviceInAssignationSlice(v.ID, globalAssign)].MonitorID) <= leastMons) && !isDeviceInAssignationSlice(v.ID, localAssign) {
unassignedDevices = append(unassignedDevices, v)
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)
}
}
leastMons = leastMons + 1
}
fmt.Println(len(unassignedDevices), "devices unassigned")
......
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