Skip to content
Snippets Groups Projects
Commit 970cfbb5 authored by Kanzhe Jiang's avatar Kanzhe Jiang
Browse files

Device is immutable. The new device needs to be returned when aged network address or AP is removed

parent d4ac8fd3
No related branches found
No related tags found
No related merge requests found
...@@ -1763,11 +1763,15 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1763,11 +1763,15 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
deviceUpdateTask.reschedule(5, TimeUnit.SECONDS); deviceUpdateTask.reschedule(5, TimeUnit.SECONDS);
} }
// ******************** /**
// Device aging methods * Remove aged network address from device
// ******************** *
* @param device
* @param currentDate
* @return the new device object since the device is immutable
*/
private void removeAgedNetworkAddresses(Device device, Date currentDate) { private Device removeAgedNetworkAddresses(Device device, Date currentDate) {
Collection<DeviceNetworkAddress> addresses = Collection<DeviceNetworkAddress> addresses =
device.getNetworkAddresses(); device.getNetworkAddresses();
...@@ -1785,9 +1789,18 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1785,9 +1789,18 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
removeNetworkAddressFromStorage(device, address); removeNetworkAddressFromStorage(device, address);
} }
} }
return devMgrMaps.getDeviceByDataLayerAddr(device.getDataLayerAddressAsLong());
} }
private void removeAgedAttachmentPoints(Device device, Date currentDate) { /**
* Remove aged device attachment point
*
* @param device
* @param currentDate
* @return the new device object since the device is immutable
*/
private Device removeAgedAttachmentPoints(Device device, Date currentDate) {
Collection<DeviceAttachmentPoint> aps = device.getAttachmentPoints(); Collection<DeviceAttachmentPoint> aps = device.getAttachmentPoints();
for (DeviceAttachmentPoint ap : aps) { for (DeviceAttachmentPoint ap : aps) {
...@@ -1804,6 +1817,8 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1804,6 +1817,8 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
removeAttachmentPointFromStorage(device, ap); removeAttachmentPointFromStorage(device, ap);
} }
} }
return devMgrMaps.getDeviceByDataLayerAddr(device.getDataLayerAddressAsLong());
} }
/** /**
...@@ -1815,8 +1830,8 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1815,8 +1830,8 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
Collection<Device> deviceColl = devMgrMaps.getDevices(); Collection<Device> deviceColl = devMgrMaps.getDevices();
for (Device device: deviceColl) { for (Device device: deviceColl) {
removeAgedNetworkAddresses(device, currentDate); device = removeAgedNetworkAddresses(device, currentDate);
removeAgedAttachmentPoints(device, currentDate); device = removeAgedAttachmentPoints(device, currentDate);
if ((device.getAttachmentPoints().size() == 0) && if ((device.getAttachmentPoints().size() == 0) &&
(device.getNetworkAddresses().size() == 0) && (device.getNetworkAddresses().size() == 0) &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment