diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java index 3fe2b492e86cbed718d2089055ab15b60758f114..7d62a6c2812a5560d31bdcff0a600f2379c73e75 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java @@ -282,7 +282,7 @@ public class Device implements IDevice { if (!deviceManager.isValidAttachmentPoint(ap.getSw(), ap.getPort())) continue; - DatapathId id = deviceManager.topology.getOpenflowDomainId(ap.getSw()); + DatapathId id = deviceManager.topology.getClusterId(ap.getSw()); apMap.put(id, ap); } @@ -345,7 +345,7 @@ public class Device implements IDevice { Set<DatapathId> visitedIslands = new HashSet<DatapathId>(); for (AttachmentPoint ap : oldAPList) { - DatapathId id = topology.getOpenflowDomainId(ap.getSw()); + DatapathId id = topology.getClusterId(ap.getSw()); AttachmentPoint trueAP = apMap.get(id); if (trueAP == null) { @@ -367,7 +367,7 @@ public class Device implements IDevice { * has not expired, add them as duplicates to the list. */ for (AttachmentPoint ap : oldAPList) { - DatapathId id = topology.getOpenflowDomainId(ap.getSw()); + DatapathId id = topology.getClusterId(ap.getSw()); if (visitedIslands.contains(id)) { if (ap.getLastSeen().getTime() > timeThreshold) { dupAPs.add(ap); @@ -472,7 +472,7 @@ public class Device implements IDevice { return true; } - DatapathId id = topology.getOpenflowDomainId(sw); + DatapathId id = topology.getClusterId(sw); AttachmentPoint oldAP = apMap.get(id); if (oldAP == null) { // No attachment on this L2 domain. @@ -507,8 +507,7 @@ public class Device implements IDevice { oldAPList.addAll(oldAPs); oldAPList.add(oldAP); this.oldAPs = oldAPList; - if (!topology.isInSameBroadcastDomain(oldAP.getSw(), - oldAP.getPort(), newAP.getSw(), newAP.getPort())) + if (!topology.isInSameArchipelago(oldAP.getSw(), newAP.getSw())) /* different network */ return true; // attachment point changed. } else if (oldAPFlag) { // retain oldAP as is. Put the newAP in oldAPs for flagging @@ -710,9 +709,6 @@ public class Device implements IDevice { @Override public IPv4Address[] getIPv4Addresses() { - // XXX - TODO we can cache this result. Let's find out if this - // is really a performance bottleneck first though. - TreeSet<IPv4Address> vals = new TreeSet<IPv4Address>(); for (Entity e : entities) { if (e.getIpv4Address().equals(IPv4Address.NONE)) diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java index cdbeb2a345fff07d71244cfdb842c4189e639a89..95b662c440f477c7dc64e5b68a86875d8bab3035 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java @@ -340,12 +340,12 @@ public class DeviceManagerImpl implements IDeviceService, IOFMessageListener, IT DatapathId oldSw = oldAP.getSw(); OFPort oldPort = oldAP.getPort(); - DatapathId oldDomain = topology.getOpenflowDomainId(oldSw); + DatapathId oldDomain = topology.getClusterId(oldSw); boolean oldBD = topology.isBroadcastPort(oldSw, oldPort); DatapathId newSw = newAP.getSw(); OFPort newPort = newAP.getPort(); - DatapathId newDomain = topology.getOpenflowDomainId(newSw); + DatapathId newDomain = topology.getClusterId(newSw); boolean newBD = topology.isBroadcastPort(newSw, newPort); if (oldDomain.getLong() < newDomain.getLong()) return -1; diff --git a/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java b/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java index 729994886e773bb41edcb75e9885ed8a41d39f45..e85d64e80a937a45015b889de3b8566ad5ca13e9 100644 --- a/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java +++ b/src/main/java/net/floodlightcontroller/loadbalancer/LoadBalancer.java @@ -128,8 +128,8 @@ public class LoadBalancer implements IFloodlightModule, new Comparator<SwitchPort>() { @Override public int compare(SwitchPort d1, SwitchPort d2) { - DatapathId d1ClusterId = topologyService.getOpenflowDomainId(d1.getNodeId()); - DatapathId d2ClusterId = topologyService.getOpenflowDomainId(d2.getNodeId()); + DatapathId d1ClusterId = topologyService.getClusterId(d1.getNodeId()); + DatapathId d2ClusterId = topologyService.getClusterId(d2.getNodeId()); return d1ClusterId.compareTo(d2ClusterId); } }; @@ -384,7 +384,7 @@ public class LoadBalancer implements IFloodlightModule, // srcDevice and/or dstDevice is null, no route can be pushed if (srcDevice == null || dstDevice == null) return; - DatapathId srcIsland = topologyService.getOpenflowDomainId(sw.getId()); + DatapathId srcIsland = topologyService.getClusterId(sw.getId()); if (srcIsland == null) { log.debug("No openflow island found for source {}/{}", @@ -398,7 +398,7 @@ public class LoadBalancer implements IFloodlightModule, boolean on_same_if = false; for (SwitchPort dstDap : dstDevice.getAttachmentPoints()) { DatapathId dstSwDpid = dstDap.getNodeId(); - DatapathId dstIsland = topologyService.getOpenflowDomainId(dstSwDpid); + DatapathId dstIsland = topologyService.getClusterId(dstSwDpid); if ((dstIsland != null) && dstIsland.equals(srcIsland)) { on_same_island = true; if ((sw.getId().equals(dstSwDpid)) && OFMessageUtils.getInPort(pi).equals(dstDap.getPortId())) { @@ -442,9 +442,9 @@ public class LoadBalancer implements IFloodlightModule, SwitchPort srcDap = srcDaps[iSrcDaps]; SwitchPort dstDap = dstDaps[iDstDaps]; DatapathId srcCluster = - topologyService.getOpenflowDomainId(srcDap.getNodeId()); + topologyService.getClusterId(srcDap.getNodeId()); DatapathId dstCluster = - topologyService.getOpenflowDomainId(dstDap.getNodeId()); + topologyService.getClusterId(dstDap.getNodeId()); int srcVsDest = srcCluster.compareTo(dstCluster); if (srcVsDest == 0) { diff --git a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java index fa88fd069ca4c700fd41f2df999923b4504dd286..edaf28950dcd4a92546da36f34473a3358221a97 100644 --- a/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java +++ b/src/main/java/net/floodlightcontroller/routing/ForwardingBase.java @@ -128,8 +128,8 @@ public abstract class ForwardingBase implements IOFMessageListener { new Comparator<SwitchPort>() { @Override public int compare(SwitchPort d1, SwitchPort d2) { - DatapathId d1ClusterId = topologyService.getOpenflowDomainId(d1.getNodeId()); - DatapathId d2ClusterId = topologyService.getOpenflowDomainId(d2.getNodeId()); + DatapathId d1ClusterId = topologyService.getClusterId(d1.getNodeId()); + DatapathId d2ClusterId = topologyService.getClusterId(d2.getNodeId()); return d1ClusterId.compareTo(d2ClusterId); } }; diff --git a/src/main/java/net/floodlightcontroller/topology/ITopologyService.java b/src/main/java/net/floodlightcontroller/topology/ITopologyService.java index 9ddb132ab94016de604f3fcd0b9b283890be9655..6667d46f7f383f63baa7dc5795ccbb897c807cbd 100644 --- a/src/main/java/net/floodlightcontroller/topology/ITopologyService.java +++ b/src/main/java/net/floodlightcontroller/topology/ITopologyService.java @@ -97,18 +97,6 @@ public interface ITopologyService extends IFloodlightService { public boolean isConsistent(DatapathId oldSw, OFPort oldPort, DatapathId newSw, OFPort newPort); - /** - * Indicates if the two switch ports are connected to the same - * broadcast domain or not. - * @param s1 - * @param p1 - * @param s2 - * @param p2 - * @return - */ - public boolean isInSameBroadcastDomain(DatapathId s1, OFPort p1, - DatapathId s2, OFPort p2); - /** * Get broadcast ports on a target switch for a given attachment point * point port. @@ -138,10 +126,18 @@ public interface ITopologyService extends IFloodlightService { public NodePortTuple getAllowedIncomingBroadcastPort(DatapathId src, OFPort srcPort); /** - * Gets the set of ports that belong to a broadcast domain. + * Gets the set of ports that participate in the broadcast within each archipelago * @return */ - public Set<NodePortTuple> getBroadcastDomainPorts(); + public Set<NodePortTuple> getAllBroadcastPorts(); + + /** + * Gets the set of ports that participate in the broadcast trees for the + * archipelago in which the swtich belongs + * @param sw + * @return + */ + public Set<NodePortTuple> getBroadcastPortsInArchipelago(DatapathId sw); /** * Gets the set of ports that belong to tunnels. @@ -164,7 +160,7 @@ public interface ITopologyService extends IFloodlightService { * @param portId * @return */ - public boolean isAllowed(DatapathId sw, OFPort portId); + public boolean isNotBlocked(DatapathId sw, OFPort portId); /** * Returns the enabled, non quarantined ports of the given switch. Returns @@ -183,7 +179,15 @@ public interface ITopologyService extends IFloodlightService { * @param switchId * @return */ - public DatapathId getOpenflowDomainId(DatapathId switchId); + public DatapathId getClusterId(DatapathId switchId); + + /** + * Return the ID of the archipelago this switch is + * a part of. The ID is the lowest cluster DPID within the archipelago. + * @param switchId + * @return + */ + public DatapathId getArchipelagoId(DatapathId switchId); /** * Determines if two switches are in the same domain/island/cluster. @@ -191,14 +195,30 @@ public interface ITopologyService extends IFloodlightService { * @param switch2 * @return true if the switches are in the same cluster */ - public boolean inSameOpenflowDomain(DatapathId switch1, DatapathId switch2); + public boolean isInSameCluster(DatapathId switch1, DatapathId switch2); + + /** + * Determines if two switches are in the same archipelago. + * @param switch1 + * @param switch2 + * @return true if the switches are in the same archipelago + */ + public boolean isInSameArchipelago(DatapathId switch1, DatapathId switch2); /** * Gets all switches in the same domain/island/cluster as the switch provided. * @param switchDPID * @return */ - public Set<DatapathId> getSwitchesInOpenflowDomain(DatapathId switchDPID); + public Set<DatapathId> getSwitchesInCluster(DatapathId switchDPID); + + /** + * Gets all cluster IDs in the same archipelago as the switch provided. + * @param switchDPID + * @return + */ + public Set<DatapathId> getClusterIdsInArchipelago(DatapathId switchDPID); + /******************************************************* * LINK FUNCTIONS @@ -217,6 +237,24 @@ public interface ITopologyService extends IFloodlightService { * @return */ public Set<OFPort> getPortsWithLinks(DatapathId sw); + + /** + * Get all links that are: + * --external + * --detected via BDDP + * --connect two clusters + * @return + */ + public Set<Link> getExternalInterClusterLinks(); + + /** + * Get all links that are: + * --internal + * --detected via LLDP + * --connect two clusters + * @return + */ + public Set<Link> getInternalInterClusterLinks(); /******************************************************* * PATH-FINDING FUNCTIONS diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java index d72e16259bd8299d68412585a669a1b0e4e410c9..ec9c6c9642e730ee97d8fcb7c3eb8d05d268b6f1 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java @@ -29,7 +29,10 @@ import org.python.google.common.collect.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.collect.ImmutableSet; + import java.util.*; +import java.util.stream.Collectors; /** * A representation of a network topology. Used internally by @@ -47,75 +50,60 @@ public class TopologyInstance { private static final Logger log = LoggerFactory.getLogger(TopologyInstance.class); - private Map<DatapathId, Set<OFPort>> switchPorts; // Set of ports for each switch - /** Set of switch ports that are marked as blocked. A set of blocked - * switch ports may be provided at the time of instantiation. In addition, - * we may add additional ports to this set. - */ + /* Global: general switch, port, link */ + private Set<DatapathId> switches; + private Map<DatapathId, Set<OFPort>> allPortsWithLinks; /* only ports with links */ + private Map<DatapathId, Set<OFPort>> allPortsPerSwitch; /* every port on the switch */ + private Map<NodePortTuple, Set<Link>> allLinks; /* every link in entire topology */ + private Map<NodePortTuple, Set<Link>> nonBcastNonTunnelLinks; /* only non-broadcast and non-tunnel links */ + private Set<NodePortTuple> tunnelPorts; /* all tunnel ports in topology */ + private Set<NodePortTuple> broadcastPorts; /* all broadcast ports in topology */ + private Map<DatapathId, Set<OFPort>> broadcastPortMap; /* broadcast ports mapped per DPID */ + private Map<NodePortTuple, Set<Link>> externalLinks; /* BDDP links b/t clusters */ + + /* Blocked */ private Set<NodePortTuple> blockedPorts; - private Map<NodePortTuple, Set<Link>> switchPortLinks; // Set of links organized by node port tuple - /** Set of links that are blocked. */ private Set<Link> blockedLinks; - private Set<DatapathId> switches; - private Set<NodePortTuple> broadcastDomainPorts; - private Set<NodePortTuple> tunnelPorts; - - private Set<Cluster> clusters; // set of openflow domains - private Map<DatapathId, Cluster> switchClusterMap; // switch to OF domain map - - // States for routing - private Map<DatapathId, BroadcastTree> destinationRootedTrees; - + /* Per-cluster */ + private Set<Cluster> clusters; private Map<DatapathId, Set<NodePortTuple>> clusterPorts; + private Map<DatapathId, Cluster> switchClusterMap; private Map<DatapathId, BroadcastTree> clusterBroadcastTrees; - private Map<DatapathId, Set<NodePortTuple>> clusterBroadcastNodePorts; - //Set of NodePortTuples of the finiteBroadcastTree - private Set<NodePortTuple> broadcastNodePorts; - //destinationRootedTrees over whole topology (not only intra-cluster tree) - private Map<DatapathId, BroadcastTree> destinationRootedFullTrees; - //Set of all links organized by node port tuple. Note that switchPortLinks does not contain all links of multi-cluster topology. - private Map<NodePortTuple, Set<Link>> allLinks; - //Set of all ports organized by DatapathId. Note that switchPorts map contains only ports with links. - private Map<DatapathId, Set<OFPort>> allPorts; - //Set of all the inter-island or "external" links. Also known as portBroadcastDomainLinks in TopologyManager. - private Map<NodePortTuple, Set<Link>> externalLinks; - // Maps broadcast ports to DatapathId - private Map<DatapathId, Set<OFPort>> broadcastPortMap; + /* Per-archipelago */ private Set<Archipelago> archipelagos; - + private Set<NodePortTuple> portsWithMoreThanTwoLinks; + private Map<DatapathId, Set<NodePortTuple>> broadcastPortsPerArchipelago; + private Map<Cluster, Archipelago> clusterArchipelagoMap; private Set<Link> nonExternalInterClusterLinks; + private Map<RouteId, List<Route>> pathcache; /* contains computed paths ordered best to worst */ - // pathcache contains n (specified in floodlightdefault.properties) routes - // in order between every switch. Calculated using Yen's algorithm. - private Map<RouteId, List<Route>> pathcache; - - protected TopologyInstance(Map<DatapathId, Set<OFPort>> switchPorts, + protected TopologyInstance(Map<DatapathId, Set<OFPort>> allPortsWithLinks, Set<NodePortTuple> blockedPorts, - Map<NodePortTuple, Set<Link>> switchPortLinks, - Set<NodePortTuple> broadcastDomainPorts, + Map<NodePortTuple, Set<Link>> nonBcastNonTunnelLinks, + Set<NodePortTuple> portsWithMoreThanTwoLinks, Set<NodePortTuple> tunnelPorts, Map<NodePortTuple, Set<Link>> allLinks, - Map<DatapathId, Set<OFPort>> allPorts, + Map<DatapathId, Set<OFPort>> allPortsPerSwitch, Map<NodePortTuple, Set<Link>> externalLinks) { - this.switches = new HashSet<DatapathId>(switchPorts.keySet()); - this.switchPorts = new HashMap<DatapathId, Set<OFPort>>(); - for (DatapathId sw : switchPorts.keySet()) { - this.switchPorts.put(sw, new HashSet<OFPort>(switchPorts.get(sw))); + this.switches = new HashSet<DatapathId>(allPortsWithLinks.keySet()); + this.allPortsWithLinks = new HashMap<DatapathId, Set<OFPort>>(); + for (DatapathId sw : allPortsWithLinks.keySet()) { + this.allPortsWithLinks.put(sw, new HashSet<OFPort>(allPortsWithLinks.get(sw))); } - this.allPorts = new HashMap<DatapathId, Set<OFPort>>(); - for (DatapathId sw : allPorts.keySet()) { - this.allPorts.put(sw, new HashSet<OFPort>(allPorts.get(sw))); + this.allPortsPerSwitch = new HashMap<DatapathId, Set<OFPort>>(); + for (DatapathId sw : allPortsPerSwitch.keySet()) { + this.allPortsPerSwitch.put(sw, new HashSet<OFPort>(allPortsPerSwitch.get(sw))); } this.blockedPorts = new HashSet<NodePortTuple>(blockedPorts); - this.switchPortLinks = new HashMap<NodePortTuple, Set<Link>>(); - for (NodePortTuple npt : switchPortLinks.keySet()) { - this.switchPortLinks.put(npt, new HashSet<Link>(switchPortLinks.get(npt))); + this.nonBcastNonTunnelLinks = new HashMap<NodePortTuple, Set<Link>>(); + for (NodePortTuple npt : nonBcastNonTunnelLinks.keySet()) { + this.nonBcastNonTunnelLinks.put(npt, new HashSet<Link>(nonBcastNonTunnelLinks.get(npt))); } this.allLinks = new HashMap<NodePortTuple, Set<Link>>(); @@ -131,21 +119,24 @@ public class TopologyInstance { this.nonExternalInterClusterLinks = new HashSet<Link>(); this.archipelagos = new HashSet<Archipelago>(); - this.broadcastDomainPorts = new HashSet<NodePortTuple>(broadcastDomainPorts); + this.portsWithMoreThanTwoLinks = new HashSet<NodePortTuple>(portsWithMoreThanTwoLinks); this.tunnelPorts = new HashSet<NodePortTuple>(tunnelPorts); this.blockedLinks = new HashSet<Link>(); this.clusters = new HashSet<Cluster>(); this.switchClusterMap = new HashMap<DatapathId, Cluster>(); - this.destinationRootedTrees = new HashMap<DatapathId, BroadcastTree>(); - this.destinationRootedFullTrees= new HashMap<DatapathId, BroadcastTree>(); - this.broadcastNodePorts= new HashSet<NodePortTuple>(); + this.clusterBroadcastTrees = new HashMap<DatapathId, BroadcastTree>(); + this.broadcastPorts= new HashSet<NodePortTuple>(); this.broadcastPortMap = new HashMap<DatapathId,Set<OFPort>>(); this.clusterBroadcastTrees = new HashMap<DatapathId, BroadcastTree>(); this.clusterBroadcastNodePorts = new HashMap<DatapathId, Set<NodePortTuple>>(); this.pathcache = new HashMap<RouteId, List<Route>>(); + + this.broadcastPortsPerArchipelago = new HashMap<DatapathId, Set<NodePortTuple>>(); + + this.clusterArchipelagoMap = new HashMap<Cluster, Archipelago>(); } protected void compute() { @@ -158,12 +149,13 @@ public class TopologyInstance { // Avoid adding blocked links // Remaining links are inter-cluster links addIntraClusterLinks(); + + log.warn("Clusters {}", clusters); // Step 1.2 Compute the archipelagos (def: group of clusters). Each archipelago - // will have its own finiteBroadcastTree, which will be randomly chosen. This is - // because each achipelago is by definition isolated from all other archipelagos. - // The broadcast tree will not be set for each archipelago until after all paths - // have been computed. This is so we don't run dijkstras redundantly + // will have its own finiteBroadcastTree, which will be chosen by running dijkstra's + // algorithm from the archipelago ID switch (lowest switch DPID). This is + // because each archipelago is by definition isolated from all other archipelagos. calculateArchipelagos(); // Step 2. Compute shortest path trees in each cluster for @@ -180,13 +172,18 @@ public class TopologyInstance { // Step 4.1 Use Yens algorithm to compute multiple paths computeOrderedPaths(); + + //computeBroadcastPortsPerArchipelago(); // Step 5. Determine broadcast switch ports for each archipelago - computeBcastNPTsFromArchipelagos(); + //computeBcastNPTsFromArchipelagos(); // Step 6. Sort into set of broadcast ports per switch, for quick lookup. // Edge ports included - computeBcastPortsPerSwitchFromBcastNTPs(); + //computeBcastPortsPerSwitchFromBcastNTPs(); + + // Make immutable + //TODO makeDataImmutable(); // Step 7. print topology. printTopology(); @@ -227,23 +224,22 @@ public class TopologyInstance { log.info("Cluster Ports: {}", clusterPorts); log.info("Tunnel Ports: {}", tunnelPorts); log.info("Clusters: {}", clusters); - log.info("Destination Rooted Full Trees: {}", destinationRootedFullTrees); log.info("Cluser Broadcast Node Ports: {}", clusterBroadcastNodePorts); log.info("Broadcast Ports Per Node (!!): {}", broadcastPortMap); - log.info("Broadcast Domain Ports: {}", broadcastDomainPorts); - log.info("Broadcast Node Ports: {}", broadcastDomainPorts); + log.info("Broadcast Domain Ports: {}", portsWithMoreThanTwoLinks); + log.info("Broadcast Node Ports: {}", portsWithMoreThanTwoLinks); log.info("Archipelagos: {}", archipelagos); log.info("-----------------------------------------------"); } private void addIntraClusterLinks() { for (DatapathId s : switches) { - if (switchPorts.get(s) == null) continue; - for (OFPort p : switchPorts.get(s)) { + if (allPortsWithLinks.get(s) == null) continue; + for (OFPort p : allPortsWithLinks.get(s)) { NodePortTuple np = new NodePortTuple(s, p); - if (switchPortLinks.get(np) == null) continue; + if (nonBcastNonTunnelLinks.get(np) == null) continue; if (isBroadcastPort(np)) continue; - for (Link l : switchPortLinks.get(np)) { + for (Link l : nonBcastNonTunnelLinks.get(np)) { if (isBlockedLink(l)) continue; if (isBroadcastLink(l)) continue; Cluster c1 = switchClusterMap.get(l.getSrc()); @@ -338,9 +334,9 @@ public class TopologyInstance { currIndex++; // Traverse the graph through every outgoing link. - if (switchPorts.get(currSw) != null){ - for (OFPort p : switchPorts.get(currSw)) { - Set<Link> lset = switchPortLinks.get(new NodePortTuple(currSw, p)); + if (allPortsWithLinks.get(currSw) != null){ + for (OFPort p : allPortsWithLinks.get(currSw)) { + Set<Link> lset = nonBcastNonTunnelLinks.get(new NodePortTuple(currSw, p)); if (lset == null) continue; for (Link l : lset) { DatapathId dstSw = l.getDst(); @@ -454,8 +450,7 @@ public class TopologyInstance { } protected boolean isBroadcastPort(NodePortTuple npt) { - //archipelagos. - return broadcastDomainPorts.contains(npt); + return broadcastPorts.contains(npt); } private class NodeDist implements Comparable<NodeDist> { @@ -618,20 +613,26 @@ public class TopologyInstance { if (srcArchipelago != null && dstArchipelago != null && !srcArchipelago.equals(dstArchipelago)) { srcArchipelago.merge(dstArchipelago); archipelagos.remove(dstArchipelago); + clusterArchipelagoMap.put(dstCluster, srcArchipelago); } // If neither were found in an existing, then form a new archipelago. else if (srcArchipelago == null && dstArchipelago == null) { - archipelagos.add(new Archipelago().add(srcCluster).add(dstCluster)); + Archipelago a = new Archipelago().add(srcCluster).add(dstCluster); + archipelagos.add(a); + clusterArchipelagoMap.put(srcCluster, a); + clusterArchipelagoMap.put(dstCluster, a); } // If only one is found in an existing, then add the one not found to the existing. else if (srcArchipelago != null && dstArchipelago == null) { srcArchipelago.add(dstCluster); + clusterArchipelagoMap.put(dstCluster, srcArchipelago); } else if (srcArchipelago == null && dstArchipelago != null) { dstArchipelago.add(srcCluster); + clusterArchipelagoMap.put(srcCluster, dstArchipelago); } srcCluster = null; @@ -701,7 +702,7 @@ public class TopologyInstance { log.debug("Cost: {}", cost); log.debug("Neighbor cost: {}", cost.get(neighbor)); - if (!cost.containsKey(neighbor) || ndist < cost.get(neighbor)) { + if (ndist < cost.get(neighbor)) { cost.put(neighbor, ndist); nexthoplinks.put(neighbor, link); @@ -728,7 +729,7 @@ public class TopologyInstance { Map<Link, Integer> linkCost = new HashMap<Link, Integer>(); long rawLinkSpeed; int linkSpeedMBps; - int tunnel_weight = switchPorts.size() + 1; + int tunnel_weight = allPortsWithLinks.size() + 1; /* pathMetrics: * 1: Hop Count (Default Metrics) @@ -854,49 +855,36 @@ public class TopologyInstance { } private void calculateShortestPathTreeInClusters() { - destinationRootedTrees.clear(); + clusterBroadcastTrees.clear(); Map<Link, Integer> linkCost = new HashMap<Link, Integer>(); - int tunnel_weight = switchPorts.size() + 1; + int tunnel_weight = allPortsWithLinks.size() + 1; for (NodePortTuple npt : tunnelPorts) { - if (switchPortLinks.get(npt) == null) continue; - for (Link link : switchPortLinks.get(npt)) { + if (nonBcastNonTunnelLinks.get(npt) == null) continue; + for (Link link : nonBcastNonTunnelLinks.get(npt)) { if (link == null) continue; linkCost.put(link, tunnel_weight); } } for (Cluster c : clusters) { - for (DatapathId node : c.links.keySet()) { - BroadcastTree tree = clusterDijkstra(c, node, linkCost, true); - destinationRootedTrees.put(node, tree); - } - } - } - - private void calculateBroadcastTreeInClusters() { - for (Cluster c : clusters) { - // c.id is the smallest node that's in the cluster - BroadcastTree tree = destinationRootedTrees.get(c.id); - clusterBroadcastTrees.put(c.id, tree); + BroadcastTree tree = clusterDijkstra(c, c.getId(), linkCost, true); + clusterBroadcastTrees.put(c.getId(), tree); } } private void computeBcastNPTsFromArchipelagos() { - if (this.destinationRootedFullTrees.size() > 0) { - //this.finiteBroadcastTree = destinationRootedFullTrees.values().iterator().next(); - for (Archipelago a : archipelagos) { - Map<DatapathId, Link> links = a.getBroadcastTree().getLinks(); - if (links == null) return; - for (DatapathId nodeId : links.keySet()) { - Link l = links.get(nodeId); - if (l == null) continue; - NodePortTuple npt1 = new NodePortTuple(l.getSrc(), l.getSrcPort()); - NodePortTuple npt2 = new NodePortTuple(l.getDst(), l.getDstPort()); - this.broadcastNodePorts.add(npt1); - this.broadcastNodePorts.add(npt2); - } + for (Archipelago a : archipelagos) { + Map<DatapathId, Link> links = a.getBroadcastTree().getLinks(); + if (links == null) return; + for (DatapathId nodeId : links.keySet()) { + Link l = links.get(nodeId); + if (l == null) continue; + NodePortTuple npt1 = new NodePortTuple(l.getSrc(), l.getSrcPort()); + NodePortTuple npt2 = new NodePortTuple(l.getDst(), l.getDstPort()); + this.broadcastPorts.add(npt1); + this.broadcastPorts.add(npt2); } } } @@ -905,9 +893,9 @@ public class TopologyInstance { this.broadcastPortMap.clear(); for (DatapathId sw : this.switches) { - for (OFPort p : this.allPorts.get(sw)){ + for (OFPort p : this.allPortsPerSwitch.get(sw)){ NodePortTuple npt = new NodePortTuple(sw, p); - if (isEdge(sw, p) || broadcastNodePorts.contains(npt)) { + if (isEdge(sw, p) || broadcastPorts.contains(npt)) { if (broadcastPortMap.containsKey(sw)) { broadcastPortMap.get(sw).add(p); } else { @@ -919,13 +907,11 @@ public class TopologyInstance { } private void calculateBroadcastNodePortsInClusters() { - clusterBroadcastTrees.clear(); - - calculateBroadcastTreeInClusters(); + clusterBroadcastNodePorts.clear(); for (Cluster c : clusters) { // c.id is the smallest node that's in the cluster - BroadcastTree tree = clusterBroadcastTrees.get(c.id); + BroadcastTree tree = clusterBroadcastTrees.get(c.getId()); //log.info("Broadcast Tree {}", tree); Set<NodePortTuple> nptSet = new HashSet<NodePortTuple>(); @@ -939,7 +925,7 @@ public class TopologyInstance { nptSet.add(npt1); nptSet.add(npt2); } - clusterBroadcastNodePorts.put(c.id, nptSet); + clusterBroadcastNodePorts.put(c.getId(), nptSet); } } @@ -989,7 +975,7 @@ public class TopologyInstance { */ protected boolean pathExists(DatapathId srcId, DatapathId dstId) { - BroadcastTree bt = destinationRootedTrees.get(dstId); + BroadcastTree bt = clusterBroadcastTrees.get(dstId); if (bt == null) return false; Link link = bt.getLinks().get(srcId); if (link == null) return false; @@ -997,12 +983,12 @@ public class TopologyInstance { } private Map<DatapathId, Set<Link>> buildLinkDpidMap(Set<DatapathId> switches, Map<DatapathId, - Set<OFPort>> switchPorts, Map<NodePortTuple, Set<Link>> allLinks) { + Set<OFPort>> allPortsWithLinks, Map<NodePortTuple, Set<Link>> allLinks) { Map<DatapathId, Set<Link>> linkDpidMap = new HashMap<DatapathId, Set<Link>>(); for (DatapathId s : switches) { - if (switchPorts.get(s) == null) continue; - for (OFPort p : switchPorts.get(s)) { + if (allPortsWithLinks.get(s) == null) continue; + for (OFPort p : allPortsWithLinks.get(s)) { NodePortTuple np = new NodePortTuple(s, p); if (allLinks.get(np) == null) continue; for (Link l : allLinks.get(np)) { @@ -1072,7 +1058,7 @@ public class TopologyInstance { return new ArrayList<Route>(routes.subList(0, k)); } } - + private Archipelago getArchipelago(DatapathId d) { for (Archipelago a : archipelagos) { if (a.getSwitches().contains(d)) { @@ -1117,7 +1103,7 @@ public class TopologyInstance { // Find link costs Map<Link, Integer> linkCost = initLinkCostMap(); - Map<DatapathId, Set<Link>> linkDpidMap = buildLinkDpidMap(switches, switchPorts, allLinks); + Map<DatapathId, Set<Link>> linkDpidMap = buildLinkDpidMap(switches, allPortsWithLinks, allLinks); Map<DatapathId, Set<Link>> copyOfLinkDpidMap = new HashMap<DatapathId, Set<Link>>(linkDpidMap); @@ -1130,13 +1116,13 @@ public class TopologyInstance { if (K < 1) { return A; } - + /* The switch is not a member of an archipelago. It must not be connected */ if (aSrc == null || aDst == null) { log.warn("One or more switches not connected. Cannot compute path b/t {} and {}", src, dst); return A; } - + if (!aSrc.equals(aDst)) { log.warn("Switches {} and {} not in same archipelago. Cannot compute path", src, dst); return A; @@ -1197,7 +1183,7 @@ public class TopologyInstance { } // Builds the new topology without the parts we want removed - copyOfLinkDpidMap = buildLinkDpidMap(switchesCopy, switchPorts, allLinksCopy); + copyOfLinkDpidMap = buildLinkDpidMap(switchesCopy, allPortsWithLinks, allLinksCopy); //log.debug("About to build route."); //log.debug("Switches: {}", switchesCopy); @@ -1291,7 +1277,7 @@ public class TopologyInstance { // Add up the weights of each link in the path // TODO Get the path cost from the route object for (NodePortTuple npt : r.getPath()) { - if (allLinks.get(npt) == null || linkCost.get(allLinks.get(npt).iterator().next()) == null) { + if (allLinks.get(npt) == null || linkCost.get(allLinks.get(npt).iterator().next()) == null) { pathCost++; } else { @@ -1384,57 +1370,63 @@ public class TopologyInstance { return result == null ? new Route(id, ImmutableList.of()) : result; /* return empty route instead of null */ } - protected BroadcastTree getBroadcastTreeForCluster(long clusterId){ - Cluster c = switchClusterMap.get(clusterId); + protected BroadcastTree getBroadcastTreeForCluster(DatapathId id){ + Cluster c = switchClusterMap.get(id); if (c == null) return null; - return clusterBroadcastTrees.get(c.id); + return clusterBroadcastTrees.get(c.getId()); } // // ITopologyService interface method helpers. // - protected boolean isInternalToOpenflowDomain(DatapathId switchid, OFPort port) { + protected boolean isInternalLinkInCluster(DatapathId switchid, OFPort port) { return !isAttachmentPointPort(switchid, port); } public boolean isAttachmentPointPort(DatapathId switchid, OFPort port) { NodePortTuple npt = new NodePortTuple(switchid, port); - if (switchPortLinks.containsKey(npt)) return false; + if (nonBcastNonTunnelLinks.containsKey(npt)) { + return false; + } return true; } - protected DatapathId getOpenflowDomainId(DatapathId switchId) { + protected DatapathId getClusterId(DatapathId switchId) { Cluster c = switchClusterMap.get(switchId); - if (c == null) return switchId; - return c.getId(); + if (c != null) { + return c.getId(); + } + return switchId; } - protected DatapathId getL2DomainId(DatapathId switchId) { - return getOpenflowDomainId(switchId); + protected DatapathId getArchipelagoId(DatapathId switchId) { + Cluster c = switchClusterMap.get(switchId); + if (c != null) { + return clusterArchipelagoMap.get(c).getId(); + } + return switchId; } - protected Set<DatapathId> getSwitchesInOpenflowDomain(DatapathId switchId) { + protected Set<DatapathId> getSwitchesInCluster(DatapathId switchId) { Cluster c = switchClusterMap.get(switchId); - if (c == null) { - // The switch is not known to topology as there - // are no links connected to it. - Set<DatapathId> nodes = new HashSet<DatapathId>(); - nodes.add(switchId); - return nodes; - } - return (c.getNodes()); + if (c != null) { + return c.getNodes(); + } + /* The switch is not known to topology as there are no links connected to it. */ + return ImmutableSet.of(switchId); } - protected boolean inSameOpenflowDomain(DatapathId switch1, DatapathId switch2) { + protected boolean isInSameCluster(DatapathId switch1, DatapathId switch2) { Cluster c1 = switchClusterMap.get(switch1); Cluster c2 = switchClusterMap.get(switch2); - if (c1 != null && c2 != null) - return (c1.getId().equals(c2.getId())); + if (c1 != null && c2 != null) { + return c1.getId().equals(c2.getId()); + } return (switch1.equals(switch2)); } - public boolean isAllowed(DatapathId sw, OFPort portId) { + protected boolean isNotBlocked(DatapathId sw, OFPort portId) { return !isBlockedPort(new NodePortTuple(sw, portId)); } @@ -1444,56 +1436,56 @@ public class TopologyInstance { protected boolean isIncomingBroadcastAllowedOnSwitchPort(DatapathId sw, OFPort portId) { if (!isEdge(sw, portId)){ NodePortTuple npt = new NodePortTuple(sw, portId); - if (broadcastNodePorts.contains(npt)) + if (broadcastPorts.contains(npt)) return true; else return false; } return true; } - - public boolean isConsistent(DatapathId oldSw, OFPort oldPort, DatapathId newSw, OFPort newPort) { - if (isInternalToOpenflowDomain(newSw, newPort)) return true; + protected boolean isConsistent(DatapathId oldSw, OFPort oldPort, DatapathId newSw, OFPort newPort) { + if (isInternalLinkInCluster(newSw, newPort)) return true; return (oldSw.equals(newSw) && oldPort.equals(newPort)); } protected Set<NodePortTuple> getBroadcastNodePortsInCluster(DatapathId sw) { - DatapathId clusterId = getOpenflowDomainId(sw); + DatapathId clusterId = getClusterId(sw); return clusterBroadcastNodePorts.get(clusterId); } - public boolean inSameBroadcastDomain(DatapathId s1, OFPort p1, DatapathId s2, OFPort p2) { + protected boolean isInSameArchipelago(DatapathId s1, DatapathId s2) { + for (Archipelago a : archipelagos) { + if (a.getSwitches().contains(s1) && a.getSwitches().contains(s2)) { + return true; + } + } return false; } - public boolean inSameL2Domain(DatapathId switch1, DatapathId switch2) { - return inSameOpenflowDomain(switch1, switch2); - } - - public NodePortTuple getOutgoingSwitchPort(DatapathId src, OFPort srcPort, + protected NodePortTuple getOutgoingSwitchPort(DatapathId src, OFPort srcPort, DatapathId dst, OFPort dstPort) { // Use this function to redirect traffic if needed. return new NodePortTuple(dst, dstPort); } - public NodePortTuple getIncomingSwitchPort(DatapathId src, OFPort srcPort, + protected NodePortTuple getIncomingSwitchPort(DatapathId src, OFPort srcPort, DatapathId dst, OFPort dstPort) { // Use this function to reinject traffic from a // different port if needed. return new NodePortTuple(src, srcPort); } - public Set<DatapathId> getSwitches() { + protected Set<DatapathId> getSwitches() { return switches; } - public Set<OFPort> getPortsWithLinks(DatapathId sw) { - return switchPorts.get(sw); + protected Set<OFPort> getPortsWithLinks(DatapathId sw) { + return allPortsWithLinks.get(sw); } - public Set<OFPort> getBroadcastPorts(DatapathId targetSw, DatapathId src, OFPort srcPort) { + protected Set<OFPort> getBroadcastPorts(DatapathId targetSw, DatapathId src, OFPort srcPort) { Set<OFPort> result = new HashSet<OFPort>(); - DatapathId clusterId = getOpenflowDomainId(targetSw); + DatapathId clusterId = getClusterId(targetSw); for (NodePortTuple npt : clusterPorts.get(clusterId)) { if (npt.getNodeId().equals(targetSw)) { result.add(npt.getPortId()); @@ -1502,11 +1494,46 @@ public class TopologyInstance { return result; } - public NodePortTuple getAllowedOutgoingBroadcastPort(DatapathId src, OFPort srcPort, DatapathId dst, OFPort dstPort) { + protected NodePortTuple getAllowedOutgoingBroadcastPort(DatapathId src, OFPort srcPort, DatapathId dst, OFPort dstPort) { return null; } - public NodePortTuple getAllowedIncomingBroadcastPort(DatapathId src, OFPort srcPort) { + protected NodePortTuple getAllowedIncomingBroadcastPort(DatapathId src, OFPort srcPort) { return null; } -} \ No newline at end of file + + protected Set<Link> getInternalInterClusterLinks() { + return nonExternalInterClusterLinks; + } + + protected Set<NodePortTuple> getAllBroadcastPorts() { + return broadcastPorts; + } + + protected Set<DatapathId> getClusterIdsInArchipelago(DatapathId sw) { + Archipelago a = getArchipelago(sw); + if (a != null) { + return a.getClusters().stream().map(c -> c.getId()).collect(Collectors.toSet()); + } + return ImmutableSet.of(); + } + + private void computeBroadcastPortsPerArchipelago() { + ImmutableSet.Builder<NodePortTuple> s = ImmutableSet.builder(); + for (Archipelago a : archipelagos) { + for (Link l : a.getBroadcastTree().getLinks().values()) { + s.add(new NodePortTuple(l.getSrc(), l.getSrcPort())); + s.add(new NodePortTuple(l.getDst(), l.getDstPort())); + } + broadcastPortsPerArchipelago.put(a.getId(), s.build()); + } + } + + protected Set<NodePortTuple> getBroadcastPortsInArchipelago(DatapathId sw) { + Archipelago a = getArchipelago(sw); + if (a != null) { + return broadcastPortsPerArchipelago.get(a.getId()); + } + return ImmutableSet.of(); + } +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index 70f6568521860f48d71f7e5439d4a735c48755f0..01c92bcf6be61114b4b81072016f00bee4a37f01 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -48,6 +48,8 @@ import org.projectfloodlight.openflow.types.U64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.collect.ImmutableSet; + import java.util.*; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -96,7 +98,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo /** * set of links that are broadcast domain links. */ - protected Map<NodePortTuple, Set<Link>> portBroadcastDomainLinks; + protected Map<NodePortTuple, Set<Link>> interClusterLinks; /** * set of tunnel links @@ -222,7 +224,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo // **************** @Override - public Map<DatapathId, Set<Link>> getAllLinks(){ + public Map<DatapathId, Set<Link>> getAllLinks() { Map<DatapathId, Set<Link>> dpidLinks = new HashMap<DatapathId, Set<Link>>(); TopologyInstance ti = getCurrentInstance(); @@ -297,20 +299,21 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo } @Override - public DatapathId getOpenflowDomainId(DatapathId switchId) { + public DatapathId getClusterId(DatapathId switchId) { TopologyInstance ti = getCurrentInstance(); - return ti.getOpenflowDomainId(switchId); + return ti.getClusterId(switchId); } @Override - public boolean inSameOpenflowDomain(DatapathId switch1, DatapathId switch2) { + public boolean isInSameCluster(DatapathId switch1, DatapathId switch2) { TopologyInstance ti = getCurrentInstance(); - return ti.inSameOpenflowDomain(switch1, switch2); + return ti.isInSameCluster(switch1, switch2); } @Override - public boolean isAllowed(DatapathId sw, OFPort portId) { - return true; + public boolean isNotBlocked(DatapathId sw, OFPort port) { + TopologyInstance ti = getCurrentInstance(); + return !ti.isBlockedPort(new NodePortTuple(sw, port)); } @Override @@ -354,7 +357,6 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// - /** Get all the ports connected to the switch */ @Override public Set<OFPort> getPortsWithLinks(DatapathId sw) { TopologyInstance ti = getCurrentInstance(); @@ -364,7 +366,8 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// - /** Get all the ports on the target switch (targetSw) on which a + /** + * Get all the ports on the target switch (targetSw) on which a * broadcast packet must be sent from a host whose attachment point * is on switch port (src, srcPort). */ @@ -400,22 +403,17 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// - /** - * Checks if the two switchports belong to the same broadcast domain. - */ + @Override - public boolean isInSameBroadcastDomain(DatapathId s1, OFPort p1, - DatapathId s2, OFPort p2) { + public boolean isInSameArchipelago(DatapathId s1, DatapathId s2) { TopologyInstance ti = getCurrentInstance(); - return ti.inSameBroadcastDomain(s1, p1, s2, p2); + return ti.isInSameArchipelago(s1, s2); } //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// - /** - * Checks if the switchport is a broadcast port or not. - */ + @Override public boolean isBroadcastPort(DatapathId sw, OFPort port) { TopologyInstance ti = getCurrentInstance(); @@ -424,10 +422,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// - /** - * Checks if the new attachment point port is consistent with the - * old attachment point port. - */ + @Override public boolean isConsistent(DatapathId oldSw, OFPort oldPort, DatapathId newSw, OFPort newPort) { @@ -461,17 +456,29 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo //////////////////////////////////////////////////////////////////////// @Override - public Set<DatapathId> getSwitchesInOpenflowDomain(DatapathId switchDPID) { + public Set<DatapathId> getSwitchesInCluster(DatapathId switchDPID) { TopologyInstance ti = getCurrentInstance(); - return ti.getSwitchesInOpenflowDomain(switchDPID); + return ti.getSwitchesInCluster(switchDPID); } //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// @Override - public Set<NodePortTuple> getBroadcastDomainPorts() { - return portBroadcastDomainLinks.keySet(); + public Set<Link> getExternalInterClusterLinks() { + ImmutableSet.Builder<Link> b = ImmutableSet.builder(); + for (Collection<Link> c : interClusterLinks.values()) { + for (Link l : c) { + b.add(l); + } + } + return b.build(); } + + @Override + public Set<Link> getInternalInterClusterLinks() { + TopologyInstance ti = getCurrentInstance(); + return ti.getInternalInterClusterLinks(); + } @Override public Set<NodePortTuple> getTunnelPorts() { @@ -663,7 +670,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo switchPorts = new HashMap<DatapathId, Set<OFPort>>(); switchPortLinks = new HashMap<NodePortTuple, Set<Link>>(); directLinks = new HashMap<NodePortTuple, Set<Link>>(); - portBroadcastDomainLinks = new HashMap<NodePortTuple, Set<Link>>(); + interClusterLinks = new HashMap<NodePortTuple, Set<Link>>(); tunnelPorts = new HashSet<NodePortTuple>(); topologyAware = new ArrayList<ITopologyListener>(); ldUpdates = new LinkedBlockingQueue<LDUpdate>(); @@ -762,7 +769,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo // If the input port is not allowed for data traffic, drop everything. // BDDP packets will not reach this stage. - if (isAllowed(sw, inPort) == false) { + if (isNotBlocked(sw, inPort) == false) { if (log.isTraceEnabled()) { log.trace("Ignoring packet because of topology " + "restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber()); @@ -856,7 +863,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo TopologyInstance ti = getCurrentInstance(); - Set<DatapathId> switches = ti.getSwitchesInOpenflowDomain(pinSwitch); + Set<DatapathId> switches = ti.getSwitchesInCluster(pinSwitch); if (switches == null) { @@ -1063,7 +1070,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo tunnelPorts, switchPortLinks, allPorts, - portBroadcastDomainLinks); + interClusterLinks); nt.compute(); @@ -1081,7 +1088,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo Set<NodePortTuple> broadcastDomainPorts = new HashSet<NodePortTuple>(); - broadcastDomainPorts.addAll(this.portBroadcastDomainLinks.keySet()); + broadcastDomainPorts.addAll(this.interClusterLinks.keySet()); Set<NodePortTuple> additionalNpt = new HashSet<NodePortTuple>(); @@ -1246,7 +1253,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo addPortToSwitch(dstId, dstPort); addLinkToStructure(switchPortLinks, link); - addLinkToStructure(portBroadcastDomainLinks, link); + addLinkToStructure(interClusterLinks, link); dtLinksUpdated = removeLinkFromStructure(directLinks, link); linksUpdated = true; } else if (type.equals(LinkType.DIRECT_LINK)) { @@ -1255,7 +1262,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo addLinkToStructure(switchPortLinks, link); addLinkToStructure(directLinks, link); - removeLinkFromStructure(portBroadcastDomainLinks, link); + removeLinkFromStructure(interClusterLinks, link); dtLinksUpdated = true; linksUpdated = true; } else if (type.equals(LinkType.TUNNEL)) { @@ -1266,7 +1273,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo public void removeLink(Link link) { linksUpdated = true; dtLinksUpdated = removeLinkFromStructure(directLinks, link); - removeLinkFromStructure(portBroadcastDomainLinks, link); + removeLinkFromStructure(interClusterLinks, link); removeLinkFromStructure(switchPortLinks, link); NodePortTuple srcNpt = @@ -1305,7 +1312,7 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo switchPorts.clear(); tunnelPorts.clear(); switchPortLinks.clear(); - portBroadcastDomainLinks.clear(); + interClusterLinks.clear(); directLinks.clear(); } @@ -1325,18 +1332,14 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo /** * Getters. No Setters. */ - public Map<DatapathId, Set<OFPort>> getSwitchPorts() { + public Map<DatapathId, Set<OFPort>> getPortsPerSwitch() { return switchPorts; } - public Map<NodePortTuple, Set<Link>> getSwitchPortLinks() { + public Map<NodePortTuple, Set<Link>> getPortsOnLinks() { return switchPortLinks; } - public Map<NodePortTuple, Set<Link>> getPortBroadcastDomainLinks() { - return portBroadcastDomainLinks; - } - public TopologyInstance getCurrentInstance() { return this.currentInstance; } @@ -1359,4 +1362,28 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo return ports; } -} + + @Override + public Set<NodePortTuple> getBroadcastPortsInArchipelago(DatapathId sw) { + TopologyInstance ti = getCurrentInstance(); + return ti.getBroadcastPortsInArchipelago(sw); + } + + @Override + public DatapathId getArchipelagoId(DatapathId switchId) { + TopologyInstance ti = getCurrentInstance(); + return ti.getArchipelagoId(switchId); + } + + @Override + public Set<DatapathId> getClusterIdsInArchipelago(DatapathId sw) { + TopologyInstance ti = getCurrentInstance(); + return ti.getClusterIdsInArchipelago(sw); + } + + @Override + public Set<NodePortTuple> getAllBroadcastPorts() { + TopologyInstance ti = getCurrentInstance(); + return ti.getAllBroadcastPorts(); + } +} \ No newline at end of file diff --git a/src/main/java/net/floodlightcontroller/topology/web/BroadcastDomainPortsResource.java b/src/main/java/net/floodlightcontroller/topology/web/AllBroadcastPortsResource.java similarity index 90% rename from src/main/java/net/floodlightcontroller/topology/web/BroadcastDomainPortsResource.java rename to src/main/java/net/floodlightcontroller/topology/web/AllBroadcastPortsResource.java index 36288ba871f7e629d3665493ef26858dc745eb2b..80deb2e5de67d2efe6d2a6d21a2c69a5fe163868 100644 --- a/src/main/java/net/floodlightcontroller/topology/web/BroadcastDomainPortsResource.java +++ b/src/main/java/net/floodlightcontroller/topology/web/AllBroadcastPortsResource.java @@ -24,13 +24,13 @@ import net.floodlightcontroller.topology.ITopologyService; import org.restlet.resource.Get; import org.restlet.resource.ServerResource; -public class BroadcastDomainPortsResource extends ServerResource { +public class AllBroadcastPortsResource extends ServerResource { @Get("json") public Set<NodePortTuple> retrieve() { ITopologyService topology = (ITopologyService)getContext().getAttributes(). get(ITopologyService.class.getCanonicalName()); - return topology.getBroadcastDomainPorts(); + return topology.getAllBroadcastPorts(); } } diff --git a/src/main/java/net/floodlightcontroller/topology/web/SwitchClustersResource.java b/src/main/java/net/floodlightcontroller/topology/web/SwitchClustersResource.java index f62c8b1b73f2de99a376c376dedd2d8d114229cf..1b373cac2e20f8e92366cc2c7cfbfa5ec1d6fc20 100644 --- a/src/main/java/net/floodlightcontroller/topology/web/SwitchClustersResource.java +++ b/src/main/java/net/floodlightcontroller/topology/web/SwitchClustersResource.java @@ -54,8 +54,8 @@ public class SwitchClustersResource extends ServerResource { for (DatapathId dpid: switchService.getAllSwitchDpids()) { DatapathId clusterDpid = (openflowDomain - ? topologyService.getOpenflowDomainId(dpid) - :topologyService.getOpenflowDomainId(dpid)); + ? topologyService.getClusterId(dpid) + :topologyService.getClusterId(dpid)); List<String> switchesInCluster = switchClusterMap.get(clusterDpid.toString()); if (switchesInCluster != null) { switchesInCluster.add(dpid.toString()); diff --git a/src/main/java/net/floodlightcontroller/topology/web/TopologyWebRoutable.java b/src/main/java/net/floodlightcontroller/topology/web/TopologyWebRoutable.java index 26c53a55d9ac6e12ff8af5c1ef52d1cc597d185c..23b085c538ee67ea68b15d7db039aadae154b5c5 100644 --- a/src/main/java/net/floodlightcontroller/topology/web/TopologyWebRoutable.java +++ b/src/main/java/net/floodlightcontroller/topology/web/TopologyWebRoutable.java @@ -36,7 +36,7 @@ public class TopologyWebRoutable implements RestletRoutable { router.attach("/external-links/json", ExternalLinksResource.class); router.attach("/tunnellinks/json", TunnelLinksResource.class); router.attach("/switchclusters/json", SwitchClustersResource.class); - router.attach("/broadcastdomainports/json", BroadcastDomainPortsResource.class); + router.attach("/broadcastports/json", AllBroadcastPortsResource.class); router.attach("/enabledports/json", EnabledPortsResource.class); router.attach("/blockedports/json", BlockedPortsResource.class); router.attach("/path/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", PathResource.class); diff --git a/src/test/java/net/floodlightcontroller/accesscontrollist/ACLTest.java b/src/test/java/net/floodlightcontroller/accesscontrollist/ACLTest.java index 7fa8150689f0054e21390bb4062f2df6ea4233a6..cf01c8cdad2c57ae7776e61b0ec587f2312007c0 100644 --- a/src/test/java/net/floodlightcontroller/accesscontrollist/ACLTest.java +++ b/src/test/java/net/floodlightcontroller/accesscontrollist/ACLTest.java @@ -408,7 +408,7 @@ public class ACLTest extends FloodlightTestCase { public void testDeviceIPV4AddrChanged() { reset(topology); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(2L), OFPort.of(1))).andReturn(true).anyTimes(); replay(topology); diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java index fab12fe53e69da2e9f4506ade5095fd2bce061e7..9689f6eeca3adf3293b0be0d291c004c7c3e5daf 100644 --- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java +++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java @@ -154,13 +154,13 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ITopologyService mockTopology = createMock(ITopologyService.class); mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort())); expectLastCall().andReturn(true).anyTimes(); - mockTopology.getOpenflowDomainId(DatapathId.of(anyLong())); + mockTopology.getClusterId(DatapathId.of(anyLong())); expectLastCall().andReturn(DatapathId.of(1L)).anyTimes(); mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort())); expectLastCall().andReturn(false).anyTimes(); mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort())); expectLastCall().andReturn(false).anyTimes(); - mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort())); + mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), DatapathId.of(anyLong())); expectLastCall().andReturn(false).anyTimes(); return mockTopology; } @@ -403,7 +403,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { deviceManager.startUp(null); ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))). + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))). andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(false).anyTimes(); @@ -574,7 +574,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { deviceManager.startUp(null); ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))). + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))). andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(false).anyTimes(); @@ -784,18 +784,18 @@ public class DeviceManagerImplTest extends FloodlightTestCase { reset(mockListener); ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(1L))). + expect(mockTopology.getClusterId(DatapathId.of(1L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(5L))). + expect(mockTopology.getClusterId(DatapathId.of(5L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(10L))). + expect(mockTopology.getClusterId(DatapathId.of(10L))). andReturn(DatapathId.of(10L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(50L))). + expect(mockTopology.getClusterId(DatapathId.of(50L))). andReturn(DatapathId.of(10L)).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(false).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), OFPort.of(anyShort()), - DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes(); + expect(mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), + DatapathId.of(anyLong()))).andReturn(false).anyTimes(); expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); @@ -901,18 +901,17 @@ public class DeviceManagerImplTest extends FloodlightTestCase { reset(mockListener); ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(1L))). + expect(mockTopology.getClusterId(DatapathId.of(1L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(2L))). + expect(mockTopology.getClusterId(DatapathId.of(2L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(3L))). + expect(mockTopology.getClusterId(DatapathId.of(3L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(4L))). + expect(mockTopology.getClusterId(DatapathId.of(4L))). andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))) .andReturn(false).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), OFPort.of(anyShort()), - DatapathId.of(anyLong()), OFPort.of(anyShort()))) + expect(mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), DatapathId.of(anyLong()))) .andReturn(false).anyTimes(); expect(mockTopology.isAttachmentPointPort(or(eq(DatapathId.of(1L)), eq(DatapathId.of(3L))), OFPort.of(anyShort()))) @@ -1025,18 +1024,17 @@ public class DeviceManagerImplTest extends FloodlightTestCase { reset(mockListener); ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(1L))). /* two different OpenFlow islands, 1 and 10 */ + expect(mockTopology.getClusterId(DatapathId.of(1L))). /* two different OpenFlow islands, 1 and 10 */ andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(5L))). + expect(mockTopology.getClusterId(DatapathId.of(5L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(10L))). + expect(mockTopology.getClusterId(DatapathId.of(10L))). andReturn(DatapathId.of(10L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(50L))). + expect(mockTopology.getClusterId(DatapathId.of(50L))). andReturn(DatapathId.of(10L)).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))) .andReturn(false).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), OFPort.of(anyShort()), - DatapathId.of(anyLong()), OFPort.of(anyShort()))) + expect(mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), DatapathId.of(anyLong()))) .andReturn(false).anyTimes(); expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))) @@ -1131,17 +1129,14 @@ public class DeviceManagerImplTest extends FloodlightTestCase { @Test public void testBDAttachmentPointLearning() throws Exception { ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(1L), OFPort.of(1))). andReturn(false).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(1L), OFPort.of(2))). andReturn(true).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1), - DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2), - DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); + expect(mockTopology.isInSameArchipelago(DatapathId.of(1L), DatapathId.of(1L))).andReturn(true).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes(); Date topologyUpdateTime = new Date(); @@ -1192,7 +1187,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { @Test public void testLOCALAttachmentPointLearning() throws Exception { ITopologyService mockTopology = createMock(ITopologyService.class); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))). + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))). andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); @@ -1202,12 +1197,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { andReturn(false).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(1L), OFPort.of(2))). andReturn(true).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1), - DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.LOCAL, - DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2), - DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes(); + expect(mockTopology.isInSameArchipelago(DatapathId.of(1L), DatapathId.of(1L))).andReturn(true).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes(); Date topologyUpdateTime = new Date(); @@ -1265,11 +1255,9 @@ public class DeviceManagerImplTest extends FloodlightTestCase { OFPort.of(EasyMock.anyShort()))) .andReturn(false) .anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), - OFPort.of(anyShort()), - DatapathId.of(anyLong()), - OFPort.of(anyShort()))) + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), + DatapathId.of(anyLong()))) .andReturn(false).anyTimes(); } @@ -1728,8 +1716,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isBroadcastPort(DatapathId.of(1L), OFPort.of(1))).andReturn(false).anyTimes(); expect(mockTopology.isBroadcastPort(DatapathId.of(5L), OFPort.of(1))).andReturn(false).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); /* different islands */ - expect(mockTopology.getOpenflowDomainId(DatapathId.of(5L))).andReturn(DatapathId.of(5L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); /* different islands */ + expect(mockTopology.getClusterId(DatapathId.of(5L))).andReturn(DatapathId.of(5L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(1L), OFPort.of(1), DatapathId.of(5L), OFPort.of(1))). andReturn(false).anyTimes(); @@ -1817,8 +1805,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase { OFPort.of(EasyMock.anyShort()))). andReturn(true). anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(5L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(5L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(EasyMock.anyLong()), OFPort.of(EasyMock.anyShort()), DatapathId.of(EasyMock.anyLong()), @@ -1962,9 +1950,9 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(false).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), OFPort.of(anyShort()), - DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))). + expect(mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), DatapathId.of(anyLong()))) + .andReturn(false).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))). andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(1L), OFPort.of(1), DatapathId.of(1L), OFPort.of(1))). andReturn(true).anyTimes(); @@ -2052,11 +2040,11 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isBroadcastPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(false).anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()), OFPort.of(anyShort()), - DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(1L))). + expect(mockTopology.isInSameArchipelago(DatapathId.of(anyLong()), DatapathId.of(anyLong()))) + .andReturn(false).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(1L))). andReturn(DatapathId.of(1L)).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(5L))). + expect(mockTopology.getClusterId(DatapathId.of(5L))). andReturn(DatapathId.of(5L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(1L), OFPort.of(1), DatapathId.of(1L), OFPort.of(2))). andReturn(false).anyTimes(); @@ -2233,7 +2221,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); replay(mockTopology); doTestDeviceQuery(); } @@ -2245,7 +2233,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); replay(mockTopology); doTestDeviceQuery(); @@ -2330,7 +2318,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); replay(mockTopology); doTestDeviceClassQuery(); @@ -2342,7 +2330,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { deviceManager.topology = mockTopology; expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); replay(mockTopology); doTestDeviceClassQuery(); @@ -2359,7 +2347,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); replay(mockTopology); Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.of(1), IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), new Date()); @@ -2493,7 +2481,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(EasyMock.anyLong()), OFPort.of(EasyMock.anyShort()), DatapathId.of(EasyMock.anyLong()), @@ -2504,10 +2492,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase { OFPort.of(EasyMock.anyShort()))) .andReturn(false) .anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(EasyMock.anyLong()), - OFPort.of(EasyMock.anyShort()), - DatapathId.of(EasyMock.anyLong()), - OFPort.of(EasyMock.anyShort()))). + expect(mockTopology.isInSameArchipelago(DatapathId.of(EasyMock.anyLong()), + DatapathId.of(EasyMock.anyLong()))). andReturn(false).anyTimes(); replay(mockTopology); @@ -2604,7 +2590,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(EasyMock.anyLong()), OFPort.of(EasyMock.anyShort()), DatapathId.of(EasyMock.anyLong()), @@ -2615,10 +2601,8 @@ public class DeviceManagerImplTest extends FloodlightTestCase { OFPort.of(EasyMock.anyShort()))) .andReturn(false) .anyTimes(); - expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(EasyMock.anyLong()), - OFPort.of(EasyMock.anyShort()), - DatapathId.of(EasyMock.anyLong()), - OFPort.of(EasyMock.anyShort()))). + expect(mockTopology.isInSameArchipelago(DatapathId.of(EasyMock.anyLong()), + DatapathId.of(EasyMock.anyLong()))). andReturn(false).anyTimes(); replay(mockTopology); @@ -2742,7 +2726,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase { expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))). andReturn(true).anyTimes(); - expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(mockTopology.getClusterId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes(); expect(mockTopology.isConsistent(DatapathId.of(EasyMock.anyLong()), OFPort.of(EasyMock.anyShort()), DatapathId.of(EasyMock.anyLong()), diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java index 7b32b47340e09fbb2e98157cbbf3e02ac087c9f6..6fd9878a2e59f7d6474c25bb63e2518889985a79 100644 --- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java +++ b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java @@ -468,8 +468,8 @@ public class ForwardingTest extends FloodlightTestCase { expect(sw2.write(capture(wc2))).andReturn(true).anyTimes(); reset(topology); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(2L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(2L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(2L), OFPort.of(3))).andReturn(true).anyTimes(); expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); @@ -538,8 +538,8 @@ public class ForwardingTest extends FloodlightTestCase { expect(sw2.write(capture(wc2))).andReturn(true).anyTimes(); reset(topology); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(2L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(2L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(2L), OFPort.of(3))).andReturn(true).anyTimes(); expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); @@ -605,7 +605,7 @@ public class ForwardingTest extends FloodlightTestCase { reset(topology); expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes(); expect(topology.isEdge(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); @@ -659,7 +659,7 @@ public class ForwardingTest extends FloodlightTestCase { reset(topology); expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes(); expect(topology.isEdge(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); @@ -687,7 +687,7 @@ public class ForwardingTest extends FloodlightTestCase { reset(topology); expect(topology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))) .andReturn(true).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); replay(topology); @@ -723,7 +723,7 @@ public class ForwardingTest extends FloodlightTestCase { reset(topology); expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes(); diff --git a/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java b/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java index c84d7039d3c23d288f38fa1a222c673ed839ce02..0a55c3151b58079da3e48e467fcc35fb1343bc0e 100644 --- a/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java +++ b/src/test/java/net/floodlightcontroller/loadbalancer/LoadBalancerTest.java @@ -460,7 +460,7 @@ public class LoadBalancerTest extends FloodlightTestCase { // Build topology reset(topology); expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes(); - expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); + expect(topology.getClusterId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes(); expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes(); diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java index ce97e92d6b2197d34370d6570aaffe02bcf2f2e6..4e82bf85a6a8d95e651cd64300bd46c94344f6d9 100644 --- a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java +++ b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java @@ -102,7 +102,7 @@ public class TopologyInstanceTest { } } if (expectedCluster != null) { - Set<DatapathId> cluster = ti.getSwitchesInOpenflowDomain(sw); + Set<DatapathId> cluster = ti.getSwitchesInCluster(sw); assertEquals(expectedCluster.length, cluster.size()); for (DatapathId sw2: cluster) { assertTrue(Arrays.binarySearch(expectedCluster, (int)sw2.getLong()) >= 0); @@ -690,7 +690,6 @@ public class TopologyInstanceTest { * NOTE: Output from the next four log.info should be mirrored! * Get paths based on latency. */ - topologyManager.clearCurrentTopology(); topologyManager.setPathMetric(LATENCY); configureTopology(linkArray, lat); List<Route> lat_paths = topologyManager.getPathsFast(one, three, k); diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java index 5310f0af93fac8a3bc0ee29500228251c3aeefc7..9ea244acd4269958cfb4fb35f5e24b911b36a9ba 100644 --- a/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java +++ b/src/test/java/net/floodlightcontroller/topology/TopologyManagerTest.java @@ -58,74 +58,74 @@ public class TopologyManagerTest extends FloodlightTestCase { @Test public void testBasic1() throws Exception { tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), U64.ZERO, ILinkDiscovery.LinkType.DIRECT_LINK); - assertTrue(tm.getSwitchPorts().size() == 2); // for two nodes. - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1); - assertTrue(tm.getSwitchPortLinks().size()==2); - assertTrue(tm.getPortBroadcastDomainLinks().size()==0); + assertTrue(tm.getPortsPerSwitch().size() == 2); // for two nodes. + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1)).size()==1); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==1); + assertTrue(tm.getPortsOnLinks().size()==2); + assertEquals(0, tm.getExternalInterClusterLinks().size()); assertTrue(tm.getTunnelPorts().size()==0); tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(2), DatapathId.of(2), OFPort.of(2), U64.ZERO, ILinkDiscovery.LinkType.MULTIHOP_LINK); - assertTrue(tm.getSwitchPorts().size() == 2); // for two nodes. - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==2); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==2); - assertTrue(tm.getSwitchPortLinks().size()==4); - assertTrue(tm.getPortBroadcastDomainLinks().size()==2); + assertTrue(tm.getPortsPerSwitch().size() == 2); // for two nodes. + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1)).size()==2); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==2); + assertTrue(tm.getPortsOnLinks().size()==4); + assertEquals(1, tm.getExternalInterClusterLinks().size()); assertTrue(tm.getTunnelPorts().size()==0); tm.removeLink(DatapathId.of(1), OFPort.of(2), DatapathId.of(2), OFPort.of(2)); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1); - assertTrue(tm.getSwitchPorts().size() == 2); - assertTrue(tm.getSwitchPortLinks().size()==2); - assertTrue(tm.getPortBroadcastDomainLinks().size()==0); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1)).size()==1); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==1); + assertTrue(tm.getPortsPerSwitch().size() == 2); + assertTrue(tm.getPortsOnLinks().size()==2); + assertEquals(0, tm.getExternalInterClusterLinks().size()); tm.removeLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1)); - assertTrue(tm.getSwitchPorts().size() == 0); - assertTrue(tm.getSwitchPortLinks().size()==0); - assertTrue(tm.getPortBroadcastDomainLinks().size()==0); + assertTrue(tm.getPortsPerSwitch().size() == 0); + assertTrue(tm.getPortsOnLinks().size()==0); + assertEquals(0, tm.getExternalInterClusterLinks().size()); } @Test public void testBasic2() throws Exception { tm.addOrUpdateLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1), U64.ZERO, ILinkDiscovery.LinkType.DIRECT_LINK); tm.addOrUpdateLink(DatapathId.of(2), OFPort.of(2), DatapathId.of(3), OFPort.of(1), U64.ZERO, ILinkDiscovery.LinkType.MULTIHOP_LINK); - assertTrue(tm.getSwitchPorts().size() == 3); // for two nodes. - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)).size()==1); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==2); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1); - assertTrue(tm.getSwitchPortLinks().size()==4); - assertTrue(tm.getPortBroadcastDomainLinks().size()==2); + assertTrue(tm.getPortsPerSwitch().size() == 3); // for two nodes. + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1)).size()==1); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==2); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(3)).size()==1); + assertTrue(tm.getPortsOnLinks().size()==4); + assertEquals(1, tm.getExternalInterClusterLinks().size()); tm.removeLink(DatapathId.of(1), OFPort.of(1), DatapathId.of(2), OFPort.of(1)); - assertTrue(tm.getSwitchPorts().size() == 2); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)) == null); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1); - assertTrue(tm.getSwitchPortLinks().size()==2); - assertTrue(tm.getPortBroadcastDomainLinks().size()==2); + assertTrue(tm.getPortsPerSwitch().size() == 2); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1)) == null); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==1); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(3)).size()==1); + assertTrue(tm.getPortsOnLinks().size()==2); + assertEquals(1, tm.getExternalInterClusterLinks().size()); // nonexistent link // no null pointer exceptions. tm.removeLink(DatapathId.of(3), OFPort.of(1), DatapathId.of(2), OFPort.of(2)); - assertTrue(tm.getSwitchPorts().size() == 2); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1)) == null); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1); - assertTrue(tm.getSwitchPortLinks().size()==2); - assertTrue(tm.getPortBroadcastDomainLinks().size()==2); + assertTrue(tm.getPortsPerSwitch().size() == 2); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1)) == null); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==1); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(3)).size()==1); + assertTrue(tm.getPortsOnLinks().size()==2); + assertEquals(1, tm.getExternalInterClusterLinks().size()); tm.removeLink(DatapathId.of(3), OFPort.of(2), DatapathId.of(1), OFPort.of(2)); - assertTrue(tm.getSwitchPorts().size() == 2); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(1))==null); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(2)).size()==1); - assertTrue(tm.getSwitchPorts().get(DatapathId.of(3)).size()==1); - assertTrue(tm.getSwitchPortLinks().size()==2); - assertTrue(tm.getPortBroadcastDomainLinks().size()==2); + assertTrue(tm.getPortsPerSwitch().size() == 2); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(1))==null); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(2)).size()==1); + assertTrue(tm.getPortsPerSwitch().get(DatapathId.of(3)).size()==1); + assertTrue(tm.getPortsOnLinks().size()==2); + assertEquals(1, tm.getExternalInterClusterLinks().size()); tm.removeLink(DatapathId.of(2), OFPort.of(2), DatapathId.of(3), OFPort.of(1)); - assertTrue(tm.getSwitchPorts().size() == 0); // for two nodes. - assertTrue(tm.getSwitchPortLinks().size()==0); - assertTrue(tm.getPortBroadcastDomainLinks().size()==0); + assertTrue(tm.getPortsPerSwitch().size() == 0); // for two nodes. + assertTrue(tm.getPortsOnLinks().size()==0); + assertEquals(0, tm.getExternalInterClusterLinks().size()); assertTrue(tm.getTunnelPorts().size()==0); }