Skip to content
Snippets Groups Projects
Commit e7c11dce authored by Gregor Maier's avatar Gregor Maier
Browse files

Merge remote-tracking branch 'bigswitch/master' into misc

Conflicts:
	bigtest/staticflowpusher/StaticFlowTest1.py
parents f27363e4 9cbbace2
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,11 @@
package net.floodlightcontroller.linkdiscovery;
import java.util.List;
public interface ILinkDiscoveryListener extends ILinkDiscovery{
public void linkDiscoveryUpdate(LDUpdate update);
public void linkDiscoveryUpdate(List<LDUpdate> updateList);
}
......@@ -324,6 +324,13 @@ IFloodlightModule, IInfoProvider, IHAListener {
private void doUpdatesThread() throws InterruptedException {
do {
LDUpdate update = updates.take();
List<LDUpdate> updateList = new ArrayList<LDUpdate>();
updateList.add(update);
// Add all the pending updates to the list.
while (updates.peek() != null) {
updateList.add(updates.remove());
}
if (linkDiscoveryAware != null) {
if (log.isTraceEnabled()) {
......@@ -335,7 +342,7 @@ IFloodlightModule, IInfoProvider, IHAListener {
}
try {
for (ILinkDiscoveryListener lda : linkDiscoveryAware) { // order maintained
lda.linkDiscoveryUpdate(update);
lda.linkDiscoveryUpdate(updateList);
}
}
catch (Exception e) {
......@@ -1113,14 +1120,24 @@ IFloodlightModule, IInfoProvider, IHAListener {
public Map<Long, Set<Link>> getSwitchLinks() {
return this.switchLinks;
}
/**
* Removes links from memory and storage.
* @param links The List of @LinkTuple to delete.
*/
protected void deleteLinks(List<Link> links, String reason) {
NodePortTuple srcNpt, dstNpt;
deleteLinks(links, reason, null);
}
/**
* Removes links from memory and storage.
* @param links The List of @LinkTuple to delete.
*/
protected void deleteLinks(List<Link> links, String reason,
List<LDUpdate> updateList) {
NodePortTuple srcNpt, dstNpt;
List<LDUpdate> linkUpdateList = new ArrayList<LDUpdate>();
lock.writeLock().lock();
try {
for (Link lt : links) {
......@@ -1148,7 +1165,7 @@ IFloodlightModule, IInfoProvider, IHAListener {
}
LinkInfo info = this.links.remove(lt);
updates.add(new LDUpdate(lt.getSrc(), lt.getSrcPort(),
linkUpdateList.add(new LDUpdate(lt.getSrc(), lt.getSrcPort(),
lt.getDst(), lt.getDstPort(),
getLinkType(lt, info),
UpdateOperation.LINK_REMOVED));
......@@ -1173,6 +1190,9 @@ IFloodlightModule, IInfoProvider, IHAListener {
}
}
} finally {
if (updateList != null)
linkUpdateList.addAll(updateList);
updates.addAll(linkUpdateList);
lock.writeLock().unlock();
}
}
......@@ -1326,7 +1346,7 @@ IFloodlightModule, IInfoProvider, IHAListener {
@Override
public void addedSwitch(IOFSwitch sw) {
if (sw.getEnabledPorts() != null) {
if (sw.getEnabledPortNumbers() != null) {
for (Short p : sw.getEnabledPortNumbers()) {
processNewPort(sw.getId(), p);
}
......@@ -1355,13 +1375,22 @@ IFloodlightModule, IInfoProvider, IHAListener {
log.trace("Handle switchRemoved. Switch {}; removing links {}",
HexString.toHexString(sw), switchLinks.get(sw));
}
List<LDUpdate> updateList = new ArrayList<LDUpdate>();
updateList.add(new LDUpdate(sw, null,
UpdateOperation.SWITCH_REMOVED));
// add all tuples with an endpoint on this switch to erase list
eraseList.addAll(switchLinks.get(sw));
deleteLinks(eraseList, "Switch Removed");
// Send a switch removed update
LDUpdate update = new LDUpdate(sw, null, UpdateOperation.SWITCH_REMOVED);
updates.add(update);
// Sending the updateList, will ensure the updates in this
// list will be added at the end of all the link updates.
// Thus, it is not necessary to explicitly add these updates
// to the queue.
deleteLinks(eraseList, "Switch Removed", updateList);
} else {
// Switch does not have any links.
updates.add(new LDUpdate(sw, null,
UpdateOperation.SWITCH_REMOVED));
}
} finally {
lock.writeLock().unlock();
......
......@@ -162,6 +162,13 @@ public class TopologyManager implements
// **********************
// ILinkDiscoveryListener
// **********************
@Override
public void linkDiscoveryUpdate(List<LDUpdate> updateList) {
if (log.isTraceEnabled()) {
log.trace("Queuing update: {}", updateList);
}
ldUpdates.addAll(updateList);
}
@Override
public void linkDiscoveryUpdate(LDUpdate update) {
......
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