Skip to content
Snippets Groups Projects
Commit 4bf09d0d authored by abat's avatar abat
Browse files

Merge into master from pull request #296:

Bug fix in the attachment point learning, where previously known AP was incorrectly added to the oldAP list. (https://github.com/floodlight/floodlight/pull/296)
parents 27919663 5267503e
No related branches found
No related tags found
No related merge requests found
...@@ -292,9 +292,6 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -292,9 +292,6 @@ entity.getLastSeenTimestamp().getTime());
protected boolean updateAttachmentPoint() { protected boolean updateAttachmentPoint() {
boolean moved = false; boolean moved = false;
List<AttachmentPoint> oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null) oldAPList.addAll(oldAPs);
List<AttachmentPoint> apList = new ArrayList<AttachmentPoint>(); List<AttachmentPoint> apList = new ArrayList<AttachmentPoint>();
if (attachmentPoints != null) apList.addAll(attachmentPoints); if (attachmentPoints != null) apList.addAll(attachmentPoints);
Map<Long, AttachmentPoint> newMap = getAPMap(apList); Map<Long, AttachmentPoint> newMap = getAPMap(apList);
...@@ -309,6 +306,8 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -309,6 +306,8 @@ entity.getLastSeenTimestamp().getTime());
new ArrayList<AttachmentPoint>(); new ArrayList<AttachmentPoint>();
if (newMap != null) newAPList.addAll(newMap.values()); if (newMap != null) newAPList.addAll(newMap.values());
this.attachmentPoints = newAPList; this.attachmentPoints = newAPList;
log.debug("DEVICE_MOVE: Old AttachmentPoints: {}," +
"New AttachmentPoints: {}", apList, newAPList);
} }
// Set the oldAPs to null. // Set the oldAPs to null.
...@@ -347,6 +346,7 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -347,6 +346,7 @@ entity.getLastSeenTimestamp().getTime());
newAP = oldAPList.remove(index); newAP = oldAPList.remove(index);
newAP.setLastSeen(lastSeen); newAP.setLastSeen(lastSeen);
this.oldAPs = oldAPList; this.oldAPs = oldAPList;
log.debug("DEVICE_MOVE: OldAPs changed for device: {}", oldAPList);
} }
// newAP now contains the new attachment point. // newAP now contains the new attachment point.
...@@ -356,6 +356,7 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -356,6 +356,7 @@ entity.getLastSeenTimestamp().getTime());
if (apMap == null || apMap.isEmpty()) { if (apMap == null || apMap.isEmpty()) {
apList.add(newAP); apList.add(newAP);
attachmentPoints = apList; attachmentPoints = apList;
log.debug("DEVICE_MOVE: First attachmentpoint point for device: {}", apList);
return true; return true;
} }
...@@ -368,6 +369,8 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -368,6 +369,8 @@ entity.getLastSeenTimestamp().getTime());
apList.addAll(apMap.values()); apList.addAll(apMap.values());
apList.add(newAP); apList.add(newAP);
this.attachmentPoints = apList; this.attachmentPoints = apList;
log.debug("DEVICE_MOVE: First access point in L2 domain. {}",
apList);
return true; // new AP found on an L2 island. return true; // new AP found on an L2 island.
} }
...@@ -388,6 +391,8 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -388,6 +391,8 @@ entity.getLastSeenTimestamp().getTime());
apMap.put(id, newAP); apMap.put(id, newAP);
this.attachmentPoints = this.attachmentPoints =
new ArrayList<AttachmentPoint>(apMap.values()); new ArrayList<AttachmentPoint>(apMap.values());
log.debug("DEVICE_MOVED: Attachment point changed to: {}," +
"putting previous in oldAP: {}", newAP, oldAP);
oldAPList = new ArrayList<AttachmentPoint>(); oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null) oldAPList.addAll(oldAPs); if (oldAPs != null) oldAPList.addAll(oldAPs);
...@@ -395,9 +400,13 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -395,9 +400,13 @@ entity.getLastSeenTimestamp().getTime());
this.oldAPs = oldAPList; this.oldAPs = oldAPList;
return true; // attachment point changed. return true; // attachment point changed.
} else { } else {
// retain oldAP as is. Put the newAP in oldAPs for flagging
// possible duplicates.
oldAPList = new ArrayList<AttachmentPoint>(); oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null) oldAPList.addAll(oldAPs); if (oldAPs != null) oldAPList.addAll(oldAPs);
oldAPList.add(oldAP); oldAPList.add(newAP);
log.debug("DEVICE_MOVED: New attachment point {} does not" +
" replace already existing one {}.", newAP, oldAP);
this.oldAPs = oldAPList; this.oldAPs = oldAPList;
} }
...@@ -516,6 +525,8 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -516,6 +525,8 @@ entity.getLastSeenTimestamp().getTime());
if (!includeError) if (!includeError)
return sp.toArray(new SwitchPort[sp.size()]); return sp.toArray(new SwitchPort[sp.size()]);
log.debug("DEVICE_APS: Getting all attachment points: APs: {}, oldAPs: {}",
this.attachmentPoints, this.oldAPs);
List<AttachmentPoint> oldAPList; List<AttachmentPoint> oldAPList;
oldAPList = new ArrayList<AttachmentPoint>(); oldAPList = new ArrayList<AttachmentPoint>();
...@@ -535,6 +546,7 @@ entity.getLastSeenTimestamp().getTime()); ...@@ -535,6 +546,7 @@ entity.getLastSeenTimestamp().getTime());
sp.add(swport); sp.add(swport);
} }
} }
log.debug("DEVICE_APS: Duplicate APs: {}", sp);
return sp.toArray(new SwitchPort[sp.size()]); return sp.toArray(new SwitchPort[sp.size()]);
} }
......
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