From fdfe6f9fa93dcfb1b941e61a590b20ea75911791 Mon Sep 17 00:00:00 2001 From: Madhavan Kasthurirangan Date: Thu, 2 May 2013 13:44:52 -0700 Subject: [PATCH] edgeUpdate API enhancement and related changes. Signed-off-by: Madhavan Kasthurirangan --- opendaylight/arphandler/pom.xml | 2 +- .../services_implementation/pom.xml | 2 +- opendaylight/clustering/stub/pom.xml | 2 +- opendaylight/configuration/api/pom.xml | 2 +- .../configuration/implementation/pom.xml | 2 +- opendaylight/containermanager/api/pom.xml | 2 +- .../containermanager/implementation/pom.xml | 2 +- opendaylight/forwarding/staticrouting/pom.xml | 2 +- .../forwardingrulesmanager/api/pom.xml | 2 +- .../implementation/pom.xml | 2 +- .../internal/FRMIntegrationTest.java | 4 +- opendaylight/hosttracker/api/pom.xml | 2 +- .../hosttracker/implementation/pom.xml | 3 +- .../hosttracker/internal/HostTracker.java | 512 ++++++------ .../hosttracker/integrationtest/pom.xml | 2 +- .../internal/HostTrackerIntegrationTest.java | 2 +- opendaylight/northbound/commons/pom.xml | 2 +- .../northbound/flowprogrammer/pom.xml | 4 +- opendaylight/northbound/hosttracker/pom.xml | 4 +- opendaylight/northbound/staticrouting/pom.xml | 4 +- opendaylight/northbound/statistics/pom.xml | 4 +- opendaylight/northbound/subnets/pom.xml | 4 +- opendaylight/northbound/switchmanager/pom.xml | 4 +- opendaylight/northbound/topology/pom.xml | 4 +- .../protocol_plugins/openflow/pom.xml | 2 +- .../openflow/internal/TopologyServices.java | 8 +- opendaylight/protocol_plugins/stub/pom.xml | 2 +- .../routing/dijkstra_implementation/pom.xml | 3 +- .../internal/DijkstraImplementation.java | 190 +++-- .../dijkstra_implementation/DijkstraTest.java | 79 +- .../MaxThruputTest.java | 76 +- opendaylight/sal/api/pom.xml | 2 +- .../sal/topology/IListenTopoUpdates.java | 28 +- .../topology/IPluginOutTopologyService.java | 21 +- .../sal/topology/TopoEdgeUpdate.java | 62 ++ opendaylight/sal/implementation/pom.xml | 2 +- .../sal/implementation/internal/Topology.java | 18 +- opendaylight/samples/loadbalancer/pom.xml | 2 +- .../samples/northbound/loadbalancer/pom.xml | 4 +- opendaylight/samples/simpleforwarding/pom.xml | 2 +- opendaylight/security/pom.xml | 2 +- opendaylight/statisticsmanager/api/pom.xml | 2 +- .../statisticsmanager/implementation/pom.xml | 2 +- .../statisticsmanager/integrationtest/pom.xml | 2 +- .../StatisticsManagerIntegrationTest.java | 2 +- opendaylight/switchmanager/api/pom.xml | 2 +- .../switchmanager/implementation/pom.xml | 2 +- opendaylight/topologymanager/pom.xml | 2 +- .../internal/TopologyManagerImpl.java | 251 +++--- .../internal/TopologyManagerImplTest.java | 766 ++++++++++-------- opendaylight/usermanager/pom.xml | 2 +- opendaylight/web/devices/pom.xml | 2 +- opendaylight/web/flows/pom.xml | 2 +- opendaylight/web/root/pom.xml | 2 +- opendaylight/web/topology/pom.xml | 2 +- opendaylight/web/troubleshoot/pom.xml | 2 +- 56 files changed, 1185 insertions(+), 936 deletions(-) create mode 100644 opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java diff --git a/opendaylight/arphandler/pom.xml b/opendaylight/arphandler/pom.xml index cf3aff744f..80d8598d45 100644 --- a/opendaylight/arphandler/pom.xml +++ b/opendaylight/arphandler/pom.xml @@ -56,7 +56,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/clustering/services_implementation/pom.xml b/opendaylight/clustering/services_implementation/pom.xml index 82a97b666f..80fc1c4099 100644 --- a/opendaylight/clustering/services_implementation/pom.xml +++ b/opendaylight/clustering/services_implementation/pom.xml @@ -70,7 +70,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/clustering/stub/pom.xml b/opendaylight/clustering/stub/pom.xml index 2670c723f4..ab4ef5ad86 100644 --- a/opendaylight/clustering/stub/pom.xml +++ b/opendaylight/clustering/stub/pom.xml @@ -46,7 +46,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/configuration/api/pom.xml b/opendaylight/configuration/api/pom.xml index 0af960d962..3993b5e71f 100644 --- a/opendaylight/configuration/api/pom.xml +++ b/opendaylight/configuration/api/pom.xml @@ -39,7 +39,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/configuration/implementation/pom.xml b/opendaylight/configuration/implementation/pom.xml index bac0184092..467e9ca1ed 100644 --- a/opendaylight/configuration/implementation/pom.xml +++ b/opendaylight/configuration/implementation/pom.xml @@ -56,7 +56,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/containermanager/api/pom.xml b/opendaylight/containermanager/api/pom.xml index 8b5ccdf780..2b354752b3 100644 --- a/opendaylight/containermanager/api/pom.xml +++ b/opendaylight/containermanager/api/pom.xml @@ -45,7 +45,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/containermanager/implementation/pom.xml b/opendaylight/containermanager/implementation/pom.xml index 1ead516adc..9e2f5662ef 100644 --- a/opendaylight/containermanager/implementation/pom.xml +++ b/opendaylight/containermanager/implementation/pom.xml @@ -62,7 +62,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/forwarding/staticrouting/pom.xml b/opendaylight/forwarding/staticrouting/pom.xml index 38f18bf67c..28f3e25d41 100644 --- a/opendaylight/forwarding/staticrouting/pom.xml +++ b/opendaylight/forwarding/staticrouting/pom.xml @@ -80,7 +80,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/forwardingrulesmanager/api/pom.xml b/opendaylight/forwardingrulesmanager/api/pom.xml index 6b639e3c63..382b11d4a3 100644 --- a/opendaylight/forwardingrulesmanager/api/pom.xml +++ b/opendaylight/forwardingrulesmanager/api/pom.xml @@ -83,7 +83,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT junit diff --git a/opendaylight/forwardingrulesmanager/implementation/pom.xml b/opendaylight/forwardingrulesmanager/implementation/pom.xml index 0031773029..d9faed36b9 100644 --- a/opendaylight/forwardingrulesmanager/implementation/pom.xml +++ b/opendaylight/forwardingrulesmanager/implementation/pom.xml @@ -126,7 +126,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java index 73c6d79d6a..8fa37b5471 100644 --- a/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java +++ b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java @@ -83,7 +83,7 @@ public class FRMIntegrationTest { mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"), // List all the bundles on which the test case depends mavenBundle("org.opendaylight.controller", "sal", - "0.4.0-SNAPSHOT"), + "0.5.0-SNAPSHOT"), mavenBundle("org.opendaylight.controller", "sal.implementation", "0.4.0-SNAPSHOT"), @@ -201,4 +201,4 @@ public class FRMIntegrationTest { Assert.assertTrue(stat.getCode().equals(StatusCode.NOTACCEPTABLE)); } -} \ No newline at end of file +} diff --git a/opendaylight/hosttracker/api/pom.xml b/opendaylight/hosttracker/api/pom.xml index 59290efbd5..f60b386baf 100644 --- a/opendaylight/hosttracker/api/pom.xml +++ b/opendaylight/hosttracker/api/pom.xml @@ -66,7 +66,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/hosttracker/implementation/pom.xml b/opendaylight/hosttracker/implementation/pom.xml index 1f24e06bad..402dfe32e3 100644 --- a/opendaylight/hosttracker/implementation/pom.xml +++ b/opendaylight/hosttracker/implementation/pom.xml @@ -46,6 +46,7 @@ org.opendaylight.controller.sal.core, org.opendaylight.controller.sal.utils, + org.opendaylight.controller.sal.topology, org.opendaylight.controller.hosttracker, org.opendaylight.controller.topologymanager, org.opendaylight.controller.sal.packet.address, @@ -112,7 +113,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java index d0f8bb5736..7c312e1577 100644 --- a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -30,7 +29,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.felix.dm.Component; -import org.apache.taglibs.standard.lang.jstl.DivideOperator; import org.opendaylight.controller.clustering.services.CacheConfigException; import org.opendaylight.controller.clustering.services.CacheExistException; import org.opendaylight.controller.clustering.services.IClusterContainerServices; @@ -51,6 +49,7 @@ import org.opendaylight.controller.sal.core.Tier; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.packet.address.DataLinkAddress; import org.opendaylight.controller.sal.packet.address.EthernetAddress; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.HexEncode; import org.opendaylight.controller.sal.utils.NodeCreator; @@ -66,16 +65,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * @file HostTracker.java - * This class tracks the location of IP Hosts as to which Switch, Port, VLAN, they are - * connected to, as well as their MAC address. This is done dynamically as well as statically. - * The dynamic mechanism consists of listening to ARP messages as well sending ARP requests. - * Static mechanism consists of Northbound APIs to add or remove the hosts from the local - * database. ARP aging is also implemented to age out dynamically learned hosts. Interface - * methods are provided for other applications to - * 1. Query the local database for a single host - * 2. Get a list of all hosts - * 3. Get notification if a host is learned/added or removed the database + * @file HostTracker.java This class tracks the location of IP Hosts as to which + * Switch, Port, VLAN, they are connected to, as well as their MAC + * address. This is done dynamically as well as statically. The dynamic + * mechanism consists of listening to ARP messages as well sending ARP + * requests. Static mechanism consists of Northbound APIs to add or remove + * the hosts from the local database. ARP aging is also implemented to age + * out dynamically learned hosts. Interface methods are provided for other + * applications to 1. Query the local database for a single host 2. Get a + * list of all hosts 3. Get notification if a host is learned/added or + * removed the database */ public class HostTracker implements IfIptoHost, IfHostListener, @@ -84,9 +83,10 @@ public class HostTracker implements IfIptoHost, IfHostListener, .getLogger(HostTracker.class); private IHostFinder hostFinder; private ConcurrentMap hostsDB; - /* Following is a list of hosts which have been requested by NB APIs to be added, - * but either the switch or the port is not sup, so they will be added here until - * both come up + /* + * Following is a list of hosts which have been requested by NB APIs to be + * added, but either the switch or the port is not sup, so they will be + * added here until both come up */ private ConcurrentMap inactiveStaticHosts; private Set newHostNotify = Collections @@ -129,22 +129,23 @@ public class HostTracker implements IfIptoHost, IfHostListener, } } - //This list contains the hosts for which ARP requests are being sent periodically + // This list contains the hosts for which ARP requests are being sent + // periodically private List ARPPendingList = new ArrayList(); /* - * This list below contains the hosts which were initially in ARPPendingList above, - * but ARP response didn't come from there hosts after multiple attempts over 8 - * seconds. The assumption is that the response didn't come back due to one of the - * following possibilities: - * 1. The L3 interface wasn't created for this host in the controller. This would - * cause arphandler not to know where to send the ARP - * 2. The host facing port is down - * 3. The IP host doesn't exist or is not responding to ARP requests - * - * Conditions 1 and 2 above can be recovered if ARP is sent when the relevant L3 - * interface is added or the port facing host comes up. Whenever L3 interface is - * added or host facing port comes up, ARP will be sent to hosts in this list. - * + * This list below contains the hosts which were initially in ARPPendingList + * above, but ARP response didn't come from there hosts after multiple + * attempts over 8 seconds. The assumption is that the response didn't come + * back due to one of the following possibilities: 1. The L3 interface + * wasn't created for this host in the controller. This would cause + * arphandler not to know where to send the ARP 2. The host facing port is + * down 3. The IP host doesn't exist or is not responding to ARP requests + * + * Conditions 1 and 2 above can be recovered if ARP is sent when the + * relevant L3 interface is added or the port facing host comes up. Whenever + * L3 interface is added or host facing port comes up, ARP will be sent to + * hosts in this list. + * * We can't recover from condition 3 above */ private ArrayList failedARPReqList = new ArrayList(); @@ -166,24 +167,21 @@ public class HostTracker implements IfIptoHost, IfHostListener, } @SuppressWarnings("deprecation") - private void allocateCache() { + private void allocateCache() { if (this.clusterContainerService == null) { - logger - .error("un-initialized clusterContainerService, can't create cache"); + logger.error("un-initialized clusterContainerService, can't create cache"); return; } logger.debug("Creating Cache for HostTracker"); try { - this.clusterContainerService.createCache("hostTrackerAH", EnumSet - .of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); - this.clusterContainerService.createCache("hostTrackerIH", EnumSet - .of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); + this.clusterContainerService.createCache("hostTrackerAH", + EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); + this.clusterContainerService.createCache("hostTrackerIH", + EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); } catch (CacheConfigException cce) { - logger - .error("Cache couldn't be created for HostTracker - check cache mode"); + logger.error("Cache couldn't be created for HostTracker - check cache mode"); } catch (CacheExistException cce) { - logger - .error("Cache for HostTracker already exists, destroy and recreate"); + logger.error("Cache for HostTracker already exists, destroy and recreate"); } logger.debug("Cache successfully created for HostTracker"); } @@ -191,8 +189,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, @SuppressWarnings({ "unchecked", "deprecation" }) private void retrieveCache() { if (this.clusterContainerService == null) { - logger - .error("un-initialized clusterContainerService, can't retrieve cache"); + logger.error("un-initialized clusterContainerService, can't retrieve cache"); return; } logger.debug("Retrieving cache for HostTrackerAH"); @@ -217,7 +214,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, } @SuppressWarnings("deprecation") - private void destroyCache() { + private void destroyCache() { if (this.clusterContainerService == null) { logger.error("un-initialized clusterMger, can't destroy cache"); return; @@ -275,10 +272,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, for (Entry entry : inactiveStaticHosts .entrySet()) { if (entry.getValue().equalsByIP(networkAddress)) { - logger - .debug( - "getHostFromInactiveDB(): Inactive Host found for IP:{} ", - networkAddress.getHostAddress()); + logger.debug( + "getHostFromInactiveDB(): Inactive Host found for IP:{} ", + networkAddress.getHostAddress()); return entry; } } @@ -332,9 +328,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, public HostNodeConnector hostFind(InetAddress networkAddress) { /* - * Sometimes at boot with containers configured in the startup - * we hit this path (from TIF) when hostFinder has not been set yet - * Caller already handles the null return + * Sometimes at boot with containers configured in the startup we hit + * this path (from TIF) when hostFinder has not been set yet Caller + * already handles the null return */ if (hostFinder == null) { @@ -344,18 +340,17 @@ public class HostTracker implements IfIptoHost, IfHostListener, HostNodeConnector host = hostQuery(networkAddress); if (host != null) { - logger.debug("hostFind(): Host found for IP: {}", networkAddress - .getHostAddress()); + logger.debug("hostFind(): Host found for IP: {}", + networkAddress.getHostAddress()); return host; } /* host is not found, initiate a discovery */ hostFinder.find(networkAddress); /* Also add this host to ARPPending List for any potential retries */ AddtoARPPendingList(networkAddress); - logger - .debug( - "hostFind(): Host Not Found for IP: {}, Inititated Host Discovery ...", - networkAddress.getHostAddress()); + logger.debug( + "hostFind(): Host Not Found for IP: {}, Inititated Host Discovery ...", + networkAddress.getHostAddress()); return null; } @@ -399,16 +394,15 @@ public class HostTracker implements IfIptoHost, IfHostListener, arphost.setHostIP(networkAddr); arphost.setSent_count((short) 1); ARPPendingList.add(arphost); - logger.debug("Host Added to ARPPending List, IP: {}", networkAddr - .toString()); + logger.debug("Host Added to ARPPending List, IP: {}", + networkAddr.toString()); } private void removePendingARPFromList(int index) { if (index >= ARPPendingList.size()) { - logger - .warn( - "removePendingARPFromList(): index greater than the List. Size:{}, Index:{}", - ARPPendingList.size(), index); + logger.warn( + "removePendingARPFromList(): index greater than the List. Size:{}, Index:{}", + ARPPendingList.size(), index); return; } ARPPending arphost = ARPPendingList.remove(index); @@ -434,8 +428,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, for (int i = 0; i < ARPPendingList.size(); i++) { arphost = ARPPendingList.get(i); if (arphost.getHostIP().equals(networkAddr)) { - /* An ARP was sent for this host. The address is learned, - * remove the request + /* + * An ARP was sent for this host. The address is learned, remove + * the request */ removePendingARPFromList(i); logger.debug("Host Removed from ARPPending List, IP: {}", @@ -451,8 +446,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, for (int i = 0; i < failedARPReqList.size(); i++) { arphost = failedARPReqList.get(i); if (arphost.getHostIP().equals(networkAddr)) { - /* An ARP was sent for this host. The address is learned, - * remove the request + /* + * An ARP was sent for this host. The address is learned, remove + * the request */ failedARPReqList.remove(i); logger.debug("Host Removed from FailedARPReqList List, IP: {}", @@ -466,9 +462,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, private void learnNewHost(HostNodeConnector host) { host.initArpSendCountDown(); hostsDB.put(host.getNetworkAddress(), host); - logger.debug("New Host Learned: MAC: {} IP: {}", HexEncode - .bytesToHexString(host.getDataLayerAddressBytes()), host - .getNetworkAddress().getHostAddress()); + logger.debug("New Host Learned: MAC: {} IP: {}", + HexEncode.bytesToHexString(host.getDataLayerAddressBytes()), + host.getNetworkAddress().getHostAddress()); } // Remove known Host @@ -479,10 +475,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, .getHostAddress()); hostsDB.remove(key); } else { - logger - .error( - "removeKnownHost(): Host for IP address {} not found in hostsDB", - key.getHostAddress()); + logger.error( + "removeKnownHost(): Host for IP address {} not found in hostsDB", + key.getHostAddress()); } } @@ -498,9 +493,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, /* Check for Host Move case */ if (hostMoved(host)) { /* - * Host has been moved from one location (switch,port, MAC, or VLAN). - * Remove the existing host with its previous location parameters, - * inform the applications, and add it as a new Host + * Host has been moved from one location (switch,port, MAC, or + * VLAN). Remove the existing host with its previous location + * parameters, inform the applications, and add it as a new Host */ HostNodeConnector removedHost = hostsDB.get(host .getNetworkAddress()); @@ -539,7 +534,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, new NotifyHostThread(host).start(); } - // Notify whoever is interested that a new host was learned (dynamically or statically) + // Notify whoever is interested that a new host was learned (dynamically or + // statically) private void notifyHostLearnedOrRemoved(HostNodeConnector host, boolean add) { // Update listeners if any if (newHostNotify != null) { @@ -557,19 +553,19 @@ public class HostTracker implements IfIptoHost, IfHostListener, } } } else { - logger - .error("notifyHostLearnedOrRemoved(): New host notify is null"); + logger.error("notifyHostLearnedOrRemoved(): New host notify is null"); } - // Topology update is for some reason outside of listeners registry logic + // Topology update is for some reason outside of listeners registry + // logic Node node = host.getnodeconnectorNode(); Host h = null; NodeConnector p = host.getnodeConnector(); try { - DataLinkAddress dla = new EthernetAddress(host - .getDataLayerAddressBytes()); - h = new org.opendaylight.controller.sal.core.Host(dla, host - .getNetworkAddress()); + DataLinkAddress dla = new EthernetAddress( + host.getDataLayerAddressBytes()); + h = new org.opendaylight.controller.sal.core.Host(dla, + host.getNetworkAddress()); } catch (ConstructionException ce) { p = null; h = null; @@ -581,23 +577,29 @@ public class HostTracker implements IfIptoHost, IfHostListener, switchManager.setNodeProp(node, tier); topologyManager.updateHostLink(p, h, UpdateType.ADDED, null); /* - * This is a temporary fix for Cisco Live's Hadoop Demonstration. - * The concept of Tiering must be revisited based on other application requirements - * and the design might warrant a separate module (as it involves tracking the topology/ - * host changes & updating the Tiering numbers in an effective manner). + * This is a temporary fix for Cisco Live's Hadoop + * Demonstration. The concept of Tiering must be revisited based + * on other application requirements and the design might + * warrant a separate module (as it involves tracking the + * topology/ host changes & updating the Tiering numbers in an + * effective manner). */ updateSwitchTiers(node, 1); /* - * The following 2 lines are added for testing purposes. - * We can remove it once the North-Bound APIs are available for testing. - - ArrayList> hierarchies = getHostNetworkHierarchy(host.getNetworkAddress()); - logHierarchies(hierarchies); + * The following 2 lines are added for testing purposes. We can + * remove it once the North-Bound APIs are available for + * testing. + * + * ArrayList> hierarchies = + * getHostNetworkHierarchy(host.getNetworkAddress()); + * logHierarchies(hierarchies); */ } else { - // No need to reset the tiering if no other hosts are currently connected - // If this switch was discovered to be an access switch, it still is even if the host is down + // No need to reset the tiering if no other hosts are currently + // connected + // If this switch was discovered to be an access switch, it + // still is even if the host is down Tier tier = new Tier(0); switchManager.setNodeProp(node, tier); topologyManager.updateHostLink(p, h, UpdateType.REMOVED, null); @@ -606,15 +608,17 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * When a new Host is learnt by the hosttracker module, it places the directly connected Node - * in Tier-1 & using this function, updates the Tier value for all other Nodes in the network - * hierarchy. - * - * This is a recursive function and it takes care of updating the Tier value for all the connected - * and eligible Nodes. - * - * @param n Node that represents one of the Vertex in the Topology Graph. - * @param currentTier The Tier on which n belongs + * When a new Host is learnt by the hosttracker module, it places the + * directly connected Node in Tier-1 & using this function, updates the Tier + * value for all other Nodes in the network hierarchy. + * + * This is a recursive function and it takes care of updating the Tier value + * for all the connected and eligible Nodes. + * + * @param n + * Node that represents one of the Vertex in the Topology Graph. + * @param currentTier + * The Tier on which n belongs */ private void updateSwitchTiers(Node n, int currentTier) { Map> ndlinks = topologyManager.getNodeEdges(); @@ -632,8 +636,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, } ArrayList needsVisiting = new ArrayList(); for (Edge lt : links) { - if (!lt.getHeadNodeConnector().getType().equals( - NodeConnector.NodeConnectorIDType.OPENFLOW)) { + if (!lt.getHeadNodeConnector().getType() + .equals(NodeConnector.NodeConnectorIDType.OPENFLOW)) { // We don't want to work on Node that are not openflow // for now continue; @@ -656,12 +660,14 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * Internal convenience routine to check the eligibility of a Switch for a Tier update. - * Any Node with Tier=0 or a Tier value that is greater than the new Tier Value is eligible - * for the update. - * - * @param n Node for which the Tier update eligibility is checked - * @param tier new Tier Value + * Internal convenience routine to check the eligibility of a Switch for a + * Tier update. Any Node with Tier=0 or a Tier value that is greater than + * the new Tier Value is eligible for the update. + * + * @param n + * Node for which the Tier update eligibility is checked + * @param tier + * new Tier Value * @return true if the Node is eligible for Tier Update * false otherwise */ @@ -690,9 +696,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * Internal convenience routine to clear all the Tier values to 0. - * This cleanup is performed during cases such as Topology Change where the existing Tier values - * might become incorrect + * Internal convenience routine to clear all the Tier values to 0. This + * cleanup is performed during cases such as Topology Change where the + * existing Tier values might become incorrect */ private void clearTiers() { Set nodes = null; @@ -727,12 +733,15 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * getHostNetworkHierarchy is the Back-end routine for the North-Bound API that returns - * the Network Hierarchy for a given Host. This API is typically used by applications like - * Hadoop for Rack Awareness functionality. - * - * @param hostAddress IP-Address of the host/node. - * @return Network Hierarchies represented by an Array of Array (of Switch-Ids as String). + * getHostNetworkHierarchy is the Back-end routine for the North-Bound API + * that returns the Network Hierarchy for a given Host. This API is + * typically used by applications like Hadoop for Rack Awareness + * functionality. + * + * @param hostAddress + * IP-Address of the host/node. + * @return Network Hierarchies represented by an Array of Array (of + * Switch-Ids as String). */ public List> getHostNetworkHierarchy(InetAddress hostAddress) { HostNodeConnector host = hostQuery(hostAddress); @@ -749,12 +758,13 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * dpidToHostNameHack is a hack function for Cisco Live Hadoop Demo. - * Mininet is used as the network for Hadoop Demos & in order to give a meaningful - * rack-awareness switch names, the DPID is organized in ASCII Characters and - * retrieved as string. - * - * @param dpid Switch DataPath Id + * dpidToHostNameHack is a hack function for Cisco Live Hadoop Demo. Mininet + * is used as the network for Hadoop Demos & in order to give a meaningful + * rack-awareness switch names, the DPID is organized in ASCII Characters + * and retrieved as string. + * + * @param dpid + * Switch DataPath Id * @return Ascii String represented by the DPID. */ private String dpidToHostNameHack(long dpid) { @@ -775,25 +785,28 @@ public class HostTracker implements IfIptoHost, IfHostListener, /** * A convenient recursive routine to obtain the Hierarchy of Switches. - * - * @param node Current Node in the Recursive routine. - * @param currHierarchy Array of Nodes that make this hierarchy on which the Current Switch belong - * @param fullHierarchy Array of multiple Hierarchies that represent a given host. + * + * @param node + * Current Node in the Recursive routine. + * @param currHierarchy + * Array of Nodes that make this hierarchy on which the Current + * Switch belong + * @param fullHierarchy + * Array of multiple Hierarchies that represent a given host. */ @SuppressWarnings("unchecked") private void updateCurrentHierarchy(Node node, ArrayList currHierarchy, List> fullHierarchy) { - //currHierarchy.add(String.format("%x", currSw.getId())); + // currHierarchy.add(String.format("%x", currSw.getId())); currHierarchy.add(dpidToHostNameHack((Long) node.getID())); ArrayList currHierarchyClone = (ArrayList) currHierarchy - .clone(); //Shallow copy as required + .clone(); // Shallow copy as required Map> ndlinks = topologyManager.getNodeEdges(); if (ndlinks == null) { - logger - .debug( - "updateCurrentHierarchy(): topologyManager returned null ndlinks for node: {}", - node); + logger.debug( + "updateCurrentHierarchy(): topologyManager returned null ndlinks for node: {}", + node); return; } Node n = NodeCreator.createOFNode((Long) node.getID()); @@ -803,8 +816,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, return; } for (Edge lt : links) { - if (!lt.getHeadNodeConnector().getType().equals( - NodeConnector.NodeConnectorIDType.OPENFLOW)) { + if (!lt.getHeadNodeConnector().getType() + .equals(NodeConnector.NodeConnectorIDType.OPENFLOW)) { // We don't want to work on Node that are not openflow // for now continue; @@ -819,7 +832,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ArrayList buildHierarchy = currHierarchy; if (currHierarchy.size() > currHierarchyClone.size()) { buildHierarchy = (ArrayList) currHierarchyClone - .clone(); //Shallow copy as required + .clone(); // Shallow copy as required fullHierarchy.add(buildHierarchy); } updateCurrentHierarchy(dstNode, buildHierarchy, fullHierarchy); @@ -827,8 +840,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, } } - @Override - public void edgeUpdate(Edge e, UpdateType type, Set props) { + private void edgeUpdate(Edge e, UpdateType type, Set props) { Long srcNid = null; Short srcPort = null; Long dstNid = null; @@ -868,11 +880,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, // At this point we know we got an openflow update, so // lets fill everything accordingly. - srcNid = (Long) e.getTailNodeConnector().getNode() - .getID(); + srcNid = (Long) e.getTailNodeConnector().getNode().getID(); srcPort = (Short) e.getTailNodeConnector().getID(); - dstNid = (Long) e.getHeadNodeConnector().getNode() - .getID(); + dstNid = (Long) e.getHeadNodeConnector().getNode().getID(); dstPort = (Short) e.getHeadNodeConnector().getID(); // Now lets update the added flag @@ -886,8 +896,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, } } - logger.debug("HostTracker Topology linkUpdate handling src:{}[port {}] dst:{}[port {}] added: {}", - new Object[] { srcNid, srcPort, dstNid, dstPort, added }); + logger.debug( + "HostTracker Topology linkUpdate handling src:{}[port {}] dst:{}[port {}] added: {}", + new Object[] { srcNid, srcPort, dstNid, dstPort, added }); clearTiers(); for (Entry entry : hostsDB.entrySet()) { HostNodeConnector host = entry.getValue(); @@ -900,6 +911,16 @@ public class HostTracker implements IfIptoHost, IfHostListener, } } + @Override + public void edgeUpdate(List topoedgeupdateList) { + for (int i = 0; i < topoedgeupdateList.size(); i++) { + Edge e = topoedgeupdateList.get(i).getEdge(); + Set p = topoedgeupdateList.get(i).getProperty(); + UpdateType type = topoedgeupdateList.get(i).getUpdateType(); + edgeUpdate(e, type, p); + } + } + public void subnetNotify(Subnet sub, boolean add) { logger.debug("Received subnet notification: {} add={}", sub, add); if (add) { @@ -922,35 +943,35 @@ public class HostTracker implements IfIptoHost, IfHostListener, for (int i = 0; i < ARPPendingList.size(); i++) { arphost = ARPPendingList.get(i); if (arphost.getSent_count() < switchManager.getHostRetryCount()) { - /* No reply has been received of first ARP Req, send the next one */ + /* + * No reply has been received of first ARP Req, send the + * next one + */ hostFinder.find(arphost.getHostIP()); arphost.sent_count++; logger.debug("ARP Sent from ARPPending List, IP: {}", arphost.getHostIP().getHostAddress()); } else if (arphost.getSent_count() >= switchManager .getHostRetryCount()) { - /* Two ARP requests have been sent without - * receiving a reply, remove this from the - * pending list + /* + * Two ARP requests have been sent without receiving a + * reply, remove this from the pending list */ removePendingARPFromList(i); - logger - .debug( - "ARP reply not received after two attempts, removing from Pending List IP: {}", - arphost.getHostIP().getHostAddress()); + logger.debug( + "ARP reply not received after two attempts, removing from Pending List IP: {}", + arphost.getHostIP().getHostAddress()); /* - * Add this host to a different list which will be processed on link - * up events + * Add this host to a different list which will be processed + * on link up events */ logger.debug("Adding the host to FailedARPReqList IP: {}", arphost.getHostIP().getHostAddress()); failedARPReqList.add(arphost); } else { - logger - .error( - "Inavlid arp_sent count for entery at index: {}", - i); + logger.error( + "Inavlid arp_sent count for entery at index: {}", i); } } } @@ -972,8 +993,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, } if (hostsDB == null) { /* hostsDB is not allocated yet */ - logger - .error("ARPRefreshHandler(): hostsDB is not allocated yet:"); + logger.error("ARPRefreshHandler(): hostsDB is not allocated yet:"); return; } for (Entry entry : hostsDB @@ -989,16 +1009,24 @@ public class HostTracker implements IfIptoHost, IfHostListener, if (arp_cntdown > switchManager.getHostRetryCount()) { host.setArpSendCountDown(arp_cntdown); } else if (arp_cntdown <= 0) { - /* No ARP Reply received in last 2 minutes, remove this host and inform applications*/ + /* + * No ARP Reply received in last 2 minutes, remove this host + * and inform applications + */ removeKnownHost(entry.getKey()); notifyHostLearnedOrRemoved(host, false); } else if (arp_cntdown <= switchManager.getHostRetryCount()) { - /* Use the services of arphandler to check if host is still there */ - logger.trace("ARP Probing ({}) for {}({})", new Object[] { - arp_cntdown, - host.getNetworkAddress().getHostAddress(), - HexEncode.bytesToHexString(host - .getDataLayerAddressBytes()) }); + /* + * Use the services of arphandler to check if host is still + * there + */ + logger.trace( + "ARP Probing ({}) for {}({})", + new Object[] { + arp_cntdown, + host.getNetworkAddress().getHostAddress(), + HexEncode.bytesToHexString(host + .getDataLayerAddressBytes()) }); host.setArpSendCountDown(arp_cntdown); hostFinder.probe(host); } @@ -1007,81 +1035,89 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * Inform the controller IP to MAC binding of a host and its - * connectivity to an openflow switch in terms of Node, port, and - * VLAN. - * - * @param networkAddr IP address of the host - * @param dataLayer Address MAC address of the host - * @param nc NodeConnector to which host is connected - * @param port Port of the switch to which host is connected - * @param vlan Vlan of which this host is member of - * - * @return Status The status object as described in {@code Status} - * indicating the result of this action. + * Inform the controller IP to MAC binding of a host and its connectivity to + * an openflow switch in terms of Node, port, and VLAN. + * + * @param networkAddr + * IP address of the host + * @param dataLayer + * Address MAC address of the host + * @param nc + * NodeConnector to which host is connected + * @param port + * Port of the switch to which host is connected + * @param vlan + * Vlan of which this host is member of + * + * @return Status The status object as described in {@code Status} + * indicating the result of this action. */ public Status addStaticHostReq(InetAddress networkAddr, byte[] dataLayerAddress, NodeConnector nc, short vlan) { if (dataLayerAddress.length != 6) { - return new Status(StatusCode.BADREQUEST, "Invalid MAC address"); + return new Status(StatusCode.BADREQUEST, "Invalid MAC address"); } HostNodeConnector host = null; try { host = new HostNodeConnector(dataLayerAddress, networkAddr, nc, - vlan); + vlan); if (hostExists(host)) { - // This host is already learned either via ARP or through a northbound request + // This host is already learned either via ARP or through a + // northbound request HostNodeConnector transHost = hostsDB.get(networkAddr); transHost.setStaticHost(true); return new Status(StatusCode.SUCCESS, null); } host.setStaticHost(true); /* - * Before adding host, Check if the switch and the port have already come up + * Before adding host, Check if the switch and the port have already + * come up */ if (switchManager.isNodeConnectorEnabled(nc)) { learnNewHost(host); notifyHostLearnedOrRemoved(host, true); } else { inactiveStaticHosts.put(nc, host); - logger - .debug( - "Switch or switchport is not up, adding host {} to inactive list", - networkAddr.getHostName()); + logger.debug( + "Switch or switchport is not up, adding host {} to inactive list", + networkAddr.getHostName()); } return new Status(StatusCode.SUCCESS, null); } catch (ConstructionException e) { - return new Status(StatusCode.INTERNALERROR, "Host could not be created"); + return new Status(StatusCode.INTERNALERROR, + "Host could not be created"); } } /** - * Update the controller IP to MAC binding of a host and its - * connectivity to an openflow switch in terms of - * switch id, switch port, and VLAN. - * - * @param networkAddr IP address of the host - * @param dataLayer Address MAC address of the host - * @param nc NodeConnector to which host is connected - * @param port Port of the switch to which host is connected - * @param vlan Vlan of which this host is member of - * - * @return boolean true if the host was added successfully, - * false otherwise + * Update the controller IP to MAC binding of a host and its connectivity to + * an openflow switch in terms of switch id, switch port, and VLAN. + * + * @param networkAddr + * IP address of the host + * @param dataLayer + * Address MAC address of the host + * @param nc + * NodeConnector to which host is connected + * @param port + * Port of the switch to which host is connected + * @param vlan + * Vlan of which this host is member of + * + * @return boolean true if the host was added successfully, false otherwise */ public boolean updateHostReq(InetAddress networkAddr, - byte[] dataLayerAddress, NodeConnector nc, - short vlan) { + byte[] dataLayerAddress, NodeConnector nc, short vlan) { if (nc == null) { return false; } HostNodeConnector host = null; try { host = new HostNodeConnector(dataLayerAddress, networkAddr, nc, - vlan); + vlan); if (!hostExists(host)) { if ((inactiveStaticHosts.get(nc)) != null) { inactiveStaticHosts.replace(nc, host); @@ -1099,11 +1135,12 @@ public class HostTracker implements IfIptoHost, IfHostListener, /** * Remove from the controller IP to MAC binding of a host and its * connectivity to an openflow switch - * - * @param networkAddr IP address of the host - * - * @return boolean true if the host was removed successfully, - * false otherwise + * + * @param networkAddr + * IP address of the host + * + * @return boolean true if the host was removed successfully, false + * otherwise */ public Status removeStaticHostReq(InetAddress networkAddress) { @@ -1112,9 +1149,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, if (host != null) { // Validation check if (!host.isStaticHost()) { - return new Status(StatusCode.FORBIDDEN, - "Host " + networkAddress.getHostName() + - " is not static"); + return new Status(StatusCode.FORBIDDEN, "Host " + + networkAddress.getHostName() + " is not static"); } // Remove and notify notifyHostLearnedOrRemoved(host, false); @@ -1128,9 +1164,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, host = entry.getValue(); // Validation check if (!host.isStaticHost()) { - return new Status(StatusCode.FORBIDDEN, - "Host " + networkAddress.getHostName() + - " is not static"); + return new Status(StatusCode.FORBIDDEN, "Host " + + networkAddress.getHostName() + " is not static"); } this.removeHostFromInactiveDB(networkAddress); return new Status(StatusCode.SUCCESS, null); @@ -1154,8 +1189,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, switch (type) { case REMOVED: long sid = (Long) node.getID(); - logger.debug("Received removedSwitch for sw id {}", HexEncode - .longToHexString(sid)); + logger.debug("Received removedSwitch for sw id {}", + HexEncode.longToHexString(sid)); for (Entry entry : hostsDB .entrySet()) { HostNodeConnector host = entry.getValue(); @@ -1204,19 +1239,17 @@ public class HostTracker implements IfIptoHost, IfHostListener, @Override public Status addStaticHost(String networkAddress, String dataLayerAddress, - NodeConnector nc, String vlan) { + NodeConnector nc, String vlan) { try { InetAddress ip = InetAddress.getByName(networkAddress); if (nc == null) { - return new Status(StatusCode.BADREQUEST, "Invalid NodeId"); + return new Status(StatusCode.BADREQUEST, "Invalid NodeId"); } return addStaticHostReq(ip, - HexEncode - .bytesFromHexString(dataLayerAddress), - nc, + HexEncode.bytesFromHexString(dataLayerAddress), nc, Short.valueOf(vlan)); } catch (UnknownHostException e) { - logger.error("",e); + logger.error("", e); return new Status(StatusCode.BADREQUEST, "Invalid Address"); } } @@ -1228,7 +1261,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, address = InetAddress.getByName(networkAddress); return removeStaticHostReq(address); } catch (UnknownHostException e) { - logger.error("",e); + logger.error("", e); return new Status(StatusCode.BADREQUEST, "Invalid Address"); } } @@ -1304,7 +1337,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, /** * Function called by the dependency manager when all the required * dependencies are satisfied - * + * */ void init(Component c) { Dictionary props = c.getServiceProperties(); @@ -1319,29 +1352,28 @@ public class HostTracker implements IfIptoHost, IfHostListener, } /** - * Function called by the dependency manager when at least one - * dependency become unsatisfied or when the component is shutting - * down because for example bundle is being stopped. - * + * Function called by the dependency manager when at least one dependency + * become unsatisfied or when the component is shutting down because for + * example bundle is being stopped. + * */ void destroy() { destroyCache(); } /** - * Function called by dependency manager after "init ()" is called - * and after the services provided by the class are registered in - * the service registry - * + * Function called by dependency manager after "init ()" is called and after + * the services provided by the class are registered in the service registry + * */ void start() { } /** - * Function called by the dependency manager before the services - * exported by the component are unregistered, this will be - * followed by a "destroy ()" calls - * + * Function called by the dependency manager before the services exported by + * the component are unregistered, this will be followed by a "destroy ()" + * calls + * */ void stop() { } diff --git a/opendaylight/hosttracker/integrationtest/pom.xml b/opendaylight/hosttracker/integrationtest/pom.xml index ff08cf334c..0d2d18ca27 100644 --- a/opendaylight/hosttracker/integrationtest/pom.xml +++ b/opendaylight/hosttracker/integrationtest/pom.xml @@ -27,7 +27,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java b/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java index f351d1afcb..fb5367c528 100644 --- a/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java +++ b/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java @@ -108,7 +108,7 @@ public class HostTrackerIntegrationTest { // List all the bundles on which the test case depends mavenBundle("org.opendaylight.controller", "sal", - "0.4.0-SNAPSHOT"), + "0.5.0-SNAPSHOT"), mavenBundle("org.opendaylight.controller", "sal.implementation", "0.4.0-SNAPSHOT"), diff --git a/opendaylight/northbound/commons/pom.xml b/opendaylight/northbound/commons/pom.xml index d52bedf819..d80d669edf 100644 --- a/opendaylight/northbound/commons/pom.xml +++ b/opendaylight/northbound/commons/pom.xml @@ -43,7 +43,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/northbound/flowprogrammer/pom.xml b/opendaylight/northbound/flowprogrammer/pom.xml index 1bfd4ebf12..a4ebfa2b64 100644 --- a/opendaylight/northbound/flowprogrammer/pom.xml +++ b/opendaylight/northbound/flowprogrammer/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -76,7 +76,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.codehaus.enunciate diff --git a/opendaylight/northbound/hosttracker/pom.xml b/opendaylight/northbound/hosttracker/pom.xml index eab9fcb0c7..5ddab37ff3 100644 --- a/opendaylight/northbound/hosttracker/pom.xml +++ b/opendaylight/northbound/hosttracker/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -81,7 +81,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/northbound/staticrouting/pom.xml b/opendaylight/northbound/staticrouting/pom.xml index eeaf550e6b..f0fd323710 100644 --- a/opendaylight/northbound/staticrouting/pom.xml +++ b/opendaylight/northbound/staticrouting/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -62,7 +62,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/northbound/statistics/pom.xml b/opendaylight/northbound/statistics/pom.xml index e10a5b1e1f..84c4020369 100644 --- a/opendaylight/northbound/statistics/pom.xml +++ b/opendaylight/northbound/statistics/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -80,7 +80,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/northbound/subnets/pom.xml b/opendaylight/northbound/subnets/pom.xml index cfba4ffce9..22c9a97458 100644 --- a/opendaylight/northbound/subnets/pom.xml +++ b/opendaylight/northbound/subnets/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller @@ -76,7 +76,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/northbound/switchmanager/pom.xml b/opendaylight/northbound/switchmanager/pom.xml index e4c73ac743..25757e66c4 100644 --- a/opendaylight/northbound/switchmanager/pom.xml +++ b/opendaylight/northbound/switchmanager/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -78,7 +78,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/northbound/topology/pom.xml b/opendaylight/northbound/topology/pom.xml index c31b478fb5..0cfa487f1c 100644 --- a/opendaylight/northbound/topology/pom.xml +++ b/opendaylight/northbound/topology/pom.xml @@ -23,7 +23,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -79,7 +79,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/protocol_plugins/openflow/pom.xml b/opendaylight/protocol_plugins/openflow/pom.xml index 614b0ff818..23c0d9d90e 100644 --- a/opendaylight/protocol_plugins/openflow/pom.xml +++ b/opendaylight/protocol_plugins/openflow/pom.xml @@ -62,7 +62,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller.thirdparty diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServices.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServices.java index 64515887c0..c0b296345e 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServices.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServices.java @@ -9,7 +9,9 @@ package org.opendaylight.controller.protocol_plugin.openflow.internal; import java.util.Dictionary; +import java.util.List; import java.util.Set; +import java.util.ArrayList; import org.apache.felix.dm.Component; import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider; @@ -22,6 +24,7 @@ import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.topology.IPluginInTopologyService; import org.opendaylight.controller.sal.topology.IPluginOutTopologyService; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; public class TopologyServices implements ITopologyServiceShimListener, IPluginInTopologyService { @@ -129,7 +132,10 @@ public class TopologyServices implements ITopologyServiceShimListener, @Override public void edgeUpdate(Edge edge, UpdateType type, Set props) { if (this.salTopoService != null) { - this.salTopoService.edgeUpdate(edge, type, props); + List topoedgeupdateList = new ArrayList(); + TopoEdgeUpdate teu = new TopoEdgeUpdate(edge, props, type); + topoedgeupdateList.add(teu); + this.salTopoService.edgeUpdate(topoedgeupdateList); } } diff --git a/opendaylight/protocol_plugins/stub/pom.xml b/opendaylight/protocol_plugins/stub/pom.xml index 36085c9e3b..c257099825 100644 --- a/opendaylight/protocol_plugins/stub/pom.xml +++ b/opendaylight/protocol_plugins/stub/pom.xml @@ -51,7 +51,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT junit diff --git a/opendaylight/routing/dijkstra_implementation/pom.xml b/opendaylight/routing/dijkstra_implementation/pom.xml index e89beb8c36..06a684f265 100644 --- a/opendaylight/routing/dijkstra_implementation/pom.xml +++ b/opendaylight/routing/dijkstra_implementation/pom.xml @@ -26,6 +26,7 @@ org.slf4j, org.opendaylight.controller.sal.routing, org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.topology, org.opendaylight.controller.sal.utils, org.opendaylight.controller.sal.reader, org.apache.commons.collections15, @@ -54,7 +55,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java b/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java index 586432d8c0..d878b231bc 100644 --- a/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java +++ b/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -27,7 +26,9 @@ import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.reader.IReadService; import org.opendaylight.controller.sal.routing.IListenRoutingUpdates; + import org.opendaylight.controller.sal.routing.IRouting; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.opendaylight.controller.topologymanager.ITopologyManagerAware; @@ -41,6 +42,7 @@ import java.lang.IllegalArgumentException; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.ArrayList; import java.util.Set; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -54,7 +56,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { .getLogger(DijkstraImplementation.class); private ConcurrentMap> topologyBWAware; private ConcurrentMap> sptBWAware; - DijkstraShortestPath mtp; //Max Throughput Path + DijkstraShortestPath mtp; // Max Throughput Path private Set routingAware; private ISwitchManager switchManager; private ITopologyManager topologyManager; @@ -112,13 +114,19 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { Bandwidth.BandwidthPropName); long srcLinkSpeed = 0, dstLinkSpeed = 0; - if ((bwSrc == null) || ((srcLinkSpeed = bwSrc.getValue()) == 0)) { - log.debug("srcNC: {} - Setting srcLinkSpeed to Default!",srcNC); - srcLinkSpeed = DEFAULT_LINK_SPEED; + if ((bwSrc == null) + || ((srcLinkSpeed = bwSrc.getValue()) == 0)) { + log.debug( + "srcNC: {} - Setting srcLinkSpeed to Default!", + srcNC); + srcLinkSpeed = DEFAULT_LINK_SPEED; } - - if ((bwDst == null) || ((dstLinkSpeed = bwDst.getValue()) == 0)) { - log.debug("dstNC: {} - Setting dstLinkSpeed to Default!",dstNC); + + if ((bwDst == null) + || ((dstLinkSpeed = bwDst.getValue()) == 0)) { + log.debug( + "dstNC: {} - Setting dstLinkSpeed to Default!", + dstNC); dstLinkSpeed = DEFAULT_LINK_SPEED; } @@ -127,13 +135,14 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { long avlDstThruPut = dstLinkSpeed - readService.getTransmitRate(dstNC); - //Use lower of the 2 available thruput as the available thruput + // Use lower of the 2 available thruput as the available + // thruput long avlThruPut = avlSrcThruPut < avlDstThruPut ? avlSrcThruPut : avlDstThruPut; if (avlThruPut <= 0) { - log.debug("Edge {}: Available Throughput {} <= 0!", - e, avlThruPut); + log.debug("Edge {}: Available Throughput {} <= 0!", e, + avlThruPut); return (double) -1; } return (double) (Bandwidth.BW1Pbps / avlThruPut); @@ -147,7 +156,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { }; } Short baseBW = Short.valueOf((short) 0); - //Initialize mtp also using the default topo + // Initialize mtp also using the default topo Graph g = this.topologyBWAware.get(baseBW); if (g == null) { log.error("Default Topology Graph is null"); @@ -175,16 +184,16 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { try { path = mtp.getMaxThroughputPath(src, dst); } catch (IllegalArgumentException ie) { - log.debug("A vertex is yet not known between {} {}", src.toString(), - dst.toString()); + log.debug("A vertex is yet not known between {} {}", + src.toString(), dst.toString()); return null; } Path res; try { res = new Path(path); } catch (ConstructionException e) { - log.debug("A vertex is yet not known between {} {}", src.toString(), - dst.toString()); + log.debug("A vertex is yet not known between {} {}", + src.toString(), dst.toString()); return null; } return res; @@ -199,16 +208,16 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { try { path = spt.getPath(src, dst); } catch (IllegalArgumentException ie) { - log.debug("A vertex is yet not known between {} {}", src.toString(), - dst.toString()); + log.debug("A vertex is yet not known between {} {}", + src.toString(), dst.toString()); return null; } Path res; try { res = new Path(path); } catch (ConstructionException e) { - log.debug("A vertex is yet not known between {} {}", src.toString(), - dst.toString()); + log.debug("A vertex is yet not known between {} {}", + src.toString(), dst.toString()); return null; } return res; @@ -229,11 +238,11 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { @Override public synchronized void clearMaxThroughput() { if (mtp != null) { - mtp.reset(); //reset maxthruput path + mtp.reset(); // reset maxthruput path } } - @SuppressWarnings( { "rawtypes", "unchecked" }) + @SuppressWarnings({ "rawtypes", "unchecked" }) private synchronized boolean updateTopo(Edge edge, Short bw, boolean added) { Graph topo = this.topologyBWAware.get(bw); DijkstraShortestPath spt = this.sptBWAware.get(bw); @@ -265,20 +274,19 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { edgePresentInGraph = topo.containsEdge(edge); if (edgePresentInGraph == false) { try { - topo.addEdge(new Edge(src, dst), src - .getNode(), dst - .getNode(), EdgeType.DIRECTED); + topo.addEdge(new Edge(src, dst), src.getNode(), + dst.getNode(), EdgeType.DIRECTED); } catch (ConstructionException e) { - log.error("",e); + log.error("", e); return edgePresentInGraph; } } } else { - //Remove the edge + // Remove the edge try { topo.removeEdge(new Edge(src, dst)); } catch (ConstructionException e) { - log.error("",e); + log.error("", e); return edgePresentInGraph; } @@ -308,26 +316,25 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { return edgePresentInGraph; } - @Override - public void edgeUpdate(Edge e, UpdateType type, Set props) { + private boolean edgeUpdate(Edge e, UpdateType type, Set props) { String srcType = null; String dstType = null; if (e == null || type == null) { log.error("Edge or Update type are null!"); - return; + return false; } else { srcType = e.getTailNodeConnector().getType(); dstType = e.getHeadNodeConnector().getType(); if (srcType.equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) { log.debug("Skip updates for {}", e); - return; + return false; } if (dstType.equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) { log.debug("Skip updates for {}", e); - return; + return false; } } @@ -347,13 +354,27 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { // Update BW topo updateTopo(e, (short) bw.getValue(), add); } - if (this.routingAware != null) { - for (IListenRoutingUpdates ra : this.routingAware) { - try { - ra.recalculateDone(); - } catch (Exception ex) { - log.error("Exception on routingAware listener call", e); - } + } + return newEdge; + } + + @Override + public void edgeUpdate(List topoedgeupdateList) { + boolean callListeners = false; + for (int i = 0; i < topoedgeupdateList.size(); i++) { + Edge e = topoedgeupdateList.get(i).getEdge(); + Set p = topoedgeupdateList.get(i).getProperty(); + UpdateType type = topoedgeupdateList.get(i).getUpdateType(); + if ((edgeUpdate(e, type, p)) && (!callListeners)) { + callListeners = true; + } + } + if ((callListeners) && (this.routingAware != null)) { + for (IListenRoutingUpdates ra : this.routingAware) { + try { + ra.recalculateDone(); + } catch (Exception ex) { + log.error("Exception on routingAware listener call", ex); } } } @@ -362,62 +383,67 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { /** * Function called by the dependency manager when all the required * dependencies are satisfied - * + * */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void init() { - log.debug("Routing init() is called"); - this.topologyBWAware = (ConcurrentMap>) new ConcurrentHashMap(); - this.sptBWAware = (ConcurrentMap>) new ConcurrentHashMap(); - // Now create the default topology, which doesn't consider the - // BW, also create the corresponding Dijkstra calculation - Graph g = new SparseMultigraph(); - Short sZero = Short.valueOf((short) 0); - this.topologyBWAware.put(sZero, g); - this.sptBWAware.put(sZero, new DijkstraShortestPath(g)); - // Topologies for other BW will be added on a needed base + log.debug("Routing init() is called"); + this.topologyBWAware = (ConcurrentMap>) new ConcurrentHashMap(); + this.sptBWAware = (ConcurrentMap>) new ConcurrentHashMap(); + // Now create the default topology, which doesn't consider the + // BW, also create the corresponding Dijkstra calculation + Graph g = new SparseMultigraph(); + Short sZero = Short.valueOf((short) 0); + this.topologyBWAware.put(sZero, g); + this.sptBWAware.put(sZero, new DijkstraShortestPath(g)); + // Topologies for other BW will be added on a needed base } + /** * Function called by the dependency manager when at least one dependency * become unsatisfied or when the component is shutting down because for * example bundle is being stopped. - * + * */ void destroy() { - log.debug("Routing destroy() is called"); + log.debug("Routing destroy() is called"); } /** - * Function called by dependency manager after "init ()" is called - * and after the services provided by the class are registered in - * the service registry - * + * Function called by dependency manager after "init ()" is called and after + * the services provided by the class are registered in the service registry + * */ - void start() { - log.debug("Routing start() is called"); - // build the routing database from the topology if it exists. - Map> edges = topologyManager.getEdges(); - if (edges.isEmpty()) { - return; - } - log.debug("Creating routing database from the topology"); - for (Iterator>> i = edges.entrySet().iterator(); i.hasNext();) { - Map.Entry> entry = i.next(); - Edge e = entry.getKey(); - Set props = entry.getValue(); - edgeUpdate(e, UpdateType.ADDED, props); - } - } + void start() { + log.debug("Routing start() is called"); + // build the routing database from the topology if it exists. + Map> edges = topologyManager.getEdges(); + if (edges.isEmpty()) { + return; + } + List topoedgeupdateList = new ArrayList(); + log.debug("Creating routing database from the topology"); + for (Iterator>> i = edges.entrySet() + .iterator(); i.hasNext();) { + Map.Entry> entry = i.next(); + Edge e = entry.getKey(); + Set props = entry.getValue(); + TopoEdgeUpdate topoedgeupdate = new TopoEdgeUpdate(e, props, + UpdateType.ADDED); + topoedgeupdateList.add(topoedgeupdate); + } + edgeUpdate(topoedgeupdateList); + } /** * Function called by the dependency manager before the services exported by * the component are unregistered, this will be followed by a "destroy ()" * calls - * + * */ - public void stop() { - log.debug("Routing stop() is called"); - } + public void stop() { + log.debug("Routing stop() is called"); + } @Override public void edgeOverUtilized(Edge edge) { @@ -450,14 +476,14 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware { this.readService = null; } } - + public void setTopologyManager(ITopologyManager tm) { - this.topologyManager = tm; + this.topologyManager = tm; } - + public void unsetTopologyManager(ITopologyManager tm) { - if (this.topologyManager == tm) { - this.topologyManager = null; - } + if (this.topologyManager == tm) { + this.topologyManager = null; + } } } diff --git a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java index fb0a560212..e3ae560d40 100644 --- a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java +++ b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -7,7 +6,6 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.routing.dijkstra_implementation; import org.opendaylight.controller.sal.core.Bandwidth; @@ -18,9 +16,11 @@ import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Path; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.NodeCreator; +import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -34,7 +34,8 @@ import org.slf4j.LoggerFactory; public class DijkstraTest { protected static final Logger logger = LoggerFactory - .getLogger(DijkstraTest.class); + .getLogger(DijkstraTest.class); + @Test public void testSinglePathRouteNoBw() { DijkstraImplementation imp = new DijkstraImplementation(); @@ -42,6 +43,7 @@ public class DijkstraTest { Node node1 = NodeCreator.createOFNode((long) 1); Node node2 = NodeCreator.createOFNode((long) 2); Node node3 = NodeCreator.createOFNode((long) 3); + List topoedgeupdateList = new ArrayList(); NodeConnector nc11 = NodeConnectorCreator.createOFNodeConnector( (short) 1, node1); NodeConnector nc21 = NodeConnectorCreator.createOFNodeConnector( @@ -50,11 +52,13 @@ public class DijkstraTest { try { edge1 = new Edge(nc11, nc21); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props = new HashSet(); props.add(new Bandwidth(0)); - imp.edgeUpdate(edge1, UpdateType.ADDED, props); + TopoEdgeUpdate teu1 = new TopoEdgeUpdate(edge1, props, UpdateType.ADDED); + topoedgeupdateList.add(teu1); + NodeConnector nc22 = NodeConnectorCreator.createOFNodeConnector( (short) 2, node2); NodeConnector nc31 = NodeConnectorCreator.createOFNodeConnector( @@ -63,11 +67,14 @@ public class DijkstraTest { try { edge2 = new Edge(nc22, nc31); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props2 = new HashSet(); - props.add(new Bandwidth(0)); - imp.edgeUpdate(edge2, UpdateType.ADDED, props2); + props2.add(new Bandwidth(0)); + TopoEdgeUpdate teu2 = new TopoEdgeUpdate(edge2, props2, + UpdateType.ADDED); + topoedgeupdateList.add(teu2); + imp.edgeUpdate(topoedgeupdateList); Path res = imp.getRoute(node1, node3); List expectedPath = (List) new LinkedList(); @@ -77,7 +84,7 @@ public class DijkstraTest { try { expectedRes = new Path(expectedPath); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } if (!res.equals(expectedRes)) { System.out.println("Actual Res is " + res); @@ -89,6 +96,7 @@ public class DijkstraTest { @Test public void testShortestPathRouteNoBw() { DijkstraImplementation imp = new DijkstraImplementation(); + List topoedgeupdateList = new ArrayList(); imp.init(); Node node1 = NodeCreator.createOFNode((long) 1); Node node2 = NodeCreator.createOFNode((long) 2); @@ -101,11 +109,12 @@ public class DijkstraTest { try { edge1 = new Edge(nc11, nc21); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props = new HashSet(); props.add(new Bandwidth(0)); - imp.edgeUpdate(edge1, UpdateType.ADDED, props); + TopoEdgeUpdate teu1 = new TopoEdgeUpdate(edge1, props, UpdateType.ADDED); + topoedgeupdateList.add(teu1); NodeConnector nc22 = NodeConnectorCreator.createOFNodeConnector( (short) 2, node2); @@ -115,11 +124,13 @@ public class DijkstraTest { try { edge2 = new Edge(nc22, nc31); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props2 = new HashSet(); - props.add(new Bandwidth(0)); - imp.edgeUpdate(edge2, UpdateType.ADDED, props2); + props2.add(new Bandwidth(0)); + TopoEdgeUpdate teu2 = new TopoEdgeUpdate(edge2, props2, + UpdateType.ADDED); + topoedgeupdateList.add(teu2); NodeConnector nc12 = NodeConnectorCreator.createOFNodeConnector( (short) 2, node1); @@ -129,11 +140,14 @@ public class DijkstraTest { try { edge3 = new Edge(nc12, nc32); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props3 = new HashSet(); - props.add(new Bandwidth(0)); - imp.edgeUpdate(edge3, UpdateType.ADDED, props3); + props3.add(new Bandwidth(0)); + TopoEdgeUpdate teu3 = new TopoEdgeUpdate(edge3, props3, + UpdateType.ADDED); + topoedgeupdateList.add(teu3); + imp.edgeUpdate(topoedgeupdateList); Path res = imp.getRoute(node1, node3); @@ -143,7 +157,7 @@ public class DijkstraTest { try { expectedRes = new Path(expectedPath); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } if (!res.equals(expectedRes)) { System.out.println("Actual Res is " + res); @@ -156,6 +170,7 @@ public class DijkstraTest { public void testShortestPathRouteNoBwAfterLinkDelete() { DijkstraImplementation imp = new DijkstraImplementation(); imp.init(); + List topoedgeupdateList = new ArrayList(); Node node1 = NodeCreator.createOFNode((long) 1); Node node2 = NodeCreator.createOFNode((long) 2); Node node3 = NodeCreator.createOFNode((long) 3); @@ -167,11 +182,12 @@ public class DijkstraTest { try { edge1 = new Edge(nc11, nc21); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props = new HashSet(); props.add(new Bandwidth(0)); - imp.edgeUpdate(edge1, UpdateType.ADDED, props); + TopoEdgeUpdate teu1 = new TopoEdgeUpdate(edge1, props, UpdateType.ADDED); + topoedgeupdateList.add(teu1); NodeConnector nc22 = NodeConnectorCreator.createOFNodeConnector( (short) 2, node2); @@ -181,11 +197,13 @@ public class DijkstraTest { try { edge2 = new Edge(nc22, nc31); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props2 = new HashSet(); - props.add(new Bandwidth(0)); - imp.edgeUpdate(edge2, UpdateType.ADDED, props2); + props2.add(new Bandwidth(0)); + TopoEdgeUpdate teu2 = new TopoEdgeUpdate(edge2, props2, + UpdateType.ADDED); + topoedgeupdateList.add(teu2); NodeConnector nc12 = NodeConnectorCreator.createOFNodeConnector( (short) 2, node1); @@ -195,13 +213,18 @@ public class DijkstraTest { try { edge3 = new Edge(nc12, nc32); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } Set props3 = new HashSet(); - props.add(new Bandwidth(0)); - imp.edgeUpdate(edge3, UpdateType.ADDED, props3); + props3.add(new Bandwidth(0)); + TopoEdgeUpdate teu3 = new TopoEdgeUpdate(edge3, props3, + UpdateType.ADDED); + topoedgeupdateList.add(teu3); + TopoEdgeUpdate teu4 = new TopoEdgeUpdate(edge3, props3, + UpdateType.REMOVED); + topoedgeupdateList.add(teu4); - imp.edgeUpdate(edge3, UpdateType.REMOVED, props3); + imp.edgeUpdate(topoedgeupdateList); Path res = imp.getRoute(node1, node3); List expectedPath = (List) new LinkedList(); @@ -211,7 +234,7 @@ public class DijkstraTest { try { expectedRes = new Path(expectedPath); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } if (!res.equals(expectedRes)) { System.out.println("Actual Res is " + res); diff --git a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java index 44cb9d19d8..17952c8037 100644 --- a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java +++ b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -16,10 +15,13 @@ import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Path; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.NodeCreator; + import java.util.LinkedList; import java.util.List; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -32,7 +34,7 @@ import org.slf4j.LoggerFactory; public class MaxThruputTest { protected static final Logger logger = LoggerFactory - .getLogger(MaxThruputTest.class); + .getLogger(MaxThruputTest.class); Map LinkCostMap = new HashMap(); @Test @@ -74,14 +76,14 @@ public class MaxThruputTest { try { edge1 = new Edge(nc11, nc21); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge1, 10); Edge edge2 = null; try { edge2 = new Edge(nc21, nc11); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge2, 10); @@ -89,14 +91,14 @@ public class MaxThruputTest { try { edge3 = new Edge(nc22, nc31); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge3, 30); Edge edge4 = null; try { edge4 = new Edge(nc31, nc22); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge4, 30); @@ -104,14 +106,14 @@ public class MaxThruputTest { try { edge5 = new Edge(nc32, nc41); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge5, 10); Edge edge6 = null; try { edge6 = new Edge(nc41, nc32); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge6, 10); @@ -119,14 +121,14 @@ public class MaxThruputTest { try { edge7 = new Edge(nc12, nc51); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge7, 20); Edge edge8 = null; try { edge8 = new Edge(nc51, nc12); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge8, 20); @@ -134,14 +136,14 @@ public class MaxThruputTest { try { edge9 = new Edge(nc52, nc61); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge9, 20); Edge edge10 = null; try { edge10 = new Edge(nc61, nc52); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge10, 20); @@ -149,29 +151,47 @@ public class MaxThruputTest { try { edge11 = new Edge(nc62, nc42); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge11, 20); Edge edge12 = null; try { edge12 = new Edge(nc42, nc62); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } LinkCostMap.put(edge12, 20); - imp.edgeUpdate(edge1, UpdateType.ADDED, null); - imp.edgeUpdate(edge2, UpdateType.ADDED, null); - imp.edgeUpdate(edge3, UpdateType.ADDED, null); - imp.edgeUpdate(edge4, UpdateType.ADDED, null); - imp.edgeUpdate(edge5, UpdateType.ADDED, null); - imp.edgeUpdate(edge6, UpdateType.ADDED, null); - imp.edgeUpdate(edge7, UpdateType.ADDED, null); - imp.edgeUpdate(edge8, UpdateType.ADDED, null); - imp.edgeUpdate(edge9, UpdateType.ADDED, null); - imp.edgeUpdate(edge10, UpdateType.ADDED, null); - imp.edgeUpdate(edge11, UpdateType.ADDED, null); - imp.edgeUpdate(edge12, UpdateType.ADDED, null); + List topoedgeupdateList = new ArrayList(); + TopoEdgeUpdate teu1 = new TopoEdgeUpdate(edge1, null, UpdateType.ADDED); + topoedgeupdateList.add(teu1); + TopoEdgeUpdate teu2 = new TopoEdgeUpdate(edge2, null, UpdateType.ADDED); + topoedgeupdateList.add(teu2); + TopoEdgeUpdate teu3 = new TopoEdgeUpdate(edge3, null, UpdateType.ADDED); + topoedgeupdateList.add(teu3); + TopoEdgeUpdate teu4 = new TopoEdgeUpdate(edge4, null, UpdateType.ADDED); + topoedgeupdateList.add(teu4); + TopoEdgeUpdate teu5 = new TopoEdgeUpdate(edge5, null, UpdateType.ADDED); + topoedgeupdateList.add(teu5); + TopoEdgeUpdate teu6 = new TopoEdgeUpdate(edge6, null, UpdateType.ADDED); + topoedgeupdateList.add(teu6); + TopoEdgeUpdate teu7 = new TopoEdgeUpdate(edge7, null, UpdateType.ADDED); + topoedgeupdateList.add(teu7); + TopoEdgeUpdate teu8 = new TopoEdgeUpdate(edge8, null, UpdateType.ADDED); + topoedgeupdateList.add(teu8); + TopoEdgeUpdate teu9 = new TopoEdgeUpdate(edge9, null, UpdateType.ADDED); + topoedgeupdateList.add(teu9); + TopoEdgeUpdate teu10 = new TopoEdgeUpdate(edge10, null, + UpdateType.ADDED); + topoedgeupdateList.add(teu10); + TopoEdgeUpdate teu11 = new TopoEdgeUpdate(edge11, null, + UpdateType.ADDED); + topoedgeupdateList.add(teu11); + TopoEdgeUpdate teu12 = new TopoEdgeUpdate(edge12, null, + UpdateType.ADDED); + topoedgeupdateList.add(teu12); + + imp.edgeUpdate(topoedgeupdateList); imp.initMaxThroughput(LinkCostMap); @@ -188,7 +208,7 @@ public class MaxThruputTest { try { expectedRes = new Path(expectedPath); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } if (!res.equals(expectedRes)) { System.out.println("Actual Res is " + res); @@ -206,7 +226,7 @@ public class MaxThruputTest { try { expectedRes = new Path(expectedPath); } catch (ConstructionException e) { - logger.error("",e); + logger.error("", e); } if (!res.equals(expectedRes)) { System.out.println("Actual Res is " + res); diff --git a/opendaylight/sal/api/pom.xml b/opendaylight/sal/api/pom.xml index 9d8c814d6d..e49ae8dbfd 100644 --- a/opendaylight/sal/api/pom.xml +++ b/opendaylight/sal/api/pom.xml @@ -10,7 +10,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT bundle diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IListenTopoUpdates.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IListenTopoUpdates.java index 8a640f1e9b..b4c44c00d9 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IListenTopoUpdates.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IListenTopoUpdates.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,11 +8,9 @@ package org.opendaylight.controller.sal.topology; -import java.util.Set; +import java.util.List; import org.opendaylight.controller.sal.core.Edge; -import org.opendaylight.controller.sal.core.Property; -import org.opendaylight.controller.sal.core.UpdateType; /** * @file IListenTopoUpdates.java @@ -28,30 +25,31 @@ import org.opendaylight.controller.sal.core.UpdateType; /** * Topology notifications provided by SAL toward the application - * + * */ public interface IListenTopoUpdates { /** * Called to update on Edge in the topology graph - * - * @param e Edge being updated - * @param type Type of update - * @param props Properties of the edge, like BandWidth and/or Latency etc. + * + * @param topoedgeupdateList + * List of topoedgeupdates Each topoedgeupdate includes edge, its + * Properties ( BandWidth and/or Latency etc) and update type. */ - public void edgeUpdate(Edge e, UpdateType type, Set props); + public void edgeUpdate(List topoedgeupdateList); /** - * Called when an Edge utilization is above the safety threshold - * configured on the controller - * - * @param edge The edge which bandwidth usage is above the safety level + * Called when an Edge utilization is above the safety threshold configured + * on the controller + * + * @param edge + * The edge which bandwidth usage is above the safety level */ public void edgeOverUtilized(Edge edge); /** * Called when the Edge utilization is back to normal, below the safety * threshold level configured on the controller - * + * * @param edge */ public void edgeUtilBackToNormal(Edge edge); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginOutTopologyService.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginOutTopologyService.java index b183240d43..b85eec8428 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginOutTopologyService.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginOutTopologyService.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,6 +8,7 @@ package org.opendaylight.controller.sal.topology; +import java.util.List; import java.util.Set; import org.opendaylight.controller.sal.core.Edge; @@ -27,21 +27,22 @@ import org.opendaylight.controller.sal.core.UpdateType; /** * Methods that are invoked from Protocol Plugin toward SAL - * + * */ public interface IPluginOutTopologyService { + /** * Called to update on Edge in the topology graph - * - * @param e Edge being updated - * @param type Type of update - * @param props Properties of the edge, like BandWidth and/or Latency etc. + * + * @param topoedgeupdateList + * List of topoedgeupdates Each topoedgeupdate includes edge, its + * Properties ( BandWidth and/or Latency etc) and update type. */ - public void edgeUpdate(Edge e, UpdateType type, Set props); + public void edgeUpdate(List topoedgeupdateList); /** - * Called when an Edge utilization is above the safety threshold - * configured on the controller + * Called when an Edge utilization is above the safety threshold configured + * on the controller * * @param edge */ @@ -50,7 +51,7 @@ public interface IPluginOutTopologyService { /** * Called when the Edge utilization is back to normal, below the safety * threshold level configured on the controller - * + * * @param edge */ public void edgeUtilBackToNormal(Edge edge); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java new file mode 100644 index 0000000000..d8da9c301b --- /dev/null +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.sal.topology; + +import java.util.Set; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; +import org.opendaylight.controller.sal.core.Edge; +import org.opendaylight.controller.sal.core.Property; +import org.opendaylight.controller.sal.core.UpdateType; + +/** + * The class represents an Edge, the Edge's Property Set and its UpdateType. + */ + +public class TopoEdgeUpdate { + private Edge edge; + private Set props; + private UpdateType type; + + public TopoEdgeUpdate(Edge e, Set p, UpdateType t) { + edge = e; + props = p; + type = t; + } + + public Edge getEdge() { + return edge; + } + + public Set getProperty() { + return props; + } + + public UpdateType getUpdateType() { + return type; + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public String toString() { + return "TopoEdgeUpdate[" + ReflectionToStringBuilder.toString(this) + + "]"; + } + + @Override + public boolean equals(Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } +} diff --git a/opendaylight/sal/implementation/pom.xml b/opendaylight/sal/implementation/pom.xml index 32f0a38157..57ccc4a9d7 100644 --- a/opendaylight/sal/implementation/pom.xml +++ b/opendaylight/sal/implementation/pom.xml @@ -52,7 +52,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Topology.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Topology.java index 8df566f728..f965d7f2c4 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Topology.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Topology.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,7 +8,9 @@ package org.opendaylight.controller.sal.implementation.internal; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.Collections; @@ -20,6 +21,7 @@ import org.opendaylight.controller.sal.topology.IListenTopoUpdates; import org.opendaylight.controller.sal.topology.IPluginInTopologyService; import org.opendaylight.controller.sal.topology.IPluginOutTopologyService; import org.opendaylight.controller.sal.topology.ITopologyService; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,16 +60,16 @@ public class Topology implements IPluginOutTopologyService, ITopologyService { /** * Function called by the dependency manager when all the required * dependencies are satisfied - * + * */ void init() { } /** - * Function called by the dependency manager when at least one - * dependency become unsatisfied or when the component is shutting - * down because for example bundle is being stopped. - * + * Function called by the dependency manager when at least one dependency + * become unsatisfied or when the component is shutting down because for + * example bundle is being stopped. + * */ void destroy() { // Make sure to clear all the data structure we use to track @@ -90,10 +92,10 @@ public class Topology implements IPluginOutTopologyService, ITopologyService { } @Override - public void edgeUpdate(Edge e, UpdateType type, Set props) { + public void edgeUpdate(List topoedgeupdateList) { synchronized (this.updateService) { for (IListenTopoUpdates s : this.updateService) { - s.edgeUpdate(e, type, props); + s.edgeUpdate(topoedgeupdateList); } } } diff --git a/opendaylight/samples/loadbalancer/pom.xml b/opendaylight/samples/loadbalancer/pom.xml index aaf1a183ca..a7583c8ab3 100644 --- a/opendaylight/samples/loadbalancer/pom.xml +++ b/opendaylight/samples/loadbalancer/pom.xml @@ -91,7 +91,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/samples/northbound/loadbalancer/pom.xml b/opendaylight/samples/northbound/loadbalancer/pom.xml index cabcf8d972..94a6ae16c2 100644 --- a/opendaylight/samples/northbound/loadbalancer/pom.xml +++ b/opendaylight/samples/northbound/loadbalancer/pom.xml @@ -22,7 +22,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT @@ -84,7 +84,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/samples/simpleforwarding/pom.xml b/opendaylight/samples/simpleforwarding/pom.xml index 7201b92b05..342d8df8c4 100644 --- a/opendaylight/samples/simpleforwarding/pom.xml +++ b/opendaylight/samples/simpleforwarding/pom.xml @@ -79,7 +79,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/security/pom.xml b/opendaylight/security/pom.xml index 8b0676ba83..2991afc1a4 100644 --- a/opendaylight/security/pom.xml +++ b/opendaylight/security/pom.xml @@ -54,7 +54,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/statisticsmanager/api/pom.xml b/opendaylight/statisticsmanager/api/pom.xml index 67329ba5e0..5c5b71dfb0 100644 --- a/opendaylight/statisticsmanager/api/pom.xml +++ b/opendaylight/statisticsmanager/api/pom.xml @@ -41,7 +41,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/statisticsmanager/implementation/pom.xml b/opendaylight/statisticsmanager/implementation/pom.xml index 98bf15d274..311204b545 100644 --- a/opendaylight/statisticsmanager/implementation/pom.xml +++ b/opendaylight/statisticsmanager/implementation/pom.xml @@ -88,7 +88,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/statisticsmanager/integrationtest/pom.xml b/opendaylight/statisticsmanager/integrationtest/pom.xml index 397480e1e6..69c686c708 100644 --- a/opendaylight/statisticsmanager/integrationtest/pom.xml +++ b/opendaylight/statisticsmanager/integrationtest/pom.xml @@ -21,7 +21,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java b/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java index fa96d5304e..2515173198 100644 --- a/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java +++ b/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java @@ -82,7 +82,7 @@ public class StatisticsManagerIntegrationTest { mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"), // List all the bundles on which the test case depends mavenBundle("org.opendaylight.controller", "sal", - "0.4.0-SNAPSHOT"), + "0.5.0-SNAPSHOT"), mavenBundle("org.opendaylight.controller", "sal.implementation", "0.4.0-SNAPSHOT"), mavenBundle("org.opendaylight.controller", "statisticsmanager", diff --git a/opendaylight/switchmanager/api/pom.xml b/opendaylight/switchmanager/api/pom.xml index d57a2d4a01..44746e5653 100644 --- a/opendaylight/switchmanager/api/pom.xml +++ b/opendaylight/switchmanager/api/pom.xml @@ -98,7 +98,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/switchmanager/implementation/pom.xml b/opendaylight/switchmanager/implementation/pom.xml index 5e9eb5f994..6f7a7ea13c 100644 --- a/opendaylight/switchmanager/implementation/pom.xml +++ b/opendaylight/switchmanager/implementation/pom.xml @@ -101,7 +101,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/topologymanager/pom.xml b/opendaylight/topologymanager/pom.xml index dd7ad2d6f0..29a060f477 100755 --- a/opendaylight/topologymanager/pom.xml +++ b/opendaylight/topologymanager/pom.xml @@ -54,7 +54,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java b/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java index 0eb7bdbc5c..e8d0d416e5 100644 --- a/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java +++ b/opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -12,6 +11,7 @@ package org.opendaylight.controller.topologymanager.internal; import java.io.FileNotFoundException; import java.io.IOException; import java.io.ObjectInputStream; +import java.util.ArrayList; import java.util.Collections; import java.util.Dictionary; import java.util.EnumSet; @@ -20,6 +20,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -44,6 +45,7 @@ import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.core.Node.NodeIDType; import org.opendaylight.controller.sal.topology.IListenTopoUpdates; import org.opendaylight.controller.sal.topology.ITopologyService; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.IObjectReader; @@ -84,37 +86,36 @@ public class TopologyManagerImpl implements ITopologyManager, private static String ROOT = GlobalConstants.STARTUPHOME.toString(); private String userLinksFileName = null; private ConcurrentMap userLinks; - + void nonClusterObjectCreate() { - edgesDB = new ConcurrentHashMap>(); - hostsDB = new ConcurrentHashMap>>(); - userLinks = new ConcurrentHashMap(); - nodeConnectorsDB = new ConcurrentHashMap>(); + edgesDB = new ConcurrentHashMap>(); + hostsDB = new ConcurrentHashMap>>(); + userLinks = new ConcurrentHashMap(); + nodeConnectorsDB = new ConcurrentHashMap>(); } - void setTopologyManagerAware(ITopologyManagerAware s) { if (this.topologyManagerAware != null) { - log.debug("Adding ITopologyManagerAware: {}", s); + log.debug("Adding ITopologyManagerAware: {}", s); this.topologyManagerAware.add(s); } } void unsetTopologyManagerAware(ITopologyManagerAware s) { if (this.topologyManagerAware != null) { - log.debug("Removing ITopologyManagerAware: {}", s); + log.debug("Removing ITopologyManagerAware: {}", s); this.topologyManagerAware.remove(s); } } void setTopoService(ITopologyService s) { - log.debug("Adding ITopologyService: {}", s); + log.debug("Adding ITopologyService: {}", s); this.topoService = s; } void unsetTopoService(ITopologyService s) { if (this.topoService == s) { - log.debug("Removing ITopologyService: {}", s); + log.debug("Removing ITopologyService: {}", s); this.topoService = null; } } @@ -134,7 +135,7 @@ public class TopologyManagerImpl implements ITopologyManager, /** * Function called by the dependency manager when all the required * dependencies are satisfied - * + * */ void init(Component c) { String containerName = null; @@ -200,9 +201,9 @@ public class TopologyManagerImpl implements ITopologyManager, } /** - * Function called after the topology manager has registered the - * service in OSGi service registry. - * + * Function called after the topology manager has registered the service in + * OSGi service registry. + * */ void started() { // SollicitRefresh MUST be called here else if called at init @@ -212,10 +213,10 @@ public class TopologyManagerImpl implements ITopologyManager, } /** - * Function called by the dependency manager when at least one - * dependency become unsatisfied or when the component is shutting - * down because for example bundle is being stopped. - * + * Function called by the dependency manager when at least one dependency + * become unsatisfied or when the component is shutting down because for + * example bundle is being stopped. + * */ void destroy() { if (this.clusterContainerService == null) { @@ -255,18 +256,18 @@ public class TopologyManagerImpl implements ITopologyManager, // Publish the save config event to the cluster nodes /** * Get the CLUSTERING SERVICES WORKING BEFORE TRYING THIS - - configSaveEvent.put(new Date().getTime(), SAVE); + * + * configSaveEvent.put(new Date().getTime(), SAVE); */ return saveConfigInternal(); } public Status saveConfigInternal() { - Status retS; + Status retS; ObjectWriter objWriter = new ObjectWriter(); - retS = objWriter.write( - new ConcurrentHashMap( + retS = objWriter + .write(new ConcurrentHashMap( userLinks), userLinksFileName); if (retS.isSuccess()) { @@ -324,11 +325,11 @@ public class TopologyManagerImpl implements ITopologyManager, } /** - * The Map returned is a copy of the current topology hence if the - * topology changes the copy doesn't - * - * @return A Map representing the current topology expressed as - * edges of the network + * The Map returned is a copy of the current topology hence if the topology + * changes the copy doesn't + * + * @return A Map representing the current topology expressed as edges of the + * network */ @Override public Map> getEdges() { @@ -340,8 +341,8 @@ public class TopologyManagerImpl implements ITopologyManager, for (Edge key : this.edgesDB.keySet()) { // Sets of props are copied because the composition of // those properties could change with time - HashSet prop = new HashSet(this.edgesDB - .get(key)); + HashSet prop = new HashSet( + this.edgesDB.get(key)); // We can simply reuse the key because the object is // immutable so doesn't really matter that we are // referencing the only owned by a different table, the @@ -354,7 +355,8 @@ public class TopologyManagerImpl implements ITopologyManager, // TODO remove with spring-dm removal /** - * @param set the topologyAware to set + * @param set + * the topologyAware to set */ public void setTopologyAware(Set set) { for (Object s : set) { @@ -411,7 +413,7 @@ public class TopologyManagerImpl implements ITopologyManager, if (this.hostsDB == null) { return; } - + switch (t) { case ADDED: case CHANGED: @@ -432,8 +434,8 @@ public class TopologyManagerImpl implements ITopologyManager, } } - @Override - public void edgeUpdate(Edge e, UpdateType type, Set props) { + private TopoEdgeUpdate edgeUpdate(Edge e, UpdateType type, + Set props) { switch (type) { case ADDED: // Make sure the props are non-null @@ -444,7 +446,7 @@ public class TopologyManagerImpl implements ITopologyManager, props = (Set) new HashSet(props); } - // Now make sure thre is the creation timestamp for the + // Now make sure there is the creation timestamp for the // edge, if not there timestamp with the first update boolean found_create = false; for (Property prop : props) { @@ -507,7 +509,7 @@ public class TopologyManagerImpl implements ITopologyManager, } } - // Now lest make sure new properties are non-null + // Now lets make sure new properties are non-null // Make sure the props are non-null if (props == null) { props = (Set) new HashSet(); @@ -538,37 +540,52 @@ public class TopologyManagerImpl implements ITopologyManager, log.trace("Edge {} {}", e.toString(), type.name()); break; } + return new TopoEdgeUpdate(e, props, type); + } + + @Override + public void edgeUpdate(List topoedgeupdateList) { + List teuList = new ArrayList(); + for (int i = 0; i < topoedgeupdateList.size(); i++) { + Edge e = topoedgeupdateList.get(i).getEdge(); + Set p = topoedgeupdateList.get(i).getProperty(); + UpdateType type = topoedgeupdateList.get(i).getUpdateType(); + TopoEdgeUpdate teu = edgeUpdate(e, type, p); + teuList.add(teu); + } // Now update the listeners for (ITopologyManagerAware s : this.topologyManagerAware) { try { - s.edgeUpdate(e, type, props); + s.edgeUpdate(teuList); } catch (Exception exc) { log.error("Exception on callback", exc); } } + } private Edge getReverseLinkTuple(TopologyUserLinkConfig link) { - TopologyUserLinkConfig rLink = new TopologyUserLinkConfig( - link.getName(), link.getDstNodeIDType(), link.getDstSwitchId(), - link.getDstNodeConnectorIDType(), link.getDstPort(), - link.getSrcNodeIDType(), link.getSrcSwitchId(), - link.getSrcNodeConnectorIDType(), link.getSrcPort()); + TopologyUserLinkConfig rLink = new TopologyUserLinkConfig( + link.getName(), link.getDstNodeIDType(), link.getDstSwitchId(), + link.getDstNodeConnectorIDType(), link.getDstPort(), + link.getSrcNodeIDType(), link.getSrcSwitchId(), + link.getSrcNodeConnectorIDType(), link.getSrcPort()); return getLinkTuple(rLink); } private Edge getLinkTuple(TopologyUserLinkConfig link) { Edge linkTuple = null; - // if atleast 1 link exists for the srcPort and atleast 1 link exists for the dstPort + // if atleast 1 link exists for the srcPort and atleast 1 link exists + // for the dstPort // that makes it ineligible for the Manual link addition // This is just an extra protection to avoid mis-programming. boolean srcLinkExists = false; boolean dstLinkExists = false; - //TODO check a way to validate the port with inventory services - //if (srcSw.getPorts().contains(srcPort) && - //dstSw.getPorts().contains(srcPort) && + // TODO check a way to validate the port with inventory services + // if (srcSw.getPorts().contains(srcPort) && + // dstSw.getPorts().contains(srcPort) && if (!srcLinkExists && !dstLinkExists) { Node sNode = null; Node dNode = null; @@ -580,44 +597,44 @@ public class TopologyManagerImpl implements ITopologyManager, String dstNodeIDType = link.getDstNodeIDType(); String dstNodeConnectorIDType = link.getDstNodeConnectorIDType(); try { - if (srcNodeIDType.equals(NodeIDType.OPENFLOW)) { + if (srcNodeIDType.equals(NodeIDType.OPENFLOW)) { sNode = new Node(srcNodeIDType, link.getSrcSwitchIDLong()); - } else { - sNode = new Node(srcNodeIDType, link.getSrcSwitchId()); - } + } else { + sNode = new Node(srcNodeIDType, link.getSrcSwitchId()); + } - if (dstNodeIDType.equals(NodeIDType.OPENFLOW)) { + if (dstNodeIDType.equals(NodeIDType.OPENFLOW)) { dNode = new Node(dstNodeIDType, link.getDstSwitchIDLong()); - } else { - dNode = new Node(dstNodeIDType, link.getDstSwitchId()); - } - - if (srcNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) { + } else { + dNode = new Node(dstNodeIDType, link.getDstSwitchId()); + } + + if (srcNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) { Short srcPort = Short.valueOf((short) 0); - if (!link.isSrcPortByName()) { - srcPort = Short.parseShort(link.getSrcPort()); - } - sPort = new NodeConnector(srcNodeConnectorIDType, - srcPort, sNode); - } else { - sPort = new NodeConnector(srcNodeConnectorIDType, - link.getSrcPort(), sNode); - } - - if (dstNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) { + if (!link.isSrcPortByName()) { + srcPort = Short.parseShort(link.getSrcPort()); + } + sPort = new NodeConnector(srcNodeConnectorIDType, srcPort, + sNode); + } else { + sPort = new NodeConnector(srcNodeConnectorIDType, + link.getSrcPort(), sNode); + } + + if (dstNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) { Short dstPort = Short.valueOf((short) 0); - if (!link.isDstPortByName()) { - dstPort = Short.parseShort(link.getDstPort()); - } - dPort = new NodeConnector(dstNodeConnectorIDType, - dstPort, dNode); - } else { - dPort = new NodeConnector(dstNodeConnectorIDType, - link.getDstPort(), dNode); - } + if (!link.isDstPortByName()) { + dstPort = Short.parseShort(link.getDstPort()); + } + dPort = new NodeConnector(dstNodeConnectorIDType, dstPort, + dNode); + } else { + dPort = new NodeConnector(dstNodeConnectorIDType, + link.getDstPort(), dNode); + } linkTuple = new Edge(sPort, dPort); } catch (ConstructionException cex) { - log.warn("Caught exception ", cex); + log.warn("Caught exception ", cex); } return linkTuple; } @@ -636,12 +653,12 @@ public class TopologyManagerImpl implements ITopologyManager, @Override public Status addUserLink(TopologyUserLinkConfig link) { if (!link.isValid()) { - return new Status(StatusCode.BADREQUEST, - "Configuration Invalid. Please check the parameters"); + return new Status(StatusCode.BADREQUEST, + "Configuration Invalid. Please check the parameters"); } if (userLinks.get(link.getName()) != null) { - return new Status(StatusCode.CONFLICT, - "Link with name : " + link.getName() + return new Status(StatusCode.CONFLICT, "Link with name : " + + link.getName() + " already exists. Please use another name"); } if (userLinks.containsValue(link)) { @@ -658,8 +675,8 @@ public class TopologyManagerImpl implements ITopologyManager, link.setStatus(TopologyUserLinkConfig.STATUS.SUCCESS); } catch (Exception e) { return new Status(StatusCode.INTERNALERROR, - "Exception while adding custom link : " + - e.getMessage()); + "Exception while adding custom link : " + + e.getMessage()); } } return new Status(StatusCode.SUCCESS, null); @@ -668,8 +685,8 @@ public class TopologyManagerImpl implements ITopologyManager, @Override public Status deleteUserLink(String linkName) { if (linkName == null) { - return new Status(StatusCode.BADREQUEST, - "A valid linkName is required to Delete a link"); + return new Status(StatusCode.BADREQUEST, + "A valid linkName is required to Delete a link"); } TopologyUserLinkConfig link = userLinks.get(linkName); @@ -678,19 +695,19 @@ public class TopologyManagerImpl implements ITopologyManager, userLinks.remove(linkName); if (linkTuple != null) { try { - //oneTopology.deleteUserConfiguredLink(linkTuple); + // oneTopology.deleteUserConfiguredLink(linkTuple); } catch (Exception e) { - log - .warn("Harmless : Exception while Deleting User Configured link {} {}", - link, e.toString()); + log.warn( + "Harmless : Exception while Deleting User Configured link {} {}", + link, e.toString()); } linkTuple = getReverseLinkTuple(link); try { - //oneTopology.deleteUserConfiguredLink(linkTuple); + // oneTopology.deleteUserConfiguredLink(linkTuple); } catch (Exception e) { - log - .warn("Harmless : Exception while Deleting User Configured Reverse link {} {}", - link, e.toString()); + log.warn( + "Harmless : Exception while Deleting User Configured Reverse link {} {}", + link, e.toString()); } } return new Status(StatusCode.SUCCESS, null); @@ -707,7 +724,7 @@ public class TopologyManagerImpl implements ITopologyManager, public String getHelp() { StringBuffer help = new StringBuffer(); help.append("---Topology Manager---\n"); - help.append("\t addTopo name \n"); + help.append("\t addTopo name \n"); help.append("\t delTopo name\n"); help.append("\t printTopo\n"); help.append("\t printNodeEdges\n"); @@ -716,11 +733,11 @@ public class TopologyManagerImpl implements ITopologyManager, public void _printTopo(CommandInterpreter ci) { for (String name : this.userLinks.keySet()) { - TopologyUserLinkConfig linkConfig = userLinks.get(name); + TopologyUserLinkConfig linkConfig = userLinks.get(name); ci.println("Name : " + name); ci.println(linkConfig); - ci.println("Edge " + getLinkTuple(linkConfig)); - ci.println("Reverse Edge " + getReverseLinkTuple(linkConfig)); + ci.println("Edge " + getLinkTuple(linkConfig)); + ci.println("Reverse Edge " + getReverseLinkTuple(linkConfig)); } } @@ -778,9 +795,9 @@ public class TopologyManagerImpl implements ITopologyManager, ci.println("Null destination port number"); return; } - TopologyUserLinkConfig config = new TopologyUserLinkConfig(name, - srcNodeIDType, dpid, srcNodeConnectorIDType, port, - dstNodeIDType, ddpid, dstNodeConnectorIDType, dport); + TopologyUserLinkConfig config = new TopologyUserLinkConfig(name, + srcNodeIDType, dpid, srcNodeConnectorIDType, port, + dstNodeIDType, ddpid, dstNodeConnectorIDType, dport); ci.println(this.addUserLink(config)); } @@ -794,23 +811,23 @@ public class TopologyManagerImpl implements ITopologyManager, } public void _printNodeEdges(CommandInterpreter ci) { - Map> nodeEdges = getNodeEdges(); - if (nodeEdges == null) { - return; - } - Set nodeSet = nodeEdges.keySet(); - if (nodeSet == null) { - return; - } + Map> nodeEdges = getNodeEdges(); + if (nodeEdges == null) { + return; + } + Set nodeSet = nodeEdges.keySet(); + if (nodeSet == null) { + return; + } ci.println(" Node Edge"); - for (Node node : nodeSet) { - Set edgeSet = nodeEdges.get(node); - if (edgeSet == null) { - continue; - } - for (Edge edge : edgeSet) { - ci.println(node + " " + edge); - } + for (Node node : nodeSet) { + Set edgeSet = nodeEdges.get(node); + if (edgeSet == null) { + continue; + } + for (Edge edge : edgeSet) { + ci.println(node + " " + edge); + } } } diff --git a/opendaylight/topologymanager/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java b/opendaylight/topologymanager/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java index c2e3df9d00..c176cb2cf3 100644 --- a/opendaylight/topologymanager/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java +++ b/opendaylight/topologymanager/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -11,8 +10,10 @@ package org.opendaylight.controller.topologymanager.internal; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentMap; @@ -31,361 +32,420 @@ import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.State; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.packet.address.EthernetAddress; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.NodeCreator; import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; -public class TopologyManagerImplTest { - - /* - * Sets the node, edges and properties for edges here: - * Edge : - * <1:1>--><11:11>; <1:2>--><11:12>; - * <3:3>--><13:13>; <3:4>--><13:14>; - * <5:5>--><15:15>; <5:6>--><15:16>; - * Method used by two tests: testGetNodeEdges and testGetEdges - * @param topoManagerImpl - * @throws ConstructionException - */ - public void setNodeEdges(TopologyManagerImpl topoManagerImpl) throws ConstructionException { - topoManagerImpl.nonClusterObjectCreate(); - - State state; - Bandwidth bw; - Latency l; - - Set props = new HashSet(); - state = new State(State.EDGE_UP); - bw = new Bandwidth(Bandwidth.BW100Gbps); - l = new Latency(Latency.LATENCY100ns); - props.add(state); - props.add(bw); - props.add(l); - - for (short i = 1; i < 6; i=(short) (i+2)) { - NodeConnector headnc1 = NodeConnectorCreator.createOFNodeConnector(i, NodeCreator.createOFNode((long)i)); - NodeConnector tailnc1 = NodeConnectorCreator.createOFNodeConnector((short)(i+10), NodeCreator.createOFNode((long)(i+10))); - Edge e1 = new Edge(headnc1, tailnc1); - topoManagerImpl.edgeUpdate(e1, UpdateType.ADDED, props); - - NodeConnector headnc2 = NodeConnectorCreator.createOFNodeConnector((short) (i+1), headnc1.getNode()); - NodeConnector tailnc2 = NodeConnectorCreator.createOFNodeConnector((short)(i+11), tailnc1.getNode()); - Edge e2 = new Edge(headnc2, tailnc2); - topoManagerImpl.edgeUpdate(e2, UpdateType.ADDED, props); - } - } - - @Test - public void testGetNodeEdges() throws ConstructionException { - TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); - setNodeEdges(topoManagerImpl); - - Map> nodeEdgeMap = topoManagerImpl.getNodeEdges(); - for (Iterator>> i = nodeEdgeMap.entrySet().iterator(); i.hasNext();) { - Map.Entry> entry = i.next(); - Node node = entry.getKey(); - Long nodeId = ((Long) node.getID()).longValue(); - Assert.assertTrue((node.getType().equals(NodeIDType.OPENFLOW))); - - Set edges = entry.getValue(); - for (Edge edge : edges) { - Long headNcId = ((Short)edge.getHeadNodeConnector().getID()).longValue(); - Long tailNcId = ((Short) edge.getTailNodeConnector().getID()).longValue(); - if (nodeId == 1 || nodeId == 3 || nodeId == 5) { - Assert.assertTrue((headNcId.equals(nodeId) && tailNcId.equals(nodeId + 10)) || - (headNcId.equals(nodeId + 10) && tailNcId.equals(nodeId)) || - (headNcId.equals(nodeId + 1) && tailNcId.equals(nodeId + 11)) || - (headNcId.equals(nodeId + 11) && tailNcId.equals(nodeId + 1))); - } else if (nodeId == 11 || nodeId == 13 || nodeId == 15) { - Assert.assertTrue((headNcId.equals(nodeId) && tailNcId.equals(nodeId - 10)) || - (headNcId.equals(nodeId) && tailNcId.equals(nodeId - 10)) || - (headNcId.equals(nodeId - 9) && tailNcId.equals(nodeId + 1)) || - (headNcId.equals(nodeId + 1) && tailNcId.equals(nodeId - 9))); - } - } - i.remove(); - } - Assert.assertTrue(nodeEdgeMap.isEmpty()); - } - - @Test - public void testGetEdges() throws ConstructionException { - TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); - setNodeEdges(topoManagerImpl); - - Map> edgeProperty = topoManagerImpl.getEdges(); - - for (Iterator >> i = edgeProperty.entrySet().iterator() ; i.hasNext();) { - Map.Entry> entry = i.next(); - Edge e = entry.getKey(); - NodeConnector headnc = e.getHeadNodeConnector(); - NodeConnector tailnc = e.getTailNodeConnector(); - - Long headNodeId = (Long) headnc.getNode().getID(); - - Long headNcId = ((Short)headnc.getID()).longValue(); - Long tailNcId = ((Short)tailnc.getID()).longValue(); - - if (headNodeId == 1 || headNodeId == 3 || headNodeId == 5) { - Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId.equals(headNodeId + 10)) || - (headNcId.equals(headNodeId + 10) && tailNcId.equals(headNodeId)) || - (headNcId.equals(headNodeId + 1) && tailNcId.equals(headNodeId + 11)) || - (headNcId.equals(headNodeId + 11) && tailNcId.equals(headNodeId + 1))); - } else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) { - Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId.equals(headNodeId - 10)) || - (headNcId.equals(headNodeId) && tailNcId.equals(headNodeId - 10)) || - (headNcId.equals(headNodeId - 9) && tailNcId.equals(headNodeId + 1)) || - (headNcId.equals(headNodeId + 1) && tailNcId.equals(headNodeId - 9))); - } - - Set prop = entry.getValue(); - for (Property p : prop) { - String pName; - long pValue; - if (p instanceof Bandwidth) { - Bandwidth b = (Bandwidth)p; - pName = Bandwidth.BandwidthPropName; - pValue = b.getValue(); - Assert.assertTrue(pName.equals(p.getName()) && pValue == Bandwidth.BW100Gbps ); - continue; - } - if (p instanceof Latency) { - Latency l = (Latency)p; - pName = Latency.LatencyPropName; - pValue = l.getValue(); - Assert.assertTrue(pName.equals(p.getName()) && pValue == Latency.LATENCY100ns); - continue; - } - if (p instanceof State) { - State state = (State)p; - pName = State.StatePropName; - pValue = state.getValue(); - Assert.assertTrue(pName.equals(p.getName()) && pValue == State.EDGE_UP); - continue; - } - } - i.remove(); - } - Assert.assertTrue(edgeProperty.isEmpty()); - } - - - @Test - public void testAddDeleteUserLink () { - TopologyUserLinkConfig link1 = new TopologyUserLinkConfig("default1", "OF", "1", "OF", "2", "OF", "1", "OF", "2"); - TopologyUserLinkConfig link2 = new TopologyUserLinkConfig("default1", "OF", "10", "OF", "20", "OF", "10", "OF", "20"); - TopologyUserLinkConfig link3 = new TopologyUserLinkConfig("default2", "OF", "1", "OF", "2", "OF", "1", "OF", "2"); - TopologyUserLinkConfig link4 = new TopologyUserLinkConfig("default20", "OF", "10", "OF", "20", "OF", "10", "OF", "20"); - - TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); - topoManagerImpl.nonClusterObjectCreate(); - - Assert.assertTrue (topoManagerImpl.addUserLink(link1).isSuccess()); - Assert.assertTrue (topoManagerImpl.addUserLink(link2).getCode() == StatusCode.CONFLICT); - Assert.assertTrue (topoManagerImpl.addUserLink(link3).getCode() == StatusCode.CONFLICT); - Assert.assertTrue (topoManagerImpl.addUserLink(link4).isSuccess()); - - Assert.assertTrue (topoManagerImpl.deleteUserLink(null).getCode() == StatusCode.BADREQUEST); - Assert.assertTrue (topoManagerImpl.deleteUserLink(link1.getName()).isSuccess()); - Assert.assertTrue (topoManagerImpl.deleteUserLink(link4.getName()).isSuccess()); - Assert.assertTrue (topoManagerImpl.getUserLinks().isEmpty()); - - } - - @Test - public void testGetUserLink () { - TopologyUserLinkConfig[] link = new TopologyUserLinkConfig[5]; - TopologyUserLinkConfig[] reverseLink = new TopologyUserLinkConfig[5]; - TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); - topoManagerImpl.nonClusterObjectCreate(); - - String name = null; - String srcNodeIDType = null; - String srcSwitchId = null; - String srcNodeConnectorIDType = null; - String srcPort = null; - String dstNodeIDType = null; - String dstSwitchId = null; - String dstNodeConnectorIDType = null; - String dstPort = null; - - /*Creating userlinks and checking for their validity*/ - link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId, - srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId, - dstNodeConnectorIDType, dstPort); - Assert.assertTrue(link[0].isValid() == false); - - srcSwitchId = "1"; - link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId, - srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId, - dstNodeConnectorIDType, dstPort); - Assert.assertTrue(link[0].isValid() == false); - - dstSwitchId = "2"; - link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId, - srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId, - dstNodeConnectorIDType, dstPort); - Assert.assertTrue(link[0].isValid() == false); - - - Integer i; - - for (i = 0; i < 5; i++) { - link[i] = new TopologyUserLinkConfig(name, srcNodeIDType, - srcSwitchId, srcNodeConnectorIDType, srcPort, - dstNodeIDType, dstSwitchId, dstNodeConnectorIDType, dstPort); - - name = Integer.toString(i + 1); - srcSwitchId = Integer.toString(i + 1); - srcPort = Integer.toString(i + 1); - dstSwitchId = Integer.toString((i + 1)*10); - dstPort = Integer.toString((i + 1)*10); - - link[i].setName(name); - link[i].setSrcSwitchId(srcSwitchId); - link[i].setSrcPort(srcPort); - link[i].setDstSwitchId(dstSwitchId); - link[i].setDstPort(dstPort); - - Assert.assertTrue(link[i].isValid() == false); - - link[i].setSrcNodeIDType("OF"); - link[i].setSrcNodeConnectorIDType("OF"); - - Assert.assertTrue(link[i].isValid() == false); - - link[i].setDstNodeIDType("OF"); - link[i].setDstNodeConnectorIDType("OF"); - - Assert.assertTrue(link[i].isValid() == true); - - reverseLink[i] = new TopologyUserLinkConfig(name, dstNodeIDType, - dstSwitchId, dstNodeConnectorIDType, dstPort, - srcNodeIDType, srcSwitchId, srcNodeConnectorIDType, srcPort); - - topoManagerImpl.addUserLink(link[i]); - } - ConcurrentMap userLinks = topoManagerImpl.getUserLinks(); - TopologyUserLinkConfig resultLink; - - for (i = 0; i < 5; i++) { - resultLink = userLinks.get(((Integer)(i + 1)).toString()); - - Assert.assertTrue(resultLink.getName().equals(reverseLink[i].getName())); - Assert.assertTrue(resultLink.getDstSwitchId().equals(reverseLink[i].getSrcSwitchId())); - Assert.assertTrue(resultLink.getDstPort().equals(reverseLink[i].getSrcPort())); - Assert.assertTrue(resultLink.getSrcSwitchId().equals(reverseLink[i].getDstSwitchId())); - Assert.assertTrue(resultLink.getSrcPort().equals(reverseLink[i].getDstPort())); - } - } - - @Test - public void testHostLinkMethods() throws ConstructionException, UnknownHostException { - TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); - topoManagerImpl.nonClusterObjectCreate(); - int hostCounter = 0; - - State state; - Bandwidth bw; - Latency l; - Set props = new HashSet(); - state = new State(State.EDGE_UP); - bw = new Bandwidth(Bandwidth.BW100Gbps); - l = new Latency(Latency.LATENCY100ns); - props.add(state); - props.add(bw); - props.add(l); - - EthernetAddress ea; - InetAddress ip; - Host[] h = new Host[5]; - NodeConnector[] nc = new NodeConnector[5]; - - /* Adding host, nodeConnector to hostsDB for the i = 0,1,2,3. No host - * added for i = 4 - */ - for (int i = 0; i < 5; i++) { - if (hostCounter < 4) { - ea = new EthernetAddress(new byte[]{(byte)0x0, (byte)0x0, - (byte)0x0, (byte)0x0, - (byte)0x0, (byte)i}); - String stringIP = new StringBuilder().append(i + 1).append(".").append(i+10).append(".").append(i+20).append(".").append(i+30).toString(); - ip = InetAddress.getByName(stringIP); - h[hostCounter] = new Host(ea, ip); - } else { - h[hostCounter] = null; - } - hostCounter++; - nc[i] = NodeConnectorCreator.createOFNodeConnector((short)(i + 1), NodeCreator.createOFNode((long)(i + 1))); - topoManagerImpl.updateHostLink(nc[i], h[i], UpdateType.ADDED, props); - } - - for (int i = 0; i < 5; i++) { - Host host = topoManagerImpl.getHostAttachedToNodeConnector(nc[i]); - if (i == 4) - Assert.assertTrue(host == null); - else - Assert.assertTrue(host.equals(h[i])); - } - - Set ncSet = topoManagerImpl.getNodeConnectorWithHost(); - for (int i = 0; i < 5; i++) { - Assert.assertTrue(ncSet.remove(nc[i])); - } - Assert.assertTrue(ncSet.isEmpty()); - } - - @Test - public void testGetNodesWithNodeConnectorHost() throws ConstructionException, UnknownHostException { - TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); - topoManagerImpl.nonClusterObjectCreate(); - int hostCounter = 0; - - State state; - Bandwidth bw; - Latency l; - Set props = new HashSet(); - state = new State(State.EDGE_UP); - bw = new Bandwidth(Bandwidth.BW100Gbps); - l = new Latency(Latency.LATENCY100ns); - props.add(state); - props.add(bw); - props.add(l); - - EthernetAddress ea; - InetAddress ip; - Host[] h = new Host[5]; - NodeConnector[] nc = new NodeConnector[5]; - - /*Adding host, nodeconnector, properties of edge to hostsDB for the first three nodes only*/ - for (int i = 1; i < 6; i++) { - if (i < 4) { - ea = new EthernetAddress(new byte[]{(byte)0x0, (byte)0x0, - (byte)0x0, (byte)0x0, - (byte)0x0, (byte)i}); - String stringIP = new StringBuilder().append(i).append(".").append(i+10).append(".").append(i+20).append(".").append(i+30).toString(); - ip = InetAddress.getByName(stringIP); - h[hostCounter] = new Host(ea, ip); - } - else { - h[hostCounter] = null; - } - hostCounter++; - nc[i - 1] = NodeConnectorCreator.createOFNodeConnector((short)i, NodeCreator.createOFNode((long)i)); - topoManagerImpl.updateHostLink(nc[i - 1], h[i - 1], UpdateType.ADDED, props); - } - - /*Get the nodes which have host connected to its nodeConnector*/ - Map> nodeNCmap = topoManagerImpl.getNodesWithNodeConnectorHost(); - for (int i = 1; i < 6; i++) { - Node node = nc[i - 1].getNode(); - Set ncSet = nodeNCmap.get(nc[i - 1].getNode()); - - Assert.assertTrue(ncSet == nodeNCmap.remove(node)); - } - - Assert.assertTrue(nodeNCmap.isEmpty()); - } -} +public class TopologyManagerImplTest { + + /* + * Sets the node, edges and properties for edges here: Edge : <1:1>--><11:11>; <1:2>--><11:12>; <3:3>--><13:13>; + * <3:4>--><13:14>; <5:5>--><15:15>; <5:6>--><15:16>; Method used by two + * tests: testGetNodeEdges and testGetEdges + * + * @param topoManagerImpl + * + * @throws ConstructionException + */ + public void setNodeEdges(TopologyManagerImpl topoManagerImpl) + throws ConstructionException { + topoManagerImpl.nonClusterObjectCreate(); + + State state; + Bandwidth bw; + Latency l; + + Set props = new HashSet(); + state = new State(State.EDGE_UP); + bw = new Bandwidth(Bandwidth.BW100Gbps); + l = new Latency(Latency.LATENCY100ns); + props.add(state); + props.add(bw); + props.add(l); + + for (short i = 1; i < 6; i = (short) (i + 2)) { + List topoedgeupdateList = new ArrayList(); + NodeConnector headnc1 = NodeConnectorCreator.createOFNodeConnector( + i, NodeCreator.createOFNode((long) i)); + NodeConnector tailnc1 = NodeConnectorCreator + .createOFNodeConnector((short) (i + 10), + NodeCreator.createOFNode((long) (i + 10))); + Edge e1 = new Edge(headnc1, tailnc1); + TopoEdgeUpdate teu1 = new TopoEdgeUpdate(e1, props, + UpdateType.ADDED); + topoedgeupdateList.add(teu1); + + NodeConnector headnc2 = NodeConnectorCreator.createOFNodeConnector( + (short) (i + 1), headnc1.getNode()); + NodeConnector tailnc2 = NodeConnectorCreator.createOFNodeConnector( + (short) (i + 11), tailnc1.getNode()); + Edge e2 = new Edge(headnc2, tailnc2); + TopoEdgeUpdate teu2 = new TopoEdgeUpdate(e2, props, + UpdateType.ADDED); + topoedgeupdateList.add(teu2); + topoManagerImpl.edgeUpdate(topoedgeupdateList); + + } + + } + + @Test + public void testGetNodeEdges() throws ConstructionException { + TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); + setNodeEdges(topoManagerImpl); + + Map> nodeEdgeMap = topoManagerImpl.getNodeEdges(); + for (Iterator>> i = nodeEdgeMap.entrySet() + .iterator(); i.hasNext();) { + Map.Entry> entry = i.next(); + Node node = entry.getKey(); + Long nodeId = ((Long) node.getID()).longValue(); + Assert.assertTrue((node.getType().equals(NodeIDType.OPENFLOW))); + + Set edges = entry.getValue(); + for (Edge edge : edges) { + Long headNcId = ((Short) edge.getHeadNodeConnector().getID()) + .longValue(); + Long tailNcId = ((Short) edge.getTailNodeConnector().getID()) + .longValue(); + if (nodeId == 1 || nodeId == 3 || nodeId == 5) { + Assert.assertTrue((headNcId.equals(nodeId) && tailNcId + .equals(nodeId + 10)) + || (headNcId.equals(nodeId + 10) && tailNcId + .equals(nodeId)) + || (headNcId.equals(nodeId + 1) && tailNcId + .equals(nodeId + 11)) + || (headNcId.equals(nodeId + 11) && tailNcId + .equals(nodeId + 1))); + } else if (nodeId == 11 || nodeId == 13 || nodeId == 15) { + Assert.assertTrue((headNcId.equals(nodeId) && tailNcId + .equals(nodeId - 10)) + || (headNcId.equals(nodeId) && tailNcId + .equals(nodeId - 10)) + || (headNcId.equals(nodeId - 9) && tailNcId + .equals(nodeId + 1)) + || (headNcId.equals(nodeId + 1) && tailNcId + .equals(nodeId - 9))); + } + } + i.remove(); + } + Assert.assertTrue(nodeEdgeMap.isEmpty()); + } + + @Test + public void testGetEdges() throws ConstructionException { + TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); + setNodeEdges(topoManagerImpl); + + Map> edgeProperty = topoManagerImpl.getEdges(); + + for (Iterator>> i = edgeProperty + .entrySet().iterator(); i.hasNext();) { + Map.Entry> entry = i.next(); + Edge e = entry.getKey(); + NodeConnector headnc = e.getHeadNodeConnector(); + NodeConnector tailnc = e.getTailNodeConnector(); + + Long headNodeId = (Long) headnc.getNode().getID(); + + Long headNcId = ((Short) headnc.getID()).longValue(); + Long tailNcId = ((Short) tailnc.getID()).longValue(); + + if (headNodeId == 1 || headNodeId == 3 || headNodeId == 5) { + Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId + .equals(headNodeId + 10)) + || (headNcId.equals(headNodeId + 10) && tailNcId + .equals(headNodeId)) + || (headNcId.equals(headNodeId + 1) && tailNcId + .equals(headNodeId + 11)) + || (headNcId.equals(headNodeId + 11) && tailNcId + .equals(headNodeId + 1))); + } else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) { + Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId + .equals(headNodeId - 10)) + || (headNcId.equals(headNodeId) && tailNcId + .equals(headNodeId - 10)) + || (headNcId.equals(headNodeId - 9) && tailNcId + .equals(headNodeId + 1)) + || (headNcId.equals(headNodeId + 1) && tailNcId + .equals(headNodeId - 9))); + } + + Set prop = entry.getValue(); + for (Property p : prop) { + String pName; + long pValue; + if (p instanceof Bandwidth) { + Bandwidth b = (Bandwidth) p; + pName = Bandwidth.BandwidthPropName; + pValue = b.getValue(); + Assert.assertTrue(pName.equals(p.getName()) + && pValue == Bandwidth.BW100Gbps); + continue; + } + if (p instanceof Latency) { + Latency l = (Latency) p; + pName = Latency.LatencyPropName; + pValue = l.getValue(); + Assert.assertTrue(pName.equals(p.getName()) + && pValue == Latency.LATENCY100ns); + continue; + } + if (p instanceof State) { + State state = (State) p; + pName = State.StatePropName; + pValue = state.getValue(); + Assert.assertTrue(pName.equals(p.getName()) + && pValue == State.EDGE_UP); + continue; + } + } + i.remove(); + } + Assert.assertTrue(edgeProperty.isEmpty()); + } + + @Test + public void testAddDeleteUserLink() { + TopologyUserLinkConfig link1 = new TopologyUserLinkConfig("default1", + "OF", "1", "OF", "2", "OF", "1", "OF", "2"); + TopologyUserLinkConfig link2 = new TopologyUserLinkConfig("default1", + "OF", "10", "OF", "20", "OF", "10", "OF", "20"); + TopologyUserLinkConfig link3 = new TopologyUserLinkConfig("default2", + "OF", "1", "OF", "2", "OF", "1", "OF", "2"); + TopologyUserLinkConfig link4 = new TopologyUserLinkConfig("default20", + "OF", "10", "OF", "20", "OF", "10", "OF", "20"); + + TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); + topoManagerImpl.nonClusterObjectCreate(); + + Assert.assertTrue(topoManagerImpl.addUserLink(link1).isSuccess()); + Assert.assertTrue(topoManagerImpl.addUserLink(link2).getCode() == StatusCode.CONFLICT); + Assert.assertTrue(topoManagerImpl.addUserLink(link3).getCode() == StatusCode.CONFLICT); + Assert.assertTrue(topoManagerImpl.addUserLink(link4).isSuccess()); + + Assert.assertTrue(topoManagerImpl.deleteUserLink(null).getCode() == StatusCode.BADREQUEST); + Assert.assertTrue(topoManagerImpl.deleteUserLink(link1.getName()) + .isSuccess()); + Assert.assertTrue(topoManagerImpl.deleteUserLink(link4.getName()) + .isSuccess()); + Assert.assertTrue(topoManagerImpl.getUserLinks().isEmpty()); + + } + + @Test + public void testGetUserLink() { + TopologyUserLinkConfig[] link = new TopologyUserLinkConfig[5]; + TopologyUserLinkConfig[] reverseLink = new TopologyUserLinkConfig[5]; + TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); + topoManagerImpl.nonClusterObjectCreate(); + + String name = null; + String srcNodeIDType = null; + String srcSwitchId = null; + String srcNodeConnectorIDType = null; + String srcPort = null; + String dstNodeIDType = null; + String dstSwitchId = null; + String dstNodeConnectorIDType = null; + String dstPort = null; + + /* Creating userlinks and checking for their validity */ + link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId, + srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId, + dstNodeConnectorIDType, dstPort); + Assert.assertTrue(link[0].isValid() == false); + + srcSwitchId = "1"; + link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId, + srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId, + dstNodeConnectorIDType, dstPort); + Assert.assertTrue(link[0].isValid() == false); + dstSwitchId = "2"; + link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId, + srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId, + dstNodeConnectorIDType, dstPort); + Assert.assertTrue(link[0].isValid() == false); + + Integer i; + + for (i = 0; i < 5; i++) { + link[i] = new TopologyUserLinkConfig(name, srcNodeIDType, + srcSwitchId, srcNodeConnectorIDType, srcPort, + dstNodeIDType, dstSwitchId, dstNodeConnectorIDType, dstPort); + + name = Integer.toString(i + 1); + srcSwitchId = Integer.toString(i + 1); + srcPort = Integer.toString(i + 1); + dstSwitchId = Integer.toString((i + 1) * 10); + dstPort = Integer.toString((i + 1) * 10); + + link[i].setName(name); + link[i].setSrcSwitchId(srcSwitchId); + link[i].setSrcPort(srcPort); + link[i].setDstSwitchId(dstSwitchId); + link[i].setDstPort(dstPort); + + Assert.assertTrue(link[i].isValid() == false); + + link[i].setSrcNodeIDType("OF"); + link[i].setSrcNodeConnectorIDType("OF"); + + Assert.assertTrue(link[i].isValid() == false); + + link[i].setDstNodeIDType("OF"); + link[i].setDstNodeConnectorIDType("OF"); + + Assert.assertTrue(link[i].isValid() == true); + + reverseLink[i] = new TopologyUserLinkConfig(name, dstNodeIDType, + dstSwitchId, dstNodeConnectorIDType, dstPort, + srcNodeIDType, srcSwitchId, srcNodeConnectorIDType, srcPort); + + topoManagerImpl.addUserLink(link[i]); + } + ConcurrentMap userLinks = topoManagerImpl + .getUserLinks(); + TopologyUserLinkConfig resultLink; + + for (i = 0; i < 5; i++) { + resultLink = userLinks.get(((Integer) (i + 1)).toString()); + + Assert.assertTrue(resultLink.getName().equals( + reverseLink[i].getName())); + Assert.assertTrue(resultLink.getDstSwitchId().equals( + reverseLink[i].getSrcSwitchId())); + Assert.assertTrue(resultLink.getDstPort().equals( + reverseLink[i].getSrcPort())); + Assert.assertTrue(resultLink.getSrcSwitchId().equals( + reverseLink[i].getDstSwitchId())); + Assert.assertTrue(resultLink.getSrcPort().equals( + reverseLink[i].getDstPort())); + } + } + + @Test + public void testHostLinkMethods() throws ConstructionException, + UnknownHostException { + TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); + topoManagerImpl.nonClusterObjectCreate(); + int hostCounter = 0; + + State state; + Bandwidth bw; + Latency l; + Set props = new HashSet(); + state = new State(State.EDGE_UP); + bw = new Bandwidth(Bandwidth.BW100Gbps); + l = new Latency(Latency.LATENCY100ns); + props.add(state); + props.add(bw); + props.add(l); + + EthernetAddress ea; + InetAddress ip; + Host[] h = new Host[5]; + NodeConnector[] nc = new NodeConnector[5]; + + /* + * Adding host, nodeConnector to hostsDB for the i = 0,1,2,3. No host + * added for i = 4 + */ + for (int i = 0; i < 5; i++) { + if (hostCounter < 4) { + ea = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) i }); + String stringIP = new StringBuilder().append(i + 1).append(".") + .append(i + 10).append(".").append(i + 20).append(".") + .append(i + 30).toString(); + ip = InetAddress.getByName(stringIP); + h[hostCounter] = new Host(ea, ip); + } else { + h[hostCounter] = null; + } + hostCounter++; + nc[i] = NodeConnectorCreator.createOFNodeConnector((short) (i + 1), + NodeCreator.createOFNode((long) (i + 1))); + topoManagerImpl + .updateHostLink(nc[i], h[i], UpdateType.ADDED, props); + } + + for (int i = 0; i < 5; i++) { + Host host = topoManagerImpl.getHostAttachedToNodeConnector(nc[i]); + if (i == 4) + Assert.assertTrue(host == null); + else + Assert.assertTrue(host.equals(h[i])); + } + + Set ncSet = topoManagerImpl.getNodeConnectorWithHost(); + for (int i = 0; i < 5; i++) { + Assert.assertTrue(ncSet.remove(nc[i])); + } + Assert.assertTrue(ncSet.isEmpty()); + } + + @Test + public void testGetNodesWithNodeConnectorHost() + throws ConstructionException, UnknownHostException { + TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl(); + topoManagerImpl.nonClusterObjectCreate(); + int hostCounter = 0; + + State state; + Bandwidth bw; + Latency l; + Set props = new HashSet(); + state = new State(State.EDGE_UP); + bw = new Bandwidth(Bandwidth.BW100Gbps); + l = new Latency(Latency.LATENCY100ns); + props.add(state); + props.add(bw); + props.add(l); + + EthernetAddress ea; + InetAddress ip; + Host[] h = new Host[5]; + NodeConnector[] nc = new NodeConnector[5]; + + /* + * Adding host, nodeconnector, properties of edge to hostsDB for the + * first three nodes only + */ + for (int i = 1; i < 6; i++) { + if (i < 4) { + ea = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) i }); + String stringIP = new StringBuilder().append(i).append(".") + .append(i + 10).append(".").append(i + 20).append(".") + .append(i + 30).toString(); + ip = InetAddress.getByName(stringIP); + h[hostCounter] = new Host(ea, ip); + } else { + h[hostCounter] = null; + } + hostCounter++; + nc[i - 1] = NodeConnectorCreator.createOFNodeConnector((short) i, + NodeCreator.createOFNode((long) i)); + topoManagerImpl.updateHostLink(nc[i - 1], h[i - 1], + UpdateType.ADDED, props); + } + + /* Get the nodes which have host connected to its nodeConnector */ + Map> nodeNCmap = topoManagerImpl + .getNodesWithNodeConnectorHost(); + for (int i = 1; i < 6; i++) { + Node node = nc[i - 1].getNode(); + Set ncSet = nodeNCmap.get(nc[i - 1].getNode()); + + Assert.assertTrue(ncSet == nodeNCmap.remove(node)); + } + + Assert.assertTrue(nodeNCmap.isEmpty()); + } +} diff --git a/opendaylight/usermanager/pom.xml b/opendaylight/usermanager/pom.xml index 4c83a3e1ce..eea85e25ea 100644 --- a/opendaylight/usermanager/pom.xml +++ b/opendaylight/usermanager/pom.xml @@ -85,7 +85,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/opendaylight/web/devices/pom.xml b/opendaylight/web/devices/pom.xml index e8a67ac9ed..12cd17c6c3 100644 --- a/opendaylight/web/devices/pom.xml +++ b/opendaylight/web/devices/pom.xml @@ -101,7 +101,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/web/flows/pom.xml b/opendaylight/web/flows/pom.xml index 4eaf227fe9..5333a7e643 100644 --- a/opendaylight/web/flows/pom.xml +++ b/opendaylight/web/flows/pom.xml @@ -106,7 +106,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/web/root/pom.xml b/opendaylight/web/root/pom.xml index 7f5c45319e..d30a6ac4c1 100644 --- a/opendaylight/web/root/pom.xml +++ b/opendaylight/web/root/pom.xml @@ -95,7 +95,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/web/topology/pom.xml b/opendaylight/web/topology/pom.xml index 38999257f1..0dd10512eb 100644 --- a/opendaylight/web/topology/pom.xml +++ b/opendaylight/web/topology/pom.xml @@ -104,7 +104,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/web/troubleshoot/pom.xml b/opendaylight/web/troubleshoot/pom.xml index 24191692a1..52958e116e 100644 --- a/opendaylight/web/troubleshoot/pom.xml +++ b/opendaylight/web/troubleshoot/pom.xml @@ -103,7 +103,7 @@ org.opendaylight.controller sal - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.controller -- 2.36.6