Merge "Bug fix for ForwardingRulesManager: addFlow and addFlowAsync are reversed."
authorAlessandro Boch <aboch@cisco.com>
Fri, 3 May 2013 13:59:01 +0000 (13:59 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 3 May 2013 13:59:01 +0000 (13:59 +0000)
108 files changed:
opendaylight/arphandler/pom.xml
opendaylight/clustering/services_implementation/pom.xml
opendaylight/clustering/stub/pom.xml
opendaylight/configuration/api/pom.xml
opendaylight/configuration/implementation/pom.xml
opendaylight/containermanager/api/pom.xml
opendaylight/containermanager/implementation/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/forwarding/staticrouting/pom.xml
opendaylight/forwardingrulesmanager/api/pom.xml
opendaylight/forwardingrulesmanager/implementation/pom.xml
opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java
opendaylight/hosttracker/api/pom.xml
opendaylight/hosttracker/implementation/pom.xml
opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java
opendaylight/hosttracker/integrationtest/pom.xml
opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java
opendaylight/northbound/commons/pom.xml
opendaylight/northbound/flowprogrammer/pom.xml
opendaylight/northbound/hosttracker/pom.xml
opendaylight/northbound/staticrouting/pom.xml
opendaylight/northbound/statistics/pom.xml
opendaylight/northbound/subnets/pom.xml
opendaylight/northbound/switchmanager/pom.xml
opendaylight/northbound/topology/pom.xml
opendaylight/protocol_plugins/openflow/pom.xml
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryShimExternalListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryShimInternalListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/ITopologyServiceShimListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServices.java
opendaylight/protocol_plugins/stub/pom.xml
opendaylight/routing/dijkstra_implementation/pom.xml
opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java
opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java
opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java
opendaylight/sal/api/pom.xml
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Config.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/discovery/IDiscoveryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IInventoryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IListenInventoryUpdates.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginInInventoryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginOutInventoryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IListenTopoUpdates.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/IPluginOutTopologyService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java [new file with mode: 0644]
opendaylight/sal/implementation/pom.xml
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Topology.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/BindingGeneratorImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/BaseYangTypes.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/BaseTypeProvider.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/GeneratorJavaFile.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/test/java/org/opendaylight/controller/sal/java/api/generator/test/GeneratorJavaFileTest.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/resources/model/testfile1.yang [deleted file]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/resources/model/testfile2.yang [deleted file]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct_combined/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/NoGenerators/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/NoGenerators_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/UnknownGenerator/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/UnknownGenerator_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/pom.xml
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ChoiceBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ChoiceCaseBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/IdentitySchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UsesNodeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/ModuleDependencySort.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/TopologicalSort.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/TypesResolutionTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/util/ModuleDependencySortTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/util/TopologicalSortTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
opendaylight/sal/yang-prototype/sal/pom.xml
opendaylight/sal/yang-prototype/yang/pom.xml
opendaylight/samples/loadbalancer/pom.xml
opendaylight/samples/northbound/loadbalancer/pom.xml
opendaylight/samples/simpleforwarding/pom.xml
opendaylight/security/pom.xml
opendaylight/statisticsmanager/api/pom.xml
opendaylight/statisticsmanager/implementation/pom.xml
opendaylight/statisticsmanager/integrationtest/pom.xml
opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java
opendaylight/switchmanager/api/pom.xml
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManagerAware.java
opendaylight/switchmanager/implementation/pom.xml
opendaylight/topologymanager/pom.xml
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManager.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java
opendaylight/topologymanager/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java
opendaylight/usermanager/pom.xml
opendaylight/web/devices/pom.xml
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/StatusJsonBean.java
opendaylight/web/devices/src/main/resources/js/page.js
opendaylight/web/flows/pom.xml
opendaylight/web/root/pom.xml
opendaylight/web/root/src/main/java/org/opendaylight/controller/web/IDaylightWeb.java
opendaylight/web/topology/pom.xml
opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java
opendaylight/web/troubleshoot/pom.xml

index cf3aff7..80d8598 100644 (file)
@@ -56,7 +56,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
 </project>
index 82a97b6..80fc1c4 100644 (file)
@@ -70,7 +70,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
 </project>
index 2670c72..ab4ef5a 100644 (file)
@@ -46,7 +46,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
 </project>
index 0af960d..3993b5e 100644 (file)
@@ -39,7 +39,7 @@
        <dependency>
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>sal</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
+               <version>0.5.0-SNAPSHOT</version>
        </dependency> 
   </dependencies>
 </project>
index bac0184..467e9ca 100644 (file)
@@ -56,7 +56,7 @@
        <dependency>
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>sal</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
+               <version>0.5.0-SNAPSHOT</version>
        </dependency> 
   </dependencies>
 </project>
index 8b5ccdf..2b35475 100644 (file)
@@ -45,7 +45,7 @@
        <dependency>
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>sal</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
+               <version>0.5.0-SNAPSHOT</version>
        </dependency> 
   </dependencies>
 </project>
index 1ead516..9e2f566 100644 (file)
@@ -62,7 +62,7 @@
        <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
        </dependency> 
   </dependencies>
 </project>
index 6a7d68c..33789ee 100644 (file)
@@ -50,6 +50,12 @@ org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
 # of.messageResponseTimer=2000
 # The switch liveness timeout value (default 60500 msec)
 # of.switchLivenessTimeout=60500
+# The flow statistics polling interval in second (default 10 sec)
+# of.flowStatsPollInterval=10
+# The port statistics polling interval in second (default 5 sec)
+# of.portStatsPollInterval=5
+# The description statistics polling interval in second (default 60 sec)
+# of.descStatsPollInterval=60
 # The maximum number of asynchronous messages can be sent before sending a Barrier Request (default 100)
 # of.barrierMessagePriorCount=100
 # The interval which determines how often the discovery packets should be sent (default 300 sec)
index 38f18bf..28f3e25 100644 (file)
@@ -80,7 +80,7 @@
        <dependency>
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>sal</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
+               <version>0.5.0-SNAPSHOT</version>
        </dependency>    
   </dependencies>
 </project>
index 6b639e3..382b11d 100644 (file)
@@ -83,7 +83,7 @@
        <dependency>
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>sal</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
+               <version>0.5.0-SNAPSHOT</version>
        </dependency>
     <dependency>
       <groupId>junit</groupId>
index 0031773..d9faed3 100644 (file)
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 73c6d79..8fa37b5 100644 (file)
@@ -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
+}
index 59290ef..f60b386 100644 (file)
@@ -66,7 +66,7 @@
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>sal</artifactId>\r
-                       <version>0.4.0-SNAPSHOT</version>\r
+                       <version>0.5.0-SNAPSHOT</version>\r
                </dependency>\r
        </dependencies>\r
 </project>\r
