Skip to content
Snippets Groups Projects
Commit 16da2f5a authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

Add switchClusterBroadcastDomainMap to maintain the set of broadcast domains...

Add switchClusterBroadcastDomainMap to maintain the set of broadcast domains connected to each cluster. [#23198243]
parent d69e73d6
No related branches found
No related tags found
No related merge requests found
......@@ -170,9 +170,13 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener,
protected Map<IOFSwitch, SwitchCluster> switchClusterMap;
protected Set<SwitchCluster> clusters;
protected Map<Long, BroadcastDomain> broadcastDomainMap;
protected Map<SwitchPortTuple, BroadcastDomain> switchPortBroadcastDomainMap;
//This map provides the ids of broadcast domains connected to a switch cluster
protected Map<Long, Set<Long>> switchClusterBroadcastDomainMap;
protected boolean isTopologyValid = false;
public static enum UpdateOperation {ADD, UPDATE, REMOVE,
......@@ -1302,6 +1306,7 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener,
Set<SwitchPortTuple> visitedSwt = new HashSet<SwitchPortTuple>();
Map<Long, BroadcastDomain> bdMap = new HashMap<Long, BroadcastDomain>();
Map<SwitchPortTuple, BroadcastDomain> spbdMap = new HashMap<SwitchPortTuple, BroadcastDomain>();
Map<Long, Set<Long>> scbdMap = new HashMap<Long, Set<Long>>();
// Do a breadth first search to get all the connected components
for(SwitchPortTuple swt: pbdLinks.keySet()) {
......@@ -1332,6 +1337,10 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener,
visitedSwt.add(otherSwt);
bd.add(otherSwt);
spbdMap.put(otherSwt, bd);
if (scbdMap.get(otherSwt.getSw().getSwitchClusterId()) == null) {
scbdMap.put(otherSwt.getSw().getSwitchClusterId(), new HashSet<Long>());
}
scbdMap.get(otherSwt.getSw().getSwitchClusterId()).add(bd.getId());
}
}
}
......@@ -1342,6 +1351,7 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener,
//Replace the current broadcast domains in the topology.
broadcastDomainMap = bdMap;
switchPortBroadcastDomainMap = spbdMap;
switchClusterBroadcastDomainMap = scbdMap;
if (bdMap.isEmpty()) {
if (log.isTraceEnabled()) {
......
......@@ -819,6 +819,7 @@ public class TopologyImplTest extends FloodlightTestCase {
topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt) == false);
assertTrue(topology.broadcastDomainMap.isEmpty());
assertTrue(topology.switchClusterBroadcastDomainMap.isEmpty());
topology.timeoutLinks();
......@@ -830,6 +831,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.isEmpty() == false);
assertTrue(topology.broadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
// Add a link info based on info that woudld be obtained from unicast LLDP
......@@ -844,6 +846,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()) == null ||
topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt) == false);
assertTrue(topology.broadcastDomainMap.size() == 0);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 0);
// Expect to timeout the unicast Valid Time, but not the multicast Valid time
......@@ -854,6 +857,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getSrc()).contains(lt));
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
// Set the multicastValidTime to be old and see if that also times out.
......@@ -865,6 +869,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()) == null ||
topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt) == false);
assertTrue(topology.broadcastDomainMap.size() == 0);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 0);
// Test again only with multicast LLDP
info = new LinkInfo(null, System.currentTimeMillis() - 40000, 0, 0);
......@@ -874,6 +879,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getSrc()).contains(lt));
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
// Call timeout and check if link is no longer present.
topology.timeoutLinks();
......@@ -883,6 +889,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()) == null ||
topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt) == false);
assertTrue(topology.broadcastDomainMap.size() == 0);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 0);
// Start clean and see if loops are also added.
lt = new LinkTuple(sw1, 1, sw1, 2);
......@@ -891,6 +898,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getSrc()).contains(lt));
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
// Start clean and see if loops are also added.
lt = new LinkTuple(sw1, 1, sw1, 3);
......@@ -899,6 +907,7 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getSrc()).contains(lt));
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
// Start clean and see if loops are also added.
lt = new LinkTuple(sw1, 4, sw1, 5);
......@@ -907,6 +916,8 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getSrc()).contains(lt));
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.size() == 2);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.get(new Long(1)).size() == 2);
// Start clean and see if loops are also added.
lt = new LinkTuple(sw1, 3, sw1, 5);
......@@ -915,6 +926,8 @@ public class TopologyImplTest extends FloodlightTestCase {
assertTrue(topology.portBroadcastDomainLinks.get(lt.getSrc()).contains(lt));
assertTrue(topology.portBroadcastDomainLinks.get(lt.getDst()).contains(lt));
assertTrue(topology.broadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.size() == 1);
assertTrue(topology.switchClusterBroadcastDomainMap.get(new Long(1)).size() == 1);
}
}
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