Skip to content
Snippets Groups Projects
Commit 81c08684 authored by abat's avatar abat
Browse files

Merge into master from pull request #27:

parents 912ea9ae 970cfbb5
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();
...@@ -1781,12 +1785,22 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1781,12 +1785,22 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
if (address.getLastSeen().before(agedBoundary)) { if (address.getLastSeen().before(agedBoundary)) {
devMgrMaps.delNwAddrByDataLayerAddr(device.getDataLayerAddressAsLong(), devMgrMaps.delNwAddrByDataLayerAddr(device.getDataLayerAddressAsLong(),
address.getNetworkAddress().intValue()); address.getNetworkAddress().intValue());
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) {
...@@ -1800,8 +1814,11 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1800,8 +1814,11 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
devMgrMaps.delDevAttachmentPoint(device, ap.getSwitchPort()); devMgrMaps.delDevAttachmentPoint(device, ap.getSwitchPort());
evHistAttachmtPt(device, ap.getSwitchPort(), EvAction.REMOVED, evHistAttachmtPt(device, ap.getSwitchPort(), EvAction.REMOVED,
"Aged"); "Aged");
removeAttachmentPointFromStorage(device, ap);
} }
} }
return devMgrMaps.getDeviceByDataLayerAddr(device.getDataLayerAddressAsLong());
} }
/** /**
...@@ -1813,8 +1830,8 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener, ...@@ -1813,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