index 1f24e06..402dfe3 100644 (file)
@@ -46,6 +46,7 @@
                                                <Import-Package>
                                                        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,
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>sal</artifactId>
-                       <version>0.4.0-SNAPSHOT</version>
+                       <version>0.5.0-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
index d0f8bb5..7c312e1 100644 (file)
@@ -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<InetAddress, HostNodeConnector> 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<NodeConnector, HostNodeConnector> inactiveStaticHosts;
     private Set<IfNewHostNotify> 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<ARPPending> ARPPendingList = new ArrayList<HostTracker.ARPPending>();
     /*
-     * 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<ARPPending> failedARPReqList = new ArrayList<HostTracker.ARPPending>();
@@ -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<NodeConnector, HostNodeConnector> 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<ArrayList<String>> 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<ArrayList<String>> 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<Node, Set<Edge>> ndlinks = topologyManager.getNodeEdges();
@@ -632,8 +636,8 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         }
         ArrayList<Node> needsVisiting = new ArrayList<Node>();
         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 <code>true</code> if the Node is eligible for Tier Update
      *         <code>false</code> 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<Node> 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<List<String>> 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<String> currHierarchy, List<List<String>> fullHierarchy) {
-        //currHierarchy.add(String.format("%x", currSw.getId()));
+        // currHierarchy.add(String.format("%x", currSw.getId()));
         currHierarchy.add(dpidToHostNameHack((Long) node.getID()));
         ArrayList<String> currHierarchyClone = (ArrayList<String>) currHierarchy
-                .clone(); //Shallow copy as required
+                .clone(); // Shallow copy as required
 
         Map<Node, Set<Edge>> 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<String> buildHierarchy = currHierarchy;
                 if (currHierarchy.size() > currHierarchyClone.size()) {
                     buildHierarchy = (ArrayList<String>) 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<Property> props) {
+    private void edgeUpdate(Edge e, UpdateType type, Set<Property> 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<InetAddress, HostNodeConnector> entry : hostsDB.entrySet()) {
             HostNodeConnector host = entry.getValue();
@@ -900,6 +911,16 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         }
     }
 
+    @Override
+    public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
+        for (int i = 0; i < topoedgeupdateList.size(); i++) {
+            Edge e = topoedgeupdateList.get(i).getEdge();
+            Set<Property> 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<InetAddress, HostNodeConnector> 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<InetAddress, HostNodeConnector> 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() {
     }
index ff08cf3..0d2d18c 100644 (file)
@@ -27,7 +27,7 @@
       <dependency>\r
       <groupId>org.opendaylight.controller</groupId>\r
       <artifactId>sal</artifactId>\r
-      <version>0.4.0-SNAPSHOT</version>\r
+      <version>0.5.0-SNAPSHOT</version>\r
     </dependency>\r
      <dependency>\r
       <groupId>org.opendaylight.controller</groupId>\r
index f351d1a..fb5367c 100644 (file)
@@ -108,7 +108,7 @@ public class HostTrackerIntegrationTest {
                 \r
                 // List all the bundles on which the test case depends\r
                 mavenBundle("org.opendaylight.controller", "sal",\r
-                        "0.4.0-SNAPSHOT"),\r
+                        "0.5.0-SNAPSHOT"),\r
                 mavenBundle("org.opendaylight.controller", "sal.implementation",\r
                         "0.4.0-SNAPSHOT"),\r
 \r
index d52bedf..d80d669 100644 (file)
@@ -43,7 +43,7 @@
       <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 1bfd4eb..a4ebfa2 100644 (file)
@@ -22,7 +22,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>    
@@ -76,7 +76,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.enunciate</groupId>
index eab9fcb..5ddab37 100644 (file)
@@ -22,7 +22,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>    
@@ -81,7 +81,7 @@
        <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
        </dependency> 
     <dependency>
          <groupId>org.opendaylight.controller</groupId>
index eeaf550..f0fd323 100644 (file)
@@ -22,7 +22,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>
@@ -62,7 +62,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index e10a5b1..84c4020 100644 (file)
@@ -22,7 +22,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>        
@@ -80,7 +80,7 @@
        <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
        </dependency> 
        
        <dependency>
index cfba4ff..22c9a97 100644 (file)
@@ -22,7 +22,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
@@ -76,7 +76,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index e4c73ac..25757e6 100644 (file)
@@ -22,7 +22,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>    
@@ -78,7 +78,7 @@
        <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
        </dependency> 
 
     <dependency>
index c31b478..0cfa487 100644 (file)
@@ -23,7 +23,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal</artifactId>
-            <version>0.4.0-SNAPSHOT</version>
+            <version>0.5.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>
@@ -79,7 +79,7 @@
        <dependency>
          <groupId>org.opendaylight.controller</groupId>
          <artifactId>sal</artifactId>
-         <version>0.4.0-SNAPSHOT</version>
+         <version>0.5.0-SNAPSHOT</version>
        </dependency>
        <dependency>
          <groupId>org.opendaylight.controller</groupId>
index 614b0ff..23c0d9d 100644 (file)
@@ -62,7 +62,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller.thirdparty</groupId>
index 24e63df..df03a04 100644 (file)
 package org.opendaylight.controller.protocol_plugin.openflow;
 
 /**
- * Wrapper of Interface class that provides inventory updates locally in the
- * protocol plugin
- *
- *
+ * Wrapper of Interface that provides inventory updates locally in the protocol
+ * plugin.
  */
 public interface IInventoryShimExternalListener extends
         IInventoryShimInternalListener {
index e7c11a6..6b32896 100644 (file)
@@ -17,10 +17,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * Interface class that provides inventory updates to inventory listeners
- * within the protocol plugin
- *
- *
+ * The Interface provides inventory updates to inventory listeners within the
+ * protocol plugin
  */
 public interface IInventoryShimInternalListener {
     /**
index 23b40a3..0c30c80 100644 (file)
@@ -16,9 +16,7 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * Interface class that provides Edge updates to the topology listeners
- *
- *
+ * The Interface provides Edge updates to the topology listeners
  */
 public interface ITopologyServiceShimListener {
     /**
index 9bccbd1..9b7d1e3 100644 (file)
@@ -358,8 +358,9 @@ public class Activator extends ComponentActivatorAbstractBase {
         if (imp.equals(TopologyServiceShim.class)) {
             c.setInterface(new String[] { IDiscoveryService.class.getName(),
                     IContainerListener.class.getName(),
-                    IRefreshInternalProvider.class.getName() }, null);
-            c.add(createServiceDependency()
+                    IRefreshInternalProvider.class.getName(),
+                    IInventoryShimExternalListener.class.getName() }, null);
+          c.add(createServiceDependency()
                     .setService(ITopologyServiceShimListener.class)
                     .setCallbacks("setTopologyServiceShimListener",
                             "unsetTopologyServiceShimListener")
index 98a2962..9dc8b3b 100644 (file)
@@ -175,6 +175,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         txRates = new HashMap<Long, Map<Short, TxRates>>(initialSize);
         descriptionListeners = new HashSet<IStatisticsListener>();
 
+        configStatsPollIntervals();
+        
         // Initialize managed timers
         statisticsTimer = new Timer();
         statisticsTimerTask = new TimerTask() {
@@ -876,6 +878,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         help.append("---OF Statistics Manager utilities---\n");
         help.append("\t ofdumpstatsmgr         - "
                 + "Print Internal Stats Mgr db\n");
+        help.append("\t ofstatsmgrintervals <fP> <pP> <dP>(in seconds) - "
+                + "Set/Show flow/port/dedscription stats poll intervals\n");
         return help.toString();
     }
 
@@ -1001,33 +1005,76 @@ public class OFStatisticsManager implements IOFStatisticsManager,
     public void _ofstatsmgrintervals(CommandInterpreter ci) {
         String flowStatsInterv = ci.nextArgument();
         String portStatsInterv = ci.nextArgument();
+        String descStatsInterv = ci.nextArgument();
 
-        if (flowStatsInterv == null || portStatsInterv == null) {
-
-            ci.println("Usage: ostatsmgrintervals <fP> <pP> (in seconds)");
+        if (flowStatsInterv == null || portStatsInterv == null
+                || descStatsInterv == null) {
+            ci.println("Usage: ostatsmgrintervals <fP> <pP> <dP>(in seconds)");
             ci.println("Current Values: fP=" + statisticsTickNumber + "s pP="
-                    + portTickNumber + "s");
+                    + portTickNumber + "s dP=" + descriptionTickNumber + "s");
             return;
         }
-        Short fP, pP;
+        Short fP, pP, dP;
         try {
             fP = Short.parseShort(flowStatsInterv);
             pP = Short.parseShort(portStatsInterv);
+            dP = Short.parseShort(descStatsInterv);
         } catch (Exception e) {
             ci.println("Invalid format values: " + e.getMessage());
             return;
         }
 
-        if (pP <= 1 || fP <= 1) {
-            ci.println("Invalid values. fP and pP have to be greater than 1.");
+        if (pP <= 1 || fP <= 1 || dP <= 1) {
+            ci.println("Invalid values. fP, pP, dP have to be greater than 1.");
             return;
         }
 
         statisticsTickNumber = fP;
         portTickNumber = pP;
+        descriptionTickNumber = dP;
 
         ci.println("New Values: fP=" + statisticsTickNumber + "s pP="
-                + portTickNumber + "s");
+                + portTickNumber + "s dP=" + descriptionTickNumber + "s");
     }
 
+    /**
+     * This method retrieves user configurations from config.ini and updates
+     * statisticsTickNumber/portTickNumber/descriptionTickNumber accordingly.
+     */
+    private void configStatsPollIntervals() {
+        String fsStr = System.getProperty("of.flowStatsPollInterval");
+        String psStr = System.getProperty("of.portStatsPollInterval");
+        String dsStr = System.getProperty("of.descStatsPollInterval");
+        Short fs, ps, ds;
+
+        if (fsStr != null) {
+            try {
+                fs = Short.parseShort(fsStr);
+                if (fs > 0) {
+                    statisticsTickNumber = fs;
+                }
+            } catch (Exception e) {
+            }
+        }
+
+        if (psStr != null) {
+            try {
+                ps = Short.parseShort(psStr);
+                if (ps > 0) {
+                    portTickNumber = ps;
+                }
+            } catch (Exception e) {
+            }
+        }
+
+        if (dsStr != null) {
+            try {
+                ds = Short.parseShort(dsStr);
+                if (ds > 0) {
+                    descriptionTickNumber = ds;
+                }
+            } catch (Exception e) {
+            }
+        }
+    }
 }
index 424af8d..af502a2 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
@@ -33,12 +34,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.opendaylight.controller.sal.core.Bandwidth;
+import org.opendaylight.controller.sal.core.Config;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.IContainerListener;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 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.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
@@ -49,7 +52,8 @@ import org.opendaylight.controller.sal.utils.GlobalConstants;
  * container configurations.
  */
 public class TopologyServiceShim implements IDiscoveryService,
-        IContainerListener, CommandProvider, IRefreshInternalProvider {
+               IContainerListener, CommandProvider, IRefreshInternalProvider,
+               IInventoryShimExternalListener {
     protected static final Logger logger = LoggerFactory
             .getLogger(TopologyServiceShim.class);
     private ConcurrentMap<String, ITopologyServiceShimListener> topologyServiceShimListeners = new ConcurrentHashMap<String, ITopologyServiceShimListener>();
@@ -645,4 +649,56 @@ public class TopologyServiceShim implements IDiscoveryService,
         logger.debug("Sent {} updates", i);
     }
 
+    @Override
+    public void updateNode(Node node, UpdateType type, Set<Property> props) {
+    }
+
+    @Override
+    public void updateNodeConnector(NodeConnector nodeConnector,
+            UpdateType type, Set<Property> props) {
+        List<String> containers = new ArrayList<String>();
+        List<String> conList = this.containerMap.get(nodeConnector);
+
+        containers.add(GlobalConstants.DEFAULT.toString());
+        if (conList != null) {
+            containers.addAll(conList);
+        }
+        
+        switch (type) {
+        case ADDED:
+            break;
+        case CHANGED:
+            if (props == null) {
+                break;
+            }
+
+            boolean rmEdge = false;
+            for (Property prop : props) {
+                if (((prop instanceof Config) && (((Config) prop).getValue() != Config.ADMIN_UP))
+                        || ((prop instanceof State) && (((State) prop)
+                                .getValue() != State.EDGE_UP))) {
+                    /*
+                     * If port admin down or link down, remove the edges
+                     * associated with the port
+                     */
+                    rmEdge = true;
+                    break;
+                }
+            }
+
+            if (rmEdge) {
+                for (String cName : containers) {
+                    removeNodeConnector(cName, nodeConnector);
+                }
+            }
+            break;
+        case REMOVED:
+            for (String cName : containers) {
+                removeNodeConnector(cName, nodeConnector);
+            }
+            break;
+        default:
+            break;
+        }
+    }
 }
index 6451588..c0b2963 100644 (file)
@@ -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<Property> props) {
         if (this.salTopoService != null) {
-            this.salTopoService.edgeUpdate(edge, type, props);
+            List<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
+            TopoEdgeUpdate teu = new TopoEdgeUpdate(edge, props, type);
+            topoedgeupdateList.add(teu);
+            this.salTopoService.edgeUpdate(topoedgeupdateList);
         }
     }
 
index 36085c9..c257099 100644 (file)
@@ -51,7 +51,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
index e89beb8..06a684f 100644 (file)
@@ -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 @@
    <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 586432d..d878b23 100644 (file)
@@ -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<Short, Graph<Node, Edge>> topologyBWAware;
     private ConcurrentMap<Short, DijkstraShortestPath<Node, Edge>> sptBWAware;
-    DijkstraShortestPath<Node, Edge> mtp; //Max Throughput Path
+    DijkstraShortestPath<Node, Edge> mtp; // Max Throughput Path
     private Set<IListenRoutingUpdates> 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<Node, Edge> 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<Node, Edge> topo = this.topologyBWAware.get(bw);
         DijkstraShortestPath<Node, Edge> 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<Property> props) {
+    private boolean edgeUpdate(Edge e, UpdateType type, Set<Property> 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<TopoEdgeUpdate> topoedgeupdateList) {
+        boolean callListeners = false;
+        for (int i = 0; i < topoedgeupdateList.size(); i++) {
+            Edge e = topoedgeupdateList.get(i).getEdge();
+            Set<Property> 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<Short, Graph<Node, Edge>>) new ConcurrentHashMap();
-       this.sptBWAware = (ConcurrentMap<Short, DijkstraShortestPath<Node, Edge>>) new ConcurrentHashMap();
-       // Now create the default topology, which doesn't consider the
-       // BW, also create the corresponding Dijkstra calculation
-       Graph<Node, Edge> 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<Short, Graph<Node, Edge>>) new ConcurrentHashMap();
+        this.sptBWAware = (ConcurrentMap<Short, DijkstraShortestPath<Node, Edge>>) new ConcurrentHashMap();
+        // Now create the default topology, which doesn't consider the
+        // BW, also create the corresponding Dijkstra calculation
+        Graph<Node, Edge> 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<Edge, Set<Property>> edges = topologyManager.getEdges();
-          if (edges.isEmpty()) {
-                  return;
-          }
-          log.debug("Creating routing database from the topology");
-          for (Iterator<Map.Entry<Edge,Set<Property>>> i = edges.entrySet().iterator();  i.hasNext();) {
-                  Map.Entry<Edge, Set<Property>> entry = i.next();
-                  Edge e = entry.getKey();
-                  Set<Property> 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<Edge, Set<Property>> edges = topologyManager.getEdges();
+        if (edges.isEmpty()) {
+            return;
+        }
+        List<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
+        log.debug("Creating routing database from the topology");
+        for (Iterator<Map.Entry<Edge, Set<Property>>> i = edges.entrySet()
+                .iterator(); i.hasNext();) {
+            Map.Entry<Edge, Set<Property>> entry = i.next();
+            Edge e = entry.getKey();
+            Set<Property> 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;
+        }
     }
 }
