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

Merge remote-tracking branch 'floodlight/master'

parents 4bced348 e8809cc5
No related branches found
No related tags found
No related merge requests found
...@@ -106,7 +106,17 @@ public class TopologyManager implements ...@@ -106,7 +106,17 @@ public class TopologyManager implements
protected SingletonTask newInstanceTask; protected SingletonTask newInstanceTask;
private Date lastUpdateTime; private Date lastUpdateTime;
protected boolean recomputeTopologyFlag;
/**
* Flag that indicates if links (direct/tunnel/multihop links) were
* updated as part of LDUpdate.
*/
protected boolean linksUpdated;
/**
* Flag that indicates if direct or tunnel links were updated as
* part of LDUpdate.
*/
protected boolean dtLinksUpdated;
/** /**
* Thread for recomputing topology. The thread is always running, * Thread for recomputing topology. The thread is always running,
...@@ -130,12 +140,14 @@ public class TopologyManager implements ...@@ -130,12 +140,14 @@ public class TopologyManager implements
} }
public boolean updateTopology() { public boolean updateTopology() {
recomputeTopologyFlag = false; boolean newInstanceFlag;
linksUpdated = false;
dtLinksUpdated = false;
applyUpdates(); applyUpdates();
createNewInstance(); newInstanceFlag = createNewInstance();
lastUpdateTime = new Date(); lastUpdateTime = new Date();
informListeners(); informListeners();
return recomputeTopologyFlag; return newInstanceFlag;
} }
// ********************** // **********************
...@@ -866,12 +878,13 @@ public class TopologyManager implements ...@@ -866,12 +878,13 @@ public class TopologyManager implements
/** /**
* This function computes a new topology instance. * This function computes a new topology instance.
* It ignores links connected to all broadcast domain ports * It ignores links connected to all broadcast domain ports
* and tunnel ports. * and tunnel ports. The method returns if a new instance of
* topology was created or not.
*/ */
protected void createNewInstance() { protected boolean createNewInstance() {
Set<NodePortTuple> blockedPorts = new HashSet<NodePortTuple>(); Set<NodePortTuple> blockedPorts = new HashSet<NodePortTuple>();
if (!recomputeTopologyFlag) return; if (!linksUpdated) return false;
Map<NodePortTuple, Set<Link>> openflowLinks; Map<NodePortTuple, Set<Link>> openflowLinks;
openflowLinks = openflowLinks =
...@@ -899,6 +912,7 @@ public class TopologyManager implements ...@@ -899,6 +912,7 @@ public class TopologyManager implements
// If needed, we may compute them differently. // If needed, we may compute them differently.
currentInstance = nt; currentInstance = nt;
currentInstanceWithoutTunnels = nt; currentInstanceWithoutTunnels = nt;
return true;
} }
...@@ -1017,18 +1031,19 @@ public class TopologyManager implements ...@@ -1017,18 +1031,19 @@ public class TopologyManager implements
addLinkToStructure(portBroadcastDomainLinks, link); addLinkToStructure(portBroadcastDomainLinks, link);
flag1 = removeLinkFromStructure(tunnelLinks, link); flag1 = removeLinkFromStructure(tunnelLinks, link);
flag2 = removeLinkFromStructure(directLinks, link); flag2 = removeLinkFromStructure(directLinks, link);
recomputeTopologyFlag = flag1 || flag2; dtLinksUpdated = flag1 || flag2;
} else if (type.equals(LinkType.TUNNEL)) { } else if (type.equals(LinkType.TUNNEL)) {
addLinkToStructure(tunnelLinks, link); addLinkToStructure(tunnelLinks, link);
removeLinkFromStructure(portBroadcastDomainLinks, link); removeLinkFromStructure(portBroadcastDomainLinks, link);
removeLinkFromStructure(directLinks, link); removeLinkFromStructure(directLinks, link);
recomputeTopologyFlag = true; dtLinksUpdated = true;
} else if (type.equals(LinkType.DIRECT_LINK)) { } else if (type.equals(LinkType.DIRECT_LINK)) {
addLinkToStructure(directLinks, link); addLinkToStructure(directLinks, link);
removeLinkFromStructure(tunnelLinks, link); removeLinkFromStructure(tunnelLinks, link);
removeLinkFromStructure(portBroadcastDomainLinks, link); removeLinkFromStructure(portBroadcastDomainLinks, link);
recomputeTopologyFlag = true; dtLinksUpdated = true;
} }
linksUpdated = true;
} }
public void removeLink(Link link) { public void removeLink(Link link) {
...@@ -1037,7 +1052,8 @@ public class TopologyManager implements ...@@ -1037,7 +1052,8 @@ public class TopologyManager implements
flag1 = removeLinkFromStructure(directLinks, link); flag1 = removeLinkFromStructure(directLinks, link);
flag2 = removeLinkFromStructure(tunnelLinks, link); flag2 = removeLinkFromStructure(tunnelLinks, link);
recomputeTopologyFlag = flag1 || flag2; linksUpdated = true;
dtLinksUpdated = flag1 || flag2;
removeLinkFromStructure(portBroadcastDomainLinks, link); removeLinkFromStructure(portBroadcastDomainLinks, link);
removeLinkFromStructure(switchPortLinks, link); removeLinkFromStructure(switchPortLinks, link);
...@@ -1068,7 +1084,7 @@ public class TopologyManager implements ...@@ -1068,7 +1084,7 @@ public class TopologyManager implements
} }
} }
public void removeLink(long srcId, short srcPort, public void removeLink(long srcId, short srcPort,
long dstId, short dstPort) { long dstId, short dstPort) {
Link link = new Link(srcId, srcPort, dstId, dstPort); Link link = new Link(srcId, srcPort, dstId, dstPort);
removeLink(link); removeLink(link);
...@@ -1089,6 +1105,8 @@ public class TopologyManager implements ...@@ -1089,6 +1105,8 @@ public class TopologyManager implements
*/ */
private void clearCurrentTopology() { private void clearCurrentTopology() {
this.clear(); this.clear();
linksUpdated = true;
dtLinksUpdated = true;
createNewInstance(); createNewInstance();
lastUpdateTime = new Date(); lastUpdateTime = new Date();
} }
......
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