Developing lightweight computation at the DSG edge

Commit 140e8377 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-assign] Refactor code to remove legacy debris (II)


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 768c18bd
...@@ -431,7 +431,7 @@ func sanitizeAssignationsInDatabase() { ...@@ -431,7 +431,7 @@ func sanitizeAssignationsInDatabase() {
for _, x := range currentMonitors { for _, x := range currentMonitors {
if w == x { if w == x {
monitorFound = true monitorFound = true
fmt.Println(fmt.Sprintf("Monitor %s found, keeping it for device %d", w, v.Device.ID)) // fmt.Println(fmt.Sprintf("Monitor %s found, keeping it for device %d", w, v.Device.ID))
} }
} }
if monitorFound == false { if monitorFound == false {
...@@ -574,9 +574,10 @@ func reassignDevs() { ...@@ -574,9 +574,10 @@ func reassignDevs() {
} else { } else {
fmt.Println("Not assigning any new device.") fmt.Println("Not assigning any new device.")
} }
fmt.Println("Global average load:", calculateGlobalAverageLoad())
} }
fmt.Println("Global average load:", calculateGlobalAverageLoad())
// Update the new assigned devices to the global shared list // Update the new assigned devices to the global shared list
if assignChange { if assignChange {
fmt.Println("Exporting the new assigned devices list") fmt.Println("Exporting the new assigned devices list")
...@@ -587,31 +588,6 @@ func reassignDevs() { ...@@ -587,31 +588,6 @@ func reassignDevs() {
} }
} }
// // Check for devices assigned locally that are no longer in the global devices list
// func checkOutdatedLocalDevices() {
//
// assignChange := false // Track changes in the assignation list
// var deldevs []cnml.DeviceMonitorAssignation // Storage for the deleted devices
// newlocalAssign := localAssign // Duplicate the local list of assigned devices
//
// for _, v := range localAssign {
// if !isDeviceInSliceByID(v.Device.ID, cnmlDevices) {
// fmt.Println("Removing old device ", v.Device.ID, " from the local assigned devices list")
// deldevs = append(deldevs, v)
// newlocalAssign = rmDeviceFromAssignationList(v.Device.ID, newlocalAssign)
// assignChange = true
// }
// }
//
// // Save the new local assigned devices, if changes have been made
// if assignChange {
// localAssign = newlocalAssign
// for _, v := range deldevs {
// goclidote.AntidoteRemoveItemFromSetInBucket(fmt.Sprintf("device-%d", v.Device.ID), "monitors", ID, dbHost, dbPort)
// }
// }
// }
func addDevicesAssignedByGraphserver() { func addDevicesAssignedByGraphserver() {
for _, v := range cnmlDevices { for _, v := range cnmlDevices {
if isDeviceInAssignationSlice(v.ID, localAssign) { if isDeviceInAssignationSlice(v.ID, localAssign) {
...@@ -823,11 +799,8 @@ func calculateGlobalAverageLoad() float64 { ...@@ -823,11 +799,8 @@ func calculateGlobalAverageLoad() float64 {
monitorAssignedDevs = append(monitorAssignedDevs, 0) monitorAssignedDevs = append(monitorAssignedDevs, 0)
} }
fmt.Println("len(globalAssign):", len(globalAssign))
for _, v := range globalAssign { for _, v := range globalAssign {
fmt.Println(v)
for _, w := range v.MonitorID { for _, w := range v.MonitorID {
fmt.Println("len(monitors):", len(monitors))
for m, x := range monitors { for m, x := range monitors {
if w == x { if w == x {
monitorAssignedDevs[m] = monitorAssignedDevs[m] + 1 monitorAssignedDevs[m] = monitorAssignedDevs[m] + 1
......
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