Merge "API 2 Documentation for opendaylight.controller.usermanager"
authorGiovanni Meo <gmeo@cisco.com>
Mon, 6 May 2013 13:48:30 +0000 (13:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 6 May 2013 13:48:30 +0000 (13:48 +0000)
139 files changed:
opendaylight/arphandler/pom.xml
opendaylight/clustering/integrationtest/pom.xml [new file with mode: 0644]
opendaylight/clustering/integrationtest/src/test/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusteringServicesIntegrationTest.java [new file with mode: 0644]
opendaylight/clustering/integrationtest/src/test/resources/logback.xml [new file with mode: 0644]
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/pom.xml
opendaylight/forwarding/staticrouting/pom.xml
opendaylight/forwardingrulesmanager/api/pom.xml
opendaylight/forwardingrulesmanager/implementation/pom.xml
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java
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/ITopologyServiceShimListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.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/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java [new file with mode: 0644]
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/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-api/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-generator-spi/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-model-api/pom.xml
opendaylight/sal/yang-prototype/code-generator/code-generator-demo/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-sal-api-gen-plugin/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/pom.xml
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_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/NoYangFiles/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/maven-yang-plugin-it/src/test/resources/YangRootNotExist/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang/pom.xml
opendaylight/sal/yang-prototype/code-generator/pom.xml
opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/pom.xml
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/pom.xml
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/pom.xml
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/AbstractTypeAwareBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/Builder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/TypeAwareBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AnyXmlBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AugmentationSchemaBuilderImpl.java
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/ConstraintsBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/DeviationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ExtensionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/FeatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/GroupingBuilderImpl.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/IdentityrefTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilder.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/NotificationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/RpcDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/TypedefBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnionTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnknownSchemaNodeBuilder.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/ParserUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/RefineHolder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangParseException.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/validator/BasicValidations.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/validator/YangModelValidationTest.java
opendaylight/sal/yang-prototype/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/pom.xml
opendaylight/sal/yang-prototype/yang/yang-binding/pom.xml
opendaylight/sal/yang-prototype/yang/yang-common/pom.xml
opendaylight/sal/yang-prototype/yang/yang-data-api/pom.xml
opendaylight/sal/yang-prototype/yang/yang-data-util/pom.xml
opendaylight/sal/yang-prototype/yang/yang-model-api/pom.xml
opendaylight/sal/yang-prototype/yang/yang-model-util/pom.xml
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java
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/implementation/pom.xml
opendaylight/switchmanager/integrationtest/pom.xml [new file with mode: 0644]
opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java [new file with mode: 0644]
opendaylight/topologymanager/pom.xml
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/resources/js/page.js
opendaylight/web/flows/pom.xml
opendaylight/web/root/pom.xml
opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java
opendaylight/web/root/src/main/resources/js/open.js
opendaylight/web/topology/pom.xml
opendaylight/web/troubleshoot/pom.xml

index cf3aff744f6ecc5e3c6ca7e7d6d58b844a62f553..80d8598d452b8d2dc501d411e6dc33fcb7307afe 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>
diff --git a/opendaylight/clustering/integrationtest/pom.xml b/opendaylight/clustering/integrationtest/pom.xml
new file mode 100644 (file)
index 0000000..24a59d2
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>commons.opendaylight</artifactId>
+    <version>1.4.0-SNAPSHOT</version>
+    <relativePath>../../commons/opendaylight</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>clustering.services.integrationtest</artifactId>
+  <version>0.4.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.infinispan</groupId>
+      <artifactId>infinispan-core</artifactId>
+      <version>5.2.3.Final</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>clustering.services</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+       <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>clustering.services-implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+  <properties>
+    <!-- Sonar jacoco plugin to get integration test coverage info -->
+    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+    <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.language>java</sonar.language>
+  </properties>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>0.5.3.201107060350</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <version>0.5.3.201107060350</version>
+        <configuration>
+          <destFile>../implementation/target/jacoco-it.exec</destFile>
+          <includes>org.opendaylight.controller.*</includes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <configuration>
+              <skip>true</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/opendaylight/clustering/integrationtest/src/test/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusteringServicesIntegrationTest.java b/opendaylight/clustering/integrationtest/src/test/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusteringServicesIntegrationTest.java
new file mode 100644 (file)
index 0000000..587a4cf
--- /dev/null
@@ -0,0 +1,235 @@
+package org.opendaylight.controller.clustering.services_implementation.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.net.InetAddress;
+import java.util.HashSet;
+import java.util.List;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.inject.Inject;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.clustering.services.CacheConfigException;
+import org.opendaylight.controller.clustering.services.CacheExistException;
+import org.opendaylight.controller.clustering.services.CacheListenerAddException;
+import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.clustering.services.IClusterServices.cacheMode;
+import org.opendaylight.controller.clustering.services.IGetUpdates;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(PaxExam.class)
+public class ClusteringServicesIntegrationTest {
+    private Logger log = LoggerFactory
+            .getLogger(ClusteringServicesIntegrationTest.class);
+    // get the OSGI bundle context
+    @Inject
+    private BundleContext bc;
+
+    private IClusterServices clusterServices = null;
+
+    // Configure the OSGi container
+    @Configuration
+    public Option[] config() {
+        return options(
+                //
+                systemProperty("logback.configurationFile").value(
+                        "file:" + PathUtils.getBaseDir()
+                                + "/src/test/resources/logback.xml"),
+                // To start OSGi console for inspection remotely
+                systemProperty("osgi.console").value("2401"),
+                // Set the systemPackages (used by clustering)
+                systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
+                // List framework bundles
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
+                        "1.0.0.v20120522-1841"),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
+                        "1.0.400.v20120522-2049"),
+                mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
+                        "3.3.100.v20120522-1822"),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
+                        "1.4.0.v20120522-1841"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
+                        "0.8.0.v201108120515"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
+                        "0.8.0.v201108120515"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
+                        "0.8.0.v201110170705"),
+                // List logger bundles
+                mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
+                mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
+                mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
+                mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
+                // List all the bundles on which the test case depends
+                mavenBundle("org.opendaylight.controller",
+                        "clustering.services", "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller",
+                        "clustering.services-implementation", "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "sal",
+                        "0.5.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller",
+                        "sal.implementation", "0.4.0-SNAPSHOT"),
+                mavenBundle("org.jboss.spec.javax.transaction",
+                        "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
+                mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+                mavenBundle("org.apache.felix",
+                        "org.apache.felix.dependencymanager", "3.1.0"),
+                junitBundles());
+    }
+
+    private String stateToString(int state) {
+        switch (state) {
+        case Bundle.ACTIVE:
+            return "ACTIVE";
+        case Bundle.INSTALLED:
+            return "INSTALLED";
+        case Bundle.RESOLVED:
+            return "RESOLVED";
+        case Bundle.UNINSTALLED:
+            return "UNINSTALLED";
+        default:
+            return "Not CONVERTED";
+        }
+    }
+
+    @Before
+    public void areWeReady() {
+        assertNotNull(bc);
+        boolean debugit = false;
+        Bundle b[] = bc.getBundles();
+        for (int i = 0; i < b.length; i++) {
+            int state = b[i].getState();
+            if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
+                log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+                        + stateToString(state));
+                debugit = true;
+            }
+        }
+        if (debugit) {
+            log.debug("Do some debugging because some bundle is "
+                    + "unresolved");
+        }
+
+        // Assert if true, if false we are good to go!
+        assertFalse(debugit);
+
+        ServiceReference r = bc.getServiceReference(IClusterServices.class
+                .getName());
+        if (r != null) {
+            this.clusterServices = (IClusterServices) bc.getService(r);
+        }
+        assertNotNull(this.clusterServices);
+
+    }
+
+    @Test
+    public void clusterTest() throws CacheExistException, CacheConfigException,
+            CacheListenerAddException {
+
+        String container1 = "Container1";
+        String container2 = "Container2";
+        String cache1 = "Cache1";
+        String cache2 = "Cache2";
+        String cache3 = "Cache3";
+
+        HashSet<cacheMode> cacheModeSet = new HashSet<cacheMode>();
+        cacheModeSet.add(cacheMode.NON_TRANSACTIONAL);
+        ConcurrentMap cm11 = this.clusterServices.createCache(container1,
+                cache1, cacheModeSet);
+        assertNotNull(cm11);
+
+        assertNull(this.clusterServices.getCache(container2, cache2));
+        assertEquals(cm11, this.clusterServices.getCache(container1, cache1));
+
+        assertFalse(this.clusterServices.existCache(container2, cache2));
+        assertTrue(this.clusterServices.existCache(container1, cache1));
+
+        ConcurrentMap cm12 = this.clusterServices.createCache(container1,
+                cache2, cacheModeSet);
+        ConcurrentMap cm23 = this.clusterServices.createCache(container2,
+                cache3, cacheModeSet);
+
+        HashSet<String> cacheList = (HashSet<String>) this.clusterServices
+                .getCacheList(container1);
+        assertEquals(2, cacheList.size());
+        assertTrue(cacheList.contains(cache1));
+        assertTrue(cacheList.contains(cache2));
+        assertFalse(cacheList.contains(cache3));
+
+        assertNotNull(this.clusterServices.getCacheProperties(container1,
+                cache1));
+
+        HashSet<IGetUpdates<?, ?>> listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
+                .getListeners(container1, cache1);
+        assertEquals(0, listeners.size());
+
+        IGetUpdates<?, ?> getUpdate1 = new GetUpdates();
+        this.clusterServices.addListener(container1, cache1, getUpdate1);
+        listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
+                .getListeners(container1, cache1);
+        assertEquals(1, listeners.size());
+        this.clusterServices.addListener(container1, cache1, new GetUpdates());
+        listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
+                .getListeners(container1, cache1);
+        assertEquals(2, listeners.size());
+
+        listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
+                .getListeners(container2, cache3);
+        assertEquals(0, listeners.size());
+
+        this.clusterServices.removeListener(container1, cache1, getUpdate1);
+        listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
+                .getListeners(container1, cache1);
+        assertEquals(1, listeners.size());
+
+        InetAddress addr = this.clusterServices.getMyAddress();
+        assertNotNull(addr);
+
+        List<InetAddress> addrList = this.clusterServices
+                .getClusteredControllers();
+
+        this.clusterServices.destroyCache(container1, cache1);
+        assertFalse(this.clusterServices.existCache(container1, cache1));
+
+    }
+
+    private class GetUpdates implements IGetUpdates<Integer, String> {
+
+        @Override
+        public void entryCreated(Integer key, String containerName,
+                String cacheName, boolean originLocal) {
+            return;
+        }
+
+        @Override
+        public void entryUpdated(Integer key, String new_value,
+                String containerName, String cacheName, boolean originLocal) {
+            return;
+        }
+
+        @Override
+        public void entryDeleted(Integer key, String containerName,
+                String cacheName, boolean originLocal) {
+            return;
+        }
+    }
+}
diff --git a/opendaylight/clustering/integrationtest/src/test/resources/logback.xml b/opendaylight/clustering/integrationtest/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..2d63ce5
--- /dev/null
@@ -0,0 +1,13 @@
+<configuration scan="true">
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+      </pattern>
+    </encoder>
+  </appender>
+
+  <root level="error">
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>
index 82a97b666f33ea12622eacc7c22d5251866da8b8..ee2f65d2c8fb166fc85230ade455e6ecf496168f 100644 (file)
   <artifactId>clustering.services-implementation</artifactId>
   <version>0.4.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
-
+  <properties>
+    <!-- Sonar properties using jacoco to retrieve integration test results -->
+    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+    <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
+    <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.language>java</sonar.language>
+  </properties>
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>0.5.3.201107060350</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <plugin>
        <groupId>org.apache.felix</groupId>
          </instructions>
        </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <configuration>
+          <includes>org.opendaylight.controller.*</includes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <phase>test</phase>
+            <goals>
+              <goal>report</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>      
     </plugins>
   </build>
   <dependencies>
index 2670c723f490ed116ec5e37da907deb52f46c53d..ab4ef5ad8664c0777a9dac66bb1d7b8ec53a28ae 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 0af960d9620f364f83d5afedefd590eb9a69eed9..3993b5e71fac9eacd0c47135a7f5866f1f701d8b 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 bac01840924d3a1eedb63722ff3ca509828565ef..467e9ca1edaec8a3e656c6be2bca8873858df869 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 8b5ccdf780f0322442501c720a11626025ae15f4..2b354752b3ee44de021ef055ed83ed2e37b1729c 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 1ead516adcb9fbb54f0514d95bb6046715460386..9e2f5662ef38b78460ba34946cd2d216bbaf3761 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 c26b38843b29833f3633e822c7ef86d45b531ef6..986f074fa35286967c45205029eaa5a61f545eae 100644 (file)
@@ -34,6 +34,7 @@
     <module>../../forwarding/staticrouting</module>
     <module>../../clustering/services</module>
     <module>../../clustering/services_implementation</module>
+    <module>../../clustering/integrationtest</module>
     <module>../../clustering/stub</module>
     <module>../../clustering/test</module>
     <module>../../configuration/api</module>
@@ -50,6 +51,7 @@
     <module>../../containermanager/implementation</module>
     <module>../../switchmanager/api</module>
     <module>../../switchmanager/implementation</module>
+    <module>../../switchmanager/integrationtest</module>
     <module>../../statisticsmanager/api</module>
     <module>../../statisticsmanager/implementation</module>
     <module>../../statisticsmanager/integrationtest</module>
index 38f18bf67c8f231b1f023fa49a06e7d91762f905..28f3e25d4142771154c073c52aeda468532b26af 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 6b639e3c632f7bcd7b7e5ed1d4c678bac28a5a07..382b11d4a3a1186bd4070557cbc4da114889b58a 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 0031773029f9619a150512e32c970b0d43c37bb7..d9faed36b9098fe94264a35639244e756e8ab493 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 110d3381df8fa13100ab42d29ca2f954ba31ddb8..eee08d3a09db224a7ace5793cbbb597b32a5c2fb 100644 (file)
@@ -604,9 +604,9 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager,
     private Status addEntriesInternal(FlowEntryInstall entry, boolean async) {
         // Install the flow on the network node
         Status status = (async)?
-                programmer.addFlow(entry.getNode(), entry.getInstall()
-                        .getFlow()) :
                 programmer.addFlowAsync(entry.getNode(), entry.getInstall()
+                        .getFlow()) :
+                programmer.addFlow(entry.getNode(), entry.getInstall()
                             .getFlow());
 
 
index 73c6d79d6a4af73a281438ad17a63fc918a7b656..8fa37b54713d3bac21a3b864574e5a5b2849756e 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 59290efbd52cdf7c27c0f19bb9610ab14793811f..f60b386baf5e0f991911e1bd2453ea168408b85b 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 1f24e06baddff0a7199e36554ef7b7122ca8afc1..e7788d999ab42482b767e6ab812567fa7c60f7c0 100644 (file)
@@ -18,7 +18,7 @@
                <!-- Sonar properties using jacoco to retrieve integration test results -->
                <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-               <sonar.jacoco.Reportpath>target/jacobo.exec</sonar.jacoco.Reportpath>
+               <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
                <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
                <sonar.language>java</sonar.language>
        </properties>
@@ -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 d0f8bb5736bce562619f3ab71a5a2596d7a81678..7c312e1577b927850e3c11839c3b817cb9282238 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 ff08cf334c49582b09153f11ce2ceca15fcb4d3c..d68189ad0f47e1d096eb1b9d09ec21d9080837fb 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
@@ -59,7 +59,7 @@
  \r
        <dependency>\r
       <groupId>org.opendaylight.controller</groupId>\r
-      <artifactId>clustering.services-implementation</artifactId>\r
+      <artifactId>clustering.stub</artifactId>\r
       <version>0.4.0-SNAPSHOT</version>\r
     </dependency>\r
 \r
index f351d1afcbee6ee06a60d022b7d68accc1eb57e2..c5407794d25abf8cc0f6d846f96d6346c92edda8 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
@@ -121,7 +121,7 @@ public class HostTrackerIntegrationTest {
                mavenBundle("org.opendaylight.controller",\r
                         "clustering.services", "0.4.0-SNAPSHOT"),\r
                mavenBundle("org.opendaylight.controller",\r
-                        "clustering.services-implementation", "0.4.0-SNAPSHOT"),\r
+                        "clustering.stub", "0.4.0-SNAPSHOT"),\r
 \r
                 // needed by forwardingrulesmanager\r
                 mavenBundle("org.opendaylight.controller", "switchmanager",\r
index d52bedf819b4556329c9c322fb3eb612c3197444..d80d669edf9bc161982569c1a39a45fda7215144 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 1bfd4ebf12fd9a7e286557708d2aded63e26cfb9..a4ebfa2b64ba6658f03cbd4f28ff505755b7b6dd 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 eab9fcb0c7a18531cf7aabe29fd853d67218ae90..5ddab37ff3f5e9ab7090512a0d23b81e88a750b3 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 eeaf550e6ba39b0d2ec7991532518bb1227429fe..f0fd3237109d7d4e3552b766e6962297962ab3a9 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 e10a5b1e1f08e7bde65dcda4f16fe1d26b61d6b2..84c40203697f1d94548c382f3546f62b0b75cb87 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 cfba4ffce9003569c224b3a932c738f151468e43..22c9a974580d08cd4b99be229be34531b4ff1421 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 e4c73ac7431f75d3cbb13dc8b83fe7fe40365079..25757e66c4ecc5e6f7ed8304d41d285e043765dc 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 c31b478fb5dc6a91c687b16ea962976fbf65fc5f..0cfa487f1c395ad7bcfb88975cb3e16c028101f8 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 614b0ff81826bea3b74c7d4219bdea0c7b653aca..23c0d9d90e3ff9b0fe3bb48713d45a6201c7a299 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 0c30c80f0df48fe4a5ca35fee756cdd7f698a464..e90823726c926d70304666055445b06df7ee4558 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -9,11 +8,13 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow;
 
+import java.util.List;
 import java.util.Set;
 
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
 
 /**
  * The Interface provides Edge updates to the topology listeners
@@ -21,18 +22,17 @@ import org.opendaylight.controller.sal.core.UpdateType;
 public interface ITopologyServiceShimListener {
     /**
      * Called to update on Edge in the topology graph
-     *
-     * @param edge                     {@link org.opendaylight.controller.sal.core.Edge} being updated
-     * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
-     * @param props            set of {@link org.opendaylight.controller.sal.core.Property} like
-     *                                                 {@link org.opendaylight.controller.sal.core.Bandwidth} and/or
-     *                                                 {@link org.opendaylight.controller.sal.core.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 edge, UpdateType type, Set<Property> props);
+    public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList);
 
     /**
-     * Called when an Edge utilization is above the safe threshold configured
-     * on the controller
+     * Called when an Edge utilization is above the safe threshold configured on
+     * the controller
+     * 
      * @param {@link org.opendaylight.controller.sal.core.Edge}
      */
     public void edgeOverUtilized(Edge edge);
@@ -40,7 +40,7 @@ public interface ITopologyServiceShimListener {
     /**
      * Called when the Edge utilization is back to normal, below the safety
      * threshold level configured on the controller
-     *
+     * 
      * @param {@link org.opendaylight.controller.sal.core.Edge}
      */
     public void edgeUtilBackToNormal(Edge edge);
index 5c51cc5862d5f4c391cd956c1c8b59e1f03059ce..9a05c3f4f100c46b2c357f59ae6256f4e497f491 100644 (file)
@@ -207,7 +207,6 @@ public class SwitchHandler implements ISwitch {
         }
         executor.shutdown();
 
-        selector = null;
         msgReadWriteService = null;
 
         if (switchHandlerThread != null) {
@@ -313,7 +312,9 @@ public class SwitchHandler implements ISwitch {
         List<OFMessage> msgs = null;
 
         try {
-            msgs = msgReadWriteService.readMessages();
+            if (msgReadWriteService != null) {
+                msgs = msgReadWriteService.readMessages();
+            }
         } catch (Exception e) {
             reportError(e);
         }
index af502a2177d12c89101ca5b2363f90a9eeabe4da..873b53ff65aa23ececb17d733d64fb438f3f6098 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.protocol_plugin.openflow.internal;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -44,6 +45,7 @@ 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.topology.TopoEdgeUpdate;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 
 /**
@@ -52,8 +54,8 @@ import org.opendaylight.controller.sal.utils.GlobalConstants;
  * container configurations.
  */
 public class TopologyServiceShim implements IDiscoveryService,
-               IContainerListener, CommandProvider, IRefreshInternalProvider,
-               IInventoryShimExternalListener {
+        IContainerListener, CommandProvider, IRefreshInternalProvider,
+        IInventoryShimExternalListener {
     protected static final Logger logger = LoggerFactory
             .getLogger(TopologyServiceShim.class);
     private ConcurrentMap<String, ITopologyServiceShimListener> topologyServiceShimListeners = new ConcurrentHashMap<String, ITopologyServiceShimListener>();
@@ -76,19 +78,31 @@ public class TopologyServiceShim implements IDiscoveryService,
 
     class NotifyEntry {
         String container;
-        Pair<Edge, Set<Property>> edgeProps;
-        UpdateType type;
+        List<TopoEdgeUpdate> teuList;
 
-        NotifyEntry(String container, Pair<Edge, Set<Property>> edgeProps,
-                UpdateType type) {
+        public NotifyEntry(String container, TopoEdgeUpdate teu) {
             this.container = container;
-            this.edgeProps = edgeProps;
-            this.type = type;
+            this.teuList = new ArrayList<TopoEdgeUpdate>();
+            if (teu != null) {
+                this.teuList.add(teu);
+            }
+        }
+
+        public NotifyEntry(String container, List<TopoEdgeUpdate> teuList) {
+            this.container = container;
+            this.teuList = new ArrayList<TopoEdgeUpdate>();
+            if (teuList != null) {
+                this.teuList.addAll(teuList);
+            }
         }
     }
 
     class TopologyNotify implements Runnable {
         private final BlockingQueue<NotifyEntry> notifyQ;
+        private NotifyEntry entry;
+        private Map<String, List<TopoEdgeUpdate>> teuMap = new HashMap<String, List<TopoEdgeUpdate>>();
+        private List<TopoEdgeUpdate> teuList;
+        private boolean notifyListeners;
 
         TopologyNotify(BlockingQueue<NotifyEntry> notifyQ) {
             this.notifyQ = notifyQ;
@@ -97,22 +111,37 @@ public class TopologyServiceShim implements IDiscoveryService,
         public void run() {
             while (true) {
                 try {
-                    NotifyEntry entry = notifyQ.take();
-
-                    ITopologyServiceShimListener topologServiceShimListener = topologyServiceShimListeners
-                            .get(entry.container);
-                    topologServiceShimListener.edgeUpdate(
-                            entry.edgeProps.getLeft(), entry.type,
-                            entry.edgeProps.getRight());
+                    teuMap.clear();
+                    notifyListeners = false;
+                    while (!notifyQ.isEmpty()) {
+                        entry = notifyQ.take();
+                        teuList = teuMap.get(entry.container);
+                        if (teuList == null) {
+                            teuList = new ArrayList<TopoEdgeUpdate>();
+                        }
+                        // group all the updates together
+                        teuList.addAll(entry.teuList);
+                        teuMap.put(entry.container, teuList);
+                        notifyListeners = true;
+                    }
+                    
+                    if (notifyListeners) {
+                        for (String container : teuMap.keySet()) {
+                            // notify the listener
+                            topologyServiceShimListeners.get(container)
+                                    .edgeUpdate(teuMap.get(container));
+                        }
+                    }
 
-                    entry = null;
+                    Thread.sleep(100);
                 } catch (InterruptedException e1) {
-                    logger.warn("TopologyNotify interrupted {}", e1.getMessage());
+                    logger.warn("TopologyNotify interrupted {}",
+                            e1.getMessage());
                     if (shuttingDown) {
                         return;
                     }
                 } catch (Exception e2) {
-                    logger.error("",e2);
+                    logger.error("", e2);
                 }
             }
         }
@@ -165,7 +194,7 @@ public class TopologyServiceShim implements IDiscoveryService,
                         return;
                     }
                 } catch (Exception e2) {
-                    logger.error("",e2);
+                    logger.error("", e2);
                 }
             }
         }
@@ -353,7 +382,8 @@ public class TopologyServiceShim implements IDiscoveryService,
                 && this.topologyServiceShimListeners.get(containerName).equals(
                         s)) {
             this.topologyServiceShimListeners.remove(containerName);
-            logger.trace("Removed topologyServiceShimListener for container: {}",
+            logger.trace(
+                    "Removed topologyServiceShimListener for container: {}",
                     containerName);
         }
     }
@@ -370,6 +400,7 @@ public class TopologyServiceShim implements IDiscoveryService,
 
     private void removeNodeConnector(String container,
             NodeConnector nodeConnector) {
+        List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
         Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
                 .get(container);
         if (edgePropsMap == null) {
@@ -381,7 +412,8 @@ public class TopologyServiceShim implements IDiscoveryService,
         if (edgeProps == null) {
             return;
         }
-        notifyEdge(container, edgeProps.getLeft(), UpdateType.REMOVED, null);
+        teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null,
+                UpdateType.REMOVED));
 
         // Remove edge in another direction
         edgeProps = edgePropsMap
@@ -389,52 +421,130 @@ public class TopologyServiceShim implements IDiscoveryService,
         if (edgeProps == null) {
             return;
         }
-        notifyEdge(container, edgeProps.getLeft(), UpdateType.REMOVED, null);
+        teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null,
+                UpdateType.REMOVED));
+
+        // Update in one shot
+        notifyEdge(container, teuList);
     }
 
-    private void notifyEdge(String container, Edge edge, UpdateType type,
-            Set<Property> props) {
+    /**
+     * Update local cache and return true if it needs to notify upper layer
+     * Topology listeners.
+     * 
+     * @param container
+     *            The network container
+     * @param edge
+     *            The edge
+     * @param type
+     *            The update type
+     * @param props
+     *            The edge properties
+     * @return true if it needs to notify upper layer Topology listeners
+     */
+    private boolean updateLocalEdgeMap(String container, Edge edge,
+            UpdateType type, Set<Property> props) {
         ConcurrentMap<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
                 .get(container);
         NodeConnector src = edge.getTailNodeConnector();
         Pair<Edge, Set<Property>> edgeProps = new ImmutablePair<Edge, Set<Property>>(
                 edge, props);
+        boolean rv = false;
 
         switch (type) {
         case ADDED:
         case CHANGED:
             if (edgePropsMap == null) {
                 edgePropsMap = new ConcurrentHashMap<NodeConnector, Pair<Edge, Set<Property>>>();
+                rv = true;
             } else {
                 if (edgePropsMap.containsKey(src)
                         && edgePropsMap.get(src).equals(edgeProps)) {
-                    // Entry already exists. Return here.
-                    return;
+                    // Entry already exists. No update.
+                    rv = false;
+                } else {
+                    rv = true;
                 }
             }
-            edgePropsMap.put(src, edgeProps);
-            edgeMap.put(container, edgePropsMap);
+            if (rv) {
+                edgePropsMap.put(src, edgeProps);
+                edgeMap.put(container, edgePropsMap);
+            }
             break;
         case REMOVED:
-            if (edgePropsMap != null) {
+            if ((edgePropsMap != null) && edgePropsMap.containsKey(src)) {
                 edgePropsMap.remove(src);
                 if (edgePropsMap.isEmpty()) {
                     edgeMap.remove(container);
                 } else {
                     edgeMap.put(container, edgePropsMap);
                 }
+                rv = true;
             }
             break;
         default:
-            logger.debug("notifyEdge: invalid {} for Edge {} in container {}",
-                    type, edge, container);
+            logger.debug(
+                    "notifyLocalEdgeMap: invalid {} for Edge {} in container {}",
+                    new Object[] { type.getName(), edge, container });
+        }
+
+        if (rv) {
+            logger.debug(
+                    "notifyLocalEdgeMap: {} for Edge {} in container {}",
+                    new Object[] { type.getName(), edge, container });
+        }
+        
+        return rv;
+    }
+
+    private void notifyEdge(String container, Edge edge, UpdateType type,
+            Set<Property> props) {
+        boolean notifyListeners;
+        
+        // Update local cache
+        notifyListeners = updateLocalEdgeMap(container, edge, type, props);
+
+        // Prepare to update TopologyService
+        if (notifyListeners) {
+            notifyQ.add(new NotifyEntry(container, new TopoEdgeUpdate(edge, props,
+                    type)));
+            logger.debug("notifyEdge: {} Edge {} in container {}", 
+                    new Object[] { type.getName(), edge, container });
+        }
+    }
+
+    private void notifyEdge(String container, List<TopoEdgeUpdate> etuList) {
+        if (etuList == null) {
             return;
         }
 
-        notifyQ.add(new NotifyEntry(container, edgeProps, type));
+        Edge edge;
+        UpdateType type;
+        List<TopoEdgeUpdate> etuNotifyList = new ArrayList<TopoEdgeUpdate>();
+        boolean notifyListeners = false, rv;
+
+        for (TopoEdgeUpdate etu : etuList) {
+            edge = etu.getEdge();
+            type = etu.getUpdateType();
+
+            // Update local cache
+            rv = updateLocalEdgeMap(container, edge, type, etu.getProperty());
+            if (rv) {
+                if (!notifyListeners) {
+                    notifyListeners = true;
+                }
+                etuNotifyList.add(etu);
+                logger.debug(
+                        "notifyEdge(TopoEdgeUpdate): {} Edge {} in container {}",
+                        new Object[] { type.getName(), edge, container });
+            }
+        }
 
-        logger.debug("notifyEdge: {} Edge {} in container {}",
-                type, edge, container);
+        // Prepare to update TopologyService
+        if (notifyListeners) {
+            notifyQ.add(new NotifyEntry(container, etuNotifyList));
+            logger.debug("notifyEdge(TopoEdgeUpdate): add notifyQ");
+        }
     }
 
     @Override
@@ -572,9 +682,12 @@ public class TopologyServiceShim implements IDiscoveryService,
             }
 
             long bw = 0;
-            for (Property prop : edgeProps.getRight()) {
-                if (prop.getName().equals(Bandwidth.BandwidthPropName)) {
-                    bw = ((Bandwidth) prop).getValue();
+            Set<Property> props = edgeProps.getRight();
+            if (props != null) {
+                for (Property prop : props) {
+                    if (prop.getName().equals(Bandwidth.BandwidthPropName)) {
+                        bw = ((Bandwidth) prop).getValue();
+                    }
                 }
             }
             count++;
@@ -638,14 +751,18 @@ public class TopologyServiceShim implements IDiscoveryService,
             return;
         }
         int i = 0;
+        List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
         for (Pair<Edge, Set<Property>> edgeProps : edgePropMap.values()) {
             if (edgeProps != null) {
                 i++;
+                teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), edgeProps
+                        .getRight(), UpdateType.ADDED));
                 logger.trace("Add edge {}", edgeProps.getLeft());
-                topologServiceShimListener.edgeUpdate(edgeProps.getLeft(),
-                        UpdateType.ADDED, edgeProps.getRight());
             }
         }
+        if (i > 0) {
+            topologServiceShimListener.edgeUpdate(teuList);
+        }
         logger.debug("Sent {} updates", i);
     }
 