index fb0a560..e3ae560 100644 (file)
@@ -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<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
         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<Property> props = new HashSet<Property>();
         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<Property> props2 = new HashSet<Property>();
-        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<Edge> expectedPath = (List<Edge>) new LinkedList<Edge>();
@@ -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<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
         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<Property> props = new HashSet<Property>();
         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<Property> props2 = new HashSet<Property>();
-        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<Property> props3 = new HashSet<Property>();
-        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<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
         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<Property> props = new HashSet<Property>();
         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<Property> props2 = new HashSet<Property>();
-        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<Property> props3 = new HashSet<Property>();
-        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<Edge> expectedPath = (List<Edge>) new LinkedList<Edge>();
@@ -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);
index 44cb9d1..17952c8 100644 (file)
@@ -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<Edge, Number> LinkCostMap = new HashMap<Edge, Number>();
 
     @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<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
+        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);
index 9d8c814..e49ae8d 100644 (file)
@@ -10,7 +10,7 @@
 \r
   <groupId>org.opendaylight.controller</groupId>\r
   <artifactId>sal</artifactId>\r
-  <version>0.4.0-SNAPSHOT</version>\r
+  <version>0.5.0-SNAPSHOT</version>\r
   <packaging>bundle</packaging>\r
 \r
   <build>\r
index c585aa2..505cc61 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -18,8 +17,8 @@ import javax.xml.bind.annotation.XmlElement;
 
 /**
  * The class represents Admin Config status
- *
- *
+ * 
+ * 
  */
 @XmlRootElement
 @SuppressWarnings("serial")
@@ -65,6 +64,6 @@ public class Config extends Property {
 
     @Override
     public String toString() {
-        return "Config[" + ReflectionToStringBuilder.toString(this) + "]";
+        return "Config["+ReflectionToStringBuilder.toString(this)+"]";
     }
 }
