Skip to content
Snippets Groups Projects
Commit 1504bd20 authored by abat's avatar abat
Browse files

Merge into master from pull request #244:

Update attachmentpoint whenever topologyChanged() notification is received.  It is not necessary to process every event; just one update call per topologyChanged() should take care of fixing all attachment point changes. (https://github.com/floodlight/floodlight/pull/244)
parents d615e008 d9eed7bd
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,29 @@ public class Device implements IDevice { ...@@ -126,6 +126,29 @@ public class Device implements IDevice {
return apMap; return apMap;
} }
protected boolean updateAttachmentPoint() {
if (this.attachmentPoints == null) return false;
List<AttachmentPoint> oldAPList =
new ArrayList<AttachmentPoint>(this.attachmentPoints);
Map<Long, AttachmentPoint> apMap = getAPMap();
if (apMap == null) {
this.attachmentPoints = null;
return true;
}
List<AttachmentPoint> newAPList =
new ArrayList<AttachmentPoint>(apMap.values());
// Since we did not add any new attachment points, it is sufficient
// to compare only the lengths.
if (oldAPList.size() == newAPList.size()) return false;
this.attachmentPoints = newAPList;
return true;
}
protected boolean updateAttachmentPoint(long sw, short port, long lastSeen){ protected boolean updateAttachmentPoint(long sw, short port, long lastSeen){
ITopologyService topology = deviceManager.topology; ITopologyService topology = deviceManager.topology;
...@@ -234,7 +257,8 @@ public class Device implements IDevice { ...@@ -234,7 +257,8 @@ public class Device implements IDevice {
for(AttachmentPoint ap: apMap.values()) { for(AttachmentPoint ap: apMap.values()) {
SwitchPort swport = new SwitchPort(ap.getSw(), SwitchPort swport = new SwitchPort(ap.getSw(),
ap.getPort()); ap.getPort());
sp.add(swport); if (deviceManager.isValidAttachmentPoint(ap.getSw(), ap.getPort()))
sp.add(swport);
} }
return sp.toArray(new SwitchPort[sp.size()]); return sp.toArray(new SwitchPort[sp.size()]);
} }
......
...@@ -58,8 +58,6 @@ import net.floodlightcontroller.devicemanager.web.DeviceRoutable; ...@@ -58,8 +58,6 @@ import net.floodlightcontroller.devicemanager.web.DeviceRoutable;
import net.floodlightcontroller.flowcache.IFlowReconcileListener; import net.floodlightcontroller.flowcache.IFlowReconcileListener;
import net.floodlightcontroller.flowcache.IFlowReconcileService; import net.floodlightcontroller.flowcache.IFlowReconcileService;
import net.floodlightcontroller.flowcache.OFMatchReconcile; import net.floodlightcontroller.flowcache.OFMatchReconcile;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LDUpdate;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.UpdateOperation;
import net.floodlightcontroller.packet.ARP; import net.floodlightcontroller.packet.ARP;
import net.floodlightcontroller.packet.DHCP; import net.floodlightcontroller.packet.DHCP;
import net.floodlightcontroller.packet.Ethernet; import net.floodlightcontroller.packet.Ethernet;
...@@ -1511,33 +1509,10 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1511,33 +1509,10 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
*/ */
@Override @Override
public void topologyChanged() { public void topologyChanged() {
List<LDUpdate> updateList = topology.getLastLinkUpdates();
for(LDUpdate u: updateList) {
if (u.getOperation() == UpdateOperation.SWITCH_REMOVED) {
processSwitchRemoved(u.getSrc());
} else if (u.getOperation() == UpdateOperation.PORT_DOWN) {
processPortDown(u.getSrc(), u.getSrcPort());
}
}
}
private void processSwitchRemoved(long sw) {
Iterator<Device> diter = deviceMap.values().iterator(); Iterator<Device> diter = deviceMap.values().iterator();
while (diter.hasNext()) { while (diter.hasNext()) {
Device d = diter.next(); Device d = diter.next();
if (d.deleteAttachmentPoint(sw)) { if (d.updateAttachmentPoint()) {
// update device attachment point changed.
sendDeviceMovedNotification(d);
}
}
}
private void processPortDown(long sw, short port) {
Iterator<Device> diter = deviceMap.values().iterator();
while (diter.hasNext()) {
Device d = diter.next();
if (d.deleteAttachmentPoint(sw, port)) {
// update device attachment point changed.
sendDeviceMovedNotification(d); sendDeviceMovedNotification(d);
} }
} }
...@@ -1552,5 +1527,4 @@ IFlowReconcileListener, IInfoProvider, IHAListener { ...@@ -1552,5 +1527,4 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
listener.deviceMoved(d); listener.deviceMoved(d);
} }
} }
} }
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