Skip to content
Snippets Groups Projects
Commit e0595ac9 authored by Kanzhe Jiang's avatar Kanzhe Jiang
Browse files

Fix a bug and some cleanup in topology

parent 7036a327
No related branches found
No related tags found
No related merge requests found
......@@ -160,9 +160,9 @@ public class TopologyInstance {
for (Long sw: switches) {
ClusterDFS cdfs = dfsList.get(sw);
if (cdfs == null) {
log.error("Do DFS object for switch {} found.", sw);
log.error("No DFS object for switch {} found.", sw);
}else if (!cdfs.isVisited()) {
dfsTraverse(0, 1, sw, switches, dfsList, currSet, clusters);
dfsTraverse(0, 1, sw, dfsList, currSet);
}
}
}
......@@ -171,7 +171,7 @@ public class TopologyInstance {
/**
* @author Srinivasan Ramasubramanian
*
* This algorithm computes the depth first search (DFS) travesral of the
* This algorithm computes the depth first search (DFS) traversal of the
* switches in the network, computes the lowpoint, and creates clusters
* (of strongly connected components).
*
......@@ -192,17 +192,13 @@ public class TopologyInstance {
* @param parentIndex: DFS index of the parent node
* @param currIndex: DFS index to be assigned to a newly visited node
* @param currSw: ID of the current switch
* @param switches: Set of switch IDs in the network
* @param dfsList: HashMap of DFS data structure for each switch
* @param currSet: Set of nodes in the current cluster in formation
* @param clusters: Set of already formed clusters
* @return long: DSF index to be used when a new node is visited
*/
private long dfsTraverse (long parentIndex, long currIndex,
long currSw, Set<Long> switches,
Map<Long, ClusterDFS> dfsList, Set <Long> currSet,
Set <Cluster> clusters) {
private long dfsTraverse (long parentIndex, long currIndex, long currSw,
Map<Long, ClusterDFS> dfsList, Set <Long> currSet) {
//Get the DFS object corresponding to the current switch
ClusterDFS currDFS = dfsList.get(currSw);
......@@ -244,7 +240,7 @@ public class TopologyInstance {
} else if (!dstDFS.isVisited()) {
// make a DFS visit
currIndex = dfsTraverse(currDFS.getDfsIndex(), currIndex, dstSw,
switches, dfsList, currSet, clusters);
dfsList, currSet);
if (currIndex < 0) return -1;
......@@ -286,8 +282,7 @@ public class TopologyInstance {
public boolean isBroadcastDomainLink(Link l) {
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
return (broadcastDomainPorts.contains(n1) ||
broadcastDomainPorts.contains(n2));
return (isBroadcastDomainPort(n1) || isBroadcastDomainPort(n2));
}
public boolean isBroadcastDomainPort(NodePortTuple npt) {
......@@ -389,7 +384,6 @@ public class TopologyInstance {
for(Cluster c: clusters) {
// c.id is the smallest node that's in the cluster
BroadcastTree tree = clusterBroadcastTrees.get(c.id);
clusterBroadcastTrees.put(c.id, tree);
//log.info("Broadcast Tree {}", tree);
Set<NodePortTuple> nptSet = new HashSet<NodePortTuple>();
......
......@@ -51,7 +51,7 @@ IRoutingService, ILinkDiscoveryListener {
protected BlockingQueue<LDUpdate> ldUpdates;
protected TopologyInstance currentInstance;
protected SingletonTask newInstanceTask;
/**
* Thread for recomputing topology. The thread is always running,
* however the function applyUpdates() has a blocking call.
......@@ -195,27 +195,27 @@ IRoutingService, ILinkDiscoveryListener {
removeLinkFromStructure(tunnelLinks, link);
removeLinkFromStructure(switchPortLinks, link);
NodePortTuple n1 = new NodePortTuple(link.getSrc(), link.getSrcPort());
NodePortTuple n2 = new NodePortTuple(link.getDst(), link.getDstPort());
NodePortTuple srcNpt = new NodePortTuple(link.getSrc(), link.getSrcPort());
NodePortTuple dstNpt = new NodePortTuple(link.getDst(), link.getDstPort());
// Remove switch ports if there are no links through those switch ports
if (switchPortLinks.get(n1) == null) {
if (switchPorts.get(link.getSrc()) != null)
switchPorts.get(link.getSrc()).remove(link.getSrcPort());
if (switchPortLinks.get(srcNpt) == null) {
if (switchPorts.get(srcNpt.getNodeId()) != null)
switchPorts.get(srcNpt.getNodeId()).remove(srcNpt.getPortId());
}
if (switchPortLinks.get(n2) == null) {
if (switchPorts.get(link.getDst()) != null)
switchPorts.get(link.getDst()).remove(link.getDstPort());
if (switchPortLinks.get(dstNpt) == null) {
if (switchPorts.get(dstNpt.getNodeId()) != null)
switchPorts.get(dstNpt.getNodeId()).remove(dstNpt.getPortId());
}
// Remove the node if no ports are present
if (switchPorts.get(link.getSrc())!=null &&
switchPorts.get(link.getSrc()).isEmpty()) {
switchPorts.remove(link.getSrc());
if (switchPorts.get(srcNpt.getNodeId())!=null &&
switchPorts.get(srcNpt.getNodeId()).isEmpty()) {
switchPorts.remove(srcNpt.getNodeId());
}
if (switchPorts.get(link.getDst())!=null &&
switchPorts.get(link.getDst()).isEmpty()) {
switchPorts.remove(link.getDst());
if (switchPorts.get(dstNpt.getNodeId())!=null &&
switchPorts.get(dstNpt.getNodeId()).isEmpty()) {
switchPorts.remove(dstNpt.getNodeId());
}
}
......
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