index 59a184e..6245c9b 100644 (file)
@@ -53,26 +53,30 @@ public class NodeConnector implements Serializable {
         ConcurrentHashMap<String, ImmutablePair<Class<? extends Object>, String>> compatibleType =
             new ConcurrentHashMap<String, ImmutablePair<Class<? extends Object>, String>>();
         /**
-         * Represent a special port pointing toward the controller,
-         * this is to send data packets toward the controller from
-         * data plane.
+         * Represents the OFPP_CONTROLLER reserved port to forward a 
+         * packet to the controller, this is to send data packets 
+         * to the controller from the data plane triggering 
+         * a packet_in event.
          */
         public static String CONTROLLER = "CTRL";
         /**
-         * Special port describing ALL the ports in the system,
-         * should be used for flooding like mechanism but better
-         * to be careful with it
+         * Represents the OFPP_ALL reserved OF port 
+         * to forward to ALL the ports in the system ,
+         * should be used for flooding like mechanism to
+         * be used cautiously to avoid excessive flooding.
          */
         public static String ALL = "ALL";
         /**
-         * Describe the local networking stack of the node
-         * on which the packet is destined. Yet another special port
+         * Represents the OFPP_LOCAL reserved OF port
+         * to access the local networking stack of the node
+         * of which the packet is destined. Typically used for
+         * inband OF communications channel.
          */
         public static String SWSTACK = "SW";
         /**
-         * Describe a special destination that invoke the
-         * traditional HW forwarding on platforms that has this
-         * provision.
+         * Describes OFPP_Normal reserved port destination that invokes 
+         * the traditional native L2/L3 HW normal forwarding functionality 
+         * if supported on the forwarding element.
          */
         public static String HWPATH = "HW";
         public static String OPENFLOW = "OF";
@@ -441,7 +445,7 @@ public class NodeConnector implements Serializable {
      *
      * @param str String to be parsed in a NodeConnector
      *
-     * @return the NodeConnector if parse is succesfull, null otherwise
+     * @return the NodeConnector if parse is successful, null otherwise
      */
     public static NodeConnector fromString(String str) {
         if (str == null) {
@@ -534,14 +538,14 @@ public class NodeConnector implements Serializable {
 
     /**
      * return a NodeConnector from a pair (type, ID) in string format
-     * not containing explicitely the Node portion which has to be
+     * not containing explicitly the Node portion which has to be
      * supplied as parameter
      *
      * @param typeStr type String to be parsed in a NodeConnector
      * @param IDStr ID String portion to be parsed in a NodeConnector
      * @param n Node to which the NodeConnector is attached
      *
-     * @return the NodeConnector if parse is succesfull, null otherwise
+     * @return the NodeConnector if parse is successful, null otherwise
      */
     public static NodeConnector fromStringNoNode(String typeStr, String IDStr,
                                                  Node n) {
index 3dda38e..29094d3 100644 (file)
@@ -16,8 +16,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * The interface class provides the methods to notify the listener when an edge
- * is added/deleted/changed
+ * The interface provides the methods to notify the listener when an edge is
+ * added/deleted/changed.
  */
 public interface IDiscoveryService {
     /**
index 2df6053..3c58ecb 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 
 /**
- * Interface class that describes methods invoked from application toward SAL to
- * solicit existing inventory data
+ * The Interface describes methods invoked from application toward SAL to
+ * solicit existing inventory data.
  */
 public interface IInventoryService {
     /**
index 41b91e1..ccfb338 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * The interface class provides the methods to notify the upper applications
- * in regards to any inventory changes.
+ * The interface provides the methods to notify the upper applications in
+ * regards to any inventory changes.
  */
 public interface IListenInventoryUpdates {
     /**
index 420f9bb..5822731 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 
 /**
- * The interface class that describes methods invoked from SAL toward the protocol
- * plugin to solicit existing inventory data.
+ * The Interface describes methods invoked from SAL toward the protocol plugin
+ * to solicit existing inventory data.
  */
 public interface IPluginInInventoryService {
     /**
index 124c34a..42c9ab7 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * The interface class describes Inventory update methods to be implemented by
- * protocol plugin
+ * The Interface describes Inventory update methods to be implemented by
+ * protocol plugin.
  */
 public interface IPluginOutInventoryService {
     /**
index 8a640f1..b4c44c0 100644 (file)
@@ -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<Property> props);
+    public void edgeUpdate(List<TopoEdgeUpdate> 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);
index b183240..b85eec8 100644 (file)
@@ -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<Property> props);
+    public void edgeUpdate(List<TopoEdgeUpdate> 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 (file)
index 0000000..d8da9c3
--- /dev/null
@@ -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<Property> props;
+    private UpdateType type;
+
+    public TopoEdgeUpdate(Edge e, Set<Property> p, UpdateType t) {
+        edge = e;
+        props = p;
+        type = t;
+    }
+
+    public Edge getEdge() {
+        return edge;
+    }
+
+    public Set<Property> 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);
+    }
+}
index 32f0a38..57ccc4a 100644 (file)
@@ -52,7 +52,7 @@
     <dependency>\r
       <groupId>org.opendaylight.controller</groupId>\r
       <artifactId>sal</artifactId>\r
-      <version>0.4.0-SNAPSHOT</version>\r
+      <version>0.5.0-SNAPSHOT</version>\r
     </dependency>\r
   </dependencies>\r
 </project>\r
index 8df566f..f965d7f 100644 (file)
@@ -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<Property> props) {
+    public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
         synchronized (this.updateService) {
             for (IListenTopoUpdates s : this.updateService) {
-                s.edgeUpdate(e, type, props);
+                s.edgeUpdate(topoedgeupdateList);
             }
         }
     }
index dcee5fe..3c0d9ed 100644 (file)
@@ -290,28 +290,15 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         return null;
     }
-
-    // private String resolveGeneratedTypePackageName(final SchemaPath
-    // schemaPath) {
-    // final StringBuilder builder = new StringBuilder();
-    // builder.append(basePackageName);
-    // if ((schemaPath != null) && (schemaPath.getPath() != null)) {
-    // final List<QName> pathToNode = schemaPath.getPath();
-    // final int traversalSteps = (pathToNode.size() - 1);
-    // for (int i = 0; i < traversalSteps; ++i) {
-    // builder.append(".");
-    // String nodeLocalName = pathToNode.get(i).getLocalName();
-    //
-    // // TODO: refactor with use of BindingGeneratorUtil class
-    // nodeLocalName = nodeLocalName.replace(":", ".");
-    // nodeLocalName = nodeLocalName.replace("-", ".");
-    // builder.append(nodeLocalName);
-    // }
-    // return validatePackage(builder.toString());
-    // }
-    // return null;
-    // }
-
+    
+    private List<GeneratedType> augmentationToGenTypes(final Module module) {
+        final List<GeneratedType> augmentGenTypes = new ArrayList<GeneratedType>();
+        
+        //TODO: add implementation
+        
+        return augmentGenTypes;
+    }
+    
     private GeneratedType containerToGenType(ContainerSchemaNode container) {
         if (container == null) {
             return null;
index b050ce6..a6425df 100644 (file)
@@ -1,67 +1,66 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.yang.types;\r
-\r
-import java.math.BigDecimal;\r
-import java.math.BigInteger;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.controller.binding.generator.util.Types;\r
-import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-public class BaseYangTypes {\r
-\r
-    private static Map<String, Type> typeMap = new HashMap<String, Type>();\r
-\r
-    public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);\r
-    public static final Type INT8_TYPE = Types.typeForClass(Byte.class);\r
-    public static final Type INT16_TYPE = Types.typeForClass(Short.class);\r
-    public static final Type INT32_TYPE = Types.typeForClass(Integer.class);\r
-    public static final Type INT64_TYPE = Types.typeForClass(Long.class);\r
-    public static final Type STRING_TYPE = Types.typeForClass(String.class);\r
-    public static final Type DECIMAL64_TYPE = Types.typeForClass(Double.class);\r
-    public static final Type UINT8_TYPE = Types.typeForClass(Short.class);\r
-    public static final Type UINT16_TYPE = Types.typeForClass(Integer.class);\r
-    public static final Type UINT32_TYPE = Types.typeForClass(Long.class);\r
-    public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class);\r
-\r
-    static {\r
-        typeMap.put("boolean", BOOLEAN_TYPE);\r
-        typeMap.put("int8", INT8_TYPE);\r
-        typeMap.put("int16", INT16_TYPE);\r
-        typeMap.put("int32", INT32_TYPE);\r
-        typeMap.put("int64", INT64_TYPE);\r
-        typeMap.put("string", STRING_TYPE);\r
-        typeMap.put("decimal64", DECIMAL64_TYPE);\r
-        typeMap.put("uint8", UINT8_TYPE);\r
-        typeMap.put("uint16", UINT16_TYPE);\r
-        typeMap.put("uint32", UINT32_TYPE);\r
-        typeMap.put("uint64", UINT64_TYPE);\r
-    }\r
-\r
-    public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {\r
-\r
-        @Override\r
-        public Type javaTypeForYangType(String type) {\r
-            return typeMap.get(type);\r
-        }\r
-\r
-        @Override\r
-        public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type) {\r
-            if (type != null) {\r
-                return typeMap.get(type.getQName().getLocalName());\r
-            }\r
-\r
-            return null;\r
-        }\r
-    };\r
-\r
-}\r
+/*
+ * 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.binding.yang.types;
+
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.controller.binding.generator.util.Types;
+import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+
+public class BaseYangTypes {
+
+    private static Map<String, Type> typeMap = new HashMap<String, Type>();
+
+    public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);
+    public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
+    public static final Type INT16_TYPE = Types.typeForClass(Short.class);
+    public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
+    public static final Type INT64_TYPE = Types.typeForClass(Long.class);
+    public static final Type STRING_TYPE = Types.typeForClass(String.class);
+    public static final Type DECIMAL64_TYPE = Types.typeForClass(Double.class);
+    public static final Type UINT8_TYPE = Types.typeForClass(Short.class);
+    public static final Type UINT16_TYPE = Types.typeForClass(Integer.class);
+    public static final Type UINT32_TYPE = Types.typeForClass(Long.class);
+    public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class);
+
+    static {
+        typeMap.put("boolean", BOOLEAN_TYPE);
+        typeMap.put("int8", INT8_TYPE);
+        typeMap.put("int16", INT16_TYPE);
+        typeMap.put("int32", INT32_TYPE);
+        typeMap.put("int64", INT64_TYPE);
+        typeMap.put("string", STRING_TYPE);
+        typeMap.put("decimal64", DECIMAL64_TYPE);
+        typeMap.put("uint8", UINT8_TYPE);
+        typeMap.put("uint16", UINT16_TYPE);
+        typeMap.put("uint32", UINT32_TYPE);
+        typeMap.put("uint64", UINT64_TYPE);
+    }
+
+    public static final TypeProvider BASE_YANG_TYPES_PROVIDER = new TypeProvider() {
+
+        @Override
+        public Type javaTypeForYangType(String type) {
+            return typeMap.get(type);
+        }
+
+        @Override
+        public Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type) {
+            if (type != null) {
+                return typeMap.get(type.getQName().getLocalName());
+            }
+
+            return null;
+        }
+    };
+
+}
index be115c9..474e4ad 100644 (file)
@@ -20,18 +20,23 @@ import java.util.Set;
 import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class GeneratorJavaFile {
 
+    private static final Logger log = LoggerFactory
+            .getLogger(GeneratorJavaFile.class);
     private final CodeGenerator interfaceGenerator;
     private final ClassCodeGenerator classGenerator;
-    private final Set<GeneratedType> types;
+    private final Set<GeneratedType> genTypes;
     private final Set<GeneratedTransferObject> genTransferObjects;
 
     public GeneratorJavaFile(final CodeGenerator codeGenerator,
             final Set<GeneratedType> types) {
         this.interfaceGenerator = codeGenerator;
-        this.types = types;
+        this.genTypes = types;
         this.genTransferObjects = new HashSet<GeneratedTransferObject>();
         classGenerator = new ClassCodeGenerator();
     }
@@ -40,72 +45,87 @@ public class GeneratorJavaFile {
             final Set<GeneratedTransferObject> genTransferObjects) {
         this.interfaceGenerator = new InterfaceGenerator();
         this.classGenerator = new ClassCodeGenerator();
-        this.types = types;
+        this.genTypes = types;
         this.genTransferObjects = genTransferObjects;
     }
 
-    public List<File> generateToFile() throws IOException {
-        return generateToFile(null);
-    }
-
+    @Deprecated
     public List<File> generateToFile(String path) throws IOException {
         final List<File> result = new ArrayList<File>();
 
-        for (GeneratedType type : types) {
-            String parentPath = generateParentPath(path,
-                    type.getPackageName());
+        for (GeneratedType genType : genTypes) {
+            final String parentPath = generateParentPath(path,
+                    genType.getPackageName());
 
-            File file = new File(parentPath, type.getName() + ".java");
-            File parent = file.getParentFile();
-            if (!parent.exists()) {
-                parent.mkdirs();
+            final File directory = new File(parentPath);
+            final File genFile = generateTypeToJavaFile(directory, genType,
+                    interfaceGenerator);
+            
+            if (genFile != null) {
+                result.add(genFile);
             }
+        }
 
-            if (!file.exists()) {
-                FileWriter fw = null;
-                BufferedWriter bw = null;
+        for (GeneratedTransferObject transferObject : genTransferObjects) {
+            final String parentPath = generateParentPath(path,
+                    transferObject.getPackageName());
 
-                file.createNewFile();
-                fw = new FileWriter(file);
-                bw = new BufferedWriter(fw);
-                Writer writer = interfaceGenerator.generate(type);
-                bw.write(writer.toString());
+            final File directory = new File(parentPath);
+            final File genFile = generateTypeToJavaFile(directory,
+                    transferObject, classGenerator);
 
-                if (bw != null) {
-                    bw.close();
-                }
-                result.add(file);
+            if (genFile != null) {
+                result.add(genFile);
             }
         }
+        return result;
+    }
 
+    public List<File> generateToFile(final File directory) throws IOException {
+        final List<File> result = new ArrayList<File>();
+        for (GeneratedType type : genTypes) {
+            final File genFile = generateTypeToJavaFile(directory, type,
+                    interfaceGenerator);
+
+            if (genFile != null) {
+                result.add(genFile);
+            }
+        }
         for (GeneratedTransferObject transferObject : genTransferObjects) {
-            String parentPath = generateParentPath(path,
-                    transferObject.getPackageName());
+            final File genFile = generateTypeToJavaFile(directory,
+                    transferObject, classGenerator);
 
-            File file = new File(parentPath, transferObject.getName() + ".java");
-            File parent = file.getParentFile();
-            if (!parent.exists()) {
-                parent.mkdirs();
+            if (genFile != null) {
+                result.add(genFile);
             }
+        }
+        return result;
+    }
 
-            if (!file.exists()) {
-                FileWriter fw = null;
-                BufferedWriter bw = null;
+    private File generateTypeToJavaFile(final File directory, final Type type,
+            final CodeGenerator generator) throws IOException {
+        if ((directory != null) && (type != null) && (generator != null)) {
 
+            if (!directory.exists()) {
+                directory.mkdirs();
+            }
+
+            final File file = new File(directory, type.getName() + ".java");
+            try (final FileWriter fw = new FileWriter(file)) {
                 file.createNewFile();
-                fw = new FileWriter(file);
-                bw = new BufferedWriter(fw);
-                Writer writer = classGenerator.generate(transferObject);
-                bw.write(writer.toString());
 
-                if (bw != null) {
-                    bw.close();
+                try (final BufferedWriter bw = new BufferedWriter(fw)) {
+                    Writer writer = generator.generate(type);
+                    bw.write(writer.toString());
                 }
-                result.add(file);
+            } catch (IOException e) {
+                log.error(e.getMessage());
+                throw new IOException(e.getMessage());
             }
-        }
 
-        return result;
+            return file;
+        }
+        return null;
     }
 
     private String generateParentPath(String path, String pkg) {
@@ -142,5 +162,4 @@ public class GeneratorJavaFile {
         }
         return fullPath;
     }
-
 }
index 4ae8cc1..90fbb6f 100644 (file)
@@ -14,7 +14,6 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -80,7 +79,8 @@ public class GeneratorJavaFileTest {
                 new InterfaceGenerator(), types);
         generator.generateToFile(PATH);
 
-        String[] files = new File(PATH + FS + "org" + FS + "opendaylight" + FS + "controller" + FS + "gen").list();
+        String[] files = new File(PATH + FS + "org" + FS + "opendaylight" + FS
+                + "controller" + FS + "gen").list();
         List<String> filesList = Arrays.asList(files);
 
         assertEquals(3, files.length);
@@ -88,7 +88,7 @@ public class GeneratorJavaFileTest {
         assertTrue(filesList.contains("Type2.java"));
         assertTrue(filesList.contains("Type3.java"));
     }
-    
+
     @Test
     public void compilationTest() throws Exception {
         final YangModelParserImpl parser = new YangModelParserImpl();
@@ -97,17 +97,12 @@ public class GeneratorJavaFileTest {
         final File sourcesDir = new File("src/test/resources/yang");
         final List<File> sourceFiles = new ArrayList<File>();
         final File[] fileArray = sourcesDir.listFiles();
-        
+
         for (int i = 0; i < fileArray.length; ++i) {
             sourceFiles.add(fileArray[i]);
         }
         
-//        String[] sourcesDirPaths = new String[sourceFiles.length];
-//        for (int i = 0; i < sourceFiles.length; i++) {
-//            sourcesDirPaths[i] = sourceFiles[i].getAbsolutePath();
-//        }
-        final Set<Module> modulesToBuild = parser
-                .parseYangModels(sourceFiles);
+        final Set<Module> modulesToBuild = parser.parseYangModels(sourceFiles);
 
         final SchemaContext context = parser
                 .resolveSchemaContext(modulesToBuild);
@@ -115,7 +110,8 @@ public class GeneratorJavaFileTest {
         final Set<GeneratedType> typesToGenerate = new HashSet<GeneratedType>();
         final Set<GeneratedTransferObject> tosToGenerate = new HashSet<GeneratedTransferObject>();
         for (Type type : types) {
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 typesToGenerate.add((GeneratedType) type);
             }
 
@@ -162,7 +158,7 @@ public class GeneratorJavaFileTest {
 
     /**
      * Search recursively given directory for *.java files.
-     *
+     * 
      * @param directory
      *            directory to search
      * @return List of java files found
index 33d1053..c48f151 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/resources/model/testfile1.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/resources/model/testfile1.yang
deleted file mode 100644 (file)
index ba0c15e..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-module types1 {
-       yang-version 1;
-    namespace "urn:simple.container.demo";
-    prefix "t1";
-    
-    import types2 {
-         prefix "data";
-         revision-date 2013-02-27;
-     }
-    
-    organization "Cisco";
-    contact "WILL-BE-DEFINED-LATER";
-    
-    revision "2013-02-27" {
-        reference " WILL BE DEFINED LATER";
-    }
-    
-    container interfaces {
-         list ifEntry {
-             key "ifIndex";
-
-             leaf ifIndex {
-                 type uint32;
-                 units minutes;
-             }
-             
-             leaf ifMtu {
-                 type int32;
-             }
-         }
-     }
-     
-       leaf testleaf {
-               type data:my-base-int32-type {
-                       range "min..max";
-               }
-       }
-       
-       leaf test-string-leaf {
-               type data:my-string-type-ext;
-       }
-       
-       leaf test-int-leaf {
-               type data:my-int-type-ext;
-       }
-       
-       leaf test-decimal-leaf {
-               type data:my-decimal-type {
-                       fraction-digits 4;
-               }
-       }
-       
-       leaf test-decimal-leaf2 {
-               type data:my-decimal-type-ext;
-       }
-
-}
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/resources/model/testfile2.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/resources/model/testfile2.yang
deleted file mode 100644 (file)
index 3e9da52..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-module types2 {
-       yang-version 1;
-    namespace "urn:simple.types.data.demo";
-    prefix "t2";
-    
-    import types1 {
-         prefix "if";
-         revision-date 2013-02-27;
-     }
-
-    organization "Cisco";
-    contact "WILL-BE-DEFINED-LATER";
-    description "This is types-data test description";
-
-    revision "2013-02-27" {
-        reference " WILL BE DEFINED LATER";
-    }
-    
-    typedef my-base-int32-type {
-               type int32 {
-               range "2..20";
-        }
-       }
-
-     typedef my-type1 {
-       type my-base-int32-type {
-               range "11..max";
-       }
-       }
-       
-       typedef my-string-type {
-               type string {
-                       pattern "[a-k]*";
-               }
-       }
-       
-       typedef my-string-type2 {
-               type my-string-type {
-                       pattern "[b-u]*";
-               }
-       }
-       
-       typedef my-string-type-ext {
-               type my-string-type2 {
-                       pattern "[e-z]*";
-               }
-       }
-       
-       typedef my-int-type {
-               type int32 {
-                       range "10..20";
-               }
-       }
-       
-       typedef my-int-type2 {
-               type my-int-type {
-                       range "12..18";
-               }
-       }
-       
-       typedef my-int-type-ext {
-               type my-int-type2 {
-                       range "14..16";
-               }
-       }
-       
-       typedef my-decimal-type {
-               type decimal64 {
-                       fraction-digits 6;
-               }
-       }
-       
-       typedef my-decimal-type-ext {
-               type decimal64 {
-                       fraction-digits 5;
-               }
-       }
-
-    augment "/if:interfaces/if:ifEntry" {
-       when "if:ifType='ds0'";
-        leaf ds0ChannelNumber {
-               type string;
-        }
-       }
-
-    leaf if-name {
-       type leafref {
-               path "/interface/name";
-        }
-    }
-     
-    leaf name {
-       type string;
-    }
-     
-       leaf nested-type-leaf {
-               type my-type1;
-       }
-
-}
index 4fd10ea..4fbffb6 100644 (file)
@@ -21,7 +21,7 @@
                             <goal>generate-resources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../Correct</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
index acb8e60..2a93515 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-resources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../Correct</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <resourceProviders>
                                 <provider>
                                     <resourceProviderClass>
index 82b2cc5..a9ec489 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../Correct</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <codeGenerators>
                             </codeGenerators>
                         </configuration>
index 96aadd2..74f9dc3 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-resources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../Correct</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <resourceProviders>
                             </resourceProviders>
                         </configuration>
index 88829df..2c7f922 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../Correct</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
index 9d4175d..fb83dc9 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-resources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../Correct</yangFilesRootDir>
+                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
                             <resourceProviders>
                                 <provider>
                                     <resourceProviderClass>
index dafba87..89e2794 100644 (file)
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <groupId>org.opendaylight.controller</groupId>\r
-    <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
-    <packaging>pom</packaging>\r
-    <name>binding-generator</name>\r
-    \r
-    <properties>\r
-               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
-       </properties>\r
-  \r
-    <modules>\r
-       <module>../yang</module>\r
-       <module>../sal/sal-schema-repository-api</module>\r
-        <module>code-generator-demo</module>\r
-        <module>yang-model-parser-api</module>\r
-        <module>yang-model-parser-impl</module>\r
-        <module>binding-model-api</module>\r
-        <module>binding-generator-api</module>\r
-        <module>binding-generator-spi</module>\r
-        <module>binding-generator-util</module>\r
-        <module>binding-generator-impl</module>\r
-        <module>binding-java-api-generator</module>\r
-        <module>maven-yang</module>\r
-        <module>maven-yang-plugin</module>\r
-        <module>maven-yang-plugin-it</module>\r
-        <module>maven-sal-api-gen-plugin</module>\r
-    </modules>\r
-    <dependencies>\r
-\r
-        <dependency>\r
-            <groupId>junit</groupId>\r
-            <artifactId>junit</artifactId>\r
-            <version>4.10</version>\r
-            <scope>test</scope>\r
-            <optional>true</optional>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.slf4j</groupId>\r
-            <artifactId>slf4j-api</artifactId>\r
-            <version>1.7.2</version>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.slf4j</groupId>\r
-            <artifactId>slf4j-simple</artifactId>\r
-            <version>1.7.2</version>\r
-        </dependency>\r
-    </dependencies>\r
-    <build>\r
-        <plugins>\r
-            <plugin>\r
-                <groupId>org.apache.maven.plugins</groupId>\r
-                <artifactId>maven-compiler-plugin</artifactId>\r
-                <version>2.0</version>\r
-                <inherited>true</inherited>\r
-                <configuration>\r
-                    <source>1.6</source>\r
-                    <target>1.6</target>\r
-                </configuration>\r
-            </plugin>\r
-            <plugin>\r
-                <groupId>org.apache.maven.plugins</groupId>\r
-                <artifactId>maven-javadoc-plugin</artifactId>\r
-                <version>2.8.1</version>\r
-                <configuration>\r
-                    <stylesheet>maven</stylesheet>\r
-                </configuration>\r
-                <executions>\r
-                    <execution>\r
-                        <goals>\r
-                            <goal>aggregate</goal>\r
-                        </goals>\r
-                        <phase>site</phase>\r
-                    </execution>\r
-                </executions>\r
-            </plugin>\r
-        </plugins>\r
-    </build>\r
-    <reporting>\r
-        <plugins>\r
-            <plugin>\r
-                <groupId>org.codehaus.mojo</groupId>\r
-                <artifactId>findbugs-maven-plugin</artifactId>\r
-                <version>2.4.0</version>\r
-                <configuration>\r
-                    <effort>Max</effort>\r
-                    <threshold>Low</threshold>\r
-                    <goal>site</goal>\r
-                </configuration>\r
-            </plugin>\r
-            <plugin>\r
-                <groupId>org.codehaus.mojo</groupId>\r
-                <artifactId>jdepend-maven-plugin</artifactId>\r
-                <version>2.0-beta-2</version>\r
-            </plugin>\r
-        </plugins>\r
-    </reporting>\r
-</project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>binding-generator</artifactId>
+    <version>1.0</version>
+    <packaging>pom</packaging>
+    <name>binding-generator</name>
+    
+    <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+       </properties>
+  
+    <modules>
+       <module>../yang</module>
+       <module>../sal/sal-schema-repository-api</module>
+        <module>code-generator-demo</module>
+        <module>yang-model-parser-api</module>
+        <module>yang-model-parser-impl</module>
+        <module>binding-model-api</module>
+        <module>binding-generator-api</module>
+        <module>binding-generator-spi</module>
+        <module>binding-generator-util</module>
+        <module>binding-generator-impl</module>
+        <module>binding-java-api-generator</module>
+        <module>maven-yang</module>
+        <module>maven-yang-plugin</module>
+        <module>maven-yang-plugin-it</module>
+        <module>maven-sal-api-gen-plugin</module>
+    </modules>
+    <dependencies>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>test</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.7.2</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0</version>
+                <inherited>true</inherited>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.8.1</version>
+                <configuration>
+                    <stylesheet>maven</stylesheet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>aggregate</goal>
+                        </goals>
+                        <phase>site</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>2.4.0</version>
+                <configuration>
+                    <effort>Max</effort>
+                    <threshold>Low</threshold>
+                    <goal>site</goal>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jdepend-maven-plugin</artifactId>
+                <version>2.0-beta-2</version>
+            </plugin>
+        </plugins>
+    </reporting>
+</project>
index eb88196..946ba4a 100644 (file)
@@ -31,22 +31,26 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 
 public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         AugmentationTargetBuilder {
+    private final ChoiceNodeImpl instance;
+    // SchemaNode args
     private final QName qname;
     private SchemaPath schemaPath;
-    private final ConstraintsBuilder constraints;
-    private final ChoiceNodeImpl instance;
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // DataSchemaNode args
     private boolean augmenting;
     private boolean configuration;
-    private String defaultCase;
-
-    private final Set<ChoiceCaseBuilder> cases = new HashSet<ChoiceCaseBuilder>();
+    private final ConstraintsBuilder constraints;
+    // DataNodeContainer args
     private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
+    // AugmentationTarget args
     private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // ChoiceNode args
+    private final Set<ChoiceCaseBuilder> cases = new HashSet<ChoiceCaseBuilder>();
+    private String defaultCase;
 
     public ChoiceBuilder(QName qname) {
         this.qname = qname;
@@ -62,6 +66,7 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         instance.setStatus(status);
         instance.setAugmenting(augmenting);
         instance.setConfiguration(configuration);
+        instance.setConstraints(constraints.build());
         instance.setDefaultCase(defaultCase);
 
         // CASES
@@ -85,8 +90,6 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         }
         instance.setUnknownSchemaNodes(unknownNodes);
 
-        instance.setConstraints(constraints.build());
-
         return instance;
     }
 
@@ -97,7 +100,8 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
     @Override
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         if (!(childNode instanceof ChoiceCaseBuilder)) {
-            ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(childNode.getQName());
+            ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(
+                    childNode.getQName());
             caseBuilder.addChildNode(childNode);
             cases.add(caseBuilder);
         } else {
index 73d7e3d..27cead1 100644 (file)
@@ -24,18 +24,18 @@ import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeB
 import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
 
-public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataSchemaNodeBuilder {
-
+public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
+        DataSchemaNodeBuilder {
     private final ChoiceCaseNodeImpl instance;
-    private final ConstraintsBuilder constraints;
     private SchemaPath schemaPath;
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
     private boolean augmenting;
+    private final ConstraintsBuilder constraints;
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
     private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     ChoiceCaseBuilder(QName qname) {
         super(qname);
@@ -110,7 +110,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
@@ -144,12 +144,14 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
 
     @Override
     public void addTypedef(TypeDefinitionBuilder typedefBuilder) {
-        throw new UnsupportedOperationException("Can not add type definition to choice case.");
+        throw new UnsupportedOperationException(
+                "Can not add type definition to choice case.");
     }
 
     @Override
     public void setConfiguration(boolean configuration) {
-        throw new UnsupportedOperationException("Can not add config definition to choice case.");
+        throw new UnsupportedOperationException(
+                "Can not add config definition to choice case.");
     }
 
     @Override
@@ -161,8 +163,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
         return augmentations;
     }
 
-
-    private static class ChoiceCaseNodeImpl implements ChoiceCaseNode {
+    private class ChoiceCaseNodeImpl implements ChoiceCaseNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -217,7 +218,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
         }
 
         private void setStatus(Status status) {
-            if(status != null) {
+            if (status != null) {
                 this.status = status;
             }
         }
@@ -251,7 +252,7 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
         }
 
         private void setUnknownSchemaNodes(List<UnknownSchemaNode> unknownNodes) {
-            if(unknownNodes != null) {
+            if (unknownNodes != null) {
                 this.unknownNodes = unknownNodes;
             }
         }
@@ -317,7 +318,6 @@ public class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements DataS
             }
         }
 
-
         @Override
         public int hashCode() {
             final int prime = 31;
index 906afd9..5cfde8e 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.parser.builder.impl;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -17,13 +18,13 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
 
-public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
-
+public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
+    private final IdentitySchemaNodeImpl instance;
     private final QName qname;
     private SchemaPath schemaPath;
-    private final IdentitySchemaNodeImpl instance;
     private IdentitySchemaNodeBuilder baseIdentity;
     private String baseIdentityName;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     IdentitySchemaNodeBuilder(final QName qname) {
         this.qname = qname;
@@ -33,11 +34,17 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
     @Override
     public IdentitySchemaNode build() {
         instance.setPath(schemaPath);
-
         if (baseIdentity != null) {
-            final IdentitySchemaNode base = baseIdentity.build();
-            instance.setBaseIdentity(base);
+            instance.setBaseIdentity(baseIdentity.build());
+        }
+
+        // UNKNOWN NODES
+        final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+        for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+            unknownNodes.add(b.build());
         }
+        instance.setUnknownSchemaNodes(unknownNodes);
+
         return instance;
     }
 
@@ -75,8 +82,7 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
 
     @Override
     public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
-        throw new IllegalStateException(
-                "Can not add schema node to identity statement");
+        addedUnknownNodes.add(unknownNode);
     }
 
     public String getBaseIdentityName() {
@@ -91,13 +97,14 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
         this.baseIdentity = baseType;
     }
 
-    private class IdentitySchemaNodeImpl implements IdentitySchemaNode {
+    private final class IdentitySchemaNodeImpl implements IdentitySchemaNode {
         private final QName qname;
         private IdentitySchemaNode baseIdentity;
         private String description;
         private String reference;
         private Status status = Status.CURRENT;
         private SchemaPath path;
+        private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
 
         private IdentitySchemaNodeImpl(final QName qname) {
             this.qname = qname;
@@ -157,7 +164,14 @@ public class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
 
         @Override
         public List<UnknownSchemaNode> getUnknownSchemaNodes() {
-            return Collections.emptyList();
+            return unknownNodes;
+        }
+
+        private void setUnknownSchemaNodes(
+                List<UnknownSchemaNode> unknownSchemaNodes) {
+            if (unknownSchemaNodes != null) {
+                this.unknownNodes = unknownSchemaNodes;
+            }
         }
 
         @Override
index e0ba03a..cca505e 100644 (file)
@@ -96,6 +96,8 @@ public class ModuleBuilder implements Builder {
      */
     @Override
     public Module build() {
+        instance.setPrefix(prefix);
+        instance.setRevision(revision);
         instance.setImports(imports);
         instance.setNamespace(namespace);
 
@@ -247,12 +249,10 @@ public class ModuleBuilder implements Builder {
 
     public void setRevision(final Date revision) {
         this.revision = revision;
-        instance.setRevision(revision);
     }
 
     public void setPrefix(final String prefix) {
         this.prefix = prefix;
-        instance.setPrefix(prefix);
     }
 
     public void setYangVersion(final String yangVersion) {
@@ -295,10 +295,8 @@ public class ModuleBuilder implements Builder {
     public ContainerSchemaNodeBuilder addContainerNode(
             final QName containerName, final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(
                 containerName);
-
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -318,10 +316,8 @@ public class ModuleBuilder implements Builder {
     public ListSchemaNodeBuilder addListNode(final QName listName,
             final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(
                 listName);
-
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -341,10 +337,8 @@ public class ModuleBuilder implements Builder {
     public LeafSchemaNodeBuilder addLeafNode(final QName leafName,
             final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(
                 leafName);
-
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -364,7 +358,6 @@ public class ModuleBuilder implements Builder {
     public LeafListSchemaNodeBuilder addLeafListNode(final QName leafListName,
             final List<String> parentPath) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
-
         final LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(
                 leafListName);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
@@ -386,7 +379,6 @@ public class ModuleBuilder implements Builder {
     public GroupingBuilder addGrouping(final QName qname,
             final List<String> parentPath) {
         final List<String> pathToGroup = new ArrayList<String>(parentPath);
-
         final GroupingBuilder builder = new GroupingBuilderImpl(qname);
         final ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes
                 .get(pathToGroup);
@@ -405,7 +397,6 @@ public class ModuleBuilder implements Builder {
     public AugmentationSchemaBuilder addAugment(final String name,
             final List<String> parentPath) {
         final List<String> pathToAugment = new ArrayList<String>(parentPath);
-
         final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(
                 name);
 
index 7d3e929..05d2faa 100644 (file)
@@ -26,8 +26,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;\r
 import org.opendaylight.controller.yang.model.parser.util.RefineHolder;\r
 \r
-public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
-\r
+final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
     private final UsesNodeImpl instance;\r
     private final SchemaPath groupingPath;\r
     private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
@@ -89,8 +88,8 @@ public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
         refines.add(refine);\r
     }\r
 \r
-    private SchemaPath parseUsesPath(final String augmentPath) {\r
-        final String[] splittedPath = augmentPath.split("/");\r
+    private SchemaPath parseUsesPath(final String groupingPathStr) {\r
+        final String[] splittedPath = groupingPathStr.split("/");\r
         final List<QName> path = new ArrayList<QName>();\r
         QName name;\r
         for (String pathElement : splittedPath) {\r
@@ -103,11 +102,11 @@ public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
             }\r
             path.add(name);\r
         }\r
-        final boolean absolute = augmentPath.startsWith("/");\r
+        final boolean absolute = groupingPathStr.startsWith("/");\r
         return new SchemaPath(path, absolute);\r
     }\r
 \r
-    private static class UsesNodeImpl implements UsesNode {\r
+    private final class UsesNodeImpl implements UsesNode {\r
         private final SchemaPath groupingPath;\r
         private Set<AugmentationSchema> augmentations = Collections.emptySet();\r
         private boolean augmenting;\r
index 50943fa..35c04a8 100644 (file)
@@ -71,6 +71,8 @@ import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.TypedefBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.UnionTypeBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.util.ModuleDependencySort;
+import org.opendaylight.controller.yang.model.parser.util.ModuleDependencySort.ModuleSimple;
 import org.opendaylight.controller.yang.model.parser.util.ParserUtils;
 import org.opendaylight.controller.yang.model.parser.util.RefineHolder;
 import org.opendaylight.controller.yang.model.parser.util.TypeConstraints;
@@ -91,7 +93,7 @@ public class YangModelParserImpl implements YangModelParser {
     public Set<Module> parseYangModels(final List<File> yangFiles) {
         if (yangFiles != null) {
             final List<InputStream> inputStreams = new ArrayList<InputStream>();
-            
+
             for (final File yangFile : yangFiles) {
                 try {
                     inputStreams.add(new FileInputStream(yangFile));
@@ -119,7 +121,7 @@ public class YangModelParserImpl implements YangModelParser {
     }
 
     private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(
-            final List<InputStream>  yangFileStreams) {
+            final List<InputStream> yangFileStreams) {
         final Map<String, TreeMap<Date, ModuleBuilder>> modules = new HashMap<String, TreeMap<Date, ModuleBuilder>>();
         final ParseTreeWalker walker = new ParseTreeWalker();
         final List<ParseTree> trees = parseStreams(yangFileStreams);
@@ -135,6 +137,9 @@ public class YangModelParserImpl implements YangModelParser {
             builders[i] = yangModelParser.getModuleBuilder();
         }
 
+        // module dependency graph sorted
+        List<ModuleSimple> sorted = new ModuleDependencySort(builders).sort();
+
         for (ModuleBuilder builder : builders) {
             final String builderName = builder.getName();
             Date builderRevision = builder.getRevision();
@@ -377,7 +382,7 @@ public class YangModelParserImpl implements YangModelParser {
         tdb.setPatterns(old.getPatterns());
         tdb.setFractionDigits(old.getFractionDigits());
         tdb.setPath(old.getPath());
-        
+
         final TypeDefinition<?> oldType = old.getType();
         if (oldType == null) {
             tdb.setType(old.getTypedef());
index 2023b47..98b81bd 100644 (file)
@@ -652,7 +652,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         final String nodeTypeStr = ctx.getChild(0).getText();
         final String[] splittedElement = nodeTypeStr.split(":");
         if (splittedElement.length == 1) {
-            nodeType = new QName(null, null, null, splittedElement[0]);
+            nodeType = new QName(null, null, yangModelPrefix, splittedElement[0]);
         } else {
             nodeType = new QName(null, null, splittedElement[0],
                     splittedElement[1]);
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/ModuleDependencySort.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/ModuleDependencySort.java
new file mode 100644 (file)
index 0000000..5c128d2
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * 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.yang.model.parser.util;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.model.api.ModuleImport;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserListenerImpl;
+import org.opendaylight.controller.yang.model.parser.util.TopologicalSort.Node;
+import org.opendaylight.controller.yang.model.parser.util.TopologicalSort.NodeImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * Creates a module dependency graph from provided {@link ModuleBuilder}s and
+ * provides a {@link #sort()} method. It is topological sort and returns modules
+ * in order in which they should be processed (e.g. if A imports B, sort returns
+ * {B, A}).
+ */
+public final class ModuleDependencySort {
+
+    private static final Date DEFAULT_REVISION = new Date(0);
+    private static final Logger logger = LoggerFactory
+            .getLogger(ModuleDependencySort.class);
+
+    private final Map<String, Map<Date, ModuleNodeImpl>> moduleGraph;
+
+    /**
+     *
+     * @param builders
+     *            Source for module dependency graph.
+     * @throws YangValidationException
+     *             if 1. there are module:revision duplicates 2. there is
+     *             imported not existing module 3. module is imported twice
+     */
+    public ModuleDependencySort(ModuleBuilder... builders) {
+        this.moduleGraph = createModuleGraph(builders);
+    }
+
+    @VisibleForTesting
+    Map<String, Map<Date, ModuleNodeImpl>> getModuleGraph() {
+        return moduleGraph;
+    }
+
+    /**
+     * Topological sort of module dependency graph.
+     *
+     * @return Sorted list of modules. Modules can be further processed in
+     *         returned order.
+     */
+    public List<ModuleSimple> sort() {
+        Set<Node> nodes = Sets.newHashSet();
+        for (Map<Date, ModuleNodeImpl> map : moduleGraph.values()) {
+            for (ModuleNodeImpl node : map.values()) {
+                nodes.add(node);
+            }
+        }
+
+        // Cast to ModuleNode from Node
+        return Lists.transform(TopologicalSort.sort(nodes),
+                new Function<Node, ModuleSimple>() {
+
+                    @Override
+                    public ModuleSimple apply(Node input) {
+                        return (ModuleSimple) input;
+                    }
+                });
+    }
+
+    private Map<String, Map<Date, ModuleNodeImpl>> createModuleGraph(
+            ModuleBuilder... builders) {
+        Map<String, Map<Date, ModuleNodeImpl>> moduleGraph = Maps.newHashMap();
+
+        processModules(moduleGraph, builders);
+        processDependencies(moduleGraph, builders);
+
+        return moduleGraph;
+    }
+
+    /**
+     * Extract module:revision from module builders
+     */
+    private void processDependencies(
+            Map<String, Map<Date, ModuleNodeImpl>> moduleGraph,
+            ModuleBuilder... builders) {
+        Map<String, Date> imported = Maps.newHashMap();
+
+        // Create edges in graph
+        for (ModuleBuilder mb : builders) {
+            String fromName = mb.getName();
+            Date fromRevision = mb.getRevision() == null ? DEFAULT_REVISION
+                    : mb.getRevision();
+            for (ModuleImport imprt : mb.getModuleImports()) {
+                String toName = imprt.getModuleName();
+                Date toRevision = imprt.getRevision() == null ? DEFAULT_REVISION
+                        : imprt.getRevision();
+
+                ModuleNodeImpl from = moduleGraph.get(fromName).get(
+                        fromRevision);
+
+                ModuleNodeImpl to = getModuleByNameAndRevision(moduleGraph,
+                        fromName, fromRevision, toName, toRevision);
+
+                /*
+                 * Check imports: If module is imported twice with different
+                 * revisions then throw exception
+                 */
+                if (imported.get(toName) != null
+                        && !imported.get(toName).equals(toRevision))
+                    ex(String
+                            .format("Module:%s imported twice with different revisions:%s, %s",
+                                    toName,
+                                    formatRevDate(imported.get(toName)),
+                                    formatRevDate(toRevision)));
+                imported.put(toName, toRevision);
+
+                from.addEdge(to);
+            }
+        }
+    }
+
+    /**
+     * Get imported module by its name and revision from moduleGraph
+     */
+    private ModuleNodeImpl getModuleByNameAndRevision(
+            Map<String, Map<Date, ModuleNodeImpl>> moduleGraph,
+            String fromName, Date fromRevision, String toName, Date toRevision) {
+        ModuleNodeImpl to = null;
+
+        if (moduleGraph.get(toName) == null
+                || !moduleGraph.get(toName).containsKey(toRevision)) {
+            // If revision is not specified in import, but module exists
+            // with different revisions, take first
+            if (moduleGraph.get(toName) != null
+                    && !moduleGraph.get(toName).isEmpty()
+                    && toRevision.equals(DEFAULT_REVISION)) {
+                to = moduleGraph.get(toName).values().iterator().next();
+                logger.warn(String
+                        .format("Import:%s:%s by module:%s:%s does not specify revision, using:%s:%s for module dependency sort",
+                                toName, formatRevDate(toRevision), fromName,
+                                formatRevDate(fromRevision), to.getName(),
+                                formatRevDate(to.getRevision())));
+            } else
+                ex(String.format("Not existing module imported:%s:%s by:%s:%s",
+                        toName, formatRevDate(toRevision), fromName,
+                        formatRevDate(fromRevision)));
+        } else {
+            to = moduleGraph.get(toName).get(toRevision);
+        }
+        return to;
+    }
+
+    private void ex(String message) {
+        throw new YangValidationException(message);
+    }
+
+    /**
+     * Extract dependencies from module builders to fill dependency graph
+     */
+    private void processModules(
+            Map<String, Map<Date, ModuleNodeImpl>> moduleGraph,
+            ModuleBuilder... builders) {
+
+        // Process nodes
+        for (ModuleBuilder mb : builders) {
+            String name = mb.getName();
+
+            Date rev = mb.getRevision();
+            if (rev == null)
+                rev = DEFAULT_REVISION;
+
+            if (moduleGraph.get(name) == null)
+                moduleGraph.put(name, Maps.<Date, ModuleNodeImpl> newHashMap());
+
+            if (moduleGraph.get(name).get(rev) != null)
+                ex(String.format("Module:%s with revision:%s declared twice",
+                        name, formatRevDate(rev)));
+
+            moduleGraph.get(name).put(rev, new ModuleNodeImpl(name, rev));
+        }
+    }
+
+    private static String formatRevDate(Date rev) {
+        return rev == DEFAULT_REVISION ? "default"
+                : YangModelParserListenerImpl.simpleDateFormat.format(rev);
+    }
+
+    /**
+     * Simple representation of module. Contains name and revision.
+     */
+    public interface ModuleSimple {
+        String getName();
+
+        Date getRevision();
+    }
+
+    static class ModuleNodeImpl extends NodeImpl implements ModuleSimple {
+        private final String name;
+        private final Date revision;
+
+        public ModuleNodeImpl(String name, Date revision) {
+            this.name = name;
+            this.revision = revision;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public Date getRevision() {
+            return revision;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((name == null) ? 0 : name.hashCode());
+            result = prime * result
+                    + ((revision == null) ? 0 : revision.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            ModuleNodeImpl other = (ModuleNodeImpl) obj;
+            if (name == null) {
+                if (other.name != null)
+                    return false;
+            } else if (!name.equals(other.name))
+                return false;
+            if (revision == null) {
+                if (other.revision != null)
+                    return false;
+            } else if (!revision.equals(other.revision))
+                return false;
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            return "Module [name=" + name + ", revision="
+                    + formatRevDate(revision) + "]";
+        }
+
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/TopologicalSort.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/TopologicalSort.java
new file mode 100644 (file)
index 0000000..333137c
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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.yang.model.parser.util;
+
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+/**
+ * Utility class that provides topological sort
+ */
+public class TopologicalSort {
+
+    /**
+     * Topological sort of dependent nodes in acyclic graphs.
+     *
+     * @return Sorted {@link List} of {@link Node}s. Order: Nodes with no
+     *         dependencies starting.
+     * @throws IllegalStateException
+     *             when cycle is present in the graph
+     */
+    public static List<Node> sort(Set<Node> nodes) {
+        List<Node> sortedNodes = Lists.newArrayList();
+
+        Set<Node> dependentNodes = getDependentNodes(nodes);
+
+        while (!dependentNodes.isEmpty()) {
+            Node n = dependentNodes.iterator().next();
+            dependentNodes.remove(n);
+
+            sortedNodes.add(n);
+
+            for (Edge e : n.getInEdges()) {
+                Node m = e.getFrom();
+                m.getOutEdges().remove(e);
+
+                if (m.getOutEdges().isEmpty()) {
+                    dependentNodes.add(m);
+                }
+            }
+        }
+
+        detectCycles(nodes);
+
+        return sortedNodes;
+    }
+
+    private static Set<Node> getDependentNodes(Set<Node> nodes) {
+        Set<Node> S = Sets.newHashSet();
+        for (Node n : nodes) {
+            if (n.getOutEdges().size() == 0) {
+                S.add(n);
+            }
+        }
+        return S;
+    }
+
+    private static void detectCycles(Set<Node> nodes) {
+        // Detect cycles
+        boolean cycle = false;
+        Node cycledNode = null;
+
+        for (Node n : nodes) {
+            if (!n.getOutEdges().isEmpty()) {
+                cycle = true;
+                cycledNode = n;
+                break;
+            }
+        }
+        Preconditions.checkState(cycle == false,
+                "Cycle detected in graph around node: " + cycledNode);
+    }
+
+    /**
+     * Interface for nodes in graph that can be sorted topologically
+     */
+    public static interface Node {
+        Set<Edge> getInEdges();
+
+        Set<Edge> getOutEdges();
+    }
+
+    /**
+     * Interface for edges in graph that can be sorted topologically
+     */
+    public static interface Edge {
+        Node getFrom();
+
+        Node getTo();
+    }
+
+    /**
+     * Basic Node implementation.
+     */
+    public static class NodeImpl implements Node {
+        private final Set<Edge> inEdges;
+        private final Set<Edge> outEdges;
+
+        @Override
+        public Set<Edge> getInEdges() {
+            return inEdges;
+        }
+
+        @Override
+        public Set<Edge> getOutEdges() {
+            return outEdges;
+        }
+
+        public void addEdge(Node to) {
+            Edge e = new EdgeImpl(this, to);
+            outEdges.add(e);
+            to.getInEdges().add(e);
+        }
+
+        public NodeImpl() {
+            inEdges = Sets.newHashSet();
+            outEdges = Sets.newHashSet();
+        }
+    }
+
+    /**
+     * Basic Edge implementation
+     */
+    public static class EdgeImpl implements Edge {
+        private final Node from;
+        private final Node to;
+
+        @Override
+        public Node getFrom() {
+            return from;
+        }
+
+        @Override
+        public Node getTo() {
+            return to;
+        }
+
+        public EdgeImpl(Node from, Node to) {
+            this.from = from;
+            this.to = to;
+
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((from == null) ? 0 : from.hashCode());
+            result = prime * result + ((to == null) ? 0 : to.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            EdgeImpl other = (EdgeImpl) obj;
+            if (from == null) {
+                if (other.from != null)
+                    return false;
+            } else if (!from.equals(other.from))
+                return false;
+            if (to == null) {
+                if (other.to != null)
+                    return false;
+            } else if (!to.equals(other.to))
+                return false;
+            return true;
+        }
+    }
+
+}
index 7acf7cb..4a48a4e 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/util/ModuleDependencySortTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/util/ModuleDependencySortTest.java
new file mode 100644 (file)
index 0000000..216d778
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * 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.yang.model.parser.util;
+
+import static org.hamcrest.core.AnyOf.*;
+import static org.hamcrest.core.Is.*;
+import static org.junit.Assert.*;
+import static org.junit.matchers.JUnitMatchers.*;
+import static org.mockito.Mockito.*;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.hamcrest.Matcher;
+import org.junit.Test;
+import org.opendaylight.controller.yang.model.api.ModuleImport;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserListenerImpl;
+import org.opendaylight.controller.yang.model.parser.util.ModuleDependencySort.ModuleNodeImpl;
+import org.opendaylight.controller.yang.model.parser.util.ModuleDependencySort.ModuleSimple;
+import org.opendaylight.controller.yang.model.parser.util.TopologicalSort.Edge;
+
+import com.google.common.collect.Sets;
+
+public class ModuleDependencySortTest {
+
+    private ModuleBuilder a = mockModule("a", null);
+    private ModuleBuilder b = mockModule("b", null);
+    private ModuleBuilder c = mockModule("c", null);
+    private ModuleBuilder d = mockModule("d", null);
+
+    @Test
+    public void testValid() throws Exception {
+
+        mockDependency(a, b);
+        mockDependency(b, c);
+        mockDependency(b, d);
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { d, b, c, a };
+        ModuleDependencySort sort = new ModuleDependencySort(builders);
+
+        assertDependencyGraph(sort.getModuleGraph());
+
+        List<ModuleSimple> l = sort.sort();
+
+        @SuppressWarnings("unchecked")
+        Matcher<String> cOrD = anyOf(is(c.getName()), is(d.getName()));
+
+        assertThat(l.get(0).getName(), cOrD);
+        assertThat(l.get(1).getName(), cOrD);
+        assertThat(l.get(2).getName(), is(b.getName()));
+        assertThat(l.get(3).getName(), is(a.getName()));
+    }
+
+    @Test(expected = YangValidationException.class)
+    public void testModuleTwice() throws Exception {
+        ModuleBuilder a2 = mockModule("a", null);
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { a, a2 };
+        try {
+            new ModuleDependencySort(builders);
+        } catch (YangValidationException e) {
+            assertThat(e.getMessage(),
+                    containsString("Module:a with revision:default declared twice"));
+            throw e;
+        }
+    }
+
+    @Test(expected = YangValidationException.class)
+    public void testImportNotExistingModule() throws Exception {
+        mockDependency(a, b);
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { a };
+        try {
+            new ModuleDependencySort(builders);
+        } catch (YangValidationException e) {
+            assertThat(e.getMessage(),
+                    containsString("Not existing module imported:b:default by:a:default"));
+            throw e;
+        }
+    }
+
+    @Test
+    public void testImportTwice() throws Exception {
+        mockDependency(a, b);
+        mockDependency(c, b);
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { a, b, c };
+        new ModuleDependencySort(builders);
+    }
+
+    @Test(expected = YangValidationException.class)
+    public void testImportTwiceDifferentRevision() throws Exception {
+        Date date = new Date();
+        ModuleBuilder b2 = mockModule("b", date);
+
+        mockDependency(a, b);
+        mockDependency(c, b2);
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { a, c, b, b2 };
+        try {
+            ModuleDependencySort aaa = new ModuleDependencySort(builders);
+            System.out.println(aaa.getModuleGraph());
+        } catch (YangValidationException e) {
+            assertThat(e.getMessage(),
+                    containsString("Module:b imported twice with different revisions:default, "
+                            + YangModelParserListenerImpl.simpleDateFormat
+                                    .format(date)));
+            throw e;
+        }
+    }
+
+    @Test
+    public void testModuleTwiceWithDifferentRevs() throws Exception {
+        ModuleBuilder a2 = mockModule("a", new Date());
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { a, a2 };
+        new ModuleDependencySort(builders);
+    }
+
+    @Test(expected = YangValidationException.class)
+    public void testModuleTwice2() throws Exception {
+        Date rev = new Date();
+        ModuleBuilder a2 = mockModule("a", rev);
+        ModuleBuilder a3 = mockModule("a", rev);
+
+        ModuleBuilder[] builders = new ModuleBuilder[] { a, a2, a3 };
+        try {
+            new ModuleDependencySort(builders);
+        } catch (YangValidationException e) {
+            assertThat(e.getMessage(), containsString("Module:a with revision:"
+                    + YangModelParserListenerImpl.simpleDateFormat.format(rev)
+                    + " declared twice"));
+            throw e;
+        }
+    }
+
+    private void assertDependencyGraph(
+            Map<String, Map<Date, ModuleNodeImpl>> moduleGraph) {
+        for (Entry<String, Map<Date, ModuleNodeImpl>> node : moduleGraph
+                .entrySet()) {
+            String name = node.getKey();
+
+            // Expects only one module revision
+
+            Set<Edge> inEdges = node.getValue().values().iterator().next()
+                    .getInEdges();
+            Set<Edge> outEdges = node.getValue().values().iterator().next()
+                    .getOutEdges();
+
+            if (name.equals("a")) {
+                assertEdgeCount(inEdges, 0, outEdges, 1);
+            } else if (name.equals("b")) {
+                assertEdgeCount(inEdges, 1, outEdges, 2);
+            } else {
+                assertEdgeCount(inEdges, 1, outEdges, 0);
+            }
+        }
+    }
+
+    private void assertEdgeCount(Set<Edge> inEdges, int i, Set<Edge> outEdges,
+            int j) {
+        assertThat(inEdges.size(), is(i));
+        assertThat(outEdges.size(), is(j));
+    }
+
+    private void mockDependency(ModuleBuilder a, ModuleBuilder b) {
+        ModuleImport imprt = mock(ModuleImport.class);
+        doReturn(b.getName()).when(imprt).getModuleName();
+        doReturn(b.getRevision()).when(imprt).getRevision();
+        a.getModuleImports().add(imprt);
+    }
+
+    private ModuleBuilder mockModule(String name, Date rev) {
+        ModuleBuilder a = mock(ModuleBuilder.class);
+        doReturn(name).when(a).getName();
+        Set<ModuleImport> set = Sets.newHashSet();
+        doReturn(set).when(a).getModuleImports();
+        if (rev != null) {
+            doReturn(rev).when(a).getRevision();
+        }
+        return a;
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/util/TopologicalSortTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/util/TopologicalSortTest.java
new file mode 100644 (file)
index 0000000..bfb94e5
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.yang.model.parser.util;
+
+import static org.hamcrest.core.Is.*;
+import static org.junit.Assert.*;
+
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.opendaylight.controller.yang.model.parser.util.TopologicalSort.Node;
+import org.opendaylight.controller.yang.model.parser.util.TopologicalSort.NodeImpl;
+
+import com.google.common.collect.Sets;
+
+public class TopologicalSortTest {
+
+    @Test(expected = IllegalStateException.class)
+    public void test() throws Exception {
+        Set<Node> nodes = Sets.newHashSet();
+
+        NodeImpl node1 = new NodeImpl();
+        nodes.add(node1);
+        NodeImpl node2 = new NodeImpl();
+        nodes.add(node2);
+        NodeImpl node3 = new NodeImpl();
+        nodes.add(node3);
+
+        node1.addEdge(node2);
+        node2.addEdge(node3);
+        node3.addEdge(node1);
+
+        try {
+            TopologicalSort.sort(nodes);
+        } catch (IllegalStateException e) {
+            throw e;
+        }
+    }
+
+    @Test
+    public void testValidSimple() throws Exception {
+        Set<Node> nodes = Sets.newHashSet();
+
+        Node node1 = new NodeImpl();
+        nodes.add(node1);
+        Node node2 = new NodeImpl();
+        nodes.add(node2);
+        Node node3 = new NodeImpl();
+        nodes.add(node3);
+        Node node4 = new NodeImpl();
+        nodes.add(node4);
+
+        ((NodeImpl) node1).addEdge(node2);
+        ((NodeImpl) node1).addEdge(node3);
+        ((NodeImpl) node2).addEdge(node4);
+        ((NodeImpl) node3).addEdge(node2);
+
+        List<Node> sorted = TopologicalSort.sort(nodes);
+
+        assertThat(sorted.get(0), is(node4));
+        assertThat(sorted.get(1), is(node2));
+        assertThat(sorted.get(2), is(node3));
+        assertThat(sorted.get(3), is(node1));
+    }
+
+}
index 4f146f7..1a7b45e 100644 (file)
@@ -3,11 +3,6 @@ module types2 {
     namespace "urn:simple.types.data.demo";
     prefix "t2";
     
-    import types1 {
-         prefix "if";
-         revision-date 2013-02-27;
-     }
-
     organization "opendaylight";
     contact "http://www.opendaylight.org/";
     
index 9f77613..2604a45 100644 (file)
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-       <modelVersion>4.0.0</modelVersion>\r
-       <groupId>org.opendaylight.controller</groupId>\r
-       <artifactId>sal</artifactId>\r
-       <version>1.0-SNAPSHOT</version>\r
-       <packaging>pom</packaging>\r
-\r
-       <modules>\r
-               <module>sal-common</module>\r
-               <module>sal-common-util</module>\r
-               <module>sal-core-api</module>\r
-               <module>sal-data-api</module>\r
-               <module>sal-binding-api</module>\r
-               <module>sal-binding-spi</module>\r
-               <module>sal-binding-broker-impl</module>\r
-               <module>sal-schema-repository-api</module>\r
-               <module>sal-core-spi</module>\r
-               <module>sal-broker-impl</module>\r
-               <module>sal-core-demo</module>\r
-       </modules>\r
-\r
-       <dependencyManagement>\r
-               <dependencies>\r
-                       <dependency>\r
-                               <groupId>com.google.guava</groupId>\r
-                               <artifactId>guava</artifactId>\r
-                               <version>14.0.1</version>\r
-                               <type>jar</type>\r
-                       </dependency>\r
-                       <dependency>\r
-                               <groupId>org.slf4j</groupId>\r
-                               <artifactId>slf4j-api</artifactId>\r
-                               <version>1.7.2</version>\r
-                       </dependency>\r
-                       <dependency>\r
-                               <groupId>junit</groupId>\r
-                               <artifactId>junit</artifactId>\r
-                               <version>4.10</version>\r
-                       </dependency>\r
-               </dependencies>\r
-       </dependencyManagement>\r
-\r
-       <dependencies>\r
-               <dependency>\r
-                       <groupId>junit</groupId>\r
-                       <artifactId>junit</artifactId>\r
-                       <scope>test</scope>\r
-                       <optional>true</optional>\r
-               </dependency>\r
-               <dependency>\r
-                       <groupId>org.mockito</groupId>\r
-                       <artifactId>mockito-all</artifactId>\r
-                       <version>1.9.5</version>\r
-                       <scope>test</scope>\r
-               </dependency>\r
-       </dependencies>\r
-       <build>\r
-               <plugins>\r
-                       <plugin>\r
-                               <groupId>org.apache.maven.plugins</groupId>\r
-                               <artifactId>maven-compiler-plugin</artifactId>\r
-                               <version>2.0</version>\r
-                               <inherited>true</inherited>\r
-                               <configuration>\r
-                                       <source>1.6</source>\r
-                                       <target>1.6</target>\r
-                               </configuration>\r
-                       </plugin>\r
-                       <plugin>\r
-       &nb