@@ -663,7 +780,7 @@ public class TopologyServiceShim implements IDiscoveryService,
         if (conList != null) {
             containers.addAll(conList);
         }
-        
+
         switch (type) {
         case ADDED:
             break;
index 64515887c07c35523b6afedbc1d4d3021915e899..b23737c52037058d246d18bad2acd32caf52abc6 100644 (file)
@@ -9,8 +9,7 @@
 package org.opendaylight.controller.protocol_plugin.openflow.internal;
 
 import java.util.Dictionary;
-import java.util.Set;
-
+import java.util.List;
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
@@ -18,10 +17,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.opendaylight.controller.sal.core.Edge;
-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 {
@@ -127,9 +125,9 @@ public class TopologyServices implements ITopologyServiceShimListener,
     }
 
     @Override
-    public void edgeUpdate(Edge edge, UpdateType type, Set<Property> props) {
+    public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
         if (this.salTopoService != null) {
-            this.salTopoService.edgeUpdate(edge, type, props);
+            this.salTopoService.edgeUpdate(topoedgeupdateList);
         }
     }
 
index 36085c9e3b9e2affc2ee05640a199baeb901f110..c257099825317f3d6e788f8caad48d320b2b9741 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 ad447b9584c79284bad5a03ad64ab07c8e7e91ce..cf93fb0a37fb1381716934da2220d6df7eba456c 100644 (file)
@@ -58,7 +58,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      *         Object
      */
     public Object[] getImplementations() {
-        Object[] res = { ReadService.class };
+        Object[] res = { ReadService.class, InventoryService.class };
         return res;
     }
 
@@ -86,6 +86,14 @@ public class Activator extends ComponentActivatorAbstractBase {
             props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
             c.setInterface(IPluginInReadService.class.getName(), props);
         }
-    }
 
+        if (imp.equals(InventoryService.class)) {
+            // export the service to be used by SAL
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            // Set the protocolPluginType property which will be used
+            // by SAL
+            props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
+            c.setInterface(IPluginInInventoryService.class.getName(), props);
+        }
+    }
 }
diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java
new file mode 100644 (file)
index 0000000..54b4ea1
--- /dev/null
@@ -0,0 +1,141 @@
+package org.opendaylight.controller.protocol_plugins.stub.internal;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.felix.dm.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.opendaylight.controller.sal.core.Actions;
+import org.opendaylight.controller.sal.core.Bandwidth;
+import org.opendaylight.controller.sal.core.Buffers;
+import org.opendaylight.controller.sal.core.Capabilities;
+import org.opendaylight.controller.sal.core.Capabilities.CapabilitiesType;
+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.Tables;
+import org.opendaylight.controller.sal.core.TimeStamp;
+import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
+
+/**
+ * Stub Implementation for IPluginInReadService used by SAL
+ *
+ *
+ */
+public class InventoryService implements IPluginInInventoryService {
+    private static final Logger logger = LoggerFactory
+            .getLogger(InventoryService.class);
+
+    private ConcurrentMap<Node, Map<String, Property>> nodeProps; // properties are maintained in global container only
+    private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps; // properties are maintained in global container only
+
+
+    /**
+     * Function called by the dependency manager when all the required
+     * dependencies are satisfied
+     *
+     */
+    void init() {
+        nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
+        nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
+
+    }
+
+    /**
+     * 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() {
+    }
+
+    /**
+     * 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
+     *
+     */
+    void stop() {
+    }
+
+    /**
+     * Retrieve nodes from openflow
+     */
+    @Override
+    public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
+
+        //  setup nodeProps
+        Map<String, Property> propMap = new HashMap<String, Property>();
+
+        Tables t = new Tables((byte)1);
+        propMap.put(Tables.TablesPropName, t);
+        Capabilities c = new Capabilities((int)3);
+        propMap.put(Capabilities.CapabilitiesPropName, c);
+        Actions a = new Actions((int)2);
+        propMap.put(Actions.ActionsPropName, a);
+        Buffers b = new Buffers((int)1);
+        propMap.put(Buffers.BuffersPropName, b);
+        Long connectedSinceTime = 100000L;
+        TimeStamp timeStamp = new TimeStamp(connectedSinceTime,
+                "connectedSince");
+        propMap.put(TimeStamp.TimeStampPropName, timeStamp);
+
+        // setup property map for all nodes
+        Node node;
+        node = NodeCreator.createOFNode(2L);
+        nodeProps.put(node, propMap);
+
+        return nodeProps;
+    }
+
+    /**
+     * Retrieve nodeConnectors from openflow
+     */
+    @Override
+    public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps(
+            Boolean refresh) {
+
+        //  setup nodeConnectorProps
+        Map<String, Property> ncPropMap = new HashMap<String, Property>();
+        Capabilities cap = new Capabilities
+                (CapabilitiesType.FLOW_STATS_CAPABILITY.getValue());
+        ncPropMap.put(Capabilities.CapabilitiesPropName, cap);
+        Bandwidth bw = new Bandwidth (Bandwidth.BW1Gbps);
+        ncPropMap.put(Bandwidth.BandwidthPropName, bw);
+        State st = new State (State.EDGE_UP);
+        ncPropMap.put(State.StatePropName, st);
+
+        // setup property map for all node connectors
+        NodeConnector nc = NodeConnectorCreator.createOFNodeConnector
+                ((short)2, NodeCreator.createOFNode(3L));
+        nodeConnectorProps.put(nc, ncPropMap);
+
+        return nodeConnectorProps;
+    }
+
+
+}
index e89beb8c3695ef417c3ef271729e73415084026b..06a684f26591fc2b14392dae3dcf8e4a7f7fb3e4 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 586432d8c09a55255b1577b409302fd40b2d7456..d878b231bcde7e71f4c3643970d2466d21e6629b 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 fb0a560212f304a75cbf5f16b9cebbe09bd0f4a9..e3ae560d40af9629a6f705f636ec833e765a8acf 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 44cb9d19d8f41969e695ba25b050ed155ac1a61c..17952c80372001d0291402fad2fdcb046d4a88df 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 9d8c814d6dbe7c37eb7302b0c50f943eaf282ebd..e49ae8dbfdcfc451ff21c781ccfc2eea9f5331ed 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 dbb93fb1b3fe364e194d5ac75b5ec1d160f53673..505cc61816c6895142cbc639834d2a740856782f 100644 (file)
@@ -64,14 +64,6 @@ public class Config extends Property {
 
     @Override
     public String toString() {
-        StringBuffer ret = new StringBuffer();
-        if (this.configValue == 0) {
-            ret.append("Down");
-        } else if (this.configValue == 1) {
-            ret.append("Up");
-        } else {
-            ret.append("Undefined");
-        }
-        return ret.toString();
+        return "Config["+ReflectionToStringBuilder.toString(this)+"]";
     }
 }
index 8a640f1e9bec8c2a2c6b34d1d358e11fcf0054ad..b4c44c00d94ba82fdb8b8ac1190321a575e697b7 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 b183240d4316bcf48f7d4b34a895a91518aff7c9..b85eec84283ab4c37918bf9916b8c0618a0a2a2b 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 32f0a38157bb242408c5a933c0f234e7a40e6aa2..57ccc4a9d7df6c8b39db1bebe741556b99e454ad 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 8df566f728c58cd60531690eff57323e50b8f4ea..f965d7f2c402e21d6cf920f15ad0413ef7bd6785 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 fcd599c73be7c95b12fe53e07f7b9f44ef0a2e5c..720a589771eb367ef636a185402faad23dc0c8e4 100644 (file)
@@ -3,19 +3,19 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-api</artifactId>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-model-api</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
       <groupId>org.opendaylight.controller</groupId>\r
       <artifactId>yang-model-api</artifactId>\r
-      <version>1.0</version>\r
+      <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index 950db94ea170ef869698d29c405287c0878a5b8f..ff5aafec98b7768820e6ae07355db529d6166661 100644 (file)
@@ -3,30 +3,30 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-impl</artifactId>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-generator-util</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
 \r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>yang-model-parser-impl</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-generator-api</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-generator-spi</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
        <groupId>jaxen</groupId>\r
index 97e5780a4de84374d930ba6bbd1ab3b1d637e3c8..96539552a54bb720f44ecb86a147ca56f83f7864 100644 (file)
@@ -3,19 +3,19 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-spi</artifactId>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-model-api</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>yang-model-api</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index b60d108d17b2dc89c453d5e70c9318cd440e8241..8a08ab4355dc86e2bcdd2ddfc933fdaafdd74b4a 100644 (file)
@@ -3,19 +3,19 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-util</artifactId>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-model-api</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
        <groupId>org.opendaylight.controller</groupId>\r
        <artifactId>yang-model-api</artifactId>\r
-       <version>1.0</version>\r
+       <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index 4517d7005d66141df8f11cf7d4db1bf462ef979d..847986c001562a6f819d7469e461d2482f2e9342 100644 (file)
@@ -4,25 +4,25 @@
        <parent>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>binding-generator</artifactId>\r
-               <version>1.0</version>\r
+               <version>0.5-SNAPSHOT</version>\r
        </parent>\r
        <artifactId>binding-java-api-generator</artifactId>\r
        <dependencies>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>binding-model-api</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>binding-generator-impl</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                        <scope>test</scope>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>binding-generator-util</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
        </dependencies>\r
 </project>
\ No newline at end of file
index c9e60b6a144c7e3a4a59296543178c8cd96c35f8..9c7ca316af938efee0b4bcc8705f37713b0f7b10 100644 (file)
@@ -3,7 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-model-api</artifactId>\r
 </project>
\ No newline at end of file
index 58608354d1d0cdec771cbbc8cd324863e703277c..37282cc5e817d99ce0e26c37ca3627be09a76dde 100644 (file)
@@ -1,31 +1,32 @@
-<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">\r
-  <modelVersion>4.0.0</modelVersion>\r
-  <parent>\r
-    <groupId>org.opendaylight.controller</groupId>\r
-    <artifactId>binding-generator</artifactId>\r
-    <version>1.0</version>\r
-  </parent>\r
-  <artifactId>code-generator-demo</artifactId>\r
-  \r
-  <dependencies>\r
-      <dependency>\r
-          <groupId>org.antlr</groupId>\r
-          <artifactId>antlr4</artifactId>\r
-          <version>4.0</version>\r
-      </dependency>\r
-      <dependency>\r
-          <groupId>org.opendaylight.controller</groupId>\r
-          <artifactId>binding-generator-impl</artifactId>\r
-          <version>1.0</version>\r
-      </dependency>\r
-      <dependency>\r
-          <groupId>org.opendaylight.controller</groupId>\r
-          <artifactId>binding-java-api-generator</artifactId>\r
-          <version>1.0</version>\r
-      </dependency>\r
-  </dependencies>\r
-  \r
-  <build>\r
+<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
+       <parent>\r
+               <groupId>org.opendaylight.controller</groupId>\r
+               <artifactId>binding-generator</artifactId>\r
+               <version>0.5-SNAPSHOT</version>\r
+       </parent>\r
+       <artifactId>code-generator-demo</artifactId>\r
+\r
+       <dependencies>\r
+               <dependency>\r
+                       <groupId>org.antlr</groupId>\r
+                       <artifactId>antlr4</artifactId>\r
+                       <version>4.0</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.opendaylight.controller</groupId>\r
+                       <artifactId>binding-generator-impl</artifactId>\r
+                       <version>0.5-SNAPSHOT</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.opendaylight.controller</groupId>\r
+                       <artifactId>binding-java-api-generator</artifactId>\r
+                       <version>0.5-SNAPSHOT</version>\r
+               </dependency>\r
+       </dependencies>\r
+\r
+       <build>\r
                <plugins>\r
                        <plugin>\r
                                <artifactId>maven-assembly-plugin</artifactId>\r
@@ -50,7 +51,6 @@
                                        </execution>\r
                                </executions>\r
                        </plugin>\r
-\r
                </plugins>\r
        </build>\r
 </project>\r
index 1f44e66a9e62d821b60f7af4511547f2988d2cc7..8f5d127414e034ca3915c2000ce95eacb88eb9dd 100644 (file)
@@ -4,36 +4,35 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>maven-sal-api-gen-plugin</artifactId>
 
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>maven-yang</artifactId>
-            <version>1.0</version>
+            <artifactId>yang-maven-plugin-spi</artifactId>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>binding-model-api</artifactId>
-            <version>1.0</version>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>binding-generator-api</artifactId>
-            <version>1.0</version>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
                <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>binding-generator-impl</artifactId>
-            <version>1.0</version>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
                <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>binding-java-api-generator</artifactId>
-            <version>1.0</version>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
     </dependencies>
-    
 </project>
index e3a54ba32a48a73cd0058d62ad5960e8fe26082f..6c574e5d859e0c948aff72d2fc3af4245c7e64ba 100644 (file)
@@ -2,11 +2,12 @@
     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>
     <parent>
-        <artifactId>binding-generator</artifactId>
+        <artifactId>yang</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
+        <relativePath>../../yang/pom.xml</relativePath>
     </parent>
-    <artifactId>maven-yang-plugin-it</artifactId>
+    <artifactId>yang-maven-plugin-it</artifactId>
 
 
     <dependencies>
index c48f1514993b166c7504d8fee2dbc63937b536c0..6a7c3f95b70f0c32905915dc338edc8490f17fe5 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -38,8 +38,8 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>maven-yang</artifactId>
-                        <version>1.0</version>
+                        <artifactId>yang-maven-plugin-spi</artifactId>
+                        <version>0.5-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 4fbffb69043b97c4766c794c4a5c12eaa5af03c4..fe67c7815282e6247ddf28019692bc1c7fe32cc9 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -49,8 +49,8 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>maven-yang</artifactId>
-                        <version>1.0</version>
+                        <artifactId>yang-maven-plugin-spi</artifactId>
+                        <version>0.5-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 2a935158c18591ab72f7c5964161fc4f8759a1a7..0e0c96a48c33e7ea2682f44a06512d687e2b24fd 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -38,8 +38,8 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>maven-yang</artifactId>
-                        <version>1.0</version>
+                        <artifactId>yang-maven-plugin-spi</artifactId>
+                        <version>0.5-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index a9ec4893f01927744979d6921478a53b32cf8ec9..f19d84886ec2006c54f54d5a16a22f3a6ea44112 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
index 74f9dc38e3d4a5ca02d061f30407095bbde3d8ef..38028b84e909189964bea3ab2a0efe57d6d4d340 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
index a64c7593943c657bca8b9b58ebf6d7f19fc951af..2308da0fed6b10dd47486832523cb6806ba8cbdf 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -38,8 +38,8 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>maven-yang</artifactId>
-                        <version>1.0</version>
+                        <artifactId>yang-maven-plugin-spi</artifactId>
+                        <version>0.5-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 2c7f9228389f82cb55ea2437e73dceff7106dbdc..2101b8471b0f5415fc0caa910c7e87e43cc02193 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -46,8 +46,8 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>maven-yang</artifactId>
-                        <version>1.0</version>
+                        <artifactId>yang-maven-plugin-spi</artifactId>
+                        <version>0.5-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index fb83dc96ec2e90b455e92ad05c40e1c6bda48d34..8ee0606631545f3038fb6412cac2a47a61b7627c 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -46,8 +46,8 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>maven-yang</artifactId>
-                        <version>1.0</version>
+                        <artifactId>yang-maven-plugin-spi</artifactId>
+                        <version>0.5-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 6b5ae5a4515707398fd5628082e357f3de33f326..3aeb2e9535ba7b7ec0caa8ca7abcafe3a653cfce 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
index 4bf399f0c32d255e631e5efcab1b6004098e701c..e82c737351b155d1fbdac480f690e6d00f86baf6 100644 (file)
@@ -2,12 +2,13 @@
     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>
     <parent>
-        <artifactId>binding-generator</artifactId>
+        <artifactId>yang</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
+        <relativePath>../../yang/pom.xml</relativePath>
     </parent>
 
-    <artifactId>maven-yang-plugin</artifactId>
+    <artifactId>yang-maven-plugin</artifactId>
     <packaging>maven-plugin</packaging>
     <description>
         This plugin is a wrapper for "yang to source code" generation.
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>yang-model-parser-impl</artifactId>
-            <version>1.0</version>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>maven-yang</artifactId>
-            <version>1.0</version>
+            <artifactId>yang-maven-plugin-spi</artifactId>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
 
         <dependency>
@@ -55,8 +56,8 @@
 
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>maven-yang</artifactId>
-            <version>1.0</version>
+            <artifactId>yang-maven-plugin-spi</artifactId>
+            <version>0.5-SNAPSHOT</version>
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
index 09dc9d727922a7caa691c62505e9d6adc45b7f63..89417b022ed259917e1fc621dd053fd676b63d13 100644 (file)
@@ -2,17 +2,18 @@
     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>
     <parent>
-        <artifactId>binding-generator</artifactId>
+        <artifactId>yang</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
+        <relativePath>../../yang/pom.xml</relativePath>
     </parent>
-    <artifactId>maven-yang</artifactId>
+    <artifactId>yang-maven-plugin-spi</artifactId>
 
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>yang-model-api</artifactId>
-            <version>1.0</version>
+            <version>0.5-SNAPSHOT</version>
         </dependency>
     </dependencies>
 
index 89e2794fd197d74e307b9e18d0e696ead405caf1..7d908c3cd0fb64e5a3632e587183b7d05c7656c9 100644 (file)
 <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>
+       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>
 
-        <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>
+       <parent>
+               <groupId>org.opendaylight.controller</groupId>
+               <artifactId>yang-prototype</artifactId>
+               <version>0.5-SNAPSHOT</version>
+       </parent>
+
+       <groupId>org.opendaylight.controller</groupId>
+       <artifactId>binding-generator</artifactId>
+       <version>0.5-SNAPSHOT</version>
+       <packaging>pom</packaging>
+       <name>binding-generator</name>
+
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+       </properties>
+
+       <modules>
+               <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-sal-api-gen-plugin</module>
+       </modules>
+       <dependencies>
+
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+                       <optional>true</optional>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-simple</artifactId>
+               </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>
 </project>
index 55797196838128613553b262922392068a601325..05981c457868ab24bf31d70e1bcd7b4f3775048e 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.0</version>
+        <version>0.5-SNAPSHOT</version>
     </parent>
     <artifactId>maven-code-gen-sample</artifactId>
 
@@ -12,8 +12,8 @@
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
-                <artifactId>maven-yang-plugin</artifactId>
-                <version>1.0</version>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -39,7 +39,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>maven-sal-api-gen-plugin</artifactId>
-                        <version>1.0</version>
+                        <version>0.5-SNAPSHOT</version>
                         <type>jar</type>
                     </dependency>
                 </dependencies>
@@ -79,7 +79,7 @@
                                                                                org.opendaylight.controller
                                                                        </groupId>
                                                                        <artifactId>
-                                                                               maven-yang-plugin
+                                                                               yang-maven-plugin
                                                                        </artifactId>
                                                                        <versionRange>
                                                                                [1.0,)
index 5bfd19d47a33f37183f411d564ec11d93e43aa32..48ebb51f389571fd8d964e24760678409702250a 100644 (file)
@@ -2,8 +2,9 @@
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.opendaylight.controller</groupId>
-    <artifactId>binding-generator</artifactId>
-    <version>1.0</version>
+    <artifactId>yang</artifactId>
+    <version>0.5-SNAPSHOT</version>
+    <relativePath>../../yang/pom.xml</relativePath>
   </parent>
   <artifactId>yang-model-parser-api</artifactId>
   
@@ -11,7 +12,7 @@
       <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>yang-model-api</artifactId>
-          <version>1.0</version>
+          <version>0.5-SNAPSHOT</version>
       </dependency>
   </dependencies>
 </project>
\ No newline at end of file
index ce0543dafd7673c3b64de5dd1633096c5d928956..10ba3f2816c4e65778fdad78dae5803ce9f8b045 100644 (file)
@@ -3,8 +3,9 @@
        <modelVersion>4.0.0</modelVersion>\r
        <parent>\r
                <groupId>org.opendaylight.controller</groupId>\r
-               <artifactId>binding-generator</artifactId>\r
-               <version>1.0</version>\r
+               <artifactId>yang</artifactId>\r
+               <version>0.5-SNAPSHOT</version>\r
+               <relativePath>../../yang/pom.xml</relativePath>\r
        </parent>\r
        <artifactId>yang-model-parser-impl</artifactId>\r
 \r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-common</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-model-api</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-model-parser-api</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-model-util</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>binding-model-api</artifactId>\r
-                       <version>1.0</version>\r
+                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
 \r
                <dependency>\r
@@ -54,7 +55,7 @@
                        <groupId>org.mockito</groupId>\r
                        <artifactId>mockito-all</artifactId>\r
                        <version>1.8.4</version>\r
-               </dependency>
+               </dependency>\r
         <dependency>\r
           <groupId>com.google.guava</groupId>\r
           <artifactId>guava</artifactId>\r
index 02b4d7ff6c9cfe28e168234f6db72c58cc1242e6..fb1464160a6719edb5440df04e8f4fbc6a2024b9 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
 /**
  * Basic implementation for TypeAwareBuilder builders.
  */
-public class AbstractTypeAwareBuilder implements TypeAwareBuilder {
+public abstract class AbstractTypeAwareBuilder implements TypeAwareBuilder {
 
     protected TypeDefinition<?> type;
     protected TypeDefinitionBuilder typedef;
index 73f2cf28ca9dacb5343aaa76922807df299c86bd..172e660413cb477cab3e85b837fcc5ff87c7ddea 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
  * Builders of all nodes, which can have 'type' statement must implement this interface.
  * [typedef, type, leaf, leaf-list, deviate]
  */
-public interface TypeAwareBuilder {
+public interface TypeAwareBuilder extends Builder {
 
     TypeDefinition<?> getType();
 
index 212e2f8d4fbbf77196e784fb18a7dd054c76c27c..68f2d06d963b159a8d1d129a0aa7c0a70b465219 100644 (file)
@@ -20,10 +20,11 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
 
 public class AnyXmlBuilder implements DataSchemaNodeBuilder {
+    private final int line;
     private final QName qname;
     private SchemaPath path;
     private final AnyXmlSchemaNodeImpl instance;
-    private final ConstraintsBuilder constraints = new ConstraintsBuilder();
+    private final ConstraintsBuilder constraints;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     private String description;
@@ -31,9 +32,11 @@ public class AnyXmlBuilder implements DataSchemaNodeBuilder {
     private Status status = Status.CURRENT;
     private boolean configuration;
 
-    public AnyXmlBuilder(final QName qname) {
+    public AnyXmlBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new AnyXmlSchemaNodeImpl(qname);
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -55,6 +58,11 @@ public class AnyXmlBuilder implements DataSchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index e7d389fc4eece95cb9b8de5e1fe5113c16914179..c85955d28948693bc397e4b3d60b560d66f8ca4b 100644 (file)
@@ -31,8 +31,8 @@ import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 
 public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
-
     private final AugmentationSchemaImpl instance;
+    private final int line;
     private final String augmentTargetStr;
     private final SchemaPath augmentTarget;
     private String whenCondition;
@@ -40,14 +40,20 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
     private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
     private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
 
-    AugmentationSchemaBuilderImpl(final String augmentTargetStr) {
+    AugmentationSchemaBuilderImpl(final String augmentTargetStr, final int line) {
         this.augmentTargetStr = augmentTargetStr;
+        this.line = line;
         final SchemaPath targetPath = YangModelBuilderUtil
                 .parseAugmentPath(augmentTargetStr);
         augmentTarget = targetPath;
         instance = new AugmentationSchemaImpl(targetPath);
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         childNodes.add(childNode);
index 946ba4ae0529352bce572b57a541a1713ad1ce3a..6660ac32155b229f256cce6e554a2deab8f657ee 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         AugmentationTargetBuilder {
     private final ChoiceNodeImpl instance;
+    private final int line;
     // SchemaNode args
     private final QName qname;
     private SchemaPath schemaPath;
@@ -52,10 +53,11 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
     private final Set<ChoiceCaseBuilder> cases = new HashSet<ChoiceCaseBuilder>();
     private String defaultCase;
 
-    public ChoiceBuilder(QName qname) {
+    public ChoiceBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new ChoiceNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -93,6 +95,11 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Set<ChoiceCaseBuilder> getCases() {
         return cases;
     }
@@ -101,7 +108,7 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         if (!(childNode instanceof ChoiceCaseBuilder)) {
             ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(
-                    childNode.getQName());
+                    childNode.getQName(), childNode.getLine());
             caseBuilder.addChildNode(childNode);
             cases.add(caseBuilder);
         } else {
index 27cead10f11a0b32eb472be311b1fb9a18ba937d..a631f00b52129e300c08f8143e64fc19142e5435 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
         DataSchemaNodeBuilder {
     private final ChoiceCaseNodeImpl instance;
+    private final int line;
     private SchemaPath schemaPath;
     private String description;
     private String reference;
@@ -37,10 +38,11 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
     private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
 
-    ChoiceCaseBuilder(QName qname) {
+    ChoiceCaseBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new ChoiceCaseNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -77,6 +79,11 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public SchemaPath getPath() {
         return schemaPath;
     }
index 905a107f3165a5a709a0e3374d4668d76a1df141..24549539a6785eddab443a90a5b3bbbd2668fbb9 100644 (file)
@@ -19,15 +19,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 
 public class ConstraintsBuilder implements Builder {
-
     private final ConstraintDefinitionImpl instance;
+    private final int line;
     private final Set<MustDefinition> mustDefinitions;
     private String whenCondition;
     private boolean mandatory;
     private Integer min;
     private Integer max;
 
-    ConstraintsBuilder() {
+    ConstraintsBuilder(final int line) {
+        this.line = line;
         instance = new ConstraintDefinitionImpl();
         mustDefinitions = new HashSet<MustDefinition>();
     }
@@ -48,6 +49,11 @@ public class ConstraintsBuilder implements Builder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Integer getMinElements() {
         return min;
     }
index 8d82bda60a878ad31f3d0478054c753cb77ccdbd..7693b3a467eb50caed6aec251842ef14896c59ab 100644 (file)
@@ -38,8 +38,8 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         implements TypeDefinitionAwareBuilder, AugmentationTargetBuilder,
         DataSchemaNodeBuilder {
-
     private final ContainerSchemaNodeImpl instance;
+    private final int line;
     private final ConstraintsBuilder constraints;
     private SchemaPath schemaPath;
     private String description;
@@ -54,10 +54,11 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
     private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    public ContainerSchemaNodeBuilder(QName qname) {
+    public ContainerSchemaNodeBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new ContainerSchemaNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -118,6 +119,11 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Set<TypeDefinitionBuilder> getTypedefs() {
         return addedTypedefs;
     }
index 0888811853d172674db74f93cb2e34b3aa86d695..53fcbf5fd2377d64f4434ff8ae733924d32fefc9 100644 (file)
@@ -14,10 +14,11 @@ import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
 
 public class DeviationBuilder implements Builder {
-
     private final DeviationImpl instance;
+    private final int line;
 
-    DeviationBuilder(final String targetPathStr) {
+    DeviationBuilder(final String targetPathStr, final int line) {
+        this.line = line;
         final SchemaPath targetPath = YangModelBuilderUtil
                 .parseAugmentPath(targetPathStr);
         instance = new DeviationImpl(targetPath);
@@ -28,6 +29,11 @@ public class DeviationBuilder implements Builder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public void setDeviate(final String deviate) {
         if ("not-supported".equals(deviate)) {
             instance.setDeviate(Deviate.NOT_SUPPORTED);
@@ -130,11 +136,12 @@ public class DeviationBuilder implements Builder {
 
         @Override
         public String toString() {
-            StringBuilder sb = new StringBuilder(DeviationImpl.class.getSimpleName());
+            StringBuilder sb = new StringBuilder(
+                    DeviationImpl.class.getSimpleName());
             sb.append("[");
-            sb.append("targetPath="+ targetPath);
-            sb.append(", deviate="+ deviate);
-            sb.append(", reference="+ reference);
+            sb.append("targetPath=" + targetPath);
+            sb.append(", deviate=" + deviate);
+            sb.append(", reference=" + reference);
             sb.append("]");
             return sb.toString();
         }
index 5828a33df919e11cb2082ade4b1439039139c884..cca167c59f95e8d414aabcb53181f3ea40d68710 100644 (file)
@@ -19,15 +19,16 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
 
 public class ExtensionBuilder implements SchemaNodeBuilder {
-
     private final ExtensionDefinitionImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private final List<UnknownSchemaNodeBuilder> addedExtensions = new ArrayList<UnknownSchemaNodeBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    ExtensionBuilder(final QName qname) {
+    ExtensionBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new ExtensionDefinitionImpl(qname);
     }
 
@@ -45,6 +46,11 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public void addExtension(UnknownSchemaNodeBuilder extension) {
         addedExtensions.add(extension);
     }
index ec5bcd7f4b80570cd514a5dfdef7a504bc7aaeec..372d786685cad15234871c754ce201b8332e7a0c 100644 (file)
@@ -19,14 +19,15 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
 
 public class FeatureBuilder implements SchemaNodeBuilder {
-
     private final FeatureDefinitionImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    FeatureBuilder(final QName qname) {
+    FeatureBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new FeatureDefinitionImpl(qname);
     }
 
@@ -44,6 +45,11 @@ public class FeatureBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index bffa7e381e9ff2ebecec083b2458f02f99d89908..1ccd0fcc483afcabfd8417c0157e8dc99b7bfc1b 100644 (file)
@@ -29,8 +29,8 @@ import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionB
 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
 
 public class GroupingBuilderImpl implements GroupingBuilder {
-
     private final GroupingDefinitionImpl instance;
+    private final int line;
     private SchemaPath schemaPath;
     private final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();
     private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
@@ -38,8 +38,9 @@ public class GroupingBuilderImpl implements GroupingBuilder {
     private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    GroupingBuilderImpl(final QName qname) {
+    GroupingBuilderImpl(final QName qname, final int line) {
         this.instance = new GroupingDefinitionImpl(qname);
+        this.line = line;
     }
 
     @Override
@@ -84,6 +85,11 @@ public class GroupingBuilderImpl implements GroupingBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     /**
      * Always returns null.
      */
index 5cfde8e7a0b7b7cbc21ababcc2c11a90dfcaf0eb..810ceeced500ca28d1bf4da4d8e83de8de5ab703 100644 (file)
@@ -20,14 +20,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 
 public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
     private final IdentitySchemaNodeImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private IdentitySchemaNodeBuilder baseIdentity;
     private String baseIdentityName;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    IdentitySchemaNodeBuilder(final QName qname) {
+    IdentitySchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new IdentitySchemaNodeImpl(qname);
     }
 
@@ -48,6 +50,11 @@ public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index 33b6416234b83750a19e249109f706ef09671281..f46b1d544a03f0626bff882fa46956367e4b1225 100644 (file)
@@ -30,12 +30,14 @@ import org.opendaylight.controller.yang.model.util.IdentityrefType;
  */
 public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder, Builder {
+    private final int line;
     private final String baseString;
     private final SchemaPath schemaPath;
     private QName baseQName;
 
 
-    public IdentityrefTypeBuilder(final String baseString, SchemaPath schemaPath) {
+    public IdentityrefTypeBuilder(final String baseString, final SchemaPath schemaPath, final int line) {
+        this.line = line;
         this.baseString = baseString;
         this.schemaPath = schemaPath;
     }
@@ -48,6 +50,11 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
         this.baseQName = baseQName;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public TypeDefinition<?> getType() {
         return null;
index 3884311e8e3da8cd88fd32a36cc482d56ca050bb..5ea82c214477665f9d761dedcafee84bd229e857 100644 (file)
@@ -25,21 +25,26 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         implements SchemaNodeBuilder, DataSchemaNodeBuilder {
     private final LeafListSchemaNodeImpl instance;
+    private final int line;
+    // SchemaNode args
     private final QName qname;
-    private final ConstraintsBuilder constraints = new ConstraintsBuilder();
     private SchemaPath schemaPath;
     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 final ConstraintsBuilder constraints;
+    // LeafListSchemaNode args
     private boolean userOrdered;
 
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
-
-    public LeafListSchemaNodeBuilder(final QName qname) {
+    public LeafListSchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new LeafListSchemaNodeImpl(qname);
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -69,6 +74,11 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
@@ -107,7 +117,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
index fe039b2394807037fbb6e0568f8f16c049f780e2..45bb17b318a981596f8e9aaffa34917bed941519 100644 (file)
@@ -24,23 +24,28 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 
 public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         DataSchemaNodeBuilder, SchemaNodeBuilder {
+    private final LeafSchemaNodeImpl instance;
+    private final int line;
+    // SchemaNode args
     private final QName qname;
     private SchemaPath path;
-    private final LeafSchemaNodeImpl instance;
-    private final ConstraintsBuilder constraints = new ConstraintsBuilder();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
-
     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 final ConstraintsBuilder constraints;
+    // leaf args
     private String defaultStr;
     private String unitsStr;
 
-    public LeafSchemaNodeBuilder(final QName qname) {
+    public LeafSchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new LeafSchemaNodeImpl(qname);
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -72,6 +77,11 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index b032b32804f2beb20b05a972bce579d88e1756b9..c9f338fed1236a00e1f008ed6864e06d524452df 100644 (file)
@@ -40,25 +40,31 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
         DataSchemaNodeBuilder, SchemaNodeBuilder, AugmentationTargetBuilder,
         TypeDefinitionAwareBuilder {
     private final ListSchemaNodeImpl instance;
-    private List<QName> keyDefinition;
-    private final ConstraintsBuilder constraints;
+    private final int line;
+    // SchemaNode args
     private SchemaPath schemaPath;
     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 boolean userOrdered;
-
+    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>();
+    // ListSchemaNode args
+    private List<QName> keyDefinition;
+    private boolean userOrdered;
 
-    public ListSchemaNodeBuilder(final QName qname) {
+    public ListSchemaNodeBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new ListSchemaNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -102,7 +108,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
 
         // AUGMENTATIONS
         final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-        for(AugmentationSchemaBuilder builder : addedAugmentations) {
+        for (AugmentationSchemaBuilder builder : addedAugmentations) {
             augmentations.add(builder.build());
         }
         instance.setAvailableAugmentations(augmentations);
@@ -120,6 +126,11 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Set<TypeDefinitionBuilder> getTypedefs() {
         return addedTypedefs;
     }
@@ -162,7 +173,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
index cca505e98505d26907b0c49202285cfda98040d6..5d72a0edf1467e9a8c029298829aa3c39701139a 100644 (file)
@@ -164,6 +164,11 @@ public class ModuleBuilder implements Builder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return 0;
+    }
+
     public Builder getNode(final List<String> path) {
         return moduleNodes.get(path);
     }
@@ -286,17 +291,18 @@ public class ModuleBuilder implements Builder {
         return imports;
     }
 
-    public ExtensionBuilder addExtension(final QName qname) {
-        final ExtensionBuilder builder = new ExtensionBuilder(qname);
+    public ExtensionBuilder addExtension(final QName qname, final int line) {
+        final ExtensionBuilder builder = new ExtensionBuilder(qname, line);
         addedExtensions.add(builder);
         return builder;
     }
 
     public ContainerSchemaNodeBuilder addContainerNode(
-            final QName containerName, final List<String> parentPath) {
+            final QName containerName, final List<String> parentPath,
+            final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(
-                containerName);
+                containerName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -314,10 +320,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public ListSchemaNodeBuilder addListNode(final QName listName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(
-                listName);
+                listName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -335,10 +341,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public LeafSchemaNodeBuilder addLeafNode(final QName leafName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(
-                leafName);
+                leafName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -356,10 +362,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public LeafListSchemaNodeBuilder addLeafListNode(final QName leafListName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(
-                leafListName);
+                leafListName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -377,9 +383,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public GroupingBuilder addGrouping(final QName qname,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToGroup = new ArrayList<String>(parentPath);
-        final GroupingBuilder builder = new GroupingBuilderImpl(qname);
+        final GroupingBuilder builder = new GroupingBuilderImpl(qname, line);
         final ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes
                 .get(pathToGroup);
         if (parentNodeBuilder != null) {
@@ -395,10 +401,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public AugmentationSchemaBuilder addAugment(final String name,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToAugment = new ArrayList<String>(parentPath);
         final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(
-                name);
+                name, line);
 
         // augment can only be in 'module' or 'uses' statement
         final UsesNodeBuilder parent = addedUsesNodes.get(pathToAugment);
@@ -414,10 +420,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public UsesNodeBuilder addUsesNode(final String groupingPathStr,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToUses = new ArrayList<String>(parentPath);
         final UsesNodeBuilder usesBuilder = new UsesNodeBuilderImpl(
-                groupingPathStr);
+                groupingPathStr, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToUses);
         if (parent != null) {
@@ -445,9 +451,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public RpcDefinitionBuilder addRpc(final QName qname,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToRpc = new ArrayList<String>(parentPath);
-        final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname);
+        final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname,
+                line);
 
         pathToRpc.add(qname.getLocalName());
         addedRpcs.put(pathToRpc, rpcBuilder);
@@ -455,7 +462,7 @@ public class ModuleBuilder implements Builder {
         final QName inputQName = new QName(qname.getNamespace(),
                 qname.getRevision(), qname.getPrefix(), "input");
         final ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(
-                inputQName);
+                inputQName, line);
         final List<String> pathToInput = new ArrayList<String>(pathToRpc);
         pathToInput.add("input");
         moduleNodes.put(pathToInput, inputBuilder);
@@ -464,7 +471,7 @@ public class ModuleBuilder implements Builder {
         final QName outputQName = new QName(qname.getNamespace(),
                 qname.getRevision(), qname.getPrefix(), "output");
         final ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(
-                outputQName);
+                outputQName, line);
         final List<String> pathToOutput = new ArrayList<String>(pathToRpc);
         pathToOutput.add("output");
         moduleNodes.put(pathToOutput, outputBuilder);
@@ -474,11 +481,12 @@ public class ModuleBuilder implements Builder {
     }
 
     public NotificationBuilder addNotification(final QName notificationName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNotification = new ArrayList<String>(
                 parentPath);
 
-        NotificationBuilder builder = new NotificationBuilder(notificationName);
+        NotificationBuilder builder = new NotificationBuilder(notificationName,
+                line);
 
         pathToNotification.add(notificationName.getLocalName());
         moduleNodes.put(pathToNotification, builder);
@@ -488,19 +496,19 @@ public class ModuleBuilder implements Builder {
     }
 
     public FeatureBuilder addFeature(final QName featureName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToFeature = new ArrayList<String>(parentPath);
         pathToFeature.add(featureName.getLocalName());
 
-        FeatureBuilder builder = new FeatureBuilder(featureName);
+        FeatureBuilder builder = new FeatureBuilder(featureName, line);
         addedFeatures.put(pathToFeature, builder);
         return builder;
     }
 
     public ChoiceBuilder addChoice(final QName choiceName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToChoice = new ArrayList<String>(parentPath);
-        ChoiceBuilder builder = new ChoiceBuilder(choiceName);
+        ChoiceBuilder builder = new ChoiceBuilder(choiceName, line);
 
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToChoice);
@@ -519,9 +527,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public ChoiceCaseBuilder addCase(final QName caseName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToCase = new ArrayList<String>(parentPath);
-        ChoiceCaseBuilder builder = new ChoiceCaseBuilder(caseName);
+        ChoiceCaseBuilder builder = new ChoiceCaseBuilder(caseName, line);
 
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToCase);
@@ -539,9 +547,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public AnyXmlBuilder addAnyXml(final QName anyXmlName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToAnyXml = new ArrayList<String>(parentPath);
-        AnyXmlBuilder builder = new AnyXmlBuilder(anyXmlName);
+        AnyXmlBuilder builder = new AnyXmlBuilder(anyXmlName, line);
 
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToAnyXml);
@@ -561,9 +569,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public TypedefBuilder addTypedef(final QName typeDefName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToType = new ArrayList<String>(parentPath);
-        TypedefBuilder builder = new TypedefBuilder(typeDefName);
+        TypedefBuilder builder = new TypedefBuilder(typeDefName, line);
         TypeDefinitionAwareBuilder parent = (TypeDefinitionAwareBuilder) moduleNodes
                 .get(pathToType);
         if (parent != null) {
@@ -587,12 +595,12 @@ public class ModuleBuilder implements Builder {
     }
 
     public void addUnionType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
+            final URI namespace, final Date revision, final int line) {
         List<String> pathToUnion = new ArrayList<String>(actualPath);
         TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
                 .get(pathToUnion);
         UnionTypeBuilder union = new UnionTypeBuilder(pathToUnion, namespace,
-                revision);
+                revision, line);
         parent.setType(union);
 
         List<String> path = new ArrayList<String>(pathToUnion);
@@ -601,31 +609,33 @@ public class ModuleBuilder implements Builder {
         moduleNodes.put(path, union);
     }
 
-    public void addIdentityrefType(String baseString, List<String> parentPath,
-            SchemaPath schemaPath) {
+    public void addIdentityrefType(final String baseString,
+            final List<String> parentPath, final SchemaPath schemaPath,
+            final int line) {
         List<String> pathToIdentityref = new ArrayList<String>(parentPath);
         TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
                 .get(pathToIdentityref);
         IdentityrefTypeBuilder identityref = new IdentityrefTypeBuilder(
-                baseString, schemaPath);
+                baseString, schemaPath, line);
         parent.setType(identityref);
         dirtyNodes.put(pathToIdentityref, parent);
     }
 
-    public DeviationBuilder addDeviation(String targetPath,
-            List<String> parentPath) {
+    public DeviationBuilder addDeviation(final String targetPath,
+            final List<String> parentPath, final int line) {
         final List<String> pathToDeviation = new ArrayList<String>(parentPath);
         pathToDeviation.add(targetPath);
-        DeviationBuilder builder = new DeviationBuilder(targetPath);
+        DeviationBuilder builder = new DeviationBuilder(targetPath, line);
         addedDeviations.put(targetPath, builder);
         moduleNodes.put(pathToDeviation, builder);
         return builder;
     }
 
-    public IdentitySchemaNodeBuilder addIdentity(QName qname,
-            List<String> parentPath) {
-        List<String> pathToIdentity = new ArrayList<String>(parentPath);
-        IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(qname);
+    public IdentitySchemaNodeBuilder addIdentity(final QName qname,
+            final List<String> parentPath, final int line) {
+        final List<String> pathToIdentity = new ArrayList<String>(parentPath);
+        final IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(
+                qname, line);
         pathToIdentity.add(qname.getLocalName());
         moduleNodes.put(pathToIdentity, builder);
         addedIdentities.add(builder);
@@ -642,11 +652,11 @@ public class ModuleBuilder implements Builder {
         }
     }
 
-    public UnknownSchemaNodeBuilder addUnknownSchemaNode(QName qname,
-            List<String> parentPath) {
+    public UnknownSchemaNodeBuilder addUnknownSchemaNode(final QName qname,
+            final List<String> parentPath, final int line) {
         final List<String> pathToUnknown = new ArrayList<String>(parentPath);
         final UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(
-                qname);
+                qname, line);
         final Builder parent = moduleNodes.get(pathToUnknown);
         if (parent instanceof RefineHolder) {
             ((RefineHolder) parent).addUnknownSchemaNode(builder);
index 3931b80ae97373754a2a28f0808b6c46d151e598..f2a0a07777e713498a2dbd2290f80163749c77e7 100644 (file)
@@ -35,15 +35,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 
 public class NotificationBuilder extends AbstractChildNodeBuilder implements
         TypeDefinitionAwareBuilder, SchemaNodeBuilder {
-
     private final NotificationDefinitionImpl instance;
+    private final int line;
     private SchemaPath schemaPath;
     private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    NotificationBuilder(QName qname) {
+    NotificationBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new NotificationDefinitionImpl(qname);
     }
 
@@ -89,6 +90,11 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public void addTypedef(final TypeDefinitionBuilder type) {
         addedTypedefs.add(type);
index 6bf7750e7c5679d254eb4f9755b12c85b83230a7..f9b1a04cf953a065b52497aadb70792602327b75 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionB
 public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         TypeDefinitionAwareBuilder {
     private final RpcDefinitionImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private ContainerSchemaNodeBuilder inputBuilder;
@@ -37,8 +38,9 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
     private final Set<GroupingBuilder> addedGroupings = new HashSet<GroupingBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    RpcDefinitionBuilder(final QName qname) {
+    RpcDefinitionBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         this.instance = new RpcDefinitionImpl(qname);
     }
 
@@ -75,6 +77,11 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     void setInput(final ContainerSchemaNodeBuilder inputBuilder) {
         this.inputBuilder = inputBuilder;
     }
index 0e768c1107f4c9a48cbc3eba653476b427509b7f..94b46e6360caeb64c12854c1a90e6b68c3f83f9f 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.yang.model.util.UnknownType;
 
 public class TypedefBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder {
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
 
@@ -42,8 +43,9 @@ public class TypedefBuilder extends AbstractTypeAwareBuilder implements
     private String units;
     private Object defaultValue;
 
-    public TypedefBuilder(final QName qname) {
+    public TypedefBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
     }
 
     @Override
@@ -80,6 +82,11 @@ public class TypedefBuilder extends AbstractTypeAwareBuilder implements
         return result;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index 9ab103d71e890696e5ae60367bb48fd5f160906d..ec889c53e85acb5efa6f0ac4425e0bca19ab821c 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.controller.yang.model.util.UnionType;
  */
 public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder, Builder {
+    private final int line;
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
     private final UnionType instance;
@@ -42,7 +43,8 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
     private final Date revision;
 
     public UnionTypeBuilder(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+            final Date revision, final int line) {
+        this.line = line;
         types = new ArrayList<TypeDefinition<?>>();
         typedefs = new ArrayList<TypeDefinitionBuilder>();
         instance = new UnionType(actualPath, namespace, revision, types);
@@ -52,6 +54,11 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         this.revision = revision;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public List<TypeDefinition<?>> getTypes() {
         return types;
     }
index f24502bab2903d2ba545be05547c521f3ab26339..c2c32ca347b4ae52d44b2111f08cd2de184217fa 100644 (file)
@@ -19,14 +19,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 
 public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
     private final UnknownSchemaNodeImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
     private QName nodeType;
     private String nodeParameter;
 
-    UnknownSchemaNodeBuilder(final QName qname) {
+    UnknownSchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new UnknownSchemaNodeImpl(qname);
     }
 
@@ -45,6 +47,11 @@ public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index 05d2faa4099e61e38c47e15fe69447ce79faaa35..65bdf6e03a6b30b3aebcf9d0703aedf90f4826b9 100644 (file)
@@ -28,13 +28,15 @@ import org.opendaylight.controller.yang.model.parser.util.RefineHolder;
 \r
 final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
     private final UsesNodeImpl instance;\r
+    private final int line;\r
     private final SchemaPath groupingPath;\r
     private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
     private List<SchemaNodeBuilder> refineBuilders = new ArrayList<SchemaNodeBuilder>();\r
     private List<RefineHolder> refines = new ArrayList<RefineHolder>();\r
 \r
-    UsesNodeBuilderImpl(final String groupingPathStr) {\r
+    UsesNodeBuilderImpl(final String groupingPathStr, final int line) {\r
         this.groupingPath = parseUsesPath(groupingPathStr);\r
+        this.line = line;\r
         instance = new UsesNodeImpl(groupingPath);\r
     }\r
 \r
@@ -49,7 +51,7 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
 \r
         // REFINES\r
         final Map<SchemaPath, SchemaNode> refineNodes = new HashMap<SchemaPath, SchemaNode>();\r
-        for(SchemaNodeBuilder refineBuilder : refineBuilders) {\r
+        for (SchemaNodeBuilder refineBuilder : refineBuilders) {\r
             SchemaNode refineNode = refineBuilder.build();\r
             refineNodes.put(refineNode.getPath(), refineNode);\r
         }\r
@@ -58,6 +60,11 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
         return instance;\r
     }\r
 \r
+    @Override\r
+    public int getLine() {\r
+        return line;\r
+    }\r
+\r
     @Override\r
     public SchemaPath getGroupingPath() {\r
         return groupingPath;\r
@@ -126,7 +133,8 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
             return augmentations;\r
         }\r
 \r
-        private void setAugmentations(final Set<AugmentationSchema> augmentations) {\r
+        private void setAugmentations(\r
+                final Set<AugmentationSchema> augmentations) {\r
             if (augmentations != null) {\r
                 this.augmentations = augmentations;\r
             }\r
@@ -147,7 +155,7 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
         }\r
 \r
         private void setRefines(Map<SchemaPath, SchemaNode> refines) {\r
-            if(refines != null) {\r
+            if (refines != null) {\r
                 this.refines = refines;\r
             }\r
         }\r
index 35c04a8713bcae29908491b443b726a5a83aabe6..c7bd7f57e843842f560f6ea5a0c0f049ba220fe5 100644 (file)
@@ -318,9 +318,10 @@ public class YangModelParserImpl implements YangModelParser {
 
         // search for module which contains referenced typedef
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                builder, unknownTypeQName.getPrefix());
+                builder, unknownTypeQName.getPrefix(), nodeToResolve.getLine());
         final TypeDefinitionBuilder lookedUpBuilder = findTypedefBuilderByName(
-                dependentModule, unknownTypeQName.getLocalName());
+                dependentModule, unknownTypeQName.getLocalName(),
+                builder.getName(), nodeToResolve.getLine());
 
         final TypeDefinitionBuilder lookedUpBuilderCopy = copyTypedefBuilder(
                 lookedUpBuilder, nodeToResolve instanceof TypeDefinitionBuilder);
@@ -344,9 +345,10 @@ public class YangModelParserImpl implements YangModelParser {
         final QName unknownTypeQName = unknownType.getQName();
         // search for module which contains referenced typedef
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                module, unknownTypeQName.getPrefix());
+                module, unknownTypeQName.getPrefix(), nodeToResolve.getLine());
         final TypeDefinitionBuilder lookedUpBuilder = findTypedefBuilderByName(
-                dependentModule, unknownTypeQName.getLocalName());
+                dependentModule, unknownTypeQName.getLocalName(),
+                module.getName(), nodeToResolve.getLine());
 
         final TypeDefinitionBuilder lookedUpBuilderCopy = copyTypedefBuilder(
                 lookedUpBuilder, nodeToResolve instanceof TypeDefinitionBuilder);
@@ -361,7 +363,7 @@ public class YangModelParserImpl implements YangModelParser {
             final UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
             final UnionTypeBuilder newUnion = new UnionTypeBuilder(
                     oldUnion.getActualPath(), oldUnion.getNamespace(),
-                    oldUnion.getRevision());
+                    oldUnion.getRevision(), old.getLine());
             for (TypeDefinition<?> td : oldUnion.getTypes()) {
                 newUnion.setType(td);
             }
@@ -375,7 +377,8 @@ public class YangModelParserImpl implements YangModelParser {
         final QName newName = new QName(oldName.getNamespace(),
                 oldName.getRevision(), oldName.getPrefix(),
                 oldName.getLocalName());
-        final TypeDefinitionBuilder tdb = new TypedefBuilder(newName);
+        final TypeDefinitionBuilder tdb = new TypedefBuilder(newName,
+                old.getLine());
 
         tdb.setRanges(old.getRanges());
         tdb.setLengths(old.getLengths());
@@ -432,7 +435,7 @@ public class YangModelParserImpl implements YangModelParser {
             final QName unknownTypeQName = unknownType.getQName();
             final String unknownTypePrefix = unknownTypeQName.getPrefix();
             final ModuleBuilder dependentModule = findDependentModule(modules,
-                    builder, unknownTypePrefix);
+                    builder, unknownTypePrefix, copy.getLine());
             final TypeDefinitionBuilder utBuilder = getTypedefBuilder(copy,
                     modules, dependentModule);
             copy.setType(utBuilder);
@@ -454,12 +457,13 @@ public class YangModelParserImpl implements YangModelParser {
     private TypeDefinitionBuilder findTypedefBuilder(
             final QName unknownTypeQName,
             final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
+            final ModuleBuilder builder, int line) {
         // search for module which contains referenced typedef
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                builder, unknownTypeQName.getPrefix());
+                builder, unknownTypeQName.getPrefix(), line);
         final TypeDefinitionBuilder lookedUpBuilder = findTypedefBuilderByName(
-                dependentModule, unknownTypeQName.getLocalName());
+                dependentModule, unknownTypeQName.getLocalName(),
+                builder.getName(), line);
         return copyTypedefBuilder(lookedUpBuilder, true);
     }
 
@@ -502,8 +506,9 @@ public class YangModelParserImpl implements YangModelParser {
             fractionDigits = ext.getFractionDigits();
             constraints.setFractionDigits(fractionDigits);
             return findConstraints(
-                    findTypedefBuilder(ext.getQName(), modules, builder),
-                    constraints, modules, builder);
+                    findTypedefBuilder(ext.getQName(), modules, builder,
+                            nodeToResolve.getLine()), constraints, modules,
+                    builder);
         } else if (referencedType instanceof UnknownType) {
             final UnknownType unknown = (UnknownType) referencedType;
             ranges = unknown.getRangeStatements();
@@ -520,9 +525,11 @@ public class YangModelParserImpl implements YangModelParser {
                 unknownTypePrefix = builder.getPrefix();
             }
             final ModuleBuilder dependentModule = findDependentModule(modules,
-                    builder, unknown.getQName().getPrefix());
+                    builder, unknown.getQName().getPrefix(),
+                    nodeToResolve.getLine());
             final TypeDefinitionBuilder utBuilder = findTypedefBuilder(
-                    unknown.getQName(), modules, builder);
+                    unknown.getQName(), modules, builder,
+                    nodeToResolve.getLine());
             return findConstraints(utBuilder, constraints, modules,
                     dependentModule);
         } else {
@@ -543,7 +550,8 @@ public class YangModelParserImpl implements YangModelParser {
      * @return typedef with name equals to given name
      */
     private TypeDefinitionBuilder findTypedefBuilderByName(
-            final ModuleBuilder dependentModule, final String name) {
+            final ModuleBuilder dependentModule, final String name,
+            final String currentModuleName, final int line) {
         TypeDefinitionBuilder result = null;
         final Set<TypeDefinitionBuilder> typedefs = dependentModule
                 .getModuleTypedefs();
@@ -554,9 +562,9 @@ public class YangModelParserImpl implements YangModelParser {
             }
         }
         if (result == null) {
-            throw new YangParseException("Target module '"
-                    + dependentModule.getName()
-                    + "' does not contain typedef '" + name + "'.");
+            throw new YangParseException(currentModuleName, line,
+                    "Target module '" + dependentModule.getName()
+                            + "' does not contain typedef '" + name + "'.");
         }
         return result;
     }
@@ -661,7 +669,7 @@ public class YangModelParserImpl implements YangModelParser {
 
                 DataSchemaNodeBuilder currentParent = null;
                 final ModuleBuilder dependentModule = findDependentModule(
-                        modules, module, prefix);
+                        modules, module, prefix, augmentBuilder.getLine());
                 for (DataSchemaNodeBuilder child : dependentModule
                         .getChildNodes()) {
                     final QName childQName = child.getQName();
@@ -733,7 +741,7 @@ public class YangModelParserImpl implements YangModelParser {
                     baseIdentityLocalName = baseIdentityName;
                 }
                 final ModuleBuilder dependentModule = findDependentModule(
-                        modules, module, baseIdentityPrefix);
+                        modules, module, baseIdentityPrefix, identity.getLine());
 
                 final Set<IdentitySchemaNodeBuilder> dependentModuleIdentities = dependentModule
                         .getAddedIdentities();
@@ -896,7 +904,7 @@ public class YangModelParserImpl implements YangModelParser {
             final ModuleBuilder module) {
         Builder result = null;
         final Builder lookedUpBuilder = findRefineTargetBuilder(groupingPath,
-                refine.getName(), modules, module);
+                refine, modules, module);
         if (lookedUpBuilder instanceof LeafSchemaNodeBuilder) {
             result = ParserUtils
                     .copyLeafBuilder((LeafSchemaNodeBuilder) lookedUpBuilder);
@@ -916,8 +924,8 @@ public class YangModelParserImpl implements YangModelParser {
             result = ParserUtils
                     .copyAnyXmlBuilder((AnyXmlBuilder) lookedUpBuilder);
         } else {
-            throw new YangParseException("Target '" + refine.getName()
-                    + "' can not be refined");
+            throw new YangParseException(module.getName(), refine.getLine(),
+                    "Target '" + refine.getName() + "' can not be refined");
         }
         return result;
     }
@@ -937,7 +945,7 @@ public class YangModelParserImpl implements YangModelParser {
      *         otherwise
      */
     private Builder findRefineTargetBuilder(final String groupingPath,
-            final String refineNodeName,
+            final RefineHolder refine,
             final Map<String, TreeMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder module) {
         final SchemaPath path = ParserUtils.parseUsesPath(groupingPath);
@@ -952,13 +960,13 @@ public class YangModelParserImpl implements YangModelParser {
         }
 
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                module, prefix);
+                module, prefix, refine.getLine());
         builderPath.add(0, "grouping");
         builderPath.add(0, dependentModule.getName());
         final GroupingBuilder builder = (GroupingBuilder) dependentModule
                 .getNode(builderPath);
 
-        return builder.getChildNode(refineNodeName);
+        return builder.getChildNode(refine.getName());
     }
 
     private QName findFullQName(
@@ -969,13 +977,13 @@ public class YangModelParserImpl implements YangModelParser {
         if (baseString.contains(":")) {
             String[] splittedBase = baseString.split(":");
             if (splittedBase.length > 2) {
-                throw new YangParseException(
+                throw new YangParseException(module.getName(), idref.getLine(),
                         "Failed to parse identityref base: " + baseString);
             }
             String prefix = splittedBase[0];
             String name = splittedBase[1];
             ModuleBuilder dependentModule = findDependentModule(modules,
-                    module, prefix);
+                    module, prefix, idref.getLine());
             result = new QName(dependentModule.getNamespace(),
                     dependentModule.getRevision(), prefix, name);
         } else {
@@ -994,15 +1002,16 @@ public class YangModelParserImpl implements YangModelParser {
                     || nodeType.getRevision() == null) {
                 try {
                     ModuleBuilder dependentModule = findDependentModule(
-                            modules, module, nodeType.getPrefix());
+                            modules, module, nodeType.getPrefix(),
+                            usnb.getLine());
                     QName newNodeType = new QName(
                             dependentModule.getNamespace(),
                             dependentModule.getRevision(),
                             nodeType.getPrefix(), nodeType.getLocalName());
                     usnb.setNodeType(newNodeType);
                 } catch (YangParseException e) {
-                    logger.debug("Failed to find unknown node type: "
-                            + nodeType);
+                    logger.debug(module.getName(), usnb.getLine(),
+                            "Failed to find unknown node type: " + nodeType);
                 }
             }
         }
@@ -1021,7 +1030,7 @@ public class YangModelParserImpl implements YangModelParser {
      */
     private ModuleBuilder findDependentModule(
             final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module, final String prefix) {
+            final ModuleBuilder module, final String prefix, final int line) {
         ModuleBuilder dependentModule = null;
         Date dependentModuleRevision = null;
 
@@ -1031,8 +1040,8 @@ public class YangModelParserImpl implements YangModelParser {
             final ModuleImport dependentModuleImport = ParserUtils
                     .getModuleImport(module, prefix);
             if (dependentModuleImport == null) {
-                throw new YangParseException("No import found with prefix '"
-                        + prefix + "' in module " + module.getName() + "'.");
+                throw new YangParseException(module.getName(), line,
+                        "No import found with prefix '" + prefix + "'.");
             }
             final String dependentModuleName = dependentModuleImport
                     .getModuleName();
@@ -1041,10 +1050,9 @@ public class YangModelParserImpl implements YangModelParser {
             final TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules
                     .get(dependentModuleName);
             if (moduleBuildersByRevision == null) {
-                throw new YangParseException(
+                throw new YangParseException(module.getName(), line,
                         "Failed to find dependent module '"
-                                + dependentModuleName + "' needed by module '"
-                                + module.getName() + "'.");
+                                + dependentModuleName + "'.");
             }
             if (dependentModuleRevision == null) {
                 dependentModule = moduleBuildersByRevision.lastEntry()
@@ -1056,7 +1064,7 @@ public class YangModelParserImpl implements YangModelParser {
         }
 
         if (dependentModule == null) {
-            throw new YangParseException(
+            throw new YangParseException(module.getName(), line,
                     "Failed to find dependent module with prefix '" + prefix
                             + "' and revision '" + dependentModuleRevision
                             + "'.");
index 98b81bd958d0ed338dc6c6a2521f233fa11928eb..511c610e3f42e25241e8ae2e01c82c3a82e2bb78 100644 (file)
@@ -78,8 +78,8 @@ import org.opendaylight.controller.yang.model.util.YangTypesConverter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class YangModelParserListenerImpl extends YangParserBaseListener {\r
-\r
+public final class YangModelParserListenerImpl extends YangParserBaseListener {
+
     private static final Logger logger = LoggerFactory
             .getLogger(YangModelParserListenerImpl.class);
 
@@ -90,7 +90,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     private String yangModelPrefix;
     private Date revision = new Date(0L);
 
-    public final static DateFormat simpleDateFormat = new SimpleDateFormat(\r
+    public final static DateFormat simpleDateFormat = new SimpleDateFormat(
             "yyyy-MM-dd");
     private final Stack<String> actualPath = new Stack<String>();
 
@@ -238,7 +238,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {
         final String augmentPath = stringFromNode(ctx);
         AugmentationSchemaBuilder builder = moduleBuilder.addAugment(
-                augmentPath, actualPath);
+                augmentPath, actualPath, ctx.getStart().getLine());
         updatePath(augmentPath);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
@@ -269,7 +269,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     public void enterExtension_stmt(YangParser.Extension_stmtContext ctx) {
         final String extName = stringFromNode(ctx);
         QName qname = new QName(namespace, revision, yangModelPrefix, extName);
-        ExtensionBuilder builder = moduleBuilder.addExtension(qname);
+        ExtensionBuilder builder = moduleBuilder.addExtension(qname, ctx
+                .getStart().getLine());
         parseSchemaNodeArgs(ctx, builder);
 
         String argument = null;
@@ -292,7 +293,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName typedefQName = new QName(namespace, revision, yangModelPrefix,
                 typedefName);
         TypedefBuilder builder = moduleBuilder.addTypedef(typedefQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
         updatePath(typedefName);
 
         builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
@@ -310,7 +311,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterType_stmt(YangParser.Type_stmtContext ctx) {
         final String typeName = stringFromNode(ctx);
-        QName typeQName = parseQName(typeName);
+        final int line = ctx.getStart().getLine();
+        final QName typeQName = parseQName(typeName);
 
         TypeDefinition<?> type = null;
         Type_body_stmtsContext typeBody = null;
@@ -324,15 +326,22 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         // if this is base yang type...
         if (YangTypesConverter.isBaseYangType(typeName)) {
             if (typeBody == null) {
+                // check for types which must have body
+                checkMissingBody(typeName, moduleName, line);
                 // if there are no constraints, just grab default base yang type
-                type = YangTypesConverter.javaTypeForBaseYangType(actualPath, namespace, revision, typeName);
+                type = YangTypesConverter.javaTypeForBaseYangType(actualPath,
+                        namespace, revision, typeName);
                 moduleBuilder.setType(type, actualPath);
             } else {
                 if ("union".equals(typeName)) {
-                    moduleBuilder.addUnionType(actualPath, namespace, revision);
-                } else if("identityref".equals(typeName)) {
-                    SchemaPath path = createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix);
-                    moduleBuilder.addIdentityrefType(getIdentityrefBase(typeBody), actualPath, path);
+                    moduleBuilder.addUnionType(actualPath, namespace, revision,
+                            line);
+                } else if ("identityref".equals(typeName)) {
+                    SchemaPath path = createActualSchemaPath(actualPath,
+                            namespace, revision, yangModelPrefix);
+                    moduleBuilder.addIdentityrefType(
+                            getIdentityrefBase(typeBody), actualPath, path,
+                            line);
                 } else {
                     List<String> typePath = new ArrayList<String>(actualPath);
                     typePath.remove(0);
@@ -381,7 +390,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName groupQName = new QName(namespace, revision, yangModelPrefix,
                 groupName);
         GroupingBuilder groupBuilder = moduleBuilder.addGrouping(groupQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
         updatePath("grouping");
         updatePath(groupName);
         parseSchemaNodeArgs(ctx, groupBuilder);
@@ -400,7 +409,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName containerQName = new QName(namespace, revision, yangModelPrefix,
                 containerName);
         ContainerSchemaNodeBuilder containerBuilder = moduleBuilder
-                .addContainerNode(containerQName, actualPath);
+                .addContainerNode(containerQName, actualPath, ctx.getStart()
+                        .getLine());
         updatePath(containerName);
 
         containerBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -429,7 +439,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName leafQName = new QName(namespace, revision, yangModelPrefix,
                 leafName);
         LeafSchemaNodeBuilder leafBuilder = moduleBuilder.addLeafNode(
-                leafQName, actualPath);
+                leafQName, actualPath, ctx.getStart().getLine());
         updatePath(leafName);
 
         leafBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -460,8 +470,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     @Override
     public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {
         final String groupingPathStr = stringFromNode(ctx);
-        moduleBuilder.addUsesNode(groupingPathStr,
-                actualPath);
+        moduleBuilder.addUsesNode(groupingPathStr, actualPath, ctx.getStart()
+                .getLine());
         updatePath(groupingPathStr);
     }
 
@@ -491,7 +501,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName leafListQName = new QName(namespace, revision, yangModelPrefix,
                 leafListName);
         LeafListSchemaNodeBuilder leafListBuilder = moduleBuilder
-                .addLeafListNode(leafListQName, actualPath);
+                .addLeafListNode(leafListQName, actualPath, ctx.getStart()
+                        .getLine());
         updatePath(leafListName);
 
         parseSchemaNodeArgs(ctx, leafListBuilder);
@@ -520,7 +531,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName containerQName = new QName(namespace, revision, yangModelPrefix,
                 containerName);
         ListSchemaNodeBuilder listBuilder = moduleBuilder.addListNode(
-                containerQName, actualPath);
+                containerQName, actualPath, ctx.getStart().getLine());
         updatePath(containerName);
 
         listBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -556,7 +567,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName anyXmlQName = new QName(namespace, revision, yangModelPrefix,
                 anyXmlName);
         AnyXmlBuilder anyXmlBuilder = moduleBuilder.addAnyXml(anyXmlQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
         updatePath(anyXmlName);
 
         anyXmlBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -577,7 +588,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName choiceQName = new QName(namespace, revision, yangModelPrefix,
                 choiceName);
         ChoiceBuilder choiceBuilder = moduleBuilder.addChoice(choiceQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
 
         updatePath(choiceName);
         choiceBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -608,7 +619,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName choiceQName = new QName(namespace, revision, yangModelPrefix,
                 caseName);
         ChoiceCaseBuilder caseBuilder = moduleBuilder.addCase(choiceQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
 
         updatePath(caseName);
         caseBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -629,7 +640,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName notificationQName = new QName(namespace, revision,
                 yangModelPrefix, notificationName);
         NotificationBuilder notificationBuilder = moduleBuilder
-                .addNotification(notificationQName, actualPath);
+                .addNotification(notificationQName, actualPath, ctx.getStart()
+                        .getLine());
         updatePath(notificationName);
 
         notificationBuilder.setPath(createActualSchemaPath(actualPath,
@@ -652,7 +664,8 @@ 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, yangModelPrefix, splittedElement[0]);
+            nodeType = new QName(null, null, yangModelPrefix,
+                    splittedElement[0]);
         } else {
             nodeType = new QName(null, null, splittedElement[0],
                     splittedElement[1]);
@@ -668,11 +681,12 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
                         splittedName[0]);
             }
         } else {
-            qname = new QName(namespace, revision, yangModelPrefix, nodeParameter);
+            qname = new QName(namespace, revision, yangModelPrefix,
+                    nodeParameter);
         }
 
         UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(
-                qname, actualPath);
+                qname, actualPath, ctx.getStart().getLine());
         builder.setNodeType(nodeType);
         builder.setNodeParameter(nodeParameter);
         updatePath(nodeParameter);
@@ -693,7 +707,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName rpcQName = new QName(namespace, revision, yangModelPrefix,
                 rpcName);
         RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
         updatePath(rpcName);
 
         rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -735,7 +749,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         QName featureQName = new QName(namespace, revision, yangModelPrefix,
                 featureName);
         FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
         updatePath(featureName);
 
         featureBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@@ -755,7 +769,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         String reference = null;
         String deviate = null;
         DeviationBuilder builder = moduleBuilder.addDeviation(targetPath,
-                actualPath);
+                actualPath, ctx.getStart().getLine());
         updatePath(targetPath);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
@@ -793,8 +807,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         final String identityName = stringFromNode(ctx);
         final QName identityQName = new QName(namespace, revision,
                 yangModelPrefix, identityName);
-        IdentitySchemaNodeBuilder builder = moduleBuilder
-                .addIdentity(identityQName, actualPath);
+        IdentitySchemaNodeBuilder builder = moduleBuilder.addIdentity(
+                identityQName, actualPath, ctx.getStart().getLine());
         updatePath(identityName);
 
         builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
index fa88a29981335c1f34c834decbc0f2bb366e53f7..8237da69b0d6fa04f1ae5be237fa4442352f0b2f 100644 (file)
@@ -103,7 +103,7 @@ public final class ParserUtils {
     public static LeafSchemaNodeBuilder copyLeafBuilder(
             final LeafSchemaNodeBuilder old) {
         final LeafSchemaNodeBuilder copy = new LeafSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         final TypeDefinition<?> type = old.getType();
 
         if (type == null) {
@@ -129,7 +129,7 @@ public final class ParserUtils {
     public static ContainerSchemaNodeBuilder copyContainerBuilder(
             final ContainerSchemaNodeBuilder old) {
         final ContainerSchemaNodeBuilder copy = new ContainerSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (UnknownSchemaNodeBuilder unknown : old.getUnknownNodes()) {
@@ -165,7 +165,7 @@ public final class ParserUtils {
     public static ListSchemaNodeBuilder copyListBuilder(
             final ListSchemaNodeBuilder old) {
         final ListSchemaNodeBuilder copy = new ListSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (UnknownSchemaNodeBuilder unknown : old.getUnknownNodes()) {
@@ -201,7 +201,7 @@ public final class ParserUtils {
     public static LeafListSchemaNodeBuilder copyLeafListBuilder(
             final LeafListSchemaNodeBuilder old) {
         final LeafListSchemaNodeBuilder copy = new LeafListSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         final TypeDefinition<?> type = old.getType();
@@ -226,7 +226,7 @@ public final class ParserUtils {
     }
 
     public static ChoiceBuilder copyChoiceBuilder(final ChoiceBuilder old) {
-        final ChoiceBuilder copy = new ChoiceBuilder(old.getQName());
+        final ChoiceBuilder copy = new ChoiceBuilder(old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (ChoiceCaseBuilder caseBuilder : old.getCases()) {
@@ -254,7 +254,7 @@ public final class ParserUtils {
     }
 
     public static AnyXmlBuilder copyAnyXmlBuilder(final AnyXmlBuilder old) {
-        final AnyXmlBuilder copy = new AnyXmlBuilder(old.getQName());
+        final AnyXmlBuilder copy = new AnyXmlBuilder(old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (UnknownSchemaNodeBuilder unknown : old.getUnknownNodes()) {
index 0c31655610410e50ab929546e4d69464462df115..5a24773707898579f2db8a05b43a7104d3f9fae3 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaN
 
 public final class RefineHolder implements Builder {
     private final String name;
+    private final int line;
     private String defaultStr;
     private String description;
     private String reference;
@@ -27,8 +28,14 @@ public final class RefineHolder implements Builder {
     private Integer maxElements;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    public RefineHolder(final String name) {
+    public RefineHolder(final String name, final int line) {
         this.name = name;
+        this.line = line;
+    }
+
+    @Override
+    public int getLine() {
+        return line;
     }
 
     public String getDefaultStr() {
index fff33b63bd513baa2b4e435b6266e497ce5ea874..49b177eb6693d3394f5c2c51d40cbda9cbdfb54b 100644 (file)
@@ -550,6 +550,7 @@ public final class YangModelBuilderUtil {
      */
     private static List<RangeConstraint> parseRangeConstraints(
             final Range_stmtContext ctx) {
+        final int line = ctx.getStart().getLine();
         List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();
         String description = null;
         String reference = null;
@@ -571,10 +572,11 @@ public final class YangModelBuilderUtil {
             Number min;
             Number max;
             if (splittedRangeDef.length == 1) {
-                min = max = parseNumberConstraintValue(splittedRangeDef[0]);
+                min = max = parseNumberConstraintValue(splittedRangeDef[0],
+                        line);
             } else {
-                min = parseNumberConstraintValue(splittedRangeDef[0]);
-                max = parseNumberConstraintValue(splittedRangeDef[1]);
+                min = parseNumberConstraintValue(splittedRangeDef[0], line);
+                max = parseNumberConstraintValue(splittedRangeDef[1], line);
             }
             RangeConstraint range = BaseConstraints.rangeConstraint(min, max,
                     description, reference);
@@ -618,6 +620,7 @@ public final class YangModelBuilderUtil {
      */
     private static List<LengthConstraint> parseLengthConstraints(
             final Length_stmtContext ctx) {
+        final int line = ctx.getStart().getLine();
         List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();
         String description = null;
         String reference = null;
@@ -639,10 +642,11 @@ public final class YangModelBuilderUtil {
             Number min;
             Number max;
             if (splittedRangeDef.length == 1) {
-                min = max = parseNumberConstraintValue(splittedRangeDef[0]);
+                min = max = parseNumberConstraintValue(splittedRangeDef[0],
+                        line);
             } else {
-                min = parseNumberConstraintValue(splittedRangeDef[0]);
-                max = parseNumberConstraintValue(splittedRangeDef[1]);
+                min = parseNumberConstraintValue(splittedRangeDef[0], line);
+                max = parseNumberConstraintValue(splittedRangeDef[1], line);
             }
             LengthConstraint range = BaseConstraints.lengthConstraint(min, max,
                     description, reference);
@@ -658,7 +662,8 @@ public final class YangModelBuilderUtil {
      * @return wrapper object of primitive java type or UnknownBoundaryNumber if
      *         type is one of special YANG values 'min' or 'max'
      */
-    private static Number parseNumberConstraintValue(final String value) {
+    private static Number parseNumberConstraintValue(final String value,
+            final int line) {
         Number result = null;
         if ("min".equals(value) || "max".equals(value)) {
             result = new UnknownBoundaryNumber(value);
@@ -666,8 +671,8 @@ public final class YangModelBuilderUtil {
             try {
                 result = Long.valueOf(value);
             } catch (NumberFormatException e) {
-                throw new YangParseException("Unable to parse range value '"
-                        + value + "'.", e);
+                throw new YangParseException("Error on line " + line
+                        + ": Unable to parse range value '" + value + "'.", e);
             }
         }
         return result;
@@ -988,35 +993,45 @@ public final class YangModelBuilderUtil {
                 typeBody, actualPath, namespace, revision, prefix);
 
         if ("decimal64".equals(typeName)) {
-            type = new Decimal64(actualPath, namespace, revision, fractionDigits);
+            type = new Decimal64(actualPath, namespace, revision,
+                    fractionDigits);
         } else if (typeName.startsWith("int")) {
             if (typeName.equals("int8")) {
-                type = new Int8(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int8(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("int16")) {
-                type = new Int16(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int16(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("int32")) {
-                type = new Int32(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int32(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("int64")) {
-                type = new Int64(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int64(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             }
         } else if (typeName.startsWith("uint")) {
             if (typeName.equals("uint8")) {
-                type = new Uint8(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint8(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("uint16")) {
-                type = new Uint16(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint16(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("uint32")) {
-                type = new Uint32(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint32(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("uint64")) {
-                type = new Uint64(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint64(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             }
         } else if ("enumeration".equals(typeName)) {
             type = new EnumerationType(actualPath, namespace, revision,
                     enumConstants);
         } else if ("string".equals(typeName)) {
-            type = new StringType(actualPath, namespace, revision, lengthStatements, patternStatements);
+            type = new StringType(actualPath, namespace, revision,
+                    lengthStatements, patternStatements);
         } else if ("bits".equals(typeName)) {
-            type = new BitsType(actualPath, namespace, revision, getBits(typeBody, actualPath, namespace,
-                    revision, prefix));
+            type = new BitsType(actualPath, namespace, revision, getBits(
+                    typeBody, actualPath, namespace, revision, prefix));
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
@@ -1025,18 +1040,19 @@ public final class YangModelBuilderUtil {
             type = new Leafref(actualPath, namespace, revision, xpath);
         } else if ("binary".equals(typeName)) {
             List<Byte> bytes = Collections.emptyList();
-            type = new BinaryType(actualPath, namespace, revision, bytes, lengthStatements, null);
+            type = new BinaryType(actualPath, namespace, revision, bytes,
+                    lengthStatements, null);
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            type = new InstanceIdentifier(actualPath, namespace, revision, null, requireInstance);
+            type = new InstanceIdentifier(actualPath, namespace, revision,
+                    null, requireInstance);
         }
         return type;
     }
 
     public static String getIdentityrefBase(Type_body_stmtsContext ctx) {
         String result = null;
-        outer:
-        for (int i = 0; i < ctx.getChildCount(); i++) {
+        outer: for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
             if (child instanceof Identityref_specificationContext) {
                 for (int j = 0; j < child.getChildCount(); j++) {
@@ -1194,52 +1210,43 @@ public final class YangModelBuilderUtil {
         return yinValue;
     }
 
-//    public static List<RefineHolder> parseRefines(Uses_stmtContext ctx) {
-//        List<RefineHolder> refines = new ArrayList<RefineHolder>();
-//
-//        for (int i = 0; i < ctx.getChildCount(); i++) {
-//            ParseTree child = ctx.getChild(i);
-//            if (child instanceof Refine_stmtContext) {
-//                final String refineTarget = stringFromNode(child);
-//                final RefineHolder refine = new RefineHolder(refineTarget);
-//                for (int j = 0; j < child.getChildCount(); j++) {
-//                    ParseTree refinePom = child.getChild(j);
-//                    if (refinePom instanceof Refine_pomContext) {
-//                        for (int k = 0; k < refinePom.getChildCount(); k++) {
-//                            ParseTree refineStmt = refinePom.getChild(k);
-//                            if (refineStmt instanceof Refine_leaf_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_leaf_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_container_stmtsContext) {
-//                                parseRefine(
-//                                        refine,
-//                                        (Refine_container_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_list_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_list_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_leaf_list_stmtsContext) {
-//                                parseRefine(
-//                                        refine,
-//                                        (Refine_leaf_list_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_choice_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_choice_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_anyxml_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_anyxml_stmtsContext) refineStmt);
-//                            }
-//                        }
-//                    }
-//                }
-//                refines.add(refine);
-//            }
-//        }
-//        return refines;
-//    }
+    /**
+     * Check this base type.
+     *
+     * @param typeName
+     *            base YANG type name
+     * @param moduleName
+     *            name of current module
+     * @param line
+     *            line in module
+     * @throws YangParseException
+     *             if this is one of YANG type which MUST contain additional
+     *             informations in its body
+     */
+    public static void checkMissingBody(final String typeName,
+            final String moduleName, final int line) throws YangParseException {
+        if ("decimal64".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'fraction-digits' statement MUST be present if the type is 'decimal64'.");
+        } else if ("identityref".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'base' statement MUST be present if the type is 'identityref'.");
+        } else if ("leafref".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'path' statement MUST be present if the type is 'leafref'.");
+        } else if("bits".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'bit' statement MUST be present if the type is 'bits'.");
+        } else if("enumeration".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'enum' statement MUST be present if the type is 'enumeration'.");
+        }
+    }
 
     public static RefineHolder parseRefine(Refine_stmtContext child) {
         final String refineTarget = stringFromNode(child);
-        final RefineHolder refine = new RefineHolder(refineTarget);
+        final RefineHolder refine = new RefineHolder(refineTarget, child
+                .getStart().getLine());
         for (int j = 0; j < child.getChildCount(); j++) {
             ParseTree refinePom = child.getChild(j);
             if (refinePom instanceof Refine_pomContext) {
@@ -1249,15 +1256,13 @@ public final class YangModelBuilderUtil {
                         parseRefine(refine,
                                 (Refine_leaf_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_container_stmtsContext) {
-                        parseRefine(
-                                refine,
+                        parseRefine(refine,
                                 (Refine_container_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_list_stmtsContext) {
                         parseRefine(refine,
                                 (Refine_list_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_leaf_list_stmtsContext) {
-                        parseRefine(
-                                refine,
+                        parseRefine(refine,
                                 (Refine_leaf_list_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_choice_stmtsContext) {
                         parseRefine(refine,
index 2c1b9b80d5b72d128a32e92623f9ea19dcb5ec64..301e5332f8d7cc38b1066c4998d9d0135488d02a 100644 (file)
@@ -19,4 +19,25 @@ public class YangParseException extends RuntimeException {
         super(errorMsg, exception);
     }
 
+    public YangParseException(final int line, final String errorMsg) {
+        super("Error on line " + line + ": " + errorMsg);
+    }
+
+    public YangParseException(final int line, final String errorMsg,
+            final Exception exception) {
+        super("Error on line " + line + ": " + errorMsg, exception);
+    }
+
+    public YangParseException(final String moduleName, final int line,
+            final String errorMsg) {
+        super("Error in module '" + moduleName + "' on line " + line + ": "
+                + errorMsg);
+    }
+
+    public YangParseException(final String moduleName, final int line,
+            final String errorMsg, final Exception exception) {
+        super("Error in module '" + moduleName + "' on line " + line + ": "
+                + errorMsg, exception);
+    }
+
 }
index f9e3fc2770c78c18127e4551b85ffdf5d1841b0a..ed8df4652ed1ffca6b0d28ea95c0c1960b5ee41a 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.antlr.v4.runtime.ParserRuleContext;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.opendaylight.controller.antlrv4.code.gen.YangParser.Yang_version_stmtContext;
 import org.opendaylight.controller.yang.model.parser.impl.YangModelParserListenerImpl;
@@ -132,6 +133,10 @@ final class BasicValidations {
             message = parent.equals(name) ? message : ValidationUtil.f(
                     "(In (sub)module:%s) %s", parent, message);
 
+            if(statement instanceof ParserRuleContext) {
+                message = "Error on line "+ ((ParserRuleContext)statement).getStart().getLine() + ": "+ message;
+            }
+
             ValidationUtil.ex(message);
         }
     }
index ffcadf63970bf1743d8532c8083d5ebf15f247e9..bd39da2919cab79c1188968b85358e5baa77450f 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.yang.model.validator;
 
-import static org.hamcrest.core.Is.*;
+import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.*;
+import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.*;
 
 import java.util.ArrayList;
@@ -17,6 +17,7 @@ import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 
+import org.antlr.v4.runtime.Token;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.junit.Before;
 import org.junit.Test;
@@ -159,8 +160,11 @@ public class YangModelValidationTest {
         int thrown = 0;
         for (String id : ids) {
             try {
+                Module_stmtContext module = mock(Module_stmtContext.class);
+                Token token = mock(Token.class);
+                when(module.getStart()).thenReturn(token);
                 BasicValidations.checkIdentifierInternal(
-                        mock(Module_stmtContext.class), id);
+                        module, id);
             } catch (YangValidationException e) {
                 thrown++;
             }
@@ -177,6 +181,9 @@ public class YangModelValidationTest {
                 "mod1");
         addChild(mod1, augument);
 
+        Token token = mock(Token.class);
+        when(augument.getStart()).thenReturn(token);
+
         try {
             valid.enterAugment_stmt(augument);
         } catch (YangValidationException e) {
diff --git a/opendaylight/sal/yang-prototype/pom.xml b/opendaylight/sal/yang-prototype/pom.xml
new file mode 100644 (file)
index 0000000..ab64b88
--- /dev/null
@@ -0,0 +1,214 @@
+<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>yang-prototype</artifactId>
+       <version>0.5-SNAPSHOT</version>
+       <packaging>pom</packaging>
+       <modules>
+               <module>yang</module>
+               <module>code-generator</module>
+       </modules>
+
+       <properties>
+               <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
+               <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
+               <sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>
+               <siteplugin>3.2</siteplugin>
+               <projectinfo>2.6</projectinfo>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <compiler.version>2.3.2</compiler.version>
+               <surefire.version>2.13</surefire.version>
+               <exam.version>3.0.0</exam.version>
+               <url.version>1.5.0</url.version>
+               <enunciate.version>1.26.2</enunciate.version>
+               <sonar.branch>${user.name}-private-view</sonar.branch>
+               <sonar.skippedModules>org.openflow.openflowj,net.sf.jung2</sonar.skippedModules>
+               <logback.version>1.0.9</logback.version>
+               <slf4j.version>1.7.2</slf4j.version>
+       </properties>
+
+       <pluginRepositories>
+               <pluginRepository>
+                       <id>central2</id>
+                       <name>central2</name>
+                       <url>${nexusproxy}/repositories/central2/</url>
+               </pluginRepository>
+       </pluginRepositories>
+
+
+       <repositories>
+               <!-- EBR release -->
+               <!-- http://repository.springsource.com/maven/bundles/release -->
+               <repository>
+                       <id>ebr-bundles-release</id>
+                       <name>ebr-bundles-release</name>
+                       <url>${nexusproxy}/repositories/ebr-bundles-release/</url>
+               </repository>
+               <!-- EBR external -->
+               <!-- http://repository.springsource.com/maven/bundles/external -->
+               <repository>
+                       <id>ebr-bundles-external</id>
+                       <name>ebr-bundles-external</name>
+                       <url>${nexusproxy}/repositories/ebr-bundles-external/</url>
+               </repository>
+               <!-- Maven repo2 mirror -->
+               <!-- http://repo2.maven.org/maven2 -->
+               <repository>
+                       <id>central2</id>
+                       <name>central2</name>
+                       <url>${nexusproxy}/repositories/central2/</url>
+               </repository>
+               <!-- Maven repo1 mirror -->
+               <!-- http://repo1.maven.org/maven2 -->
+               <repository>
+                       <id>central</id>
+                       <name>central</name>
+                       <url>${nexusproxy}/repositories/central/</url>
+               </repository>
+               <!-- Pax mirror -->
+               <!-- https://oss.sonatype.org/content/repositories/ops4j-releases -->
+               <repository>
+                       <id>ops4j-releases</id>
+                       <name>ops4j-releases</name>
+                       <url>${nexusproxy}/repositories/ops4j-releases/</url>
+               </repository>
+               <!-- Third Packages hosted in local maven because not available in other 
+                       places -->
+               <repository>
+                       <id>thirdparty</id>
+                       <name>thirdparty</name>
+                       <url>${nexusproxy}/repositories/thirdparty/</url>
+               </repository>
+               <!-- Jboss mirror -->
+               <!-- https://repository.jboss.org/nexus/content/repositories/releases -->
+               <repository>
+                       <id>jboss.releases</id>
+                       <name>jboss.releases</name>
+                       <url>${nexusproxy}/repositories/jboss.releases/</url>
+               </repository>
+               <!-- OpenDayLight Released artifact -->
+               <repository>
+                       <id>opendaylight-release</id>
+                       <name>opendaylight-release</name>
+                       <url>${nexusproxy}/repositories/opendaylight.release/</url>
+               </repository>
+               <!-- OpenDayLight Snapshot artifact -->
+               <repository>
+                       <id>opendaylight-snapshot</id>
+                       <name>opendaylight-snapshot</name>
+                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+               </repository>
+       </repositories>
+       <distributionManagement>
+               <!-- OpenDayLight Released artifact -->
+               <repository>
+                       <id>opendaylight-release</id>
+                       <url>${nexusproxy}/repositories/opendaylight.release/</url>
+               </repository>
+               <!-- OpenDayLight Snapshot artifact -->
+               <snapshotRepository>
+                       <id>opendaylight-snapshot</id>
+                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+               </snapshotRepository>
+               <!-- Site deployment -->
+               <!-- site>
+                       <id>website</id>
+                       <url>${sitedeploy}</url>
+               </site -->
+       </distributionManagement>
+
+
+       <dependencyManagement>
+               <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>
+       </dependencyManagement>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>${compiler.version}</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>
+       <profiles>
+               <profile>
+                       <id>viewbuild</id>
+                       <activation>
+                               <activeByDefault>true</activeByDefault>
+                       </activation>
+                       <properties>
+                               <build.suffix>${project.version}</build.suffix>
+                       </properties>
+               </profile>
+               <profile>
+                       <id>jenkins</id>
+                       <activation>
+                               <property>
+                                       <name>BUILDSUFFIX</name>
+                               </property>
+                       </activation>
+                       <properties>
+                               <build.suffix>${BUILDSUFFIX}</build.suffix>
+                       </properties>
+               </profile>
+       </profiles>
+</project>
index 68134d4ac81db09199ce682ae109a39d8eb81d9d..0ac2bbe569b010475810db978d5685de9ebe1d75 100644 (file)
@@ -1,84 +1,94 @@
-<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>yang</artifactId>
-    <version>1.0</version>
-    <packaging>pom</packaging>
-    <modules>
-       <module>yang-common</module>
-        <module>yang-data-api</module>
-        <module>yang-data-util</module>
-        <module>yang-model-api</module>
-        <module>yang-model-util</module>
-        <module>yang-binding</module>
-    </modules>
-    <dependencies>
+<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>
+       <parent>
+               <groupId>org.opendaylight.controller</groupId>
+               <artifactId>yang-prototype</artifactId>
+               <version>0.5-SNAPSHOT</version>
+       </parent>
 
-        <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>
+       <groupId>org.opendaylight.controller</groupId>
+       <artifactId>yang</artifactId>
+       <version>0.5-SNAPSHOT</version>
+       <packaging>pom</packaging>
+       <modules>
+               <module>yang-common</module>
+               <module>yang-data-api</module>
+               <module>yang-data-util</module>
+               <module>yang-model-api</module>
+               <module>yang-model-util</module>
+               <module>yang-binding</module>
+               <module>../code-generator/yang-model-parser-api</module>
+               <module>../code-generator/yang-model-parser-impl</module>
+               <module>../code-generator/maven-yang</module>
+               <module>../code-generator/maven-yang-plugin</module>
+               <module>../code-generator/maven-yang-plugin-it</module>
+
+       </modules>
+       <dependencies>
+
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+                       <optional>true</optional>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-simple</artifactId>
+               </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 3ddd4b37fcafb30cdd6615652c56cfb14c1c33b9..e679adeb11d598635e456f7111f9225204577229 100644 (file)
@@ -3,7 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-binding</artifactId>\r
 </project>
\ No newline at end of file
index b072ab3c1ba913e3ef13e6defbf48f2da2bea514..f296579fcc95936dc0897d1f3254ec2688913480 100644 (file)
@@ -3,7 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-common</artifactId>\r
 </project>
\ No newline at end of file
index 358cabd2d5f74961b7a69f92f53ad7266d3e1183..b38c21cd79612a825f3365cc75ce76439b52041a 100644 (file)
@@ -3,7 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-data-api</artifactId>\r
   \r
@@ -12,7 +12,7 @@
        <dependency>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>yang-common</artifactId>\r
-               <version>1.0</version>\r
+               <version>${project.version}</version>\r
        </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index 2595d5d8a7b32292c0cbec19a5f514195347e6a5..7606f07484a051e0377750d027739af02019e30a 100644 (file)
@@ -3,14 +3,14 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-data-util</artifactId>\r
   <dependencies>\r
        <dependency>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>yang-data-api</artifactId>\r
-               <version>1.0</version>\r
+               <version>0.5-SNAPSHOT</version>\r
        </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index bf1a4ce76fa1b6f8c75fd5b02a3a60b47abf76fd..24bbdd5e35d0dcb36c228157aa91abb2994c617a 100644 (file)
@@ -3,7 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-model-api</artifactId>\r
   \r
@@ -11,7 +11,7 @@
        <dependency>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>yang-common</artifactId>\r
-               <version>1.0</version>\r
+               <version>0.5-SNAPSHOT</version>\r
        </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index 47a14e12ff5c16d5e4281b6cfc4f85668de5ea37..9b56180deb37cdc9bd732f5e24c49a11c2b61a2c 100644 (file)
@@ -3,14 +3,15 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>1.0</version>\r
+    <version>0.5-SNAPSHOT</version>\r
+    <relativePath>../../yang/pom.xml</relativePath>\r
   </parent>\r
   <artifactId>yang-model-util</artifactId>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>yang-model-api</artifactId>\r
-          <version>1.0</version>\r
+          <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
   </dependencies>\r
 </project>\r
index 6d41321bfd0cb5042c150f3f77779e9f68cc344a..e4d176c12b1e62d45e4eb94e6ffe87e332c005a8 100644 (file)
@@ -73,8 +73,6 @@ public class YangTypesConverter {
             type = new StringType(actualPath, namespace, revision);\r
         } else if("binary".equals(typeName)) {\r
             type = new BinaryType(actualPath, namespace, revision);\r
-        } else if("bits".equals(typeName)) {\r
-            type = new BitsType(actualPath, namespace, revision);\r
         } else if("boolean".equals(typeName)) {\r
             type = new BooleanType(actualPath, namespace, revision);\r
         } else if("empty".equals(typeName)) {\r
index aaf1a183cad4e0564383bbc451c033f96fc849c5..a7583c8ab383eea5b069086f913b8004cf0bf445 100644 (file)
@@ -91,7 +91,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 cabcf8d972bcbef0853bb13d6e08375cf61e0c7a..94a6ae16c2b6abf10ded91fd16cf488fd81656dc 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>    
@@ -84,7 +84,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 7201b92b05fe81b1706234c516b63a6815ebb73a..342d8df8c45c384471eda8a7c26c8b304391e533 100644 (file)
@@ -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>    
   </dependencies>
 </project>
index 8b0676ba8391995bc073d2e15b4b3bc95631038b..2991afc1a413ea345b9b20e6491fea39d6e068e8 100644 (file)
@@ -54,7 +54,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 67329ba5e09f3b5ca65fc209d458d6bdc897baf2..5c5b71dfb060b98718c785225a1a199b22494789 100644 (file)
@@ -41,7 +41,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 98bf15d274a6991bb90aca18961f1744c829d094..fdc2efa5c207baf25b7bfe8ca90ae24ce53768c7 100644 (file)
@@ -16,7 +16,7 @@
     <!-- Sonar properties using jacoco to retrieve integration test results -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-    <sonar.jacoco.Reportpath>target/jacobo.exec</sonar.jacoco.Reportpath>
+    <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
     <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
@@ -88,7 +88,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>
       <version>0.4.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>
index 397480e1e60fbd61df3181af6c5483d3459e2644..69c686c708563b2db9da3a490fcc38daf7f84778 100644 (file)
@@ -21,7 +21,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 fa96d5304e0c8c603c27db1bb2b188a3787e7862..251517319822f930c0d4e71eb1819c84fd574645 100644 (file)
@@ -82,7 +82,7 @@ public class StatisticsManagerIntegrationTest {
                 mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
                 // List all the bundles on which the test case depends
                 mavenBundle("org.opendaylight.controller", "sal",
-                        "0.4.0-SNAPSHOT"),
+                        "0.5.0-SNAPSHOT"),
                 mavenBundle("org.opendaylight.controller",
                         "sal.implementation", "0.4.0-SNAPSHOT"),
                 mavenBundle("org.opendaylight.controller", "statisticsmanager",
index d57a2d4a01d69d493d5b7ed150e2987d4cb3d67b..44746e565393bd333dcbb723b20dc393ee1854ef 100644 (file)
@@ -98,7 +98,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 5e9eb5f994c19f0faa6ba175281cd6b481f0fb5f..6f7a7ea13c0ed1954dd44a9ff4602fcb4e567ac3 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>
diff --git a/opendaylight/switchmanager/integrationtest/pom.xml b/opendaylight/switchmanager/integrationtest/pom.xml
new file mode 100644 (file)
index 0000000..bdf00f4
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>commons.opendaylight</artifactId>
+    <version>1.4.0-SNAPSHOT</version>
+    <relativePath>../../../opendaylight/commons/opendaylight</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>switchmanager.integrationtest</artifactId>
+  <version>0.4.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>switchmanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+      <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>switchmanager.implementation</artifactId>
+         <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+     <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
+     <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>containermanager</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>containermanager.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>clustering.services</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>clustering.stub</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>configuration</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>configuration.implementation</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>protocol_plugins.stub</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+  <properties>
+    <!-- Sonar jacoco plugin to get integration test coverage info -->
+    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+    <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.language>java</sonar.language>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>0.5.3.201107060350</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <version>0.5.3.201107060350</version>
+        <configuration>
+          <destFile>../implementation/target/jacoco-it.exec</destFile>
+          <includes>org.opendaylight.controller.*</includes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <configuration>
+              <skip>true</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java b/opendaylight/switchmanager/integrationtest/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchmanagerIntegrationTest.java
new file mode 100644 (file)
index 0000000..450a717
--- /dev/null
@@ -0,0 +1,230 @@
+
+/*
+ * 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.switchmanager.internal;
+
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Bundle;
+import javax.inject.Inject;
+
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.sal.core.Actions;
+import org.opendaylight.controller.sal.core.Bandwidth;
+import org.opendaylight.controller.sal.core.Buffers;
+import org.opendaylight.controller.sal.core.Capabilities;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.State;
+import org.opendaylight.controller.sal.core.TimeStamp;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.Capabilities.CapabilitiesType;
+import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
+import org.opendaylight.controller.switchmanager.*;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
+import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
+import org.opendaylight.controller.switchmanager.ISwitchManager;
+
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
+import org.osgi.framework.BundleContext;
+import static org.junit.Assert.*;
+import org.ops4j.pax.exam.junit.Configuration;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+public class SwitchmanagerIntegrationTest {
+    private Logger log = LoggerFactory
+            .getLogger(SwitchmanagerIntegrationTest.class);
+    // get the OSGI bundle context
+    @Inject
+    private BundleContext bc;
+
+    private ISwitchManager switchManager = null;
+
+    // Configure the OSGi container
+    @Configuration
+    public Option[] config() {
+        return options(
+                systemProperty("logback.configurationFile").value(
+                        "file:" + PathUtils.getBaseDir()
+                                + "/src/test/resources/logback.xml"),
+                // To start OSGi console for inspection remotely
+                systemProperty("osgi.console").value("2401"),
+                // Set the systemPackages (used by clustering)
+                systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
+                // List framework bundles
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
+                        "1.0.0.v20120522-1841"),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
+                        "1.0.400.v20120522-2049"),
+                mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
+                        "3.3.100.v20120522-1822"),
+                mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
+                        "1.4.0.v20120522-1841"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
+                        "0.8.0.v201108120515"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
+                        "0.8.0.v201108120515"),
+                mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
+                        "0.8.0.v201110170705"),
+                // List logger bundles
+                mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
+                mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
+                mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
+                mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
+
+                mavenBundle("org.opendaylight.controller", "switchmanager",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "switchmanager.implementation",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "sal",
+                        "0.5.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "sal.implementation",
+                        "0.4.0-SNAPSHOT"),
+               mavenBundle("org.opendaylight.controller", "containermanager",
+                        "0.4.0-SNAPSHOT"),
+               mavenBundle("org.opendaylight.controller", "containermanager.implementation",
+                       "0.4.0-SNAPSHOT"),
+               mavenBundle("org.opendaylight.controller", "clustering.services",
+                       "0.4.0-SNAPSHOT"),
+               mavenBundle("org.opendaylight.controller", "clustering.stub",
+                       "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "configuration",
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller", "configuration.implementation", 
+                        "0.4.0-SNAPSHOT"),
+                mavenBundle("org.opendaylight.controller",
+                        "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+                mavenBundle("org.jboss.spec.javax.transaction",
+                        "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
+                mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+                mavenBundle("org.apache.felix",
+                        "org.apache.felix.dependencymanager", "3.1.0"),
+                junitBundles());
+    }
+
+    private String stateToString(int state) {
+        switch (state) {
+        case Bundle.ACTIVE:
+            return "ACTIVE";
+        case Bundle.INSTALLED:
+            return "INSTALLED";
+        case Bundle.RESOLVED:
+            return "RESOLVED";
+        case Bundle.UNINSTALLED:
+            return "UNINSTALLED";
+        default:
+            return "Not CONVERTED";
+        }
+    }
+
+    @Before
+    public void areWeReady() {
+        assertNotNull(bc);
+        boolean debugit = false;
+        Bundle b[] = bc.getBundles();
+        for (int i = 0; i < b.length; i++) {
+            int state = b[i].getState();
+            if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
+                log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+                        + stateToString(state));
+                debugit = true;
+            }
+        }
+        if (debugit) {
+            log.debug("Do some debugging because some bundle is "
+                    + "unresolved");
+        }
+
+        // Assert if true, if false we are good to go!
+        assertFalse(debugit);
+
+         // Now lets create a hosttracker for testing purpose
+         ServiceReference s = bc
+             .getServiceReference(ISwitchManager.class.getName());
+         if (s != null) {
+                 this.switchManager = (ISwitchManager)bc.getService(s);
+         }
+
+         // If StatisticsManager is null, cannot run tests.
+         assertNotNull(this.switchManager);
+    }
+
+
+    @Test
+    public void testNodeProp() throws UnknownHostException {
+        assertNotNull(this.switchManager);
+
+        Node node = NodeCreator.createOFNode((long)2);
+        Map<String, Property> propMap = this.switchManager.getNodeProps(node);
+        Assert.assertFalse(propMap.isEmpty());
+
+        Assert.assertTrue(this.switchManager.getNodeProp
+                (node, Capabilities.CapabilitiesPropName)
+                .equals(new Capabilities((int)3)));
+        Assert.assertTrue(this.switchManager.getNodeProp
+                (node, Actions.ActionsPropName)
+                .equals(new Actions((int)2)));
+        Assert.assertTrue(this.switchManager.getNodeProp
+                (node, Buffers.BuffersPropName)
+                .equals(new Buffers((int)1)));
+        Assert.assertTrue(this.switchManager.getNodeProp
+                (node, TimeStamp.TimeStampPropName)
+                .equals(new TimeStamp(100000L, "connectedSince")));
+    }
+
+    @Test
+    public void testNodeConnectorProp() throws UnknownHostException {
+        assertNotNull(this.switchManager);
+
+        NodeConnector nc = NodeConnectorCreator.createOFNodeConnector
+                ((short)2, NodeCreator.createOFNode((long)3));
+        Map<String, Property> propMap = this.switchManager.getNodeConnectorProps(nc);
+        Assert.assertFalse(propMap.isEmpty());
+
+        Assert.assertTrue(this.switchManager.getNodeConnectorProp
+                (nc, Capabilities.CapabilitiesPropName)
+                .equals(new Capabilities
+                        (CapabilitiesType.FLOW_STATS_CAPABILITY.getValue())));
+        Assert.assertTrue(this.switchManager.getNodeConnectorProp
+                (nc, Bandwidth.BandwidthPropName)
+                .equals(new Bandwidth (Bandwidth.BW1Gbps)));
+        Assert.assertTrue(this.switchManager.getNodeConnectorProp
+                (nc, State.StatePropName)
+                .equals(new State (State.EDGE_UP)));
+    }
+}
index dd7ad2d6f033228da3e40a8fdce3bd7d51a07cca..29a060f477e9905256970f0cd7be78c68002c253 100755 (executable)
@@ -54,7 +54,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 0eb7bdbc5c3ac57bc44f8168189456614e8eff98..e8d0d416e5dd6dd4764a2b7e7e19bc73ca4fdd1c 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -12,6 +11,7 @@ package org.opendaylight.controller.topologymanager.internal;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.ObjectInputStream;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.EnumSet;
@@ -20,6 +20,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -44,6 +45,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
 import org.opendaylight.controller.sal.topology.ITopologyService;
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
 import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.IObjectReader;
@@ -84,37 +86,36 @@ public class TopologyManagerImpl implements ITopologyManager,
     private static String ROOT = GlobalConstants.STARTUPHOME.toString();
     private String userLinksFileName = null;
     private ConcurrentMap<String, TopologyUserLinkConfig> userLinks;
-    
+
     void nonClusterObjectCreate() {
-       edgesDB = new ConcurrentHashMap<Edge, Set<Property>>();
-       hostsDB = new ConcurrentHashMap<NodeConnector, ImmutablePair<Host, Set<Property>>>();
-       userLinks = new ConcurrentHashMap<String, TopologyUserLinkConfig>();
-       nodeConnectorsDB = new ConcurrentHashMap<NodeConnector, Set<Property>>();
+        edgesDB = new ConcurrentHashMap<Edge, Set<Property>>();
+        hostsDB = new ConcurrentHashMap<NodeConnector, ImmutablePair<Host, Set<Property>>>();
+        userLinks = new ConcurrentHashMap<String, TopologyUserLinkConfig>();
+        nodeConnectorsDB = new ConcurrentHashMap<NodeConnector, Set<Property>>();
     }
-    
 
     void setTopologyManagerAware(ITopologyManagerAware s) {
         if (this.topologyManagerAware != null) {
-               log.debug("Adding ITopologyManagerAware: {}", s);
+            log.debug("Adding ITopologyManagerAware: {}", s);
             this.topologyManagerAware.add(s);
         }
     }
 
     void unsetTopologyManagerAware(ITopologyManagerAware s) {
         if (this.topologyManagerAware != null) {
-               log.debug("Removing ITopologyManagerAware: {}", s);
+            log.debug("Removing ITopologyManagerAware: {}", s);
             this.topologyManagerAware.remove(s);
         }
     }
 
     void setTopoService(ITopologyService s) {
-       log.debug("Adding ITopologyService: {}", s);
+        log.debug("Adding ITopologyService: {}", s);
         this.topoService = s;
     }
 
     void unsetTopoService(ITopologyService s) {
         if (this.topoService == s) {
-               log.debug("Removing ITopologyService: {}", s);
+            log.debug("Removing ITopologyService: {}", s);
             this.topoService = null;
         }
     }
@@ -134,7 +135,7 @@ public class TopologyManagerImpl implements ITopologyManager,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     *
+     * 
      */
     void init(Component c) {
         String containerName = null;
@@ -200,9 +201,9 @@ public class TopologyManagerImpl implements ITopologyManager,
     }
 
     /**
-     * Function called after the topology manager has registered the
-     * service in OSGi service registry.
-     *
+     * Function called after the topology manager has registered the service in
+     * OSGi service registry.
+     * 
      */
     void started() {
         // SollicitRefresh MUST be called here else if called at init
@@ -212,10 +213,10 @@ public class TopologyManagerImpl implements ITopologyManager,
     }
 
     /**
-     * Function called by the dependency manager when at least one
-     * dependency become unsatisfied or when the component is shutting
-     * down because for example bundle is being stopped.
-     *
+     * Function called by the dependency manager when at least one dependency
+     * become unsatisfied or when the component is shutting down because for
+     * example bundle is being stopped.
+     * 
      */
     void destroy() {
         if (this.clusterContainerService == null) {
@@ -255,18 +256,18 @@ public class TopologyManagerImpl implements ITopologyManager,
         // Publish the save config event to the cluster nodes
         /**
          * Get the CLUSTERING SERVICES WORKING BEFORE TRYING THIS
-
-        configSaveEvent.put(new Date().getTime(), SAVE);
+         * 
+         * configSaveEvent.put(new Date().getTime(), SAVE);
          */
         return saveConfigInternal();
     }
 
     public Status saveConfigInternal() {
-       Status retS;
+        Status retS;
         ObjectWriter objWriter = new ObjectWriter();
 
-        retS = objWriter.write(
-                new ConcurrentHashMap<String, TopologyUserLinkConfig>(
+        retS = objWriter
+                .write(new ConcurrentHashMap<String, TopologyUserLinkConfig>(
                         userLinks), userLinksFileName);
 
         if (retS.isSuccess()) {
@@ -324,11 +325,11 @@ public class TopologyManagerImpl implements ITopologyManager,
     }
 
     /**
-     * The Map returned is a copy of the current topology hence if the
-     * topology changes the copy doesn't
-     *
-     * @return A Map representing the current topology expressed as
-     * edges of the network
+     * The Map returned is a copy of the current topology hence if the topology
+     * changes the copy doesn't
+     * 
+     * @return A Map representing the current topology expressed as edges of the
+     *         network
      */
     @Override
     public Map<Edge, Set<Property>> getEdges() {
@@ -340,8 +341,8 @@ public class TopologyManagerImpl implements ITopologyManager,
         for (Edge key : this.edgesDB.keySet()) {
             // Sets of props are copied because the composition of
             // those properties could change with time
-            HashSet<Property> prop = new HashSet<Property>(this.edgesDB
-                    .get(key));
+            HashSet<Property> prop = new HashSet<Property>(
+                    this.edgesDB.get(key));
             // We can simply reuse the key because the object is
             // immutable so doesn't really matter that we are
             // referencing the only owned by a different table, the
@@ -354,7 +355,8 @@ public class TopologyManagerImpl implements ITopologyManager,
 
     // TODO remove with spring-dm removal
     /**
-     * @param set the topologyAware to set
+     * @param set
+     *            the topologyAware to set
      */
     public void setTopologyAware(Set<Object> set) {
         for (Object s : set) {
@@ -411,7 +413,7 @@ public class TopologyManagerImpl implements ITopologyManager,
         if (this.hostsDB == null) {
             return;
         }
-        
+
         switch (t) {
         case ADDED:
         case CHANGED:
@@ -432,8 +434,8 @@ public class TopologyManagerImpl implements ITopologyManager,
         }
     }
 
-    @Override
-    public void edgeUpdate(Edge e, UpdateType type, Set<Property> props) {
+    private TopoEdgeUpdate edgeUpdate(Edge e, UpdateType type,
+            Set<Property> props) {
         switch (type) {
         case ADDED:
             // Make sure the props are non-null
@@ -444,7 +446,7 @@ public class TopologyManagerImpl implements ITopologyManager,
                 props = (Set<Property>) new HashSet(props);
             }
 
-            // Now make sure thre is the creation timestamp for the
+            // Now make sure there is the creation timestamp for the
             // edge, if not there timestamp with the first update
             boolean found_create = false;
             for (Property prop : props) {
@@ -507,7 +509,7 @@ public class TopologyManagerImpl implements ITopologyManager,
                 }
             }
 
-            // Now lest make sure new properties are non-null
+            // Now lets make sure new properties are non-null
             // Make sure the props are non-null
             if (props == null) {
                 props = (Set<Property>) new HashSet();
@@ -538,37 +540,52 @@ public class TopologyManagerImpl implements ITopologyManager,
             log.trace("Edge {}  {}", e.toString(), type.name());
             break;
         }
+        return new TopoEdgeUpdate(e, props, type);
+    }
+
+    @Override
+    public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
+        List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
+        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();
+            TopoEdgeUpdate teu = edgeUpdate(e, type, p);
+            teuList.add(teu);
+        }
 
         // Now update the listeners
         for (ITopologyManagerAware s : this.topologyManagerAware) {
             try {
-                s.edgeUpdate(e, type, props);
+                s.edgeUpdate(teuList);
             } catch (Exception exc) {
                 log.error("Exception on callback", exc);
             }
         }
+
     }
 
     private Edge getReverseLinkTuple(TopologyUserLinkConfig link) {
-               TopologyUserLinkConfig rLink = new TopologyUserLinkConfig(
-                               link.getName(), link.getDstNodeIDType(), link.getDstSwitchId(),
-                               link.getDstNodeConnectorIDType(), link.getDstPort(),
-                               link.getSrcNodeIDType(), link.getSrcSwitchId(),
-                               link.getSrcNodeConnectorIDType(), link.getSrcPort());
+        TopologyUserLinkConfig rLink = new TopologyUserLinkConfig(
+                link.getName(), link.getDstNodeIDType(), link.getDstSwitchId(),
+                link.getDstNodeConnectorIDType(), link.getDstPort(),
+                link.getSrcNodeIDType(), link.getSrcSwitchId(),
+                link.getSrcNodeConnectorIDType(), link.getSrcPort());
         return getLinkTuple(rLink);
     }
 
     private Edge getLinkTuple(TopologyUserLinkConfig link) {
         Edge linkTuple = null;
 
-        // if atleast 1 link exists for the srcPort and atleast 1 link exists for the dstPort
+        // if atleast 1 link exists for the srcPort and atleast 1 link exists
+        // for the dstPort
         // that makes it ineligible for the Manual link addition
         // This is just an extra protection to avoid mis-programming.
         boolean srcLinkExists = false;
         boolean dstLinkExists = false;
-        //TODO check a way to validate the port with inventory services
-        //if (srcSw.getPorts().contains(srcPort) &&
-        //dstSw.getPorts().contains(srcPort) &&
+        // TODO check a way to validate the port with inventory services
+        // if (srcSw.getPorts().contains(srcPort) &&
+        // dstSw.getPorts().contains(srcPort) &&
         if (!srcLinkExists && !dstLinkExists) {
             Node sNode = null;
             Node dNode = null;
@@ -580,44 +597,44 @@ public class TopologyManagerImpl implements ITopologyManager,
             String dstNodeIDType = link.getDstNodeIDType();
             String dstNodeConnectorIDType = link.getDstNodeConnectorIDType();
             try {
-               if (srcNodeIDType.equals(NodeIDType.OPENFLOW)) {
+                if (srcNodeIDType.equals(NodeIDType.OPENFLOW)) {
                     sNode = new Node(srcNodeIDType, link.getSrcSwitchIDLong());
-               } else {
-                    sNode = new Node(srcNodeIDType, link.getSrcSwitchId());                            
-               }
+                } else {
+                    sNode = new Node(srcNodeIDType, link.getSrcSwitchId());
+                }
 
-               if (dstNodeIDType.equals(NodeIDType.OPENFLOW)) {
+                if (dstNodeIDType.equals(NodeIDType.OPENFLOW)) {
                     dNode = new Node(dstNodeIDType, link.getDstSwitchIDLong());
-               } else {
-                    dNode = new Node(dstNodeIDType, link.getDstSwitchId());                            
-               }
-       
-               if (srcNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
+                } else {
+                    dNode = new Node(dstNodeIDType, link.getDstSwitchId());
+                }
+
+                if (srcNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
                     Short srcPort = Short.valueOf((short) 0);
-                               if (!link.isSrcPortByName()) {
-                                       srcPort = Short.parseShort(link.getSrcPort());
-                               }
-                                       sPort = new NodeConnector(srcNodeConnectorIDType, 
-                                                       srcPort, sNode);
-               } else {
-                               sPort = new NodeConnector(srcNodeConnectorIDType,
-                                               link.getSrcPort(), sNode);                      
-               }
-
-               if (dstNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
+                    if (!link.isSrcPortByName()) {
+                        srcPort = Short.parseShort(link.getSrcPort());
+                    }
+                    sPort = new NodeConnector(srcNodeConnectorIDType, srcPort,
+                            sNode);
+                } else {
+                    sPort = new NodeConnector(srcNodeConnectorIDType,
+                            link.getSrcPort(), sNode);
+                }
+
+                if (dstNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
                     Short dstPort = Short.valueOf((short) 0);
-                               if (!link.isDstPortByName()) {
-                           dstPort = Short.parseShort(link.getDstPort());
-                       }
-                                       dPort = new NodeConnector(dstNodeConnectorIDType,
-                                                       dstPort, dNode);
-               } else {
-                                       dPort = new NodeConnector(dstNodeConnectorIDType,
-                                                       link.getDstPort(), dNode);
-               }
+                    if (!link.isDstPortByName()) {
+                        dstPort = Short.parseShort(link.getDstPort());
+                    }
+                    dPort = new NodeConnector(dstNodeConnectorIDType, dstPort,
+                            dNode);
+                } else {
+                    dPort = new NodeConnector(dstNodeConnectorIDType,
+                            link.getDstPort(), dNode);
+                }
                 linkTuple = new Edge(sPort, dPort);
             } catch (ConstructionException cex) {
-               log.warn("Caught exception ", cex);
+                log.warn("Caught exception ", cex);
             }
             return linkTuple;
         }
@@ -636,12 +653,12 @@ public class TopologyManagerImpl implements ITopologyManager,
     @Override
     public Status addUserLink(TopologyUserLinkConfig link) {
         if (!link.isValid()) {
-            return new Status(StatusCode.BADREQUEST, 
-                       "Configuration Invalid. Please check the parameters");
+            return new Status(StatusCode.BADREQUEST,
+                    "Configuration Invalid. Please check the parameters");
         }
         if (userLinks.get(link.getName()) != null) {
-            return new Status(StatusCode.CONFLICT, 
-                       "Link with name : " + link.getName()
+            return new Status(StatusCode.CONFLICT, "Link with name : "
+                    + link.getName()
                     + " already exists. Please use another name");
         }
         if (userLinks.containsValue(link)) {
@@ -658,8 +675,8 @@ public class TopologyManagerImpl implements ITopologyManager,
                 link.setStatus(TopologyUserLinkConfig.STATUS.SUCCESS);
             } catch (Exception e) {
                 return new Status(StatusCode.INTERNALERROR,
-                               "Exception while adding custom link : " + 
-                                               e.getMessage());
+                        "Exception while adding custom link : "
+                                + e.getMessage());
             }
         }
         return new Status(StatusCode.SUCCESS, null);
@@ -668,8 +685,8 @@ public class TopologyManagerImpl implements ITopologyManager,
     @Override
     public Status deleteUserLink(String linkName) {
         if (linkName == null) {
-            return new Status(StatusCode.BADREQUEST, 
-                       "A valid linkName is required to Delete a link");
+            return new Status(StatusCode.BADREQUEST,
+                    "A valid linkName is required to Delete a link");
         }
 
         TopologyUserLinkConfig link = userLinks.get(linkName);
@@ -678,19 +695,19 @@ public class TopologyManagerImpl implements ITopologyManager,
         userLinks.remove(linkName);
         if (linkTuple != null) {
             try {
-                //oneTopology.deleteUserConfiguredLink(linkTuple);
+                // oneTopology.deleteUserConfiguredLink(linkTuple);
             } catch (Exception e) {
-                log
-                        .warn("Harmless : Exception while Deleting User Configured link {} {}",
-                                link, e.toString());
+                log.warn(
+                        "Harmless : Exception while Deleting User Configured link {} {}",
+                        link, e.toString());
             }
             linkTuple = getReverseLinkTuple(link);
             try {
-                //oneTopology.deleteUserConfiguredLink(linkTuple);
+                // oneTopology.deleteUserConfiguredLink(linkTuple);
             } catch (Exception e) {
-                log
-                        .warn("Harmless : Exception while Deleting User Configured Reverse link {} {}",
-                                link, e.toString());
+                log.warn(
+                        "Harmless : Exception while Deleting User Configured Reverse link {} {}",
+                        link, e.toString());
             }
         }
         return new Status(StatusCode.SUCCESS, null);
@@ -707,7 +724,7 @@ public class TopologyManagerImpl implements ITopologyManager,
     public String getHelp() {
         StringBuffer help = new StringBuffer();
         help.append("---Topology Manager---\n");
-               help.append("\t addTopo name <NodeIDType> <src-sw-id> <NodeConnectorIDType> <port-number> <NodeIDType> <dst-sw-id> <NodeConnectorIDType> <port-number>\n");
+        help.append("\t addTopo name <NodeIDType> <src-sw-id> <NodeConnectorIDType> <port-number> <NodeIDType> <dst-sw-id> <NodeConnectorIDType> <port-number>\n");
         help.append("\t delTopo name\n");
         help.append("\t printTopo\n");
         help.append("\t printNodeEdges\n");
@@ -716,11 +733,11 @@ public class TopologyManagerImpl implements ITopologyManager,
 
     public void _printTopo(CommandInterpreter ci) {
         for (String name : this.userLinks.keySet()) {
-               TopologyUserLinkConfig linkConfig = userLinks.get(name);
+            TopologyUserLinkConfig linkConfig = userLinks.get(name);
             ci.println("Name : " + name);
             ci.println(linkConfig);
-            ci.println("Edge " +  getLinkTuple(linkConfig));
-            ci.println("Reverse Edge " +  getReverseLinkTuple(linkConfig));
+            ci.println("Edge " + getLinkTuple(linkConfig));
+            ci.println("Reverse Edge " + getReverseLinkTuple(linkConfig));
         }
     }
 
@@ -778,9 +795,9 @@ public class TopologyManagerImpl implements ITopologyManager,
             ci.println("Null destination port number");
             return;
         }
-               TopologyUserLinkConfig config = new TopologyUserLinkConfig(name,
-                               srcNodeIDType, dpid, srcNodeConnectorIDType, port,
-                               dstNodeIDType, ddpid, dstNodeConnectorIDType, dport);
+        TopologyUserLinkConfig config = new TopologyUserLinkConfig(name,
+                srcNodeIDType, dpid, srcNodeConnectorIDType, port,
+                dstNodeIDType, ddpid, dstNodeConnectorIDType, dport);
         ci.println(this.addUserLink(config));
     }
 
@@ -794,23 +811,23 @@ public class TopologyManagerImpl implements ITopologyManager,
     }
 
     public void _printNodeEdges(CommandInterpreter ci) {
-       Map<Node, Set<Edge>> nodeEdges = getNodeEdges();        
-       if (nodeEdges == null) {
-               return;
-       }
-       Set<Node> nodeSet = nodeEdges.keySet();
-       if (nodeSet == null) {
-               return;
-       }
+        Map<Node, Set<Edge>> nodeEdges = getNodeEdges();
+        if (nodeEdges == null) {
+            return;
+        }
+        Set<Node> nodeSet = nodeEdges.keySet();
+        if (nodeSet == null) {
+            return;
+        }
         ci.println("        Node                                         Edge");
-       for (Node node : nodeSet) {
-               Set<Edge> edgeSet = nodeEdges.get(node);
-               if (edgeSet == null) {
-                       continue;
-               }
-               for (Edge edge : edgeSet) {
-                       ci.println(node + "             " + edge);
-               }
+        for (Node node : nodeSet) {
+            Set<Edge> edgeSet = nodeEdges.get(node);
+            if (edgeSet == null) {
+                continue;
+            }
+            for (Edge edge : edgeSet) {
+                ci.println(node + "             " + edge);
+            }
         }
     }
 
index c2e3df9d00f53d4853f2324f8f946fa92def309d..c176cb2cf3e50ba3b878e5923efeafe108059851 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -11,8 +10,10 @@ package org.opendaylight.controller.topologymanager.internal;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
@@ -31,361 +32,420 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.State;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.packet.address.EthernetAddress;
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
 import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
 import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig;
 
-public class TopologyManagerImplTest { 
-       
-       /*
-        * Sets the node, edges and properties for edges here:
-        * Edge <SwitchId : NodeConnectorId> :
-        * <1:1>--><11:11>; <1:2>--><11:12>; 
-        * <3:3>--><13:13>; <3:4>--><13:14>;
-        * <5:5>--><15:15>; <5:6>--><15:16>;
-        * Method used by two tests: testGetNodeEdges and testGetEdges
-        * @param topoManagerImpl
-        * @throws ConstructionException
-        */
-       public void setNodeEdges(TopologyManagerImpl topoManagerImpl) throws ConstructionException {
-               topoManagerImpl.nonClusterObjectCreate();
-               
-               State state;
-               Bandwidth bw;
-               Latency l;
-               
-               Set<Property> props = new HashSet<Property>();
-               state = new State(State.EDGE_UP);
-               bw = new Bandwidth(Bandwidth.BW100Gbps);
-               l = new Latency(Latency.LATENCY100ns);
-               props.add(state);
-               props.add(bw);
-               props.add(l);
-               
-               for (short i = 1; i < 6; i=(short) (i+2)) {
-                               NodeConnector headnc1 = NodeConnectorCreator.createOFNodeConnector(i, NodeCreator.createOFNode((long)i));
-                               NodeConnector tailnc1 = NodeConnectorCreator.createOFNodeConnector((short)(i+10), NodeCreator.createOFNode((long)(i+10)));
-                               Edge e1 = new Edge(headnc1, tailnc1);
-                               topoManagerImpl.edgeUpdate(e1, UpdateType.ADDED, props);
-
-                               NodeConnector headnc2 = NodeConnectorCreator.createOFNodeConnector((short) (i+1), headnc1.getNode());
-                               NodeConnector tailnc2 = NodeConnectorCreator.createOFNodeConnector((short)(i+11), tailnc1.getNode());
-                               Edge e2 = new Edge(headnc2, tailnc2);
-                               topoManagerImpl.edgeUpdate(e2, UpdateType.ADDED, props);                                
-               }
-       }
-       
-       @Test
-       public void testGetNodeEdges() throws ConstructionException  {
-               TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
-               setNodeEdges(topoManagerImpl);  
-               
-               Map<Node, Set<Edge>> nodeEdgeMap = topoManagerImpl.getNodeEdges();
-               for (Iterator<Map.Entry<Node,Set<Edge>>> i = nodeEdgeMap.entrySet().iterator();  i.hasNext();) {
-                       Map.Entry<Node, Set<Edge>> entry = i.next();
-                       Node node = entry.getKey();
-                       Long nodeId = ((Long) node.getID()).longValue();
-                       Assert.assertTrue((node.getType().equals(NodeIDType.OPENFLOW)));
-                                               
-                       Set<Edge> edges = entry.getValue();
-                       for (Edge edge : edges) {
-                               Long headNcId =  ((Short)edge.getHeadNodeConnector().getID()).longValue();
-                               Long tailNcId = ((Short) edge.getTailNodeConnector().getID()).longValue();
-                               if (nodeId == 1 || nodeId == 3 || nodeId == 5) {
-                                       Assert.assertTrue((headNcId.equals(nodeId) && tailNcId.equals(nodeId + 10)) ||
-                                                                         (headNcId.equals(nodeId + 10) && tailNcId.equals(nodeId)) ||
-                                                                         (headNcId.equals(nodeId + 1) && tailNcId.equals(nodeId + 11)) ||
-                                                                         (headNcId.equals(nodeId + 11) && tailNcId.equals(nodeId + 1)));
-                               } else if (nodeId == 11 || nodeId == 13 || nodeId == 15) {
-                                       Assert.assertTrue((headNcId.equals(nodeId) && tailNcId.equals(nodeId - 10)) ||
-                                                                        (headNcId.equals(nodeId) && tailNcId.equals(nodeId - 10)) ||
-                                                                        (headNcId.equals(nodeId - 9) && tailNcId.equals(nodeId + 1)) ||
-                                                                        (headNcId.equals(nodeId + 1) && tailNcId.equals(nodeId - 9)));
-                               }
-                       }
-                       i.remove();
-               }
-               Assert.assertTrue(nodeEdgeMap.isEmpty());
-       }
-       
-       @Test
-       public void testGetEdges() throws ConstructionException  {
-               TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
-               setNodeEdges(topoManagerImpl);
-
-               Map<Edge, Set<Property>> edgeProperty = topoManagerImpl.getEdges();
-               
-               for (Iterator <Map.Entry<Edge, Set<Property>>> i = edgeProperty.entrySet().iterator() ;  i.hasNext();) {
-                       Map.Entry<Edge, Set<Property>> entry = i.next();
-                       Edge e = entry.getKey();
-                       NodeConnector headnc = e.getHeadNodeConnector();
-                       NodeConnector tailnc = e.getTailNodeConnector();
-                       
-                       Long headNodeId = (Long) headnc.getNode().getID();
-                       
-                       Long headNcId =  ((Short)headnc.getID()).longValue();
-                       Long tailNcId = ((Short)tailnc.getID()).longValue();
-                       
-                       if (headNodeId == 1 || headNodeId == 3 || headNodeId == 5) {
-                               Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId.equals(headNodeId + 10)) ||
-                                                                 (headNcId.equals(headNodeId + 10) && tailNcId.equals(headNodeId)) ||
-                                                                 (headNcId.equals(headNodeId + 1) && tailNcId.equals(headNodeId + 11)) ||
-                                                                 (headNcId.equals(headNodeId + 11) && tailNcId.equals(headNodeId + 1)));
-                       } else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) {
-                               Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId.equals(headNodeId - 10)) ||
-                                                                (headNcId.equals(headNodeId) && tailNcId.equals(headNodeId - 10)) ||
-                                                                (headNcId.equals(headNodeId - 9) && tailNcId.equals(headNodeId + 1)) ||
-                                                                (headNcId.equals(headNodeId + 1) && tailNcId.equals(headNodeId - 9)));
-                       }
-
-                       Set<Property> prop = entry.getValue();
-                       for (Property p : prop) {
-                               String pName;
-                               long pValue;
-                               if (p instanceof Bandwidth) {
-                                       Bandwidth b = (Bandwidth)p;
-                                       pName = Bandwidth.BandwidthPropName;
-                                       pValue  = b.getValue();
-                                       Assert.assertTrue(pName.equals(p.getName()) && pValue == Bandwidth.BW100Gbps );
-                                       continue;
-                               }
-                               if (p instanceof Latency) {
-                                       Latency l = (Latency)p;
-                                       pName = Latency.LatencyPropName;
-                                       pValue  = l.getValue();
-                                       Assert.assertTrue(pName.equals(p.getName()) && pValue == Latency.LATENCY100ns);
-                                       continue;
-                               }
-                               if (p instanceof State) {
-                                       State state = (State)p;
-                                       pName = State.StatePropName;
-                                       pValue  = state.getValue();
-                                       Assert.assertTrue(pName.equals(p.getName()) && pValue  == State.EDGE_UP);
-                                       continue;
-                               }
-                       }
-                       i.remove();
-               }
-               Assert.assertTrue(edgeProperty.isEmpty());
-       }
-       
-       
-       @Test
-       public void testAddDeleteUserLink () {
-               TopologyUserLinkConfig link1 = new TopologyUserLinkConfig("default1", "OF", "1", "OF", "2", "OF", "1", "OF", "2"); 
-               TopologyUserLinkConfig link2 = new TopologyUserLinkConfig("default1", "OF", "10", "OF", "20", "OF", "10", "OF", "20"); 
-               TopologyUserLinkConfig link3 = new TopologyUserLinkConfig("default2", "OF", "1", "OF", "2", "OF", "1", "OF", "2"); 
-               TopologyUserLinkConfig link4 = new TopologyUserLinkConfig("default20", "OF", "10", "OF", "20", "OF", "10", "OF", "20"); 
-               
-               TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
-               topoManagerImpl.nonClusterObjectCreate();
-               
-               Assert.assertTrue (topoManagerImpl.addUserLink(link1).isSuccess());             
-               Assert.assertTrue (topoManagerImpl.addUserLink(link2).getCode() == StatusCode.CONFLICT);                
-               Assert.assertTrue (topoManagerImpl.addUserLink(link3).getCode() == StatusCode.CONFLICT);                
-               Assert.assertTrue (topoManagerImpl.addUserLink(link4).isSuccess());             
-               
-               Assert.assertTrue (topoManagerImpl.deleteUserLink(null).getCode() == StatusCode.BADREQUEST);    
-               Assert.assertTrue (topoManagerImpl.deleteUserLink(link1.getName()).isSuccess());        
-               Assert.assertTrue (topoManagerImpl.deleteUserLink(link4.getName()).isSuccess());        
-               Assert.assertTrue (topoManagerImpl.getUserLinks().isEmpty());
-
-       }
-       
-       @Test   
-       public void testGetUserLink () {
-               TopologyUserLinkConfig[] link = new TopologyUserLinkConfig[5];
-               TopologyUserLinkConfig[] reverseLink = new TopologyUserLinkConfig[5];
-               TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
-               topoManagerImpl.nonClusterObjectCreate();
-               
-               String name = null;
-               String srcNodeIDType = null;
-               String srcSwitchId = null;
-               String srcNodeConnectorIDType = null;
-               String srcPort = null;
-               String dstNodeIDType = null;
-               String dstSwitchId = null;
-               String dstNodeConnectorIDType = null;
-               String dstPort = null;
-               
-               /*Creating userlinks and checking for their validity*/
-               link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
-                               srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
-                               dstNodeConnectorIDType, dstPort);
-               Assert.assertTrue(link[0].isValid() == false);
-               
-               srcSwitchId = "1";
-               link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
-                               srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
-                               dstNodeConnectorIDType, dstPort);
-               Assert.assertTrue(link[0].isValid() == false);
-               
-               dstSwitchId = "2";
-               link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
-                               srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
-                               dstNodeConnectorIDType, dstPort);
-               Assert.assertTrue(link[0].isValid() == false);
-
-               
-               Integer i;
-               
-               for (i = 0; i < 5; i++) {
-                       link[i] = new TopologyUserLinkConfig(name, srcNodeIDType,
-                                       srcSwitchId, srcNodeConnectorIDType, srcPort,
-                                       dstNodeIDType, dstSwitchId, dstNodeConnectorIDType, dstPort);
-
-                       name = Integer.toString(i + 1);
-                       srcSwitchId = Integer.toString(i + 1);
-                       srcPort = Integer.toString(i + 1);
-                       dstSwitchId = Integer.toString((i + 1)*10);
-                       dstPort = Integer.toString((i + 1)*10);
-                       
-                       link[i].setName(name);
-                       link[i].setSrcSwitchId(srcSwitchId);
-                       link[i].setSrcPort(srcPort);
-                       link[i].setDstSwitchId(dstSwitchId);
-                       link[i].setDstPort(dstPort);
-                       
-                       Assert.assertTrue(link[i].isValid() == false);
-                       
-                       link[i].setSrcNodeIDType("OF");
-                       link[i].setSrcNodeConnectorIDType("OF");
-
-                       Assert.assertTrue(link[i].isValid() == false);
-
-                       link[i].setDstNodeIDType("OF");
-                       link[i].setDstNodeConnectorIDType("OF");
-                       
-                       Assert.assertTrue(link[i].isValid() == true);
-
-                       reverseLink[i] = new TopologyUserLinkConfig(name, dstNodeIDType,
-                                       dstSwitchId, dstNodeConnectorIDType, dstPort,
-                                       srcNodeIDType, srcSwitchId, srcNodeConnectorIDType, srcPort);
-
-                       topoManagerImpl.addUserLink(link[i]);
-               }
-               ConcurrentMap<String, TopologyUserLinkConfig> userLinks = topoManagerImpl.getUserLinks();
-               TopologyUserLinkConfig resultLink;
-
-               for (i = 0; i < 5; i++) {
-                       resultLink = userLinks.get(((Integer)(i + 1)).toString());
-                                                       
-                       Assert.assertTrue(resultLink.getName().equals(reverseLink[i].getName()));
-                       Assert.assertTrue(resultLink.getDstSwitchId().equals(reverseLink[i].getSrcSwitchId()));
-                       Assert.assertTrue(resultLink.getDstPort().equals(reverseLink[i].getSrcPort()));
-                       Assert.assertTrue(resultLink.getSrcSwitchId().equals(reverseLink[i].getDstSwitchId()));
-                       Assert.assertTrue(resultLink.getSrcPort().equals(reverseLink[i].getDstPort()));
-               }
-       }
-       
-       @Test
-        public void testHostLinkMethods() throws ConstructionException, UnknownHostException  {
-               TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
-               topoManagerImpl.nonClusterObjectCreate();
-               int hostCounter = 0;
-               
-               State state;
-               Bandwidth bw;
-               Latency l;
-               Set<Property> props = new HashSet<Property>();
-               state = new State(State.EDGE_UP);
-               bw = new Bandwidth(Bandwidth.BW100Gbps);
-               l = new Latency(Latency.LATENCY100ns);
-               props.add(state);
-               props.add(bw);
-               props.add(l);
-
-               EthernetAddress ea;
-               InetAddress ip;
-               Host[] h = new Host[5];
-               NodeConnector[] nc = new NodeConnector[5];
-               
-               /* Adding host, nodeConnector to hostsDB for the i = 0,1,2,3.  No host
-                * added for i = 4
-                */
-               for (int i = 0; i < 5; i++) {
-                       if (hostCounter < 4) {
-                               ea = new EthernetAddress(new byte[]{(byte)0x0, (byte)0x0,
-                                               (byte)0x0, (byte)0x0,
-                                               (byte)0x0, (byte)i});
-                               String stringIP = new StringBuilder().append(i + 1).append(".").append(i+10).append(".").append(i+20).append(".").append(i+30).toString();
-                               ip = InetAddress.getByName(stringIP);
-                               h[hostCounter] = new Host(ea, ip);
-                       } else {
-                               h[hostCounter] = null;
-                       }
-                       hostCounter++;
-                       nc[i] = NodeConnectorCreator.createOFNodeConnector((short)(i + 1), NodeCreator.createOFNode((long)(i + 1)));
-                       topoManagerImpl.updateHostLink(nc[i], h[i], UpdateType.ADDED, props);
-               }
-               
-               for (int i = 0; i < 5; i++) {
-                       Host host = topoManagerImpl.getHostAttachedToNodeConnector(nc[i]);
-                       if (i == 4)
-                               Assert.assertTrue(host == null);
-                       else
-                               Assert.assertTrue(host.equals(h[i]));                   
-               }
-               
-               Set<NodeConnector> ncSet =      topoManagerImpl.getNodeConnectorWithHost();
-               for (int i = 0; i < 5; i++) {
-                       Assert.assertTrue(ncSet.remove(nc[i]));
-               }
-               Assert.assertTrue(ncSet.isEmpty());
-       }
-       
-       @Test
-       public void testGetNodesWithNodeConnectorHost() throws ConstructionException, UnknownHostException {
-               TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
-               topoManagerImpl.nonClusterObjectCreate();
-               int hostCounter = 0;
-               
-               State state;
-               Bandwidth bw;
-               Latency l;
-               Set<Property> props = new HashSet<Property>();
-               state = new State(State.EDGE_UP);
-               bw = new Bandwidth(Bandwidth.BW100Gbps);
-               l = new Latency(Latency.LATENCY100ns);
-               props.add(state);
-               props.add(bw);
-               props.add(l);
-
-               EthernetAddress ea;
-               InetAddress ip;
-               Host[] h = new Host[5];
-               NodeConnector[] nc = new NodeConnector[5];
-               
-               /*Adding host, nodeconnector, properties of edge to hostsDB for the first three nodes only*/
-               for (int i = 1; i < 6; i++) {
-                       if (i < 4) {
-                               ea = new EthernetAddress(new byte[]{(byte)0x0, (byte)0x0,
-                                               (byte)0x0, (byte)0x0,
-                                               (byte)0x0, (byte)i});
-                               String stringIP = new StringBuilder().append(i).append(".").append(i+10).append(".").append(i+20).append(".").append(i+30).toString();
-                               ip = InetAddress.getByName(stringIP);
-                               h[hostCounter] = new Host(ea, ip);
-                       }
-                       else {
-                               h[hostCounter] = null;
-                       }
-                       hostCounter++;
-                       nc[i - 1] = NodeConnectorCreator.createOFNodeConnector((short)i, NodeCreator.createOFNode((long)i));
-                       topoManagerImpl.updateHostLink(nc[i - 1], h[i - 1], UpdateType.ADDED, props);
-               }
-               
-               /*Get the nodes which have host connected to its nodeConnector*/
-               Map<Node, Set<NodeConnector>> nodeNCmap = topoManagerImpl.getNodesWithNodeConnectorHost();
-               for (int i = 1; i < 6; i++) {
-                       Node node = nc[i - 1].getNode();
-                       Set<NodeConnector> ncSet = nodeNCmap.get(nc[i - 1].getNode());
-
-                       Assert.assertTrue(ncSet == nodeNCmap.remove(node));
-               }
-       
-               Assert.assertTrue(nodeNCmap.isEmpty());
-       }
-}
+public class TopologyManagerImplTest {
+
+    /*
+     * Sets the node, edges and properties for edges here: Edge <SwitchId :
+     * NodeConnectorId> : <1:1>--><11:11>; <1:2>--><11:12>; <3:3>--><13:13>;
+     * <3:4>--><13:14>; <5:5>--><15:15>; <5:6>--><15:16>; Method used by two
+     * tests: testGetNodeEdges and testGetEdges
+     * 
+     * @param topoManagerImpl
+     * 
+     * @throws ConstructionException
+     */
+    public void setNodeEdges(TopologyManagerImpl topoManagerImpl)
+            throws ConstructionException {
+        topoManagerImpl.nonClusterObjectCreate();
+
+        State state;
+        Bandwidth bw;
+        Latency l;
+
+        Set<Property> props = new HashSet<Property>();
+        state = new State(State.EDGE_UP);
+        bw = new Bandwidth(Bandwidth.BW100Gbps);
+        l = new Latency(Latency.LATENCY100ns);
+        props.add(state);
+        props.add(bw);
+        props.add(l);
+
+        for (short i = 1; i < 6; i = (short) (i + 2)) {
+            List<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
+            NodeConnector headnc1 = NodeConnectorCreator.createOFNodeConnector(
+                    i, NodeCreator.createOFNode((long) i));
+            NodeConnector tailnc1 = NodeConnectorCreator
+                    .createOFNodeConnector((short) (i + 10),
+                            NodeCreator.createOFNode((long) (i + 10)));
+            Edge e1 = new Edge(headnc1, tailnc1);
+            TopoEdgeUpdate teu1 = new TopoEdgeUpdate(e1, props,
+                    UpdateType.ADDED);
+            topoedgeupdateList.add(teu1);
+
+            NodeConnector headnc2 = NodeConnectorCreator.createOFNodeConnector(
+                    (short) (i + 1), headnc1.getNode());
+            NodeConnector tailnc2 = NodeConnectorCreator.createOFNodeConnector(
+                    (short) (i + 11), tailnc1.getNode());
+            Edge e2 = new Edge(headnc2, tailnc2);
+            TopoEdgeUpdate teu2 = new TopoEdgeUpdate(e2, props,
+                    UpdateType.ADDED);
+            topoedgeupdateList.add(teu2);
+            topoManagerImpl.edgeUpdate(topoedgeupdateList);
+
+        }
+
+    }
+
+    @Test
+    public void testGetNodeEdges() throws ConstructionException {
+        TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
+        setNodeEdges(topoManagerImpl);
+
+        Map<Node, Set<Edge>> nodeEdgeMap = topoManagerImpl.getNodeEdges();
+        for (Iterator<Map.Entry<Node, Set<Edge>>> i = nodeEdgeMap.entrySet()
+                .iterator(); i.hasNext();) {
+            Map.Entry<Node, Set<Edge>> entry = i.next();
+            Node node = entry.getKey();
+            Long nodeId = ((Long) node.getID()).longValue();
+            Assert.assertTrue((node.getType().equals(NodeIDType.OPENFLOW)));
+
+            Set<Edge> edges = entry.getValue();
+            for (Edge edge : edges) {
+                Long headNcId = ((Short) edge.getHeadNodeConnector().getID())
+                        .longValue();
+                Long tailNcId = ((Short) edge.getTailNodeConnector().getID())
+                        .longValue();
+                if (nodeId == 1 || nodeId == 3 || nodeId == 5) {
+                    Assert.assertTrue((headNcId.equals(nodeId) && tailNcId
+                            .equals(nodeId + 10))
+                            || (headNcId.equals(nodeId + 10) && tailNcId
+                                    .equals(nodeId))
+                            || (headNcId.equals(nodeId + 1) && tailNcId
+                                    .equals(nodeId + 11))
+                            || (headNcId.equals(nodeId + 11) && tailNcId
+                                    .equals(nodeId + 1)));
+                } else if (nodeId == 11 || nodeId == 13 || nodeId == 15) {
+                    Assert.assertTrue((headNcId.equals(nodeId) && tailNcId
+                            .equals(nodeId - 10))
+                            || (headNcId.equals(nodeId) && tailNcId
+                                    .equals(nodeId - 10))
+                            || (headNcId.equals(nodeId - 9) && tailNcId
+                                    .equals(nodeId + 1))
+                            || (headNcId.equals(nodeId + 1) && tailNcId
+                                    .equals(nodeId - 9)));
+                }
+            }
+            i.remove();
+        }
+        Assert.assertTrue(nodeEdgeMap.isEmpty());
+    }
+
+    @Test
+    public void testGetEdges() throws ConstructionException {
+        TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
+        setNodeEdges(topoManagerImpl);
+
+        Map<Edge, Set<Property>> edgeProperty = topoManagerImpl.getEdges();
+
+        for (Iterator<Map.Entry<Edge, Set<Property>>> i = edgeProperty
+                .entrySet().iterator(); i.hasNext();) {
+            Map.Entry<Edge, Set<Property>> entry = i.next();
+            Edge e = entry.getKey();
+            NodeConnector headnc = e.getHeadNodeConnector();
+            NodeConnector tailnc = e.getTailNodeConnector();
+
+            Long headNodeId = (Long) headnc.getNode().getID();
+
+            Long headNcId = ((Short) headnc.getID()).longValue();
+            Long tailNcId = ((Short) tailnc.getID()).longValue();
+
+            if (headNodeId == 1 || headNodeId == 3 || headNodeId == 5) {
+                Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
+                        .equals(headNodeId + 10))
+                        || (headNcId.equals(headNodeId + 10) && tailNcId
+                                .equals(headNodeId))
+                        || (headNcId.equals(headNodeId + 1) && tailNcId
+                                .equals(headNodeId + 11))
+                        || (headNcId.equals(headNodeId + 11) && tailNcId
+                                .equals(headNodeId + 1)));
+            } else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) {
+                Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
+                        .equals(headNodeId - 10))
+                        || (headNcId.equals(headNodeId) && tailNcId
+                                .equals(headNodeId - 10))
+                        || (headNcId.equals(headNodeId - 9) && tailNcId
+                                .equals(headNodeId + 1))
+                        || (headNcId.equals(headNodeId + 1) && tailNcId
+                                .equals(headNodeId - 9)));
+            }
+
+            Set<Property> prop = entry.getValue();
+            for (Property p : prop) {
+                String pName;
+                long pValue;
+                if (p instanceof Bandwidth) {
+                    Bandwidth b = (Bandwidth) p;
+                    pName = Bandwidth.BandwidthPropName;
+                    pValue = b.getValue();
+                    Assert.assertTrue(pName.equals(p.getName())
+                            && pValue == Bandwidth.BW100Gbps);
+                    continue;
+                }
+                if (p instanceof Latency) {
+                    Latency l = (Latency) p;
+                    pName = Latency.LatencyPropName;
+                    pValue = l.getValue();
+                    Assert.assertTrue(pName.equals(p.getName())
+                            && pValue == Latency.LATENCY100ns);
+                    continue;
+                }
+                if (p instanceof State) {
+                    State state = (State) p;
+                    pName = State.StatePropName;
+                    pValue = state.getValue();
+                    Assert.assertTrue(pName.equals(p.getName())
+                            && pValue == State.EDGE_UP);
+                    continue;
+                }
+            }
+            i.remove();
+        }
+        Assert.assertTrue(edgeProperty.isEmpty());
+    }
+
+    @Test
+    public void testAddDeleteUserLink() {
+        TopologyUserLinkConfig link1 = new TopologyUserLinkConfig("default1",
+                "OF", "1", "OF", "2", "OF", "1", "OF", "2");
+        TopologyUserLinkConfig link2 = new TopologyUserLinkConfig("default1",
+                "OF", "10", "OF", "20", "OF", "10", "OF", "20");
+        TopologyUserLinkConfig link3 = new TopologyUserLinkConfig("default2",
+                "OF", "1", "OF", "2", "OF", "1", "OF", "2");
+        TopologyUserLinkConfig link4 = new TopologyUserLinkConfig("default20",
+                "OF", "10", "OF", "20", "OF", "10", "OF", "20");
+
+        TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
+        topoManagerImpl.nonClusterObjectCreate();
+
+        Assert.assertTrue(topoManagerImpl.addUserLink(link1).isSuccess());
+        Assert.assertTrue(topoManagerImpl.addUserLink(link2).getCode() == StatusCode.CONFLICT);
+        Assert.assertTrue(topoManagerImpl.addUserLink(link3).getCode() == StatusCode.CONFLICT);
+        Assert.assertTrue(topoManagerImpl.addUserLink(link4).isSuccess());
+
+        Assert.assertTrue(topoManagerImpl.deleteUserLink(null).getCode() == StatusCode.BADREQUEST);
+        Assert.assertTrue(topoManagerImpl.deleteUserLink(link1.getName())
+                .isSuccess());
+        Assert.assertTrue(topoManagerImpl.deleteUserLink(link4.getName())
+                .isSuccess());
+        Assert.assertTrue(topoManagerImpl.getUserLinks().isEmpty());
+
+    }
+
+    @Test
+    public void testGetUserLink() {
+        TopologyUserLinkConfig[] link = new TopologyUserLinkConfig[5];
+        TopologyUserLinkConfig[] reverseLink = new TopologyUserLinkConfig[5];
+        TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
+        topoManagerImpl.nonClusterObjectCreate();
+
+        String name = null;
+        String srcNodeIDType = null;
+        String srcSwitchId = null;
+        String srcNodeConnectorIDType = null;
+        String srcPort = null;
+        String dstNodeIDType = null;
+        String dstSwitchId = null;
+        String dstNodeConnectorIDType = null;
+        String dstPort = null;
+
+        /* Creating userlinks and checking for their validity */
+        link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
+                srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
+                dstNodeConnectorIDType, dstPort);
+        Assert.assertTrue(link[0].isValid() == false);
+
+        srcSwitchId = "1";
+        link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
+                srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
+                dstNodeConnectorIDType, dstPort);
+        Assert.assertTrue(link[0].isValid() == false);
 
+        dstSwitchId = "2";
+        link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
+                srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
+                dstNodeConnectorIDType, dstPort);
+        Assert.assertTrue(link[0].isValid() == false);
+
+        Integer i;
+
+        for (i = 0; i < 5; i++) {
+            link[i] = new TopologyUserLinkConfig(name, srcNodeIDType,
+                    srcSwitchId, srcNodeConnectorIDType, srcPort,
+                    dstNodeIDType, dstSwitchId, dstNodeConnectorIDType, dstPort);
+
+            name = Integer.toString(i + 1);
+            srcSwitchId = Integer.toString(i + 1);
+            srcPort = Integer.toString(i + 1);
+            dstSwitchId = Integer.toString((i + 1) * 10);
+            dstPort = Integer.toString((i + 1) * 10);
+
+            link[i].setName(name);
+            link[i].setSrcSwitchId(srcSwitchId);
+            link[i].setSrcPort(srcPort);
+            link[i].setDstSwitchId(dstSwitchId);
+            link[i].setDstPort(dstPort);
+
+            Assert.assertTrue(link[i].isValid() == false);
+
+            link[i].setSrcNodeIDType("OF");
+            link[i].setSrcNodeConnectorIDType("OF");
+
+            Assert.assertTrue(link[i].isValid() == false);
+
+            link[i].setDstNodeIDType("OF");
+            link[i].setDstNodeConnectorIDType("OF");
+
+            Assert.assertTrue(link[i].isValid() == true);
+
+            reverseLink[i] = new TopologyUserLinkConfig(name, dstNodeIDType,
+                    dstSwitchId, dstNodeConnectorIDType, dstPort,
+                    srcNodeIDType, srcSwitchId, srcNodeConnectorIDType, srcPort);
+
+            topoManagerImpl.addUserLink(link[i]);
+        }
+        ConcurrentMap<String, TopologyUserLinkConfig> userLinks = topoManagerImpl
+                .getUserLinks();
+        TopologyUserLinkConfig resultLink;
+
+        for (i = 0; i < 5; i++) {
+            resultLink = userLinks.get(((Integer) (i + 1)).toString());
+
+            Assert.assertTrue(resultLink.getName().equals(
+                    reverseLink[i].getName()));
+            Assert.assertTrue(resultLink.getDstSwitchId().equals(
+                    reverseLink[i].getSrcSwitchId()));
+            Assert.assertTrue(resultLink.getDstPort().equals(
+                    reverseLink[i].getSrcPort()));
+            Assert.assertTrue(resultLink.getSrcSwitchId().equals(
+                    reverseLink[i].getDstSwitchId()));
+            Assert.assertTrue(resultLink.getSrcPort().equals(
+                    reverseLink[i].getDstPort()));
+        }
+    }
+
+    @Test
+    public void testHostLinkMethods() throws ConstructionException,
+            UnknownHostException {
+        TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
+        topoManagerImpl.nonClusterObjectCreate();
+        int hostCounter = 0;
+
+        State state;
+        Bandwidth bw;
+        Latency l;
+        Set<Property> props = new HashSet<Property>();
+        state = new State(State.EDGE_UP);
+        bw = new Bandwidth(Bandwidth.BW100Gbps);
+        l = new Latency(Latency.LATENCY100ns);
+        props.add(state);
+        props.add(bw);
+        props.add(l);
+
+        EthernetAddress ea;
+        InetAddress ip;
+        Host[] h = new Host[5];
+        NodeConnector[] nc = new NodeConnector[5];
+
+        /*
+         * Adding host, nodeConnector to hostsDB for the i = 0,1,2,3. No host
+         * added for i = 4
+         */
+        for (int i = 0; i < 5; i++) {
+            if (hostCounter < 4) {
+                ea = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
+                        (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) i });
+                String stringIP = new StringBuilder().append(i + 1).append(".")
+                        .append(i + 10).append(".").append(i + 20).append(".")
+                        .append(i + 30).toString();
+                ip = InetAddress.getByName(stringIP);
+                h[hostCounter] = new Host(ea, ip);
+            } else {
+                h[hostCounter] = null;
+            }
+            hostCounter++;
+            nc[i] = NodeConnectorCreator.createOFNodeConnector((short) (i + 1),
+                    NodeCreator.createOFNode((long) (i + 1)));
+            topoManagerImpl
+                    .updateHostLink(nc[i], h[i], UpdateType.ADDED, props);
+        }
+
+        for (int i = 0; i < 5; i++) {
+            Host host = topoManagerImpl.getHostAttachedToNodeConnector(nc[i]);
+            if (i == 4)
+                Assert.assertTrue(host == null);
+            else
+                Assert.assertTrue(host.equals(h[i]));
+        }
+
+        Set<NodeConnector> ncSet = topoManagerImpl.getNodeConnectorWithHost();
+        for (int i = 0; i < 5; i++) {
+            Assert.assertTrue(ncSet.remove(nc[i]));
+        }
+        Assert.assertTrue(ncSet.isEmpty());
+    }
+
+    @Test
+    public void testGetNodesWithNodeConnectorHost()
+            throws ConstructionException, UnknownHostException {
+        TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
+        topoManagerImpl.nonClusterObjectCreate();
+        int hostCounter = 0;
+
+        State state;
+        Bandwidth bw;
+        Latency l;
+        Set<Property> props = new HashSet<Property>();
+        state = new State(State.EDGE_UP);
+        bw = new Bandwidth(Bandwidth.BW100Gbps);
+        l = new Latency(Latency.LATENCY100ns);
+        props.add(state);
+        props.add(bw);
+        props.add(l);
+
+        EthernetAddress ea;
+        InetAddress ip;
+        Host[] h = new Host[5];
+        NodeConnector[] nc = new NodeConnector[5];
+
+        /*
+         * Adding host, nodeconnector, properties of edge to hostsDB for the
+         * first three nodes only
+         */
+        for (int i = 1; i < 6; i++) {
+            if (i < 4) {
+                ea = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
+                        (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) i });
+                String stringIP = new StringBuilder().append(i).append(".")
+                        .append(i + 10).append(".").append(i + 20).append(".")
+                        .append(i + 30).toString();
+                ip = InetAddress.getByName(stringIP);
+                h[hostCounter] = new Host(ea, ip);
+            } else {
+                h[hostCounter] = null;
+            }
+            hostCounter++;
+            nc[i - 1] = NodeConnectorCreator.createOFNodeConnector((short) i,
+                    NodeCreator.createOFNode((long) i));
+            topoManagerImpl.updateHostLink(nc[i - 1], h[i - 1],
+                    UpdateType.ADDED, props);
+        }
+
+        /* Get the nodes which have host connected to its nodeConnector */
+        Map<Node, Set<NodeConnector>> nodeNCmap = topoManagerImpl
+                .getNodesWithNodeConnectorHost();
+        for (int i = 1; i < 6; i++) {
+            Node node = nc[i - 1].getNode();
+            Set<NodeConnector> ncSet = nodeNCmap.get(nc[i - 1].getNode());
+
+            Assert.assertTrue(ncSet == nodeNCmap.remove(node));
+        }
+
+        Assert.assertTrue(nodeNCmap.isEmpty());
+    }
+}
index 4c83a3e1ceedcf55c601b50c30c5edcc8101056b..eea85e25eaaa1f85742b5959b84dc9e534e346fb 100644 (file)
@@ -85,7 +85,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 e8a67ac9edf56131c9b9340cddc93be405c12096..12cd17c6c32a97e1788c62afd4f71fc033d8e4fa 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 7898f78c6214466edba0383e7908f33336e23781..c7ba7aab1e4b258706c82055e99a81f4edf14aaa 100644 (file)
@@ -88,7 +88,6 @@ public class Devices implements IDaylightWeb {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
         List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
-        Map<String, String> portListStatus = new HashMap<String, String>();
         for (Switch device : switchManager.getNetworkDevices()) {
             HashMap<String, String> nodeDatum = new HashMap<String, String>();
             Node node = device.getNode();
@@ -112,38 +111,41 @@ public class Devices implements IDaylightWeb {
             nodeDatum.put("mac",
                     HexEncode.bytesToHexString(device.getDataLayerAddress()));
             StringBuffer sb1 = new StringBuffer();
-            StringBuffer sb2 = new StringBuffer();
             Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
-            String nodeConnectorName;
-            String nodeConnectorNumberToStr;
             if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
                 Map<Short, String> portList = new HashMap<Short, String>();
                 for (NodeConnector nodeConnector : nodeConnectorSet) {
-                    nodeConnectorNumberToStr = nodeConnector.getID().toString();
+                    String nodeConnectorNumberToStr = nodeConnector.getID().toString();
                     Name ncName = ((Name) switchManager.getNodeConnectorProp(
                             nodeConnector, Name.NamePropName));
                     Config portStatus = ((Config) switchManager
                             .getNodeConnectorProp(nodeConnector,
                                     Config.ConfigPropName));
-                    nodeConnectorName = (ncName != null) ? ncName.getValue()
+                    
+                    String nodeConnectorName = (ncName != null) ? ncName.getValue()
                             : "";
+                    nodeConnectorName += " ("+nodeConnector.getID()+")";
+                    
+                    if (portStatus != null) {
+                        if (portStatus.getValue() == Config.ADMIN_UP) {
+                            nodeConnectorName = "<span style='color:green;'>"+nodeConnectorName+"</span>";
+                        } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
+                            nodeConnectorName = "<span style='color:red;'>"+nodeConnectorName+"</span>";
+                        }
+                    }
+                    
                     portList.put(Short.parseShort(nodeConnectorNumberToStr),
                             nodeConnectorName);
-                    portListStatus
-                            .put(nodeConnectorName, portStatus.toString());
                 }
 
-                Map<Short, String> sortedPortList = new TreeMap<Short, String>(
-                        portList);
+                Map<Short, String> sortedPortList = new TreeMap<Short, String>(portList);
 
                 for (Entry<Short, String> e : sortedPortList.entrySet()) {
-                    sb1.append(e.getValue() + "(" + e.getKey() + ")");
+                    sb1.append(e.getValue());
                     sb1.append("<br>");
-                    sb2.append(portListStatus.get(e.getValue()) + "<br>");
                 }
             }
             nodeDatum.put("ports", sb1.toString());
-            nodeDatum.put("portStatus", sb2.toString());
             nodeData.add(nodeDatum);
         }
         DevicesJsonBean result = new DevicesJsonBean();
index 29f03d514b0d58c6e16e78f286e95750f68b5641..96b16bf92cc2da50be0c06da2ac3e946edca8b7d 100644 (file)
@@ -18,7 +18,7 @@ one.f.dashlet = {
        },
     staticRouteConfig : {
         id : 'staticRouteConfig',
-        name : 'Static route Configuration'
+        name : 'Static Route Configuration'
     },
     subnetGatewayConfig : {
         id : 'subnetGatewayConfig',
@@ -90,11 +90,10 @@ one.f.switchmanager.nodesLearnt = {
 
                one.f.switchmanager.nodesLearnt.ajax.main(url, function(content) {
                        var body = one.f.switchmanager.nodesLearnt.data.abridged(content);
-                       var $table = one.f.switchmanager.createTable(["Node Name", "Node ID", "Ports", "Port Status"], body);
+                       var $table = one.f.switchmanager.createTable(["Node Name", "Node ID", "Ports"], body);
                        $dashlet.append($table);
                });
        },
-
        ajax : {
                main : function(url, callback) {
                        $.getJSON(url, function(data) {
@@ -106,7 +105,7 @@ one.f.switchmanager.nodesLearnt = {
                initialize: {
                        updateNode: function(evt) {
                                var nodeId = decodeURIComponent(evt.target.id);
-                               var h3 = "Update node information";
+                               var h3 = "Update Node Information";
                    var footer = one.f.switchmanager.nodesLearnt.modal.footer.updateNode();
                    var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.modal, h3, "", footer);
                    
@@ -130,7 +129,7 @@ one.f.switchmanager.nodesLearnt = {
                        }
                },
                body: {
-                       updateNode: function(nodeId, portStatus, switchDetails, tiers) {
+                       updateNode: function(nodeId, switchDetails, tiers) {
                                var $form = $(document.createElement('form'));
                                var $fieldset = $(document.createElement('fieldset'));
                                // node ID. not editable.
@@ -148,13 +147,6 @@ one.f.switchmanager.nodesLearnt = {
                                        $input.attr('value', switchDetails["nodeName"]);
                                }
                                $fieldset.append($label).append($input);
-                               // Port Status. not editable.
-                               var $label = one.lib.form.label("Port Status");
-                               var $input = one.lib.form.input("Port Status");
-                               $input.attr('id', one.f.switchmanager.nodesLearnt.id.modal.form.portStatus);
-                               $input.attr("disabled", true);
-                               $input.attr("value", portStatus);
-                               $fieldset.append($label).append($input);
                                // node tier
                                var $label = one.lib.form.label("Tier");
                                var $select = one.lib.form.select.create(tiers);
@@ -246,7 +238,6 @@ one.f.switchmanager.nodesLearnt = {
                                entry.push(aTag);
                                entry.push(value["nodeId"]);
                                entry.push(value["ports"]);
-                               entry.push(value["portStatus"]);
                                tr.entry = entry;
                                result.push(tr);
                        });
@@ -644,7 +635,8 @@ one.f.switchmanager.staticRouteConfig = {
                        var body = one.f.switchmanager.staticRouteConfig.data.staticRouteConfig(content);
                        // first column contains checkbox. no need for header
                        content.columnNames.splice(0,0," ");
-                       var $table = one.f.switchmanager.createTable(content.columnNames, body);
+                       var tableHeaders = ['', 'Name', 'Static Route', 'Next Hop Address'];
+                       var $table = one.f.switchmanager.createTable(tableHeaders, body);
                        $dashlet.append($table);
                });
        },
@@ -1017,4 +1009,4 @@ $('.dash .nav a', '#main').click(function() {
 // activate first tab on each dashlet
 $('.dash .nav').each(function(index, value) {
     $($(value).find('li')[0]).find('a').click();
-});
\ No newline at end of file
+});
index 4eaf227fe947c0f01c5a86e5514f2b7c78f76dd8..5333a7e6434bfa1f86eb0a40db49e5892532d667 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 7f5c45319e2064cef7019a1949ea9eca098f0955..d30a6ac4c1cad7d5c4bcd9646e5304cb013100aa 100644 (file)
@@ -95,7 +95,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 1ab8dff116aff1f176f168d66ae979de83e35dec..7c45bb8cee04433502b3ad5e3567f8d211c87428 100644 (file)
@@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
 import org.opendaylight.controller.sal.authorization.UserLevel;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.usermanager.IUserManager;
 import org.opendaylight.controller.usermanager.internal.UserConfig;
 import org.springframework.stereotype.Controller;
@@ -94,6 +95,31 @@ public class DaylightWebAdmin {
 
         return userManager.removeLocalUser(userName).getDescription();
     }
+    
+    @RequestMapping(value = "/users/password/{username}", method = RequestMethod.POST)
+    @ResponseBody
+    public Status changePassword(@PathVariable("username") String username, HttpServletRequest request,
+            @RequestParam("currentPassword") String currentPassword, @RequestParam("newPassword") String newPassword) {
+        String user = request.getUserPrincipal().getName();
+        
+        IUserManager userManager = (IUserManager) ServiceHelper
+                .getGlobalInstance(IUserManager.class, this);
+        if (userManager == null) {
+            return new Status(StatusCode.GONE, "User Manager not found");
+        }
+        
+        if (!authorize(userManager, UserLevel.NETWORKADMIN, request)) {
+            return new Status(StatusCode.FORBIDDEN, "Operation not permitted");
+        }
+        
+        if (newPassword.isEmpty()) {
+            return new Status(StatusCode.BADREQUEST, "Empty passwords not allowed");
+        }
+        
+        Status status = userManager.changeLocalUserPassword(user, currentPassword, newPassword);
+        
+        return status;
+    }
 
     /**
      * Is the operation permitted for the given level
index 629d5bbaacffcb42d510d1f8ca56614398d57a30..dda63be90e35f35f35e9d7a1944b6af1d1b71980 100644 (file)
@@ -124,13 +124,25 @@ one.main.admin = {
                 form : {
                     name : "one_main_admin_id_modal_add_form_name",
                     role : "one_main_admin_id_modal_add_form_role",
-                    password : "one_main_admin_id_modal_add_form_password"
+                    password : "one_main_admin_id_modal_add_form_password",
+                                       verify : "one_main_admin_id_modal_add_form_verify"
                 }
             },
             remove : {
                 user : "one_main_admin_id_modal_remove_user",
-                close : "one_main_admin_id_modal_remove_close"
-            }
+                close : "one_main_admin_id_modal_remove_close",
+                               password : 'one_main_admin_id_modal_remove_password'
+            },
+                       password : {
+                               modal : 'one_main_admin_id_modal_password_modal',
+                               submit : 'one_main_admin_id_modal_password_submit',
+                               cancel : 'one_main_admin_id_modal_password_cancel',
+                               form : {
+                                       old : 'one_main_admin_id_modal_password_form_old',
+                                       set : 'one_main_admin_id_modal_password_form_new',
+                                       verify : 'one_main_admin_id_modal_password_form_verify'
+                               }
+                       }
         },
         add : {
             user : "one_main_admin_id_add_user"
@@ -138,7 +150,8 @@ one.main.admin = {
     },
     address : {
         root : "/admin",
-        users : "/users"
+        users : "/users",
+               password : '/admin/users/password/'
     },
     modal : {
         initialize : function(callback) {
@@ -239,7 +252,7 @@ one.main.admin = {
     remove : {
         modal : {
             initialize : function(id) {
-                var h3 = "Remove User";
+                var h3 = "Edit User";
                 var footer = one.main.admin.remove.footer();
                 var $body = one.main.admin.remove.body();
                 var $modal = one.lib.modal.spawn(one.main.admin.id.modal.user,
@@ -278,6 +291,13 @@ one.main.admin = {
                                                     });
                                 });
 
+                               // change password binding
+                               $('#' + one.main.admin.id.modal.remove.password, $modal).click(function() {
+                                       one.main.admin.password.initialize(id, function() {
+                                               $modal.modal('hide');
+                                       });
+                               });
+
                 $modal.modal();
             },
             ajax : function(id, callback) {
@@ -297,6 +317,11 @@ one.main.admin = {
             var $removeButton = one.lib.dashlet.button.button(removeButton);
             footer.push($removeButton);
 
+                       var change = one.lib.dashlet.button.single('Change Password',
+                                       one.main.admin.id.modal.remove.password, 'btn-success', '');
+                       var $change = one.lib.dashlet.button.button(change);
+                       footer.push($change);
+
             var closeButton = one.lib.dashlet.button.single("Close",
                     one.main.admin.id.modal.remove.close, "", "");
             var $closeButton = one.lib.dashlet.button.button(closeButton);
@@ -306,7 +331,7 @@ one.main.admin = {
         },
         body : function() {
             var $p = $(document.createElement('p'));
-            $p.append("Remove user?");
+            $p.append('Select an action');
             return $p;
         },
     },
@@ -364,6 +389,13 @@ one.main.admin = {
                         '#' + one.main.admin.id.modal.add.form.role).find(
                         'option:selected').attr('value');
 
+                               // password check
+                               var verify = $('#'+one.main.admin.id.modal.add.form.verify).val();
+                               if (user.password != verify) {
+                                       alert('Passwords do not match');
+                                       return false;
+                               }
+
                 var resource = {};
                 resource['json'] = JSON.stringify(user);
                 resource['action'] = 'add'
@@ -391,6 +423,12 @@ one.main.admin = {
             $input.attr('id', one.main.admin.id.modal.add.form.password);
             $input.attr('type', 'password');
             $fieldset.append($label).append($input);
+                       // password verify
+                       var $label = one.lib.form.label('Verify Password');
+                       var $input = one.lib.form.input('Verify Password');
+                       $input.attr('id', one.main.admin.id.modal.add.form.verify);
+                       $input.attr('type', 'password');
+                       $fieldset.append($label).append($input);
             // roles
             var $label = one.lib.form.label('Roles');
             var options = {
@@ -418,7 +456,96 @@ one.main.admin = {
 
             return footer;
         }
-    }
+    },
+       password : {
+               initialize : function(id, successCallback) {
+                       var h3 = 'Change Password';
+                       var footer = one.main.admin.password.footer();
+                       var $body = one.main.admin.password.body(id);;
+                       var $modal = one.lib.modal.spawn(one.main.admin.id.modal.password.modal,
+                               h3, $body, footer);
+
+                       // cancel binding
+                       $('#'+one.main.admin.id.modal.password.cancel, $modal).click(function() {
+                               $modal.modal('hide');
+                       });
+
+                       // change password binding
+                       $('#'+one.main.admin.id.modal.password.submit, $modal).click(function() {
+                               one.main.admin.password.submit(id, $modal, function(result) {
+                                       if (result.code == 'SUCCESS') {
+                                               $modal.modal('hide');
+                                               successCallback();
+                                       } else {
+                                               alert(result.code+': '+result.description);
+                                       }
+                               });
+                       });
+
+                       $modal.modal();
+               },
+               submit : function(id, $modal, callback) {
+                       var resource = {};
+                       resource.newPassword = $('#'+one.main.admin.id.modal.password.form.set, $modal).val();
+
+                       // verify password
+                       var verify = $('#'+one.main.admin.id.modal.password.form.verify, $modal).val();
+                       if (verify != resource.newPassword) {
+                               alert('Passwords do not match');
+                               return false;
+                       }
+
+                       resource.currentPassword = $('#'+one.main.admin.id.modal.password.form.old, $modal).val();
+
+                       $.post(one.main.admin.address.password+id, resource, function(data) {
+                               callback(data);
+                       });
+               },
+               body : function(id) {
+                       var $form = $(document.createElement('form'));
+                       var $fieldset = $(document.createElement('fieldset'));
+                       // user
+                       var $label = one.lib.form.label('Username');
+                       var $input = one.lib.form.input('');
+                       $input.attr('disabled', 'disabled');
+                       $input.val(id);
+                       $fieldset.append($label)
+                               .append($input);
+                       // old password
+            var $label = one.lib.form.label('Old Password');
+            var $input = one.lib.form.input('Old Password');
+            $input.attr('id', one.main.admin.id.modal.password.form.old);
+            $input.attr('type', 'password');
+            $fieldset.append($label).append($input);
+                       // new password
+            var $label = one.lib.form.label('New Password');
+            var $input = one.lib.form.input('New Password');
+            $input.attr('id', one.main.admin.id.modal.password.form.set);
+            $input.attr('type', 'password');
+            $fieldset.append($label).append($input);
+                       // verify new password
+                       var $label = one.lib.form.label('Verify Password');
+                       var $input = one.lib.form.input('Verify Password');
+                       $input.attr('id', one.main.admin.id.modal.password.form.verify);
+                       $input.attr('type', 'password');
+                       $fieldset.append($label).append($input);
+                       // return
+                       $form.append($fieldset);
+                       return $form;
+               },
+               footer : function() {
+                       var footer = [];
+                       var submit = one.lib.dashlet.button.single('Submit',
+                               one.main.admin.id.modal.password.submit, 'btn-primary', '');
+                       var $submit = one.lib.dashlet.button.button(submit);
+                       footer.push($submit);
+                       var cancel = one.lib.dashlet.button.single('Cancel',
+                               one.main.admin.id.modal.password.cancel, '', '');
+                       var $cancel = one.lib.dashlet.button.button(cancel);
+                       footer.push($cancel);
+                       return footer;
+               }
+       }
 }
 
 one.main.dashlet = {
@@ -478,4 +605,4 @@ $.ajaxSetup({
 });
 
 /** MAIN PAGE LOAD */
-one.main.menu.load();
\ No newline at end of file
+one.main.menu.load();
index 38999257f13af86da6ae2b7976958a6167aff982..0dd10512ebe3254b5fb44f5f7c12a71e0fecfd16 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 24191692a1364deb490169775d7282b67cc72da4..52958e116e15f68304c03cdc16d651e35b18f676 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>