Merge "Replaced Equals/HashcodeBuilder for DatapacketListener"
authorAlessandro Boch <aboch@cisco.com>
Mon, 3 Jun 2013 22:19:15 +0000 (22:19 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 3 Jun 2013 22:19:15 +0000 (22:19 +0000)
144 files changed:
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java
opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIntegrationTest.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/AllTableStatistics.java [new file with mode: 0644]
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/TableStatistics.java [new file with mode: 0644]
opendaylight/northbound/statistics/src/test/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundTest.java
opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IDiscoveryListener.java [new file with mode: 0644]
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryProvider.java [new file with mode: 0644]
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IOFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IPluginReadServiceFilter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableConverter.java [new file with mode: 0644]
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableStatisticsConverter.java [new file with mode: 0644]
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java
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
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/StubNodeConnectorFactory.java [new file with mode: 0644]
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/StubNodeFactory.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeTable.java [new file with mode: 0644]
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/IPluginInReadService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/IReadService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java [new file with mode: 0644]
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/INodeConnectorFactory.java [new file with mode: 0644]
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/INodeFactory.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeTableCreator.java [new file with mode: 0644]
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/NodeTableTest.java [new file with mode: 0644]
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/reader/NodeTableStatisticsTest.java [new file with mode: 0644]
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Inventory.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.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-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/TypeProviderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AugmentedTypeTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypesTest.java
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-java-api-generator/src/test/java/org/opendaylight/controller/sal/java/api/generator/test/GeneratorJavaFileTest.java
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_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest2/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Generator/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/NoOutputDir/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/samples/maven-code-gen-sample/src/main/java/Example.java
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/parser/builder/api/TypeAwareBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AnyXmlBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AugmentationSchemaBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ChoiceBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ChoiceCaseBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ConstraintsBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ContainerSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/DeviationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ExtensionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/FeatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/GroupingBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/IdentityrefTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/LeafListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/LeafSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/NotificationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/RpcDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/TypedefBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UnionTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UnknownSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UsesNodeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/ParserUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/TestUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/TypesResolutionTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/YangParserTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile1.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile3.yang
opendaylight/sal/yang-prototype/pom.xml
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/AbstractSignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractUnsignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BinaryType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BitsType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BooleanType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Decimal64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EmptyType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EnumerationType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java [deleted file]
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityrefType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/InstanceIdentifier.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int8.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Leafref.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/StringType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint8.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/UnionType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java
opendaylight/statisticsmanager/api/src/main/java/org/opendaylight/controller/statisticsmanager/IStatisticsManager.java
opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/switchmanager/implementation/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImplTest.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java

index df4526e6f9cbac41fc4df3b07de19dc12caee8fd..a8d7beb49b560c65f0c52c03271b31f3704cd318 100644 (file)
@@ -56,6 +56,8 @@ org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
 # of.portStatsPollInterval=5
 # The description statistics polling interval in second (default 60 sec)
 # of.descStatsPollInterval=60
+# The table statistics polling interval in second (default 10 sec)
+#  of.tableStatsPollInterval=10
 # The maximum number of asynchronous messages can be sent before sending a Barrier Request (default 100)
 # of.barrierMessagePriorCount=100
 # The interval which determines how often the discovery packets should be sent (default 300 sec)
index 4365db30668cdd9b635545e77db5af7893b9c300..5fbe12bd1ca44218a9629e50489540bd85d83302 100644 (file)
@@ -1041,13 +1041,11 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager,
 
     @Override
     public List<FlowEntry> getFlowEntriesForGroup(String policyName) {
-        List<FlowEntry> list = null;
+        List<FlowEntry> list = new ArrayList<FlowEntry>();
         if (this.groupFlows != null && this.groupFlows.containsKey(policyName)) {
-            list = new ArrayList<FlowEntry>();
             for (FlowEntryInstall entries : groupFlows.get(policyName)) {
                 list.add(entries.getOriginal());
             }
-            return new ArrayList<FlowEntry>();
         }
         return list;
     }
index 4997e37a252cb136b9304726f1f0e0298962baf2..32a9c5a6fc7bb16705635635e0a52f3b85f96c13 100644 (file)
@@ -29,9 +29,16 @@ import java.util.Arrays;
 import org.apache.commons.codec.binary.Base64;
 
 import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONTokener;
 
+import org.opendaylight.controller.hosttracker.IfIptoHost;
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.switchmanager.IInventoryListener;
 import org.opendaylight.controller.usermanager.IUserManager;
 
 @RunWith(PaxExam.class)
@@ -42,6 +49,7 @@ public class NorthboundIntegrationTest {
     @Inject
     private BundleContext bc;
     private IUserManager users = null;
+    private IInventoryListener invtoryListener = null;
 
     private String stateToString(int state) {
         switch (state) {
@@ -86,6 +94,14 @@ public class NorthboundIntegrationTest {
         // If UserManager is null, cannot login to run tests.
         assertNotNull(this.users);
 
+        r = bc.getServiceReference(IfIptoHost.class.getName());
+        if (r != null) {
+            this.invtoryListener = (IInventoryListener)bc.getService(r);
+        }
+
+        // If inventoryListener is null, cannot run hosttracker tests.
+        assertNotNull(this.invtoryListener);
+        
     }
 
     // static variable to pass response code from getJsonResult()
@@ -153,7 +169,8 @@ public class NorthboundIntegrationTest {
             String result = getJsonResult(baseURL + "flowstats");
             JSONTokener jt = new JSONTokener(result);
             JSONObject json = new JSONObject(jt);
-            JSONObject flowStatistics = json.getJSONObject("flowStatistics");
+            JSONObject flowStatistics = 
+                    getJsonInstance (json, "flowStatistics", 0xCAFE); 
             JSONObject node = flowStatistics.getJSONObject("node");
             // test that node was returned properly
             Assert.assertTrue(node.getInt("@id") == 0xCAFE);
@@ -172,7 +189,8 @@ public class NorthboundIntegrationTest {
             result = getJsonResult(baseURL + "portstats");
             jt = new JSONTokener(result);
             json = new JSONObject(jt);
-            JSONObject portStatistics = json.getJSONObject("portStatistics");
+            JSONObject portStatistics = 
+                    getJsonInstance (json, "portStatistics", 0xCAFE); 
             JSONObject node2 = portStatistics.getJSONObject("node");
             // test that node was returned properly
             Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
@@ -333,6 +351,276 @@ public class NorthboundIntegrationTest {
         }
     }
 
+    // method to extract a JSONObject with specified node ID from a JSONObject
+    //   that may contain an array of JSONObjects
+    // This is specifically written for  statistics manager northbound REST interface
+    // array_name should be either "flowStatistics" or "portStatistics"
+    private JSONObject getJsonInstance (JSONObject json, String array_name, Integer nodeId) throws JSONException
+    {
+        JSONObject result = null;
+        if (json.get(array_name) instanceof JSONArray){
+            JSONArray json_array = json.getJSONArray(array_name);
+            for (int i = 0; i < json_array.length(); i++) {
+                result = json_array.getJSONObject(i);
+                Integer nid = result.getJSONObject("node").getInt("@id");
+                if ( nid.equals(nodeId) )  break;
+            }
+        }
+        else {
+            result = json.getJSONObject(array_name);
+            Integer nid = result.getJSONObject("node").getInt("@id");
+            if ( ! nid.equals(nodeId) )  result = null;
+        }
+        return result;
+    }
+    
+
+    // a class to construct query parameter for HTTP request
+    private class QueryParameter {
+        StringBuilder queryString = null;
+        
+        // constructor
+        QueryParameter (String key, String value) {
+            queryString = new StringBuilder();
+            queryString.append("?").append(key).append("=").append(value);
+        }
+        
+        // method to add more query parameter
+        QueryParameter add (String key, String value){
+            this.queryString.append("&").append(key).append("=").append(value);
+            return this;
+        }
+        
+        // method to get the query parameter string
+        String getString (){
+            return this.queryString.toString();
+        }
+
+    }
+    
+    
+    @Test
+    public void testHostTracker() {
+
+        System.out.println("Starting HostTracker JAXB client.");
+
+        // setup 2 host models for @POST method
+        // 1st host
+        String networkAddress_1 = "192.168.0.8";
+        String dataLayerAddress_1 = "11:22:33:44:55:66";
+        String nodeType_1 = "STUB";
+        Integer nodeId_1 = 3366;
+        String nodeConnectorType_1 = "STUB";
+        Integer nodeConnectorId_1 = 12;
+        String vlan_1 = "4";
+        
+        
+        // 2nd host
+        String networkAddress_2 = "10.1.1.1";
+        String dataLayerAddress_2 = "1A:2B:3C:4D:5E:6F";
+        String nodeType_2 = "STUB";
+        Integer nodeId_2 = 4477;
+        String nodeConnectorType_2 = "STUB";
+        Integer nodeConnectorId_2 = 34;
+        String vlan_2 = "0";
+        
+        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
+
+        // test POST method: addHost()
+        try {
+            String queryParameter = 
+                    new QueryParameter("dataLayerAddress", dataLayerAddress_1)
+                    .add("nodeType", nodeType_1)
+                    .add("nodeId", nodeId_1.toString())
+                    .add("nodeConnectorType", nodeConnectorType_1)
+                    .add("nodeConnectorId", nodeConnectorId_1.toString())
+                    .add("vlan", vlan_1)
+                    .getString();
+
+            String result = getJsonResult(baseURL +"/" + networkAddress_1 + queryParameter, "POST");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 201);
+            
+            // vlan is not passed through query parameter but should be defaulted to "0"
+            queryParameter = 
+                    new QueryParameter("dataLayerAddress", dataLayerAddress_2)
+                    .add("nodeType", nodeType_2)
+                    .add("nodeId", nodeId_2.toString())
+                    .add("nodeConnectorType", nodeConnectorType_2)
+                    .add("nodeConnectorId", nodeConnectorId_2.toString())
+                    .getString();
+
+            result = getJsonResult(baseURL +"/" + networkAddress_2 + queryParameter, "POST");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 201);
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        
+        // define variables for decoding returned strings
+        String networkAddress;
+        JSONObject host_jo, dl_jo, nc_jo, node_jo;
+        
+        // the two hosts should be in inactive host DB
+        // test GET method: getInactiveHosts()
+        try {
+            String result = getJsonResult(baseURL +"/inactive", "GET");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
+            
+            JSONTokener jt = new JSONTokener(result);
+            JSONObject json = new JSONObject(jt);
+            // there should be at least two hosts in the DB
+            Assert.assertTrue (json.get("host") instanceof JSONArray);
+            JSONArray ja = json.getJSONArray("host");
+            Integer count = ja.length();
+            Assert.assertTrue (count == 2);
+            
+            for ( int i = 0; i < count; i++) {
+                host_jo = ja.getJSONObject(i);
+                dl_jo = host_jo.getJSONObject("dataLayerAddress");
+                nc_jo = host_jo.getJSONObject("nodeConnector");
+                node_jo = nc_jo.getJSONObject("node");
+                
+                networkAddress = host_jo.getString("networkAddress");
+                if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
+                    Assert.assertTrue (dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_1));
+                    Assert.assertTrue (nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_1));
+                    Assert.assertTrue (Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+                    Assert.assertTrue (node_jo.getString("@type").equalsIgnoreCase(nodeType_1));
+                    Assert.assertTrue (Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+                    Assert.assertTrue (host_jo.getString("vlan").equalsIgnoreCase(vlan_1));
+                }
+                else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
+                    Assert.assertTrue (dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_2));
+                    Assert.assertTrue (nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_2));
+                    Assert.assertTrue (Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
+                    Assert.assertTrue (node_jo.getString("@type").equalsIgnoreCase(nodeType_2));
+                    Assert.assertTrue (Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
+                    Assert.assertTrue (host_jo.getString("vlan").equalsIgnoreCase(vlan_2));
+                }
+                else {
+                    Assert.assertTrue(false);
+                }
+            }
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        
+        // test GET method: getActiveHosts() - no host expected
+        try {
+            String result = getJsonResult(baseURL, "GET");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
+            
+            JSONTokener jt = new JSONTokener(result);
+            JSONObject json = new JSONObject(jt);
+            Assert.assertFalse(hostInJson(json, networkAddress_1));
+            Assert.assertFalse(hostInJson(json, networkAddress_2));
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        
+        // put the 1st host into active host DB
+        Node nd;
+        NodeConnector ndc;
+        try {
+            nd = new Node(nodeType_1, nodeId_1);
+            ndc = new NodeConnector(nodeConnectorType_1, nodeConnectorId_1, nd);
+            this.invtoryListener.notifyNodeConnector(ndc,
+                    UpdateType.ADDED, null);
+        }catch(ConstructionException e){
+            ndc = null;
+            nd = null;
+        }
+        
+        // verify the host shows up in active host DB
+        try {
+            String result = getJsonResult(baseURL, "GET");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
+            
+            JSONTokener jt = new JSONTokener(result);
+            JSONObject json = new JSONObject(jt);
+            Assert.assertTrue(hostInJson(json, networkAddress_1));
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        
+        
+        // test GET method for getHostDetails()
+        try {
+            String result = getJsonResult(baseURL+"/"+networkAddress_1, "GET");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
+            
+            JSONTokener jt = new JSONTokener(result);
+            JSONObject json = new JSONObject(jt);
+
+            Assert.assertFalse(json.length() == 0);
+            
+            dl_jo = json.getJSONObject("dataLayerAddress");
+            nc_jo = json.getJSONObject("nodeConnector");
+            node_jo = nc_jo.getJSONObject("node");
+            
+            Assert.assertTrue (json.getString("networkAddress").equalsIgnoreCase(networkAddress_1));
+            Assert.assertTrue (dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_1));
+            Assert.assertTrue (nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_1));
+            Assert.assertTrue (Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+            Assert.assertTrue (node_jo.getString("@type").equalsIgnoreCase(nodeType_1));
+            Assert.assertTrue (Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+            Assert.assertTrue (json.getString("vlan").equalsIgnoreCase(vlan_1));
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        
+        // test DELETE method for deleteFlow()
+        try {
+            String result = getJsonResult(baseURL+"/"+networkAddress_1, "DELETE");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
+            
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        
+        // verify host_1 removed from active host DB
+        // test GET method: getActiveHosts() - no host expected
+        try {
+            String result = getJsonResult(baseURL, "GET");
+            Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
+            
+            JSONTokener jt = new JSONTokener(result);
+            JSONObject json = new JSONObject(jt);
+            
+            Assert.assertFalse(hostInJson(json, networkAddress_1));
+        } catch (Exception e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
+        }
+        }
+        
+        private Boolean hostInJson (JSONObject json, String hostIp) throws JSONException  {
+       // input JSONObject may be empty
+        if ( json.length() == 0 ) {
+            return false;
+        }
+        if (json.get("host") instanceof JSONArray){
+            JSONArray ja = json.getJSONArray("host");
+            for (int i = 0; i < ja.length(); i++) {
+                String na = ja.getJSONObject(i).getString("networkAddress");
+                if (na.equalsIgnoreCase(hostIp))
+                    return true;
+                }
+            return false;
+        } 
+        else {
+            String na = json.getJSONObject("host").getString("networkAddress");
+            return (na.equalsIgnoreCase(hostIp)) ? true : false;
+        }
+    }
+
+
     // Configure the OSGi container
     @Configuration
     public Option[] config() {
diff --git a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/AllTableStatistics.java b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/AllTableStatistics.java
new file mode 100644 (file)
index 0000000..5b998ee
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.statistics.northbound;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class AllTableStatistics {
+    @XmlElement
+    List<TableStatistics> tableStatistics;
+    //To satisfy JAXB
+    private AllTableStatistics() {
+    }
+
+    public AllTableStatistics(List<TableStatistics> tableStatistics) {
+        this.tableStatistics = tableStatistics;
+    }
+
+    public List<TableStatistics> getTableStatistics() {
+        return tableStatistics;
+    }
+
+    public void setTableStatistics(List<TableStatistics> tableStatistics) {
+        this.tableStatistics = tableStatistics;
+    }
+
+}
index 5cddc663c69283bd61b097ec6137da97736589e5..dee52932bda41ed77ca5b0be273bae94886b791e 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
@@ -113,9 +114,9 @@ public class StatisticsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(AllFlowStatistics.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The containerName is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 404, condition = "The containerName is not found"),
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public AllFlowStatistics getFlowStatistics(
             @PathParam("containerName") String containerName) {
         if (!NorthboundUtils.isAuthorized(
@@ -168,9 +169,9 @@ public class StatisticsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(FlowStatistics.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The containerName is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 404, condition = "The containerName is not found"),
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public FlowStatistics getFlowStatistics(
             @PathParam("containerName") String containerName,
             @PathParam("nodeType") String nodeType,
@@ -216,9 +217,9 @@ public class StatisticsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(AllPortStatistics.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The containerName is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 404, condition = "The containerName is not found"),
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public AllPortStatistics getPortStatistics(
             @PathParam("containerName") String containerName) {
 
@@ -270,9 +271,9 @@ public class StatisticsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(PortStatistics.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The containerName is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 404, condition = "The containerName is not found"),
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public PortStatistics getPortStatistics(
             @PathParam("containerName") String containerName,
             @PathParam("nodeType") String nodeType,
@@ -304,6 +305,108 @@ public class StatisticsNorthbound {
                 statisticsManager.getNodeConnectorStatistics(node));
     }
 
+    /**
+     * Returns a list of all the Table Statistics on all Nodes.
+     *
+     * @param containerName
+     *            Name of the Container. The Container name for the base
+     *            controller is "default".
+     *
+     * @return Returns a list of all the Table Statistics in a given Node.
+     */
+    @Path("/{containerName}/tablestats")
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @TypeHint(TableStatistics.class)
+    @StatusCodes({
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 404, condition = "The containerName is not found"),
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+    public AllTableStatistics getTableStatistics(
+            @PathParam("containerName") String containerName) {
+
+        if (!NorthboundUtils.isAuthorized(
+                getUserName(), containerName, Privilege.READ, this)) {
+            throw new UnauthorizedException(
+                    "User is not authorized to perform this operation on container "
+                            + containerName);
+        }
+        handleDefaultDisabled(containerName);
+
+        IStatisticsManager statisticsManager = getStatisticsService(containerName);
+        if (statisticsManager == null) {
+            throw new ServiceUnavailableException("Statistics "
+                    + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        ISwitchManager switchManager = (ISwitchManager) ServiceHelper
+                .getInstance(ISwitchManager.class, containerName, this);
+        if (switchManager == null) {
+            throw new ServiceUnavailableException("Switch manager "
+                    + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        List<TableStatistics> statistics = new ArrayList<TableStatistics>();
+        for (Node node : switchManager.getNodes()) {
+            List<NodeTableStatistics> stat = statisticsManager
+                    .getNodeTableStatistics(node);
+            TableStatistics tableStat = new TableStatistics(node, stat);
+            statistics.add(tableStat);
+        }
+        return new AllTableStatistics(statistics);
+    }
+
+    /**
+     * Returns a list of all the Table Statistics on all Nodes.
+     *
+     * @param containerName
+     *            Name of the Container. The Container name for the base
+     *            controller is "default".
+     * @param nodeType
+     *            Node Type as specifid by Node class
+     * @param Node
+     *            Identifier
+     * @return Returns a list of all the Table Statistics in a given Node.
+     */
+    @Path("/{containerName}/tablestats/{nodeType}/{nodeId}")
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @TypeHint(TableStatistics.class)
+    @StatusCodes({
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 404, condition = "The containerName is not found"),
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+    public TableStatistics getTableStatistics(
+            @PathParam("containerName") String containerName,
+            @PathParam("nodeType") String nodeType,
+            @PathParam("nodeId") String nodeId) {
+
+        if (!NorthboundUtils.isAuthorized(
+                getUserName(), containerName, Privilege.READ, this)) {
+            throw new UnauthorizedException(
+                    "User is not authorized to perform this operation on container "
+                            + containerName);
+        }
+        handleDefaultDisabled(containerName);
+
+        IStatisticsManager statisticsManager = getStatisticsService(containerName);
+        if (statisticsManager == null) {
+            throw new ServiceUnavailableException("Statistics "
+                    + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        ISwitchManager switchManager = (ISwitchManager) ServiceHelper
+                .getInstance(ISwitchManager.class, containerName, this);
+        if (switchManager == null) {
+            throw new ServiceUnavailableException("Switch manager "
+                    + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        Node node = handleNodeAvailability(containerName, nodeType, nodeId);
+        return new TableStatistics(node,
+                statisticsManager.getNodeTableStatistics(node));
+    }
+
     private void handleDefaultDisabled(String containerName) {
         IContainerManager containerManager = (IContainerManager) ServiceHelper
                 .getGlobalInstance(IContainerManager.class, this);
diff --git a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/TableStatistics.java b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/TableStatistics.java
new file mode 100644 (file)
index 0000000..a1c2019
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.statistics.northbound;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class TableStatistics {
+    @XmlElement
+    private Node node;
+    @XmlElement(name="tableStat")
+    private List<NodeTableStatistics> tableStats;
+
+    // To satisfy JAXB
+    @SuppressWarnings("unused")
+    private TableStatistics() {
+    }
+
+    public TableStatistics(Node node, List<NodeTableStatistics> tableStats) {
+        super();
+        this.node = node;
+        this.tableStats = tableStats;
+    }
+
+    public Node getNode() {
+        return node;
+    }
+
+    public void setNode(Node node) {
+        this.node = node;
+    }
+
+    public List<NodeTableStatistics> getTableStats() {
+        return tableStats;
+    }
+
+    public void setTableStats(List<NodeTableStatistics> tableStats) {
+        this.tableStats = tableStats;
+    }
+
+}
index 3790ae8ea925f9b92a7caefc6d1d9170e92a2520..0764c0b0077d25f9d33e2d173079a16e2bae9078 100644 (file)
@@ -1,17 +1,27 @@
+
+/*
+ * 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.statistics.northbound;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import junit.framework.TestCase;
+
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 import org.opendaylight.controller.sal.utils.NodeCreator;
 
-import junit.framework.TestCase;
-
 public class StatisticsNorthboundTest extends TestCase {
 
     @Test
@@ -64,4 +74,28 @@ public class StatisticsNorthboundTest extends TestCase {
         Assert.assertTrue(aps.getPortStatistics() == null);
     }
 
+    @Test
+    public void testTableStatistics() {
+        List<NodeTableStatistics> nts = new ArrayList<NodeTableStatistics>();
+        Node node = NodeCreator.createOFNode(1L);
+        TableStatistics ts = new TableStatistics(node, nts);
+
+        Assert.assertTrue(ts.getNode().equals(node));
+        Assert.assertTrue(ts.getTableStats().equals(nts));
+        Node node2 = NodeCreator.createOFNode(2L);
+        ts.setNode(node2);
+        Assert.assertTrue(ts.getNode().equals(node2));
+        ts.setTableStats(null);
+        Assert.assertTrue(ts.getTableStats() == null);
+    }
+
+    @Test
+    public void testAllTableStatistics() {
+        List<TableStatistics> ts = new ArrayList<TableStatistics>();
+        AllTableStatistics ats = new AllTableStatistics(ts);
+        Assert.assertTrue(ats.getTableStatistics().equals(ts));
+        ats.setTableStatistics(null);
+        Assert.assertTrue(ats.getTableStatistics() == null);
+    }
+
 }
index 7bdd3f322b4ab5d85dceb896f0d19dbca772f20f..e92583a33a9543c30c60b269ddc67a0c075c8561 100644 (file)
@@ -39,7 +39,6 @@ import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailab
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
-import org.opendaylight.controller.sal.core.MacAddress;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
@@ -51,7 +50,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
 /**
  * The class provides Northbound REST APIs to access the nodes, node connectors
  * and their properties.
- * 
+ *
  */
 
 @Path("/")
@@ -102,9 +101,9 @@ public class SwitchNorthbound {
     }
 
     /**
-     * 
+     *
      * Retrieve a list of all the nodes and their properties in the network
-     * 
+     *
      * @param containerName
      *            The container for which we want to retrieve the list
      * @return A list of Pair each pair represents a
@@ -129,7 +128,7 @@ public class SwitchNorthbound {
                             + containerName);
         }
 
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
@@ -141,7 +140,6 @@ public class SwitchNorthbound {
             return null;
         }
 
-        byte[] controllerMac = switchManager.getControllerMAC();
         for (Node node : nodes) {
             Map<String, Property> propMap = switchManager.getNodeProps(node);
             if (propMap == null) {
@@ -149,10 +147,6 @@ public class SwitchNorthbound {
             }
             Set<Property> props = new HashSet<Property>(propMap.values());
 
-            byte[] nodeMac = switchManager.getNodeMAC(node);
-            Property macAddr = new MacAddress(controllerMac, nodeMac);
-            props.add(macAddr);
-
             NodeProperties nodeProps = new NodeProperties(node, props);
             res.add(nodeProps);
         }
@@ -162,7 +156,7 @@ public class SwitchNorthbound {
 
     /**
      * Add a Name/Tier property to a node
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @param nodeType
@@ -204,7 +198,7 @@ public class SwitchNorthbound {
         }
         handleDefaultDisabled(containerName);
 
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
@@ -225,7 +219,7 @@ public class SwitchNorthbound {
 
     /**
      * Delete a property of a node
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @param nodeType
@@ -261,7 +255,7 @@ public class SwitchNorthbound {
         }
         handleDefaultDisabled(containerName);
 
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
@@ -278,10 +272,10 @@ public class SwitchNorthbound {
     }
 
     /**
-     * 
+     *
      * Retrieve a list of all the node connectors and their properties in a
      * given node
-     * 
+     *
      * @param containerName
      *            The container for which we want to retrieve the list
      * @param nodeType
@@ -315,7 +309,7 @@ public class SwitchNorthbound {
                             + containerName);
         }
 
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
@@ -347,7 +341,7 @@ public class SwitchNorthbound {
 
     /**
      * Add a Name/Bandwidth property to a node connector
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @param nodeType
@@ -396,7 +390,7 @@ public class SwitchNorthbound {
 
         handleDefaultDisabled(containerName);
 
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
@@ -425,7 +419,7 @@ public class SwitchNorthbound {
 
     /**
      * Delete a property of a node connector
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @param nodeType
@@ -469,7 +463,7 @@ public class SwitchNorthbound {
 
         handleDefaultDisabled(containerName);
 
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
@@ -492,7 +486,7 @@ public class SwitchNorthbound {
 
     /*    *//**
      * Retrieve a list of Span ports that were configured previously.
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @return list of
@@ -501,17 +495,17 @@ public class SwitchNorthbound {
      */
     /*
      * @Path("/span-config/{containerName}")
-     * 
+     *
      * @GET
-     * 
+     *
      * @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-     * 
+     *
      * @StatusCodes( {
-     * 
+     *
      * @ResponseCode(code = 200, condition = "Operation successful"),
-     * 
+     *
      * @ResponseCode(code = 404, condition = "The containerName is not found"),
-     * 
+     *
      * @ResponseCode(code = 503, condition =
      * "One or more of Controller Services are unavailable") }) public
      * List<SpanConfig> getSpanConfigList(@PathParam("containerName") String
@@ -519,11 +513,11 @@ public class SwitchNorthbound {
      * getIfSwitchManagerService(containerName); if (switchManager == null) {
      * throw new ServiceUnavailableException("Switch Manager " +
      * RestMessages.SERVICEUNAVAILABLE.toString()); }
-     * 
+     *
      * return switchManager.getSpanConfigList(); }
      *//**
      * Add a span configuration
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @param config
@@ -533,34 +527,34 @@ public class SwitchNorthbound {
      */
     /*
      * @Path("/span-config/{containerName}")
-     * 
+     *
      * @PUT
-     * 
+     *
      * @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-     * 
+     *
      * @StatusCodes( {
-     * 
+     *
      * @ResponseCode(code = 200, condition = "Operation successful"),
-     * 
+     *
      * @ResponseCode(code = 404, condition = "The containerName is not found"),
-     * 
+     *
      * @ResponseCode(code = 503, condition =
      * "One or more of Controller Services are unavailable") }) public Response
      * addSpanConfig(@PathParam("containerName") String containerName,
-     * 
+     *
      * @TypeHint(SubnetConfig.class) JAXBElement<SpanConfig> config) {
      * ISwitchManager switchManager = (ISwitchManager)
      * getIfSwitchManagerService(containerName); if (switchManager == null) {
      * throw new ServiceUnavailableException("Switch Manager " +
      * RestMessages.SERVICEUNAVAILABLE.toString()); }
-     * 
+     *
      * String ret = switchManager.addSpanConfig(config.getValue()); if
      * (ret.equals(ReturnString.SUCCESS.toString())) { return
      * Response.status(Response.Status.CREATED).build(); } throw new
      * InternalServerErrorException(ret); }
      *//**
      * Delete a span configuration
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @param config
@@ -570,27 +564,27 @@ public class SwitchNorthbound {
      */
     /*
      * @Path("/span-config/{containerName}")
-     * 
+     *
      * @DELETE
-     * 
+     *
      * @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-     * 
+     *
      * @StatusCodes( {
-     * 
+     *
      * @ResponseCode(code = 200, condition = "Operation successful"),
-     * 
+     *
      * @ResponseCode(code = 404, condition = "The containerName is not found"),
-     * 
+     *
      * @ResponseCode(code = 503, condition =
      * "One or more of Controller Services are unavailable") }) public Response
      * deleteSpanConfig(@PathParam("containerName") String containerName,
-     * 
+     *
      * @TypeHint(SubnetConfig.class) JAXBElement<SpanConfig> config) {
      * ISwitchManager switchManager = (ISwitchManager)
      * getIfSwitchManagerService(containerName); if (switchManager == null) {
      * throw new ServiceUnavailableException("Switch Manager " +
      * RestMessages.SERVICEUNAVAILABLE.toString()); }
-     * 
+     *
      * String ret = switchManager.removeSpanConfig(config.getValue()); if
      * (ret.equals(ReturnString.SUCCESS.toString())) { return
      * Response.ok().build(); } throw new ResourceNotFoundException(ret); }
@@ -598,7 +592,7 @@ public class SwitchNorthbound {
 
     /**
      * Save the current switch configurations
-     * 
+     *
      * @param containerName
      *            Name of the Container
      * @return Response as dictated by the HTTP Response Status code
@@ -619,7 +613,7 @@ public class SwitchNorthbound {
                     "User is not authorized to perform this operation on container "
                             + containerName);
         }
-        ISwitchManager switchManager = (ISwitchManager) getIfSwitchManagerService(containerName);
+        ISwitchManager switchManager = getIfSwitchManagerService(containerName);
         if (switchManager == null) {
             throw new ServiceUnavailableException("Switch Manager "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IDiscoveryListener.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IDiscoveryListener.java
new file mode 100644 (file)
index 0000000..ecc5d6e
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * 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.protocol_plugin.openflow;
+
+import org.opendaylight.controller.sal.discovery.IDiscoveryService;
+
+/**
+ * The interface provides method to notify the local plugin listener when an
+ * edge is discovered or removed.
+ */
+public interface IDiscoveryListener extends IDiscoveryService {
+
+}
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryProvider.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryProvider.java
new file mode 100644 (file)
index 0000000..6b2ea30
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.protocol_plugin.openflow;
+
+import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
+
+/**
+ * The Interface provides inventory service to the local plugin modules
+ */
+public interface IInventoryProvider extends IPluginInInventoryService {
+
+}
index 18fe686dd5be1dbf98bbafea3841b9803e7fbd93..74dc84aec9613671bb24a17bfd38f788b5c8f35d 100644 (file)
@@ -22,9 +22,9 @@ public interface IOFStatisticsManager {
     /**
      * Return all the statistics for all the flows present on the specified switch
      *
-        * @param switchId the openflow datapath id
-        * @return      the list of openflow statistics
-        */
+     * @param switchId the openflow datapath id
+     * @return the list of openflow statistics
+     */
     List<OFStatistics> getOFFlowStatistics(Long switchId);
 
     /**
@@ -39,7 +39,7 @@ public interface IOFStatisticsManager {
     /**
      * Return the description statistics for the specified switch.
      *
-        * @param switchId the openflow datapath id
+     * @param switchId the openflow datapath id
      * @return the list of openflow statistics
      */
     List<OFStatistics> getOFDescStatistics(Long switchId);
@@ -47,7 +47,7 @@ public interface IOFStatisticsManager {
     /**
      * Returns the statistics for all the ports on the specified switch
      *
-        * @param switchId the openflow datapath id
+     * @param switchId the openflow datapath id
      * @return the list of openflow statistics
      */
     List<OFStatistics> getOFPortStatistics(Long switchId);
@@ -55,7 +55,7 @@ public interface IOFStatisticsManager {
     /**
      * Returns the statistics for the specified switch port
      *
-        * @param switchId the openflow datapath id
+     * @param switchId the openflow datapath id
      * @param portId the openflow switch port id
      * @return the list of openflow statistics
      */
@@ -64,7 +64,7 @@ public interface IOFStatisticsManager {
     /**
      * Returns the number of flows installed on the switch
      *
-        * @param switchId the openflow datapath id
+     * @param switchId the openflow datapath id
      * @return the number of flows installed on the switch
      */
     int getFlowsNumber(long switchId);
@@ -77,12 +77,12 @@ public interface IOFStatisticsManager {
      * @param switchId the openflow datapath id of the target switch
      * @param statType the openflow statistics type
      * @param target the target object. For flow statistics it is the OFMatch.
-     *                                  For port statistics, it is the port id. If null the query
-     *                                  will be performed for all the targets for the specified
-     *                                  statistics type. 
-     *                                  
+     *                                  For port statistics, it is the port id. If null the query
+     *                                  will be performed for all the targets for the specified
+     *                                  statistics type.
+     * 
      * @param timeout the timeout in milliseconds the system will wait for a response
-     *                   from the switch, before declaring failure 
+     *                  from the switch, before declaring failure
      * @return the list of openflow statistics
      */
     List<OFStatistics> queryStatistics(Long switchId,
@@ -97,4 +97,21 @@ public interface IOFStatisticsManager {
      */
     long getTransmitRate(Long switchId, Short port);
 
+    /**
+     * Returns the statistics for the specified switch table
+     *
+     * @param switchId the openflow datapath id
+     * @param tableId the openflow switch table id
+     * @return the list of openflow statistics
+     */
+    List<OFStatistics> getOFTableStatistics(Long switchId, Byte tableId);
+
+    /**
+     * Returns all the table statistics for the node specified
+     *
+     * @param switchId the openflow datapath id
+     * @return the list of openflow statistics
+     */
+    List<OFStatistics> getOFTableStatistics(Long switchId);
+
 }
index a000024e9e0c7e5355e49e668cb966f71f004080..af474f0e67215492f29418ed66628bf6d3b2833b 100644 (file)
@@ -13,10 +13,12 @@ import java.util.List;
 
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 
 /**
  * Interface to serve the hardware information requests coming from SAL
@@ -77,6 +79,24 @@ public interface IPluginReadServiceFilter {
     public List<NodeConnectorStatistics> readAllNodeConnector(String container,
             Node node, boolean cached);
 
+    /**
+     * Returns the table statistics of the node as specified by the given container
+     * @param node
+     * @param cached
+     * @return
+     */
+    public NodeTableStatistics readNodeTable(String container,
+            NodeTable nodeTable, boolean cached);
+
+    /**
+     * Returns the table statistics of all the tables for the specified node
+     *
+     * @param node
+     * @return
+     */
+    public List<NodeTableStatistics> readAllNodeTable(String containerName,
+            Node node, boolean cached);
+
     /**
      * Returns the average transmit rate for the specified node conenctor on
      * the given container. If the node connector does not belong to the passed
index 30834cbe1371ca9f42f08e2160751dd51ac2079c..a93a8b7243cede7e2d81d212160dbe7a97806539 100644 (file)
@@ -14,7 +14,9 @@ import java.util.Hashtable;
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketListen;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux;
+import org.opendaylight.controller.protocol_plugin.openflow.IDiscoveryListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IFlowProgrammerNotifier;
+import org.opendaylight.controller.protocol_plugin.openflow.IInventoryProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
@@ -28,7 +30,6 @@ import org.opendaylight.controller.protocol_plugin.openflow.core.internal.Contro
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.controller.sal.core.IContainerListener;
 import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
@@ -44,8 +45,8 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Openflow protocol plugin Activator
- * 
- * 
+ *
+ *
  */
 public class Activator extends ComponentActivatorAbstractBase {
     protected static final Logger logger = LoggerFactory
@@ -54,7 +55,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function called when the activator starts just after some initializations
      * are done by the ComponentActivatorAbstractBase.
-     * 
+     *
      */
     public void init() {
     }
@@ -62,7 +63,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function called when the activator stops just before the cleanup done by
      * ComponentActivatorAbstractBase
-     * 
+     *
      */
     public void destroy() {
     }
@@ -70,8 +71,8 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function that is used to communicate to dependency manager the list of
      * known implementations for services inside a container
-     * 
-     * 
+     *
+     *
      * @return An array containing all the CLASS objects that will be
      *         instantiated in order to get an fully working implementation
      *         Object
@@ -86,7 +87,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function that is called when configuration of the dependencies is
      * required.
-     * 
+     *
      * @param c
      *            dependency manager Component object, used for configuring the
      *            dependencies exported and imported
@@ -121,8 +122,8 @@ public class Activator extends ComponentActivatorAbstractBase {
             // export the service
             c.setInterface(
                     new String[] { IPluginInInventoryService.class.getName(),
-                            IInventoryShimInternalListener.class.getName() },
-                    null);
+                            IInventoryShimInternalListener.class.getName(),
+                            IInventoryProvider.class.getName() }, null);
 
             // Now lets add a service dependency to make sure the
             // provider of service exists
@@ -193,8 +194,8 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function that is used to communicate to dependency manager the list of
      * known implementations for services that are container independent.
-     * 
-     * 
+     *
+     *
      * @return An array containing all the CLASS objects that will be
      *         instantiated in order to get an fully working implementation
      *         Object
@@ -210,7 +211,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function that is called when configuration of the dependencies is
      * required.
-     * 
+     *
      * @param c
      *            dependency manager Component object, used for configuring the
      *            dependencies exported and imported
@@ -299,16 +300,16 @@ public class Activator extends ComponentActivatorAbstractBase {
                     .setRequired(true));
             c.add(createContainerServiceDependency(
                     GlobalConstants.DEFAULT.toString())
-                    .setService(IPluginInInventoryService.class)
-                    .setCallbacks("setPluginInInventoryService",
-                            "unsetPluginInInventoryService").setRequired(true));
+                    .setService(IInventoryProvider.class)
+                    .setCallbacks("setInventoryProvider",
+                    "unsetInventoryProvider").setRequired(true));
             c.add(createServiceDependency().setService(IDataPacketMux.class)
                     .setCallbacks("setIDataPacketMux", "unsetIDataPacketMux")
                     .setRequired(true));
             c.add(createServiceDependency()
-                    .setService(IDiscoveryService.class)
-                    .setCallbacks("setDiscoveryService",
-                            "unsetDiscoveryService").setRequired(true));
+                    .setService(IDiscoveryListener.class)
+                    .setCallbacks("setDiscoveryListener",
+                            "unsetDiscoveryListener").setRequired(true));
         }
 
         // DataPacket mux/demux services, which is teh actual engine
@@ -355,7 +356,7 @@ public class Activator extends ComponentActivatorAbstractBase {
         }
 
         if (imp.equals(TopologyServiceShim.class)) {
-            c.setInterface(new String[] { IDiscoveryService.class.getName(),
+            c.setInterface(new String[] { IDiscoveryListener.class.getName(),
                     IContainerListener.class.getName(),
                     IRefreshInternalProvider.class.getName(),
                     IInventoryShimExternalListener.class.getName() }, null);
index 0cbaf67d9ed9452afc0927de7b9b487547663713..3be6f22742432795a55f17540fa03b8792b1bac9 100644 (file)
@@ -26,6 +26,8 @@ import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketListen;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux;
+import org.opendaylight.controller.protocol_plugin.openflow.IDiscoveryListener;
+import org.opendaylight.controller.protocol_plugin.openflow.IInventoryProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
@@ -45,8 +47,6 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.State;
 import org.opendaylight.controller.sal.core.UpdateType;
-import org.opendaylight.controller.sal.discovery.IDiscoveryService;
-import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
 import org.opendaylight.controller.sal.packet.Ethernet;
 import org.opendaylight.controller.sal.packet.LLDP;
 import org.opendaylight.controller.sal.packet.LLDPTLV;
@@ -67,8 +67,8 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     private static Logger logger = LoggerFactory
             .getLogger(DiscoveryService.class);
     private IController controller = null;
-    private IDiscoveryService discoveryService = null;
-    private IPluginInInventoryService pluginInInventoryService = null;
+    private IDiscoveryListener discoveryListener = null;
+    private IInventoryProvider inventoryProvider = null;
     private IDataPacketMux iDataPacketMux = null;
 
     private List<NodeConnector> readyListHi = null; // newly added ports go into
@@ -292,6 +292,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
                     inPkt.getIncomingNodeConnector(), e);
             return PacketResult.IGNORED;
         }
+
         if (ethPkt.getPayload() instanceof LLDP) {
             NodeConnector dst = inPkt.getIncomingNodeConnector();
             if (isEnabled(dst)) {
@@ -360,7 +361,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
 
     /*
      * Handle discovery frames generated by our controller
-     * 
+     *
      * @return true if it's a success
      */
     private boolean processDiscoveryPacket(NodeConnector dstNodeConnector,
@@ -430,11 +431,11 @@ public class DiscoveryService implements IInventoryShimExternalListener,
             return null;
         }
 
-        if (pluginInInventoryService == null) {
+        if (inventoryProvider == null) {
             return null;
         }
 
-        Map<NodeConnector, Map<String, Property>> props = pluginInInventoryService
+        Map<NodeConnector, Map<String, Property>> props = inventoryProvider
                 .getNodeConnectorProps(false);
         if (props == null) {
             return null;
@@ -775,7 +776,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
 
     /**
      * Update Production Edge
-     * 
+     *
      * @param edge
      *            The Production Edge
      * @param props
@@ -811,7 +812,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
 
     /**
      * Remove Production Edge for a given edge port
-     * 
+     *
      * @param edgePort
      *            The OF edge port
      */
@@ -826,8 +827,8 @@ public class DiscoveryService implements IInventoryShimExternalListener,
         }
 
         // notify Topology
-        if (this.discoveryService != null) {
-            this.discoveryService.notifyEdge(edge, UpdateType.REMOVED, null);
+        if (this.discoveryListener != null) {
+            this.discoveryListener.notifyEdge(edge, UpdateType.REMOVED, null);
         }
         logger.trace("Remove edge {}", edge);
     }
@@ -858,8 +859,8 @@ public class DiscoveryService implements IInventoryShimExternalListener,
         }
 
         // notify Topology
-        if (this.discoveryService != null) {
-            this.discoveryService.notifyEdge(edge, UpdateType.REMOVED, null);
+        if (this.discoveryListener != null) {
+            this.discoveryListener.notifyEdge(edge, UpdateType.REMOVED, null);
         }
         logger.trace("Remove {}", nodeConnector);
     }
@@ -869,11 +870,11 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     }
 
     private void updateEdge(Edge edge, UpdateType type, Set<Property> props) {
-        if (discoveryService == null) {
+        if (discoveryListener == null) {
             return;
         }
 
-        this.discoveryService.notifyEdge(edge, type, props);
+        this.discoveryListener.notifyEdge(edge, type, props);
 
         NodeConnector src = edge.getTailNodeConnector(), dst = edge
                 .getHeadNodeConnector();
@@ -1382,9 +1383,6 @@ public class DiscoveryService implements IInventoryShimExternalListener,
         removeDiscovery(node);
     }
 
-    public void updateNode(Node node, Set<Property> props) {
-    }
-
     void setController(IController s) {
         this.controller = s;
     }
@@ -1395,12 +1393,12 @@ public class DiscoveryService implements IInventoryShimExternalListener,
         }
     }
 
-    public void setPluginInInventoryService(IPluginInInventoryService service) {
-        this.pluginInInventoryService = service;
+    public void setInventoryProvider(IInventoryProvider service) {
+        this.inventoryProvider = service;
     }
 
-    public void unsetPluginInInventoryService(IPluginInInventoryService service) {
-        this.pluginInInventoryService = null;
+    public void unsetInventoryProvider(IInventoryProvider service) {
+        this.inventoryProvider = null;
     }
 
     public void setIDataPacketMux(IDataPacketMux service) {
@@ -1413,13 +1411,13 @@ public class DiscoveryService implements IInventoryShimExternalListener,
         }
     }
 
-    void setDiscoveryService(IDiscoveryService s) {
-        this.discoveryService = s;
+    void setDiscoveryListener(IDiscoveryListener s) {
+        this.discoveryListener = s;
     }
 
-    void unsetDiscoveryService(IDiscoveryService s) {
-        if (this.discoveryService == s) {
-            this.discoveryService = null;
+    void unsetDiscoveryListener(IDiscoveryListener s) {
+        if (this.discoveryListener == s) {
+            this.discoveryListener = null;
         }
     }
 
@@ -1444,7 +1442,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init() {
         logger.trace("Init called");
@@ -1474,7 +1472,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
      * 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() {
         transmitQ = null;
@@ -1493,7 +1491,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     /**
      * 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() {
         discoveryTimer.schedule(discoveryTimerTask, discoveryTimerTick,
@@ -1513,7 +1511,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
      * 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() {
         shuttingDown = true;
@@ -1563,7 +1561,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     /**
      * This method returns the interval which determines how often the discovery
      * packets will be sent. Default is 300 seconds.
-     * 
+     *
      * @return The discovery interval in second
      */
     private int getDiscoveryInterval() {
@@ -1583,7 +1581,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     /**
      * This method returns the timeout value in waiting for response of a
      * discovery query. Default is 60 seconds.
-     * 
+     *
      * @return The discovery timeout in second
      */
     private int getDiscoveryTimeout() {
@@ -1603,7 +1601,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
     /**
      * This method returns the number of retries after the initial discovery
      * packet is not received within the timeout period. Default is 2 times.
-     * 
+     *
      * @return The number of discovery retries
      */
     private int getDiscoveryRetry() {
index 8af9b3ea058d894bf544c960bedf019256924721..7a2ace5bae6008e0262b06755d1e70bec668219f 100644 (file)
@@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
+import org.opendaylight.controller.protocol_plugin.openflow.IInventoryProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
@@ -44,11 +45,11 @@ import org.slf4j.LoggerFactory;
  * container of the network. Each instance gets container specific inventory
  * events from InventoryServiceShim. It interacts with SAL to pass inventory
  * data to the upper application.
- * 
- * 
+ *
+ *
  */
 public class InventoryService implements IInventoryShimInternalListener,
-        IPluginInInventoryService {
+        IPluginInInventoryService, IInventoryProvider {
     protected static final Logger logger = LoggerFactory
             .getLogger(InventoryService.class);
     private Set<IPluginOutInventoryService> pluginOutInventoryServices = Collections
@@ -71,7 +72,7 @@ public class InventoryService implements IInventoryShimInternalListener,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     @SuppressWarnings("rawtypes")
     void init(Component c) {
@@ -92,7 +93,7 @@ public class InventoryService implements IInventoryShimInternalListener,
      * 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() {
         logger.trace("DESTROY called!");
@@ -101,7 +102,7 @@ public class InventoryService implements IInventoryShimInternalListener,
     /**
      * 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() {
         logger.trace("START called!");
@@ -111,7 +112,7 @@ public class InventoryService implements IInventoryShimInternalListener,
      * 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() {
         logger.trace("STOP called!");
@@ -299,7 +300,7 @@ public class InventoryService implements IInventoryShimInternalListener,
             }
         }
     }
-    
+
     private void updateNode(Node node, Set<Property> properties) {
         logger.trace("{} updated, props: {}", node, properties);
         if (nodeProps == null || !nodeProps.containsKey(node) ||
@@ -315,7 +316,7 @@ public class InventoryService implements IInventoryShimInternalListener,
             Property currentProperty = propertyMap.get(name);
             if (!property.equals(currentProperty)) {
                 propertyMap.put(name, property);
-                newProperties.add(property);                
+                newProperties.add(property);
             }
         }
 
index c472747a8e16eac2b421e17931f51a9d09f1b84f..f7210a333bd870d87216128b73cffb8a8402842f 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Description;
 import org.opendaylight.controller.sal.core.IContainerListener;
+import org.opendaylight.controller.sal.core.MacAddress;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -51,17 +52,17 @@ import org.slf4j.LoggerFactory;
  * The class describes a shim layer that bridges inventory events from Openflow
  * core to various listeners. The notifications are filtered based on container
  * configurations.
- * 
- * 
+ *
+ *
  */
 public class InventoryServiceShim implements IContainerListener,
         IMessageListener, ISwitchStateListener, IStatisticsListener {
     protected static final Logger logger = LoggerFactory
             .getLogger(InventoryServiceShim.class);
     private IController controller = null;
-    private ConcurrentMap<String, IInventoryShimInternalListener> inventoryShimInternalListeners = new ConcurrentHashMap<String, IInventoryShimInternalListener>();
-    private List<IInventoryShimExternalListener> inventoryShimExternalListeners = new CopyOnWriteArrayList<IInventoryShimExternalListener>();
-    private ConcurrentMap<NodeConnector, List<String>> containerMap = new ConcurrentHashMap<NodeConnector, List<String>>();
+    private final ConcurrentMap<String, IInventoryShimInternalListener> inventoryShimInternalListeners = new ConcurrentHashMap<String, IInventoryShimInternalListener>();
+    private final List<IInventoryShimExternalListener> inventoryShimExternalListeners = new CopyOnWriteArrayList<IInventoryShimExternalListener>();
+    private final ConcurrentMap<NodeConnector, List<String>> containerMap = new ConcurrentHashMap<NodeConnector, List<String>>();
 
     void setController(IController s) {
         this.controller = s;
@@ -133,7 +134,7 @@ public class InventoryServiceShim implements IContainerListener,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init() {
         this.controller.addMessageListener(OFType.PORT_STATUS, this);
@@ -152,7 +153,7 @@ public class InventoryServiceShim implements IContainerListener,
      * 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() {
         this.controller.removeMessageListener(OFType.PACKET_IN, this);
@@ -202,8 +203,9 @@ public class InventoryServiceShim implements IContainerListener,
 
     @Override
     public void switchAdded(ISwitch sw) {
-        if (sw == null)
+        if (sw == null) {
             return;
+        }
 
         // Add all the nodeConnectors of this switch
         Map<NodeConnector, Set<Property>> ncProps = InventoryServiceHelper
@@ -219,8 +221,9 @@ public class InventoryServiceShim implements IContainerListener,
 
     @Override
     public void switchDeleted(ISwitch sw) {
-        if (sw == null)
+        if (sw == null) {
             return;
+        }
 
         removeNode(sw);
     }
@@ -389,6 +392,7 @@ public class InventoryServiceShim implements IContainerListener,
         Long connectedSinceTime = (connectedSince == null) ? 0 : connectedSince
                 .getTime();
         props.add(new TimeStamp(connectedSinceTime, "connectedSince"));
+        props.add(new MacAddress(deriveMacAddress(sid)));
 
         byte tables = sw.getTables();
         Tables t = new Tables(tables);
@@ -410,6 +414,7 @@ public class InventoryServiceShim implements IContainerListener,
         if (b != null) {
             props.add(b);
         }
+
         // Notify all internal and external listeners
         notifyInventoryShimListener(node, type, props);
     }
@@ -447,15 +452,24 @@ public class InventoryServiceShim implements IContainerListener,
             logger.error("{}", e.getMessage());
             return;
         }
-        
+
         Set<Property> properties = new HashSet<Property>(1);
         Description desc = new Description(
                 descriptionStats.getDatapathDescription());
         properties.add(desc);
-        
+
         // Notify all internal and external listeners
         notifyInventoryShimListener(node, UpdateType.CHANGED, properties);
-    }  
+    }
+
+    private byte[] deriveMacAddress(long dpid) {
+        byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
-   
+        for (short i = 0; i < 6; i++) {
+            mac[5 - i] = (byte) dpid;
+            dpid >>= 8;
+        }
+
+        return mac;
+    }
 }
index d6100e3fdc499c2bd53eb9eb45c414c70e8517d1..78fddc773637c8aefb338b729d4e416e66e85441 100644 (file)
@@ -54,6 +54,7 @@ import org.openflow.protocol.statistics.OFPortStatisticsRequest;
 import org.openflow.protocol.statistics.OFQueueStatisticsRequest;
 import org.openflow.protocol.statistics.OFStatistics;
 import org.openflow.protocol.statistics.OFStatisticsType;
+import org.openflow.protocol.statistics.OFTableStatistics;
 import org.openflow.protocol.statistics.OFVendorStatistics;
 import org.openflow.util.HexString;
 import org.osgi.framework.BundleContext;
@@ -67,23 +68,26 @@ import org.slf4j.LoggerFactory;
  * provides an API to directly query the switch about the statistics
  */
 public class OFStatisticsManager implements IOFStatisticsManager,
-        IInventoryShimExternalListener, CommandProvider {
+IInventoryShimExternalListener, CommandProvider {
     private static final Logger log = LoggerFactory
             .getLogger(OFStatisticsManager.class);
     private static final int initialSize = 64;
     private static final long flowStatsPeriod = 10000;
     private static final long descriptionStatsPeriod = 60000;
     private static final long portStatsPeriod = 5000;
+    private static final long tableStatsPeriod = 10000;
     private static final long tickPeriod = 1000;
     private static short statisticsTickNumber = (short) (flowStatsPeriod / tickPeriod);
     private static short descriptionTickNumber = (short) (descriptionStatsPeriod / tickPeriod);
     private static short portTickNumber = (short) (portStatsPeriod / tickPeriod);
+    private static short tableTickNumber = (short) (tableStatsPeriod / tickPeriod);
     private static short factoredSamples = (short) 2;
     private static short counter = 1;
     private IController controller = null;
     private ConcurrentMap<Long, List<OFStatistics>> flowStatistics;
     private ConcurrentMap<Long, List<OFStatistics>> descStatistics;
     private ConcurrentMap<Long, List<OFStatistics>> portStatistics;
+    private ConcurrentMap<Long, List<OFStatistics>> tableStatistics;
     private List<OFStatistics> dummyList;
     private ConcurrentMap<Long, StatisticsTicks> statisticsTimerTicks;
     protected BlockingQueue<StatsRequest> pendingStatsRequests;
@@ -164,6 +168,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         flowStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
         descStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
         portStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
+        tableStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
         dummyList = new ArrayList<OFStatistics>(1);
         statisticsTimerTicks = new ConcurrentHashMap<Long, StatisticsTicks>(
                 initialSize);
@@ -283,6 +288,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
             type = t;
         }
 
+        @Override
         public String toString() {
             return "SReq = {switchId=" + switchId + ", type=" + type + "}";
         }
@@ -339,6 +345,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         private short flowStatisticsTicks;
         private short descriptionTicks;
         private short portStatisticsTicks;
+        private short tableStatisticsTicks;
 
         public StatisticsTicks(boolean scattered) {
             if (scattered) {
@@ -350,10 +357,12 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                         % statisticsTickNumber);
                 descriptionTicks = (short) (1 + counter % descriptionTickNumber);
                 portStatisticsTicks = (short) (1 + counter % portTickNumber);
+                tableStatisticsTicks = (short) (1 + counter % tableTickNumber);
             } else {
                 flowStatisticsTicks = statisticsTickNumber;
                 descriptionTicks = descriptionTickNumber;
                 portStatisticsTicks = portTickNumber;
+                tableStatisticsTicks = tableTickNumber;
             }
         }
 
@@ -387,9 +396,20 @@ public class OFStatisticsManager implements IOFStatisticsManager,
             return false;
         }
 
+        public boolean decrementTableTicksIsZero() {
+            // Please ensure no code is inserted between the if check and the
+            // descriptionTicks reset
+            if(--tableStatisticsTicks == 0) {
+                tableStatisticsTicks = tableTickNumber;
+                return true;
+            }
+            return false;
+        }
+
+        @Override
         public String toString() {
             return "{fT=" + flowStatisticsTicks + ",dT=" + descriptionTicks
-                    + ",pT=" + portStatisticsTicks + "}";
+                    + ",pT=" + portStatisticsTicks + ",tT=" + tableStatisticsTicks + "}";
         }
     }
 
@@ -438,6 +458,16 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                     printInfoMessage("Port", request);
                 }
             }
+
+            if(clock.decrementTableTicksIsZero() == true) {
+                request = new StatsRequest(switchId, OFStatisticsType.TABLE);
+                // If a request for this switch is already in the queue, skip to
+                // add this new request
+                if (!pendingStatsRequests.contains(request)
+                        && false == pendingStatsRequests.offer(request)) {
+                    printInfoMessage("Table", request);
+                }
+            }
         }
     }
 
@@ -454,6 +484,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                 OFStatisticsType.DESC));
         pendingStatsRequests.remove(new StatsRequest(switchId,
                 OFStatisticsType.PORT));
+        pendingStatsRequests.remove(new StatsRequest(switchId,
+                OFStatisticsType.TABLE));
         // Take care of the TX rate databases
         switchPortStatsUpdated.remove(switchId);
         txRates.remove(switchId);
@@ -491,6 +523,9 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                 // Wake up the thread which maintains the TX byte counters for
                 // each port
                 switchPortStatsUpdated.offer(switchId);
+            } else if (statType == OFStatisticsType.TABLE) {
+                // Overwrite cache
+                tableStatistics.put(switchId, values);
             }
         }
     }
@@ -591,6 +626,20 @@ public class OFStatisticsManager implements IOFStatisticsManager,
             } else if (statsType == OFStatisticsType.DESC) {
                 type = "DESC";
             } else if (statsType == OFStatisticsType.TABLE) {
+                if(target != null){
+                    if (!(target instanceof Byte)) {
+                        // Malformed request
+                        log.warn("Invalid table id for table stats request: {}",
+                                target.getClass());
+                        return null;
+                    }
+                    byte targetTable = (Byte) target;
+                    OFTableStatistics specificReq = new OFTableStatistics();
+                    specificReq.setTableId(targetTable);
+                    req.setStatistics(Collections
+                            .singletonList((OFStatistics) specificReq));
+                    requestLength += specificReq.getLength();
+                }
                 type = "TABLE";
             }
             req.setLengthU(requestLength);
@@ -602,7 +651,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
             } else if (result instanceof OFError) {
                 log.warn("Switch {} failed to handle ({}) stats request: {}",
                         new Object[] { HexString.toHexString(switchId), type,
-                                Utils.getOFErrorString((OFError) result) });
+                        Utils.getOFErrorString((OFError) result) });
                 if (this.switchSupportsVendorExtStats.get(switchId) == Boolean.TRUE) {
                     log.warn(
                             "Switching back to regular Flow stats requests for switch {}",
@@ -791,6 +840,31 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         return list;
     }
 
+    @Override
+    public List<OFStatistics> getOFTableStatistics(Long switchId) {
+        if (!tableStatistics.containsKey(switchId)) {
+            return this.dummyList;
+        }
+
+        return tableStatistics.get(switchId);
+    }
+
+    @Override
+    public List<OFStatistics> getOFTableStatistics(Long switchId, Byte tableId) {
+        if (!tableStatistics.containsKey(switchId)) {
+            return this.dummyList;
+        }
+
+        List<OFStatistics> list = new ArrayList<OFStatistics>(1);
+        for (OFStatistics stats : tableStatistics.get(switchId)) {
+            if (((OFTableStatistics) stats).getTableId() == tableId) {
+                list.add(stats);
+                break;
+            }
+        }
+        return list;
+    }
+
     @Override
     public int getFlowsNumber(long switchId) {
         return this.flowStatistics.get(switchId).size();
@@ -938,6 +1012,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         ci.println("Flow Stats Period: " + statisticsTickNumber + " s");
         ci.println("Desc Stats Period: " + descriptionTickNumber + " s");
         ci.println("Port Stats Period: " + portTickNumber + " s");
+        ci.println("Table Stats Period: " + tableTickNumber + " s");
     }
 
     public void _resetSwitchCapability(CommandInterpreter ci) {
@@ -1008,6 +1083,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         String flowStatsInterv = ci.nextArgument();
         String portStatsInterv = ci.nextArgument();
         String descStatsInterv = ci.nextArgument();
+        String tableStatsInterv = ci.nextArgument();
 
         if (flowStatsInterv == null || portStatsInterv == null
                 || descStatsInterv == null) {
@@ -1016,27 +1092,30 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                     + portTickNumber + "s dP=" + descriptionTickNumber + "s");
             return;
         }
-        Short fP, pP, dP;
+        Short fP, pP, dP, tP;
         try {
             fP = Short.parseShort(flowStatsInterv);
             pP = Short.parseShort(portStatsInterv);
             dP = Short.parseShort(descStatsInterv);
+            tP = Short.parseShort(tableStatsInterv);
         } catch (Exception e) {
             ci.println("Invalid format values: " + e.getMessage());
             return;
         }
 
-        if (pP <= 1 || fP <= 1 || dP <= 1) {
-            ci.println("Invalid values. fP, pP, dP have to be greater than 1.");
+        if (pP <= 1 || fP <= 1 || dP <= 1 || tP <= 1) {
+            ci.println("Invalid values. fP, pP, dP, tP have to be greater than 1.");
             return;
         }
 
         statisticsTickNumber = fP;
         portTickNumber = pP;
         descriptionTickNumber = dP;
+        tableTickNumber = tP;
 
         ci.println("New Values: fP=" + statisticsTickNumber + "s pP="
-                + portTickNumber + "s dP=" + descriptionTickNumber + "s");
+                + portTickNumber + "s dP=" + descriptionTickNumber + "s tP="
+                + tableTickNumber + "s");
     }
 
     /**
@@ -1047,7 +1126,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         String fsStr = System.getProperty("of.flowStatsPollInterval");
         String psStr = System.getProperty("of.portStatsPollInterval");
         String dsStr = System.getProperty("of.descStatsPollInterval");
-        Short fs, ps, ds;
+        String tsStr = System.getProperty("of.tableStatsPollInterval");
+        Short fs, ps, ds, ts;
 
         if (fsStr != null) {
             try {
@@ -1078,5 +1158,15 @@ public class OFStatisticsManager implements IOFStatisticsManager,
             } catch (Exception e) {
             }
         }
+
+        if (tsStr != null) {
+            try{
+                ts = Short.parseShort(tsStr);
+                if (ts > 0) {
+                    tableTickNumber = ts;
+                }
+            } catch (Exception e) {
+            }
+        }
     }
 }
index 9ff3d21ff0a5ddbff953066b9e2b3553f3807617..20d13b7a3dc9325244ff05f5f586cd1b8e31e1d9 100644 (file)
@@ -20,11 +20,13 @@ import org.slf4j.LoggerFactory;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.IPluginInReadService;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 
 /**
  * Container Instance of IPluginInReadService implementation class
@@ -146,4 +148,24 @@ public class ReadService implements IPluginInReadService {
         }
         return filter.getTransmitRate(containerName, connector);
     }
+
+    @Override
+    public NodeTableStatistics readNodeTable(NodeTable table, boolean cached) {
+        if (!table.getNode().getType()
+                .equals(NodeIDType.OPENFLOW)) {
+            logger.error("Invalid node type");
+            return null;
+        }
+        return filter.readNodeTable(containerName, table, cached);
+    }
+
+    @Override
+    public List<NodeTableStatistics> readAllNodeTable(Node node, boolean cached) {
+        if (!node.getType().equals(NodeIDType.OPENFLOW)) {
+            logger.error("Invalid node type");
+            return null;
+        }
+
+        return filter.readAllNodeTable(containerName, node, cached);
+    }
 }
index 1b71c3bec34f70b382af55c094e7acb7f86f0fdf..bcb01b1392ac8661f2ee6aeb3db5e34c47362a41 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.IContainerListener;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
@@ -40,10 +41,12 @@ import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
-
+import org.opendaylight.controller.sal.utils.NodeTableCreator;
+import org.openflow.protocol.statistics.OFTableStatistics;
 /**
  * Read Service shim layer which is in charge of filtering the flow statistics
  * based on container. It is a Global instance.
@@ -58,6 +61,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
     private IController controller = null;
     private IOFStatisticsManager statsMgr = null;
     private Map<String, Set<NodeConnector>> containerToNc;
+    private Map<String, Set<NodeTable>> containerToNt;
 
     public void setController(IController core) {
         this.controller = core;
@@ -76,6 +80,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
      */
     void init() {
         containerToNc = new HashMap<String, Set<NodeConnector>>();
+        containerToNt = new HashMap<String, Set<NodeTable>>();
     }
 
     /**
@@ -174,9 +179,9 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         long sid = (Long) node.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFDescStatistics(sid) : statsMgr.queryStatistics(sid,
-                OFStatisticsType.DESC, null);
+                        OFStatisticsType.DESC, null);
 
-        return new DescStatisticsConverter(ofList).getHwDescription();
+                return new DescStatisticsConverter(ofList).getHwDescription();
     }
 
     /**
@@ -235,6 +240,28 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         return newList;
     }
 
+
+    public List<OFStatistics> filterTableListPerContainer(
+            String container, long switchId, List<OFStatistics> list) {
+        if (list == null) {
+            return null;
+        }
+
+        // Create new filtered list of node tables
+        List<OFStatistics> newList = new ArrayList<OFStatistics>();
+
+        for (OFStatistics stat : list) {
+            OFTableStatistics target = (OFTableStatistics) stat;
+            NodeTable nt = NodeTableCreator.createOFNodeTable(
+                    target.getTableId(), NodeCreator.createOFNode(switchId));
+            if (containerOwnsNodeTable(container, nt)) {
+                newList.add(target);
+            }
+        }
+
+        return newList;
+    }
+
     /**
      * Returns whether the specified flow (flow match + actions)
      * belongs to the container
@@ -251,7 +278,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         }
         return (flowPortsBelongToContainer(container, node, flow)
                 && flowVlanBelongsToContainer(container, node, flow) && flowSpecAllowsFlow(
-                container, flow.getMatch()));
+                        container, flow.getMatch()));
     }
 
     /**
@@ -270,6 +297,22 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         return (portSet == null) ? false : portSet.contains(p);
     }
 
+    /**
+     * Returns whether the passed NodeConnector belongs to the container
+     *
+     * @param container        container name
+     * @param table            node table to test
+     * @return                 true if belongs false otherwise
+     */
+    public boolean containerOwnsNodeTable(String container, NodeTable table) {
+        // All node table belong to the default container
+        if (container.equals(GlobalConstants.DEFAULT.toString())) {
+            return true;
+        }
+        Set<NodeTable> tableSet = containerToNt.get(container);
+        return (tableSet == null) ? false : tableSet.contains(table);
+    }
+
     /**
      * Returns whether the container flowspec allows the passed flow
      *
@@ -382,11 +425,11 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         short portId = (Short) connector.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFPortStatistics(sid, portId) : statsMgr.queryStatistics(
-                sid, OFStatisticsType.PORT, portId);
+                        sid, OFStatisticsType.PORT, portId);
 
-        List<NodeConnectorStatistics> ncStatistics = new PortStatisticsConverter(
-                sid, ofList).getNodeConnectorStatsList();
-        return (ncStatistics.isEmpty()) ? new NodeConnectorStatistics()
+                List<NodeConnectorStatistics> ncStatistics = new PortStatisticsConverter(
+                        sid, ofList).getNodeConnectorStatsList();
+                return (ncStatistics.isEmpty()) ? new NodeConnectorStatistics()
                 : ncStatistics.get(0);
     }
 
@@ -397,12 +440,12 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         long sid = (Long) node.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFPortStatistics(sid) : statsMgr.queryStatistics(sid,
-                OFStatisticsType.FLOW, null);
+                        OFStatisticsType.FLOW, null);
 
-        List<OFStatistics> filteredList = filterPortListPerContainer(
-                containerName, sid, ofList);
+                List<OFStatistics> filteredList = filterPortListPerContainer(
+                        containerName, sid, ofList);
 
-        return new PortStatisticsConverter(sid, filteredList)
+                return new PortStatisticsConverter(sid, filteredList)
                 .getNodeConnectorStatsList();
     }
 
@@ -418,4 +461,39 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         return statsMgr.getTransmitRate(switchId, port);
     }
 
+    @Override
+    public NodeTableStatistics readNodeTable(String containerName,
+            NodeTable table, boolean cached) {
+        if (!containerOwnsNodeTable(containerName, table)) {
+            return null;
+        }
+        Node node = table.getNode();
+        long sid = (Long) node.getID();
+        Byte tableId = (Byte) table.getID();
+        List<OFStatistics> ofList = (cached == true) ? statsMgr
+                .getOFTableStatistics(sid, tableId) : statsMgr.queryStatistics(
+                        sid, OFStatisticsType.TABLE, tableId);
+
+                List<NodeTableStatistics> ntStatistics = new TableStatisticsConverter(
+                        sid, ofList).getNodeTableStatsList();
+
+                return (ntStatistics.isEmpty()) ? new NodeTableStatistics()
+                : ntStatistics.get(0);
+    }
+
+    @Override
+    public List<NodeTableStatistics> readAllNodeTable(String containerName,
+            Node node, boolean cached) {
+        long sid = (Long) node.getID();
+        List<OFStatistics> ofList = (cached == true) ? statsMgr
+                .getOFTableStatistics(sid) : statsMgr.queryStatistics(sid,
+                        OFStatisticsType.FLOW, null);
+
+                List<OFStatistics> filteredList = filterTableListPerContainer(
+                        containerName, sid, ofList);
+
+                return new TableStatisticsConverter(sid, filteredList)
+                .getNodeTableStatsList();
+    }
+
 }
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableConverter.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableConverter.java
new file mode 100644 (file)
index 0000000..0b53284
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.protocol_plugin.openflow.internal;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeTable;
+import org.opendaylight.controller.sal.utils.NodeTableCreator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TableConverter {
+    private static final Logger log = LoggerFactory
+            .getLogger(TableConverter.class);
+
+    public static NodeTable toNodeTable(byte tableId, Node node) {
+        log.trace("Openflow table ID: {}", Byte.toString(tableId));
+        return NodeTableCreator.createNodeTable(tableId, node);
+    }
+
+    public static byte toOFTable(NodeTable salTable) {
+        log.trace("SAL Table: {}", salTable);
+        return (Byte) salTable.getID();
+    }
+}
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableStatisticsConverter.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableStatisticsConverter.java
new file mode 100644 (file)
index 0000000..993f897
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.protocol_plugin.openflow.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.openflow.protocol.statistics.OFStatistics;
+import org.openflow.protocol.statistics.OFTableStatistics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Converts an openflow list of table statistics in a SAL list of
+ * NodeTableStatistics objects
+ */
+public class TableStatisticsConverter {
+    private static final Logger log = LoggerFactory
+            .getLogger(TableStatisticsConverter.class);
+
+    private final long switchId;
+    private List<OFStatistics> ofStatsList;
+    private List<NodeTableStatistics> ntStatsList;
+
+    public TableStatisticsConverter(long switchId, List<OFStatistics> statsList) {
+        this.switchId = switchId;
+        if (statsList == null || statsList.isEmpty()) {
+            this.ofStatsList = new ArrayList<OFStatistics>(1); // dummy list
+        } else {
+            this.ofStatsList = new ArrayList<OFStatistics>(statsList);
+        }
+        this.ntStatsList = null;
+    }
+
+    public List<NodeTableStatistics> getNodeTableStatsList() {
+        if (this.ofStatsList != null && this.ntStatsList == null) {
+            this.ntStatsList = new ArrayList<NodeTableStatistics>();
+            OFTableStatistics ofTableStat;
+            Node node = NodeCreator.createOFNode(switchId);
+            for (OFStatistics ofStat : this.ofStatsList) {
+                ofTableStat = (OFTableStatistics) ofStat;
+                NodeTableStatistics ntStat = new NodeTableStatistics();
+                ntStat.setNodeTable(TableConverter.toNodeTable(
+                        ofTableStat.getTableId(), node));
+                ntStat.setActiveCount(ofTableStat.getActiveCount());
+                ntStat.setLookupCount(ofTableStat.getLookupCount());
+                ntStat.setMatchedCount(ofTableStat.getMatchedCount());
+                this.ntStatsList.add(ntStat);
+            }
+        }
+        log.trace("OFStatistics: {} NodeTableStatistics: {}", ofStatsList,
+                ntStatsList);
+        return this.ntStatsList;
+    }
+}
index 873b53ff65aa23ececb17d733d64fb438f3f6098..1d7b4263e7b191cc13e83666130464442b66b5f2 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.protocol_plugin.openflow.IDiscoveryListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
@@ -44,7 +45,6 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.State;
 import org.opendaylight.controller.sal.core.UpdateType;
-import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 
@@ -53,7 +53,7 @@ import org.opendaylight.controller.sal.utils.GlobalConstants;
  * OpenFlow core to various listeners. The notifications are filtered based on
  * container configurations.
  */
-public class TopologyServiceShim implements IDiscoveryService,
+public class TopologyServiceShim implements IDiscoveryListener,
         IContainerListener, CommandProvider, IRefreshInternalProvider,
         IInventoryShimExternalListener {
     protected static final Logger logger = LoggerFactory
@@ -124,7 +124,7 @@ public class TopologyServiceShim implements IDiscoveryService,
                         teuMap.put(entry.container, teuList);
                         notifyListeners = true;
                     }
-                    
+
                     if (notifyListeners) {
                         for (String container : teuMap.keySet()) {
                             // notify the listener
@@ -203,7 +203,7 @@ public class TopologyServiceShim implements IDiscoveryService,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init() {
         logger.trace("Init called");
@@ -313,7 +313,7 @@ public class TopologyServiceShim implements IDiscoveryService,
      * 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() {
         logger.trace("DESTROY called!");
@@ -324,7 +324,7 @@ public class TopologyServiceShim implements IDiscoveryService,
     /**
      * 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() {
         logger.trace("START called!");
@@ -338,7 +338,7 @@ public class TopologyServiceShim implements IDiscoveryService,
      * 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() {
         logger.trace("STOP called!");
@@ -431,7 +431,7 @@ public class TopologyServiceShim implements IDiscoveryService,
     /**
      * Update local cache and return true if it needs to notify upper layer
      * Topology listeners.
-     * 
+     *
      * @param container
      *            The network container
      * @param edge
@@ -493,14 +493,14 @@ public class TopologyServiceShim implements IDiscoveryService,
                     "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);
 
@@ -508,7 +508,7 @@ public class TopologyServiceShim implements IDiscoveryService,
         if (notifyListeners) {
             notifyQ.add(new NotifyEntry(container, new TopoEdgeUpdate(edge, props,
                     type)));
-            logger.debug("notifyEdge: {} Edge {} in container {}", 
+            logger.debug("notifyEdge: {} Edge {} in container {}",
                     new Object[] { type.getName(), edge, container });
         }
     }
@@ -712,11 +712,11 @@ public class TopologyServiceShim implements IDiscoveryService,
      * pushes the updates to ALL the applications that have registered as
      * listeners for this service. SAL has no way of knowing which application
      * requested for the refresh.
-     * 
+     *
      * As an example of this case, is stopping and starting the Topology
      * Manager. When the topology Manager is stopped, and restarted, it will no
      * longer have the latest topology. Hence, a request is sent here.
-     * 
+     *
      * @param containerName
      * @return void
      */
@@ -731,7 +731,7 @@ public class TopologyServiceShim implements IDiscoveryService,
      * Reading the current topology database, the method will replay all the
      * edge updates for the ITopologyServiceShimListener instance in the given
      * container, which will in turn publish them toward SAL.
-     * 
+     *
      * @param containerName
      */
     private void TopologyBulkUpdate(String containerName) {
index 9c47b3b9839dec497ff8dc0d6a23d3e896aad35d..8e4c985c06b76ea6055717ae7a5d46370335673e 100644 (file)
@@ -7,6 +7,7 @@ import org.apache.felix.dm.Component;
 
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.controller.sal.core.IContainerListener;
+import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
 import org.opendaylight.controller.sal.utils.INodeFactory;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -104,7 +105,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     }
     
     public Object[] getGlobalImplementations() {
-        Object[] res = { FlowProgrammerService.class, StubNodeFactory.class };
+        Object[] res = { FlowProgrammerService.class, StubNodeFactory.class, StubNodeConnectorFactory.class };
         return res;
     }
     
@@ -126,5 +127,15 @@ public class Activator extends ComponentActivatorAbstractBase {
             props.put("protocolName", "STUB");
             c.setInterface(INodeFactory.class.getName(), props);
         }
+        if (imp.equals(StubNodeConnectorFactory.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", "STUB");
+            props.put("protocolName", "STUB");
+            c.setInterface(INodeConnectorFactory.class.getName(), props);
+        }
+        
     }
 }
index 64d4fc167597e39e2ca479ad5984221071ed346a..b4d6166d3636efa901aa490a8dd0d23dad0bbe4c 100644 (file)
@@ -115,6 +115,21 @@ public class InventoryService implements IPluginInInventoryService {
         }       
      
         nodeProps.put(node, propMap);
+        
+        try{
+            node = new Node("STUB", 3366);
+        }catch(ConstructionException e){
+            node = null;
+        }       
+        nodeProps.put(node, propMap);
+        
+        try{
+            node = new Node("STUB", 4477);
+        }catch(ConstructionException e){
+            node = null;
+        }       
+        nodeProps.put(node, propMap);
+        
         return nodeProps;
     }
 
@@ -146,7 +161,26 @@ public class InventoryService implements IPluginInInventoryService {
             node = null;
         }
         nodeConnectorProps.put(nc, ncPropMap);
-        return nodeConnectorProps;
+
+        try{
+            node = new Node("STUB", 3366);
+            nc = new NodeConnector("STUB", 12, node);
+         } catch(ConstructionException e){
+            nc = null;
+            node = null;
+         }
+         nodeConnectorProps.put(nc, ncPropMap);
+
+         try{
+            node = new Node("STUB", 4477);
+            nc = new NodeConnector("STUB", 34, node);
+         }catch(ConstructionException e){
+            nc = null;
+            node = null;
+         }
+         nodeConnectorProps.put(nc, ncPropMap);
+
+         return nodeConnectorProps;
     }
 
 
index 68bd3af751036c6a7c7a120e0813844efe4b0ed8..27ba897fdfc57b44e0d2d4c2ae391ffeae9364c3 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.controller.sal.action.SwPath;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchType;
@@ -43,7 +44,7 @@ import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.IPluginInReadService;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
-
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 /**
  * Stub Implementation for IPluginInReadService used by SAL
  * 
@@ -233,4 +234,33 @@ public class ReadService implements IPluginInReadService {
         return 100;
     }
 
+    @Override
+    public NodeTableStatistics readNodeTable(NodeTable table, boolean b) {
+        NodeTableStatistics stats = new NodeTableStatistics();
+        stats.setNodeTable(table);
+        stats.setActiveCount(4);
+        stats.setLookupCount(4);
+        stats.setMatchedCount(4);
+
+        return stats;
+    }
+
+    @Override
+    public List<NodeTableStatistics> readAllNodeTable(Node node, boolean cached) {
+        NodeTableStatistics stats = new NodeTableStatistics();
+        try {
+            NodeTable nt = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node);
+            stats.setNodeTable(nt);
+        } catch (ConstructionException e) {
+            // couldn't create nodetable.
+        }
+
+        stats.setActiveCount(4);
+        stats.setLookupCount(4);
+        stats.setMatchedCount(4);
+
+        List<NodeTableStatistics> result = new ArrayList<NodeTableStatistics>();
+        result.add(stats);
+        return result;
+    }
 }
diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/StubNodeConnectorFactory.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/StubNodeConnectorFactory.java
new file mode 100644 (file)
index 0000000..0c1963d
--- /dev/null
@@ -0,0 +1,49 @@
+package org.opendaylight.controller.protocol_plugins.stub.internal;
+
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
+import org.opendaylight.controller.sal.core.Node;
+
+public class StubNodeConnectorFactory implements INodeConnectorFactory
+    {
+      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.
+       * 
+       */
+      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() {
+      }
+      
+      public NodeConnector fromStringNoNode(String typeStr, String IDStr,
+              Node n){
+          if(typeStr.equals("STUB")){
+              try {
+                  return new NodeConnector(typeStr, Integer.parseInt(IDStr), n);
+              } catch (Exception ex) {
+                  return null;
+              }
+          }
+          return null;
+      }
+}
index c2ce473303632b90602986b806690a5f225146e4..5b8ee12e567791f963caee163415f1db41616edf 100644 (file)
@@ -35,7 +35,7 @@ public class StubNodeFactory implements INodeFactory
       void stop() {
       }
       
-      public Node fromString(String nodeId, String nodeType){
+      public Node fromString(String nodeType, String nodeId){
           if(nodeType.equals("STUB"))
               try{
                   return new Node("STUB", Integer.parseInt(nodeId));
index b4d1045bac2e461c4c408b6ae04e5531f07e4b53..d5fbdbc74371df64bbd204ed7965e156c21512da 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -19,86 +18,75 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 
 /**
- * The class contains the controller MAC address and node MAC address.
- *
- *
+ * The class contains MAC address property.
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class MacAddress extends Property {
+public class MacAddress extends Property implements Cloneable {
     private static final long serialVersionUID = 1L;
-    @XmlElement
-    private byte[] controllerMacAddress;
-    @XmlElement
-    private byte[] nodeMacAddress;
-    public static final String MacPropName = "macAddress";
+    @XmlElement(name="macAddress")
+    private final byte[] address;
+    public static final String name = "macAddress";
 
     /*
      * Private constructor used for JAXB mapping
      */
     private MacAddress() {
-        super(MacPropName);
-        this.controllerMacAddress = null;
-        this.nodeMacAddress = null;
-    }
-
-       /**
-        * Constructor to create DatalinkAddress property which contains the
-        * controller MAC address and node MAC address. The property will be
-        * attached to a {@link org.opendaylight.controller.sal.core.Node}.
-        * 
-        * @param controllerMacAddress Data Link Address for the controller
-        * @param nodeMacAddress Data Link Address for the node
-        * 
-        * @return the constructed object
-        */
-    public MacAddress(byte[] controllerMacAddress, byte[] nodeMacAddress) {
-        super(MacPropName);
-       
-        this.controllerMacAddress = controllerMacAddress;
-        this.nodeMacAddress = nodeMacAddress;
+        super(name);
+        this.address = null;
     }
 
     /**
-     * @return the controller MAC address
+     * Constructor to create DatalinkAddress property which contains the MAC
+     * address. The property will be attached to a
+     * {@link org.opendaylight.controller.sal.core.Node}.
+     *
+     *
+     * @param nodeMacAddress
+     *            Data Link Address for the node
+     *
+     * @return the constructed object
      */
-    public byte[] getControllerMacAddress() {
-        return this.controllerMacAddress;
+    public MacAddress(byte[] nodeMacAddress) {
+        super(name);
+        this.address = nodeMacAddress.clone();
     }
 
     /**
      * @return the node MAC address
      */
-    public byte[] getNodeMacAddress() {
-        return this.nodeMacAddress;
+    public byte[] getMacAddress() {
+        return this.address.clone();
     }
 
+    @Override
     public MacAddress clone() {
-       return new MacAddress(this.controllerMacAddress, this.nodeMacAddress);
+        return new MacAddress(this.address);
     }
 
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + Arrays.hashCode(controllerMacAddress);
-        result = prime * result + Arrays.hashCode(nodeMacAddress);
+        result = prime * result + Arrays.hashCode(address);
         return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (!super.equals(obj))
+        }
+        if (!super.equals(obj)) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         MacAddress other = (MacAddress) obj;
-        if (!Arrays.equals(controllerMacAddress, other.controllerMacAddress))
-            return false;
-        if (!Arrays.equals(nodeMacAddress, other.nodeMacAddress))
+        if (!Arrays.equals(address, other.address)) {
             return false;
+        }
         return true;
     }
 
index 4c7f278209096e16c857f57c6f49d9da7ea94c9f..ef0c0667aa22eeff199ea83ad3769adfaba7cfb9 100644 (file)
@@ -445,7 +445,7 @@ public class Node implements Serializable {
                     .getGlobalInstance(INodeFactory.class, new Node(), "(protocolName="+typeStr+")");
             if(f==null)
                 return null;
-            return f.fromString(IDStr, typeStr);
+            return f.fromString(typeStr, IDStr);
         }
     }
 }
index 495af7970c7f0597ad50fc1e39863aafd3753fd6..9c49a315082d5af561fb5c1b6cf6e7ff94eabf87 100644 (file)
@@ -28,6 +28,9 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
+import org.opendaylight.controller.sal.utils.INodeFactory;
+import org.opendaylight.controller.sal.utils.ServiceHelper;
 
 /**
  * Describe a generic network element attachment points,
@@ -602,8 +605,13 @@ public class NodeConnector implements Serializable {
                 return null;
             }
         } else {
-            // Lookup via OSGi service registry
+            //Use INodeConnectorFactory to create a NodeConnector of registered type.
+            //The protocol plugin being used depends on typeStr.
+            INodeConnectorFactory f = (INodeConnectorFactory) ServiceHelper
+                    .getGlobalInstance(INodeConnectorFactory.class, new NodeConnector(), "(protocolName="+typeStr+")");
+            if(f==null)
+                return null;
+            return f.fromStringNoNode(typeStr, IDStr, n);
         }
-        return null;
     }
 }
diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeTable.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeTable.java
new file mode 100644 (file)
index 0000000..22c3796
--- /dev/null
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.core;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NodeTable implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    public static final Short SPECIALNODETABLEID = (short) 0;
+
+    /**
+     * Enum-like static class created with the purpose of identifing
+     * multiple type of nodes in the SDN network. The type is
+     * necessary to figure out to later on correctly use the
+     * nodeTableID. Using a static class instead of an Enum so we can add
+     * dynamically new types without changing anything in the
+     * surround.
+     */
+    public static final class NodeTableIDType {
+        private static final ConcurrentHashMap<String, Class<? extends Object>> compatibleType =
+                new ConcurrentHashMap<String, Class<? extends Object>>();
+        /**
+         * These are in compliance with the compatibility types in 'Node'
+         */
+        public static String OPENFLOW = "OF";
+        public static String PCEP = "PE";
+        public static String ONEPK = "PK";
+        public static String PRODUCTION = "PR";
+
+        // Pre-populated types, just here for convenience and ease of
+        // unit-testing, but certainly those could live also outside.
+        // Currently we allow these 4. It can be changed later.
+        static {
+            compatibleType.put(OPENFLOW, Byte.class);
+            compatibleType.put(PCEP, UUID.class);
+            compatibleType.put(ONEPK, String.class);
+            compatibleType.put(PRODUCTION, String.class);
+        }
+
+        /**
+         * Return the type of the class expected for the
+         * NodeTableID, it's used for validity check in the constructor
+         *
+         * @param type, the type of the NodeTable for which we
+         * want to retrieve the compatible class to be used as ID.
+         *
+         * @return The Class which is supposed to instantiate the ID
+         * for the NodeTableID
+         */
+        public static Class<?> getClassType(String type) {
+            return compatibleType.get(type);
+        }
+
+        /**
+         * Returns all the registered nodeTableIDTypes currently available
+         *
+         * @return The current registered NodeTableIDTypes
+         */
+        public static Set<String> values() {
+            return compatibleType.keySet();
+        }
+
+        /**
+         * Register a new ID for which NodeTable can be created
+         *
+         * @param type, the new type being registered
+         * @param compatibleID, the type of class to be accepted as ID
+         *
+         * @return true if registered, false otherwise
+         */
+        public static boolean registerIDType(String type,
+                Class<? extends Object> compatibleID) {
+            if (compatibleType.get(type) != null) {
+                return false;
+            }  else {
+                compatibleType.put(type, compatibleID);
+                return true;
+            }
+        }
+
+        /**
+         * UNRegister a new ID for which Node can be created
+         *
+         * @param type, the type being UN-registered
+         *
+         */
+        public static void unRegisterIDType(String type) {
+            compatibleType.remove(type);
+        }
+    }
+
+    // Elements that constitute the NodeTable
+    private Object nodeTableID;
+    private String nodeTableType;
+    @XmlElement(name = "node")
+    private Node nodeTableNode;
+
+    // Helper field for JAXB
+    private String nodeTableIDString;
+
+    /**
+     * Private constructor used for JAXB mapping
+     */
+    private NodeTable() {
+        this.nodeTableIDString = null;
+        this.nodeTableID = null;
+        this.nodeTableType = null;
+        this.nodeTableNode = null;
+    }
+
+    public NodeTable(String nodeTableType, Object id, Node node) throws ConstructionException {
+        if (NodeTableIDType.getClassType(nodeTableType) != null &&
+                NodeTableIDType.getClassType(nodeTableType).isInstance(id) &&
+                node.getType().equals(nodeTableType)) {
+            this.nodeTableType = nodeTableType;
+            this.nodeTableID = id;
+            this.nodeTableNode = node;
+        } else {
+            throw new ConstructionException("Type of incoming object:"
+                    + id.getClass() + " not compatible with expected type:"
+                    + NodeTableIDType.getClassType(nodeTableType)
+                    + " or Node type incompatible:" + node.getType());
+        }
+    }
+
+    /**
+     * Copy constructor for NodeTable
+     *
+     * @param src NodeTable to copy from
+     *
+     */
+    public NodeTable(NodeTable src) throws ConstructionException {
+        if (src != null) {
+            this.nodeTableType = src.getType();
+            // Here we can reference the object because that is
+            // supposed to be an immutable identifier as well like a
+            // UUID/Integer and so on, hence no need to create a copy
+            // of it
+            this.nodeTableID = src.getID();
+            this.nodeTableNode = new Node(src.getNode());
+        } else {
+            throw
+            new ConstructionException("Null incoming object to copy from");
+        }
+    }
+
+    /**
+     * @return the nodeTableID
+     */
+    public Object getID() {
+        return this.nodeTableID;
+    }
+
+    /**
+     * @return the nodeTableType
+     */
+    public String getType() {
+        return this.nodeTableType;
+    }
+
+    /**
+     * @param type the nodeTableType to set
+     *
+     * Private setter for nodeConnectorType to be called by JAXB not by anyone
+     * else, NodeConnector is immutable
+     */
+    private void setType(String type) {
+        this.nodeTableType = type;
+        if (this.nodeTableIDString != null) {
+            this.fillmeFromString(type, this.nodeTableIDString);
+        }
+    }
+
+    /**
+     * @return the nodeTableNode
+     */
+    public Node getNode() {
+        return this.nodeTableNode;
+    }
+
+    /**
+     * @param nodeTableNode the nodeTableNode to set
+     */
+    public void setNodeTableNode(Node nodeTableNode) {
+        this.nodeTableNode = nodeTableNode;
+    }
+
+    /**
+     * @return the nodeTableIDString
+     */
+    @XmlAttribute(name = "id")
+    public String getNodeTableIDString() {
+        return this.nodeTableIDString.toString();
+    }
+
+    /**
+     * @param nodeTableIDString the nodeTableIDString to set
+     */
+    @SuppressWarnings("unused")
+    private void setNodeTableIDString(String IDStr) {
+        this.nodeTableIDString = IDStr;
+        if (this.nodeTableType != null) {
+            this.fillmeFromString(this.nodeTableType, IDStr);
+        }
+    }
+
+    /**
+     * fill the current object from the string parameters passed, will
+     * be only used by JAXB
+     *
+     * @param typeStr string representing the type of the Node
+     * @param IDStr String representation of the ID
+     */
+    private void fillmeFromString(String typeStr, String IDStr) {
+        if (typeStr == null) {
+            return;
+        }
+
+        if (IDStr == null) {
+            return;
+        }
+
+        this.nodeTableType = typeStr;
+        this.nodeTableID = (byte) Byte.parseByte(IDStr);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((nodeTableID == null) ? 0 : nodeTableID.hashCode());
+        result = prime
+                * result
+                + ((nodeTableNode == null) ? 0 : nodeTableNode
+                        .hashCode());
+        result = prime
+                * result
+                + ((nodeTableType == null) ? 0 : nodeTableType
+                        .hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        NodeTable other = (NodeTable) obj;
+        if (nodeTableID == null) {
+            if (other.nodeTableID != null)
+                return false;
+        } else if (!nodeTableID.equals(other.nodeTableID))
+            return false;
+        if (nodeTableNode == null) {
+            if (other.nodeTableNode != null)
+                return false;
+        } else if (!nodeTableNode.equals(other.nodeTableNode))
+            return false;
+        if (nodeTableType == null) {
+            if (other.nodeTableType != null)
+                return false;
+        } else if (!nodeTableType.equals(other.nodeTableType))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return this.getNodeTableIdAsString() + "@" + this.nodeTableNode;
+    }
+
+    public String getNodeTableIdAsString() {
+        return this.nodeTableType.toString() + "|"
+                + this.nodeTableID.toString();
+    }
+
+}
index d50c81e8d79cd519968a441ac664766a8dc33fa1..97d3eac808845ef7e4c8627414c8ec9e2161898a 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -25,19 +24,18 @@ import javax.xml.bind.annotation.XmlSeeAlso;
  */
 
 /**
- * Abstract base class for a Property that can be attached to any sal
- * core element
- *
+ * Abstract base class for a Property that can be attached to any sal core
+ * element
  */
 @XmlRootElement
 @XmlSeeAlso({ Config.class, Name.class, State.class, TimeStamp.class,
-               Latency.class, Bandwidth.class, Tier.class, Actions.class,
-               AdvertisedBandwidth.class, Buffers.class, Capabilities.class,
-               MacAddress.class, PeerBandwidth.class, SupportedBandwidth.class,
-               Tables.class })
-abstract public class Property implements Serializable {
+    Latency.class, Bandwidth.class, Tier.class, Actions.class,
+    AdvertisedBandwidth.class, Buffers.class, Capabilities.class,
+    MacAddress.class, PeerBandwidth.class, SupportedBandwidth.class,
+    Tables.class })
+abstract public class Property implements Serializable, Cloneable {
     private static final long serialVersionUID = 1L;
-    private String name;
+    private final String name;
 
     /**
      * Private constructor used for JAXB mapping
@@ -58,10 +56,10 @@ abstract public class Property implements Serializable {
     /**
      * Used to copy the Property in a polymorphic way
      *
-     *
      * @return A clone of this Property
      */
-    abstract public Property clone();
+    @Override
+    public abstract Property clone();
 
     @Override
     public int hashCode() {
@@ -73,18 +71,23 @@ abstract public class Property implements Serializable {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         Property other = (Property) obj;
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         return true;
     }
 
index c563037f1e6be9bce538780ba0dd8c93b2c3e31c..1b950d7cf592df1a78fc775d3a4c390a274d4efa 100644 (file)
@@ -13,6 +13,7 @@ import java.util.List;
 
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 
 /**
@@ -63,10 +64,25 @@ public interface IPluginInReadService {
     public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
             boolean cached);
 
+    /**
+     * Returns the table statistics for the node
+     * @param node
+     * @return
+     */
+    public NodeTableStatistics readNodeTable(NodeTable table, boolean cached);
+
+    /**
+     * Returns all the table statistics for the node
+     * @param node
+     * @return
+     */
+    public List<NodeTableStatistics> readAllNodeTable(Node node, boolean cached);
+
     /**
      * Returns the averaged transmit rate for the specified node connector
      * @param connector
      * @return tx rate [bps]
      */
     public long getTransmitRate(NodeConnector connector);
+
 }
index 3a9f828d942fc294d01e93606802c86233894058..ae975f1a58d21c7d30b52f7e878b48db4db905f0 100644 (file)
@@ -13,6 +13,7 @@ import java.util.List;
 
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 
 /**
@@ -88,6 +89,28 @@ public interface IReadService {
      */
     List<NodeConnectorStatistics> readNodeConnectors(Node node);
 
+    /**
+     * Read the Table statistics for the given node table
+     * @param table
+     */
+    NodeTableStatistics readNodeTable(NodeTable table);
+
+    /**
+     * Read the Table statistics for the given node
+     * This is not used. Querying all tables on a node is not currently a feature.
+     * @param table
+     */
+    List<NodeTableStatistics> readNodeTable(Node node);
+
+    /**
+     * Get the table statistics for the given node table
+     * This call results in a direct polling of the information from the node
+     * Caller will be blocked until the node replies or request times out
+     *
+     * @param table
+     */
+    NodeTableStatistics nonCachedReadNodeTable(NodeTable table);
+
     /**
      * Get the node connectors statistics information for the network node
      * This call results in a direct polling of the information from the node
diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java
new file mode 100644 (file)
index 0000000..3ccf8f5
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.reader;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.sal.core.NodeTable;
+
+/**
+ * @author Aditya Prakash Vaja <aditya.vaja@bigswitch.com>
+ * Represents the Table statistics for the node
+ * 
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NodeTableStatistics {
+    @XmlElement
+    private NodeTable nodeTable;
+    @XmlElement
+    private String name;
+    @XmlElement
+    private int activeCount;
+    @XmlElement
+    private long lookupCount;
+    @XmlElement
+    private long matchedCount;
+
+
+    //To Satisfy JAXB
+    public NodeTableStatistics() {
+
+    }
+
+    /**
+     * @return the node table
+     */
+    public NodeTable getNodeTable() {
+        return nodeTable;
+    }
+
+    /**
+     * @param table of the node
+     */
+    public void setNodeTable(NodeTable table) {
+        this.nodeTable = table;
+    }
+
+    /**
+     * @return name of the table
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name - set the table name to name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @return the activeCount
+     */
+    public int getActiveCount() {
+        return activeCount;
+    }
+
+    /**
+     * @param activeCount the activeCount to set
+     */
+    public void setActiveCount(int activeCount) {
+        this.activeCount = activeCount;
+    }
+
+    /**
+     * @return the lookupCount
+     */
+    public long getLookupCount() {
+        return lookupCount;
+    }
+
+    /**
+     * @param lookupCount the lookupCount to set
+     */
+    public void setLookupCount(long lookupCount) {
+        this.lookupCount = lookupCount;
+    }
+
+    /**
+     * @return the matchedCount
+     */
+    public long getMatchedCount() {
+        return matchedCount;
+    }
+
+    /**
+     * @param matchedCount the matchedCount to set
+     */
+    public void setMatchedCount(long matchedCount) {
+        this.matchedCount = matchedCount;
+    }
+
+    @Override
+    public String toString() {
+        return "NodeTableStats[tableId = " + nodeTable
+                + ", activeCount = " + activeCount
+                + ", lookupCount = " + lookupCount
+                + ", matchedCount = " + matchedCount + "]";
+    }
+}
diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/INodeConnectorFactory.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/INodeConnectorFactory.java
new file mode 100644 (file)
index 0000000..317976d
--- /dev/null
@@ -0,0 +1,29 @@
+
+/*
+ * 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.utils;
+
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+
+/**
+ * @file   INodeFactory.java
+ *
+ * @brief  Define the interface to be called when looking up custom node types
+ *
+ */
+
+public interface INodeConnectorFactory {
+    /**
+     * Method to get custom NodeConnector types from protocol plugins
+     *
+     */
+    public NodeConnector fromStringNoNode(String typeStr, String IDStr,
+            Node n);
+}
index 29ba7d6222537cf24f2c4c922aefdfbdeeb79609..dce6eb03f6885329cfd910ade984366ff7a8e5c8 100644 (file)
@@ -23,5 +23,5 @@ public interface INodeFactory {
      * Method to get custom node types from protocol plugins
      *
      */
-    public Node fromString(String nodeId, String nodeType);
+    public Node fromString(String nodeType, String nodeId);
 }
diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeTableCreator.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeTableCreator.java
new file mode 100644 (file)
index 0000000..5d69810
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.utils;
+
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeTable;
+import org.opendaylight.controller.sal.core.NodeTable.NodeTableIDType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeTableCreator {
+    protected static final Logger logger = LoggerFactory
+            .getLogger(NodeTableCreator.class);
+
+    /**
+     * Generic NodeTable creator
+     * The nodeTable type is OPENFLOW only for the time being
+     *
+     * @param portId
+     * @param node
+     * @return
+     */
+    public static NodeTable createNodeTable(byte tableId, Node node) {
+        try {
+            return new NodeTable(NodeTableIDType.OPENFLOW, tableId, node);
+        } catch (ConstructionException e1) {
+            logger.error("",e1);
+            return null;
+        }
+    }
+
+    public static NodeTable createOFNodeTable(byte tableId, Node node) {
+        try {
+            return new NodeTable(NodeTableIDType.OPENFLOW, tableId, node);
+        } catch (ConstructionException e1) {
+            logger.error("",e1);
+            return null;
+        }
+    }
+
+}
diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/NodeTableTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/core/NodeTableTest.java
new file mode 100644 (file)
index 0000000..57286fe
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.core;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+
+public class NodeTableTest {
+    @Test
+    public void testNodeTableOpenFlowOfWrongType() {
+        try {
+            Node node = NodeCreator.createOFNode((long) 20);
+            NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, "name", node);
+
+            // If we reach this point the exception was not raised
+            // which should have been the case
+            Assert.assertTrue(false);
+        } catch (ConstructionException e) {
+            // If we reach this point the exception has been raised
+            // and so test passed
+            System.out.println("Got exception as expected!:" + e);
+            Assert.assertTrue(true);
+        }
+    }
+
+    @Test
+    public void testNodeTableOpenFlowOfCorrectType() {
+        try {
+            Node node = NodeCreator.createOFNode((long) 20);
+            NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node);
+
+            // If we reach this point the exception has not been
+            // raised so we passed the test
+            System.out.println("Got node table:" + of1);
+            Assert.assertTrue(true);
+        } catch (ConstructionException e) {
+            // If we reach this point the exception was raised
+            // which is not expected
+            Assert.assertTrue(false);
+        }
+    }
+
+    @Test
+    public void testTwoOpenFlowNodeTableEquals() {
+        try {
+            Node node1 = NodeCreator.createOFNode((long) 20);
+            NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
+            NodeTable of2 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
+
+            Assert.assertTrue(of1.equals(of2));
+        } catch (ConstructionException e) {
+            // If we reach this point the exception was raised
+            // which is not expected
+            Assert.assertTrue(false);
+        }
+    }
+
+    @Test
+    public void testTwoOpenFlowNodeTableDifferents() {
+        try {
+            Node node1 = NodeCreator.createOFNode((long) 20);
+            NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
+            Node node2 = NodeCreator.createOFNode((long) 40);
+            NodeTable of2 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("20"), node2);
+
+            Assert.assertTrue(!of1.equals(of2));
+        } catch (ConstructionException e) {
+            // If we reach this point the exception was raised
+            // which is not expected
+            Assert.assertTrue(false);
+        }
+    }
+}
diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/reader/NodeTableStatisticsTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/reader/NodeTableStatisticsTest.java
new file mode 100644 (file)
index 0000000..c0d6bb6
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013 Big Switch Networks, Inc.  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.reader;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.sal.core.NodeTable;
+import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.NodeTableCreator;
+
+public class NodeTableStatisticsTest {
+
+    @Test
+    public void testNodeTableStatisticsMethods() {
+        NodeTable nt = NodeTableCreator.createNodeTable(Byte.valueOf("2") , NodeCreator.createOFNode((long)20));
+        NodeTableStatistics ntStats = new NodeTableStatistics();
+
+        ntStats.setNodeTable(nt);
+        ntStats.setActiveCount(100);
+        ntStats.setLookupCount(200);
+        ntStats.setMatchedCount(500);
+        ntStats.setName("Test");
+
+        Assert.assertTrue(ntStats.getNodeTable().equals(nt));
+        Assert.assertTrue(ntStats.getActiveCount() == 100);
+        Assert.assertTrue(ntStats.getLookupCount() == 200);
+        Assert.assertTrue(ntStats.getMatchedCount() == 500);
+        Assert.assertTrue(ntStats.getName().equals("Test"));
+    }
+}
index b5f5e2b2552720e41add54428b5099405fa3b518..1cc57bac66e797cead08f0e2300b325f3622afe1 100644 (file)
@@ -9,9 +9,12 @@
 
 package org.opendaylight.controller.sal.implementation.internal;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -31,8 +34,8 @@ import org.slf4j.LoggerFactory;
 public class Inventory implements IPluginOutInventoryService, IInventoryService {
     protected static final Logger logger = LoggerFactory
             .getLogger(Inventory.class);
-    private IListenInventoryUpdates updateService = null;
-    private IPluginInInventoryService pluginService = null;
+    private List<IListenInventoryUpdates> updateService = new CopyOnWriteArrayList<IListenInventoryUpdates>();
+    private List<IPluginInInventoryService> pluginService = new CopyOnWriteArrayList<IPluginInInventoryService>();
 
     /**
      * Function called by the dependency manager when all the required
@@ -80,55 +83,80 @@ public class Inventory implements IPluginOutInventoryService, IInventoryService
 
     public void setPluginService(IPluginInInventoryService service) {
         logger.trace("Got plugin service set request {}", service);
-        this.pluginService = service;
+        this.pluginService.add(service);
     }
 
     public void unsetPluginService(IPluginInInventoryService service) {
         logger.trace("Got plugin service UNset request");
-        this.pluginService = null;
+        this.pluginService.remove(service);
     }
 
     public void setUpdateService(IListenInventoryUpdates service) {
         logger.trace("Got update service set request {}", service);
-        this.updateService = service;
+        this.updateService.add(service);
     }
 
     public void unsetUpdateService(IListenInventoryUpdates service) {
         logger.trace("Got a service UNset request");
-        this.updateService = null;
+        this.updateService.remove(service);
     }
 
     @Override
     public void updateNode(Node node, UpdateType type, Set<Property> props) {
+        if (type == null) {
+            logger.trace("Input type is null");
+            return;
+        }
+
         logger.trace("{} {}", node, type);
-        if (updateService != null) {
-            updateService.updateNode(node, type, props);
+
+        for (IListenInventoryUpdates s : this.updateService) {
+            s.updateNode(node, type, props);
         }
     }
 
     @Override
     public void updateNodeConnector(NodeConnector nodeConnector,
             UpdateType type, Set<Property> props) {
+        if (type == null) {
+            logger.trace("Input type is null");
+            return;
+        }
+
         logger.trace("{} {}", nodeConnector, type);
 
-        if ((updateService != null) && (type != null)) {
-            updateService.updateNodeConnector(nodeConnector, type, props);
+        for (IListenInventoryUpdates s : this.updateService) {
+            s.updateNodeConnector(nodeConnector, type, props);
         }
     }
 
     @Override
     public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
-        if (pluginService != null)
-            return pluginService.getNodeProps();
-        else
-            return null;
+        ConcurrentMap<Node, Map<String, Property>> nodeProps =
+            new ConcurrentHashMap<Node, Map<String, Property>>(), rv;
+
+        for (IPluginInInventoryService s : this.pluginService) {
+            rv = s.getNodeProps();
+            if (rv != null) {
+                nodeProps.putAll(rv);
+            }
+        }
+
+        return nodeProps;
     }
 
     @Override
     public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps() {
-        if (pluginService != null)
-            return pluginService.getNodeConnectorProps(true);
-        else
-            return null;
+        ConcurrentMap<NodeConnector, Map<String, Property>> ncProps =
+            new ConcurrentHashMap<NodeConnector, Map<String, Property>>(), rv;
+
+        for (IPluginInInventoryService s : this.pluginService) {
+            rv = s.getNodeConnectorProps(true);
+            if (rv != null) {
+                ncProps.putAll(rv);
+            }
+        }
+
+        return ncProps;
     }
 }
index 0ee48d5b880b8efd4039e98d0d8c217aaf095a96..fce0a39719234a58e1d37c98b5d84d3ae67fe6d7 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.controller.sal.action.Output;
 import org.opendaylight.controller.sal.action.PopVlan;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
@@ -35,10 +36,12 @@ import org.opendaylight.controller.sal.reader.IPluginInReadService;
 import org.opendaylight.controller.sal.reader.IReadService;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.NodeTableCreator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
@@ -110,7 +113,7 @@ public class ReadService implements IReadService, CommandProvider {
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
             logger.trace("Prop key:({}) value:({})", entry.getKey(),
-                       entry.getValue());
+                    entry.getValue());
         }
 
         Object value = props.get("protocolPluginType");
@@ -137,7 +140,7 @@ public class ReadService implements IReadService, CommandProvider {
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
             logger.trace("Prop key:({}) value:({})", entry.getKey(),
-                       entry.getValue());
+                    entry.getValue());
         }
 
         Object value = props.get("protocoloPluginType");
@@ -158,7 +161,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readFlow(node, flow, true);
+                        .readFlow(node, flow, true);
             }
         }
         logger.warn("Plugin unavailable");
@@ -170,7 +173,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readFlow(node, flow, false);
+                        .readFlow(node, flow, false);
             }
         }
         logger.warn("Plugin unavailable");
@@ -182,7 +185,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readAllFlow(node, true);
+                        .readAllFlow(node, true);
             }
         }
         logger.warn("Plugin unavailable");
@@ -194,7 +197,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readAllFlow(node, false);
+                        .readAllFlow(node, false);
             }
         }
         logger.warn("Plugin unavailable");
@@ -206,7 +209,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readDescription(node, true);
+                        .readDescription(node, true);
             }
         }
         logger.warn("Plugin unavailable");
@@ -218,7 +221,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readDescription(node, false);
+                        .readDescription(node, false);
             }
         }
         logger.warn("Plugin unavailable");
@@ -231,7 +234,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null && node != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readNodeConnector(connector, true);
+                        .readNodeConnector(connector, true);
             }
         }
         logger.warn("Plugin unavailable");
@@ -245,7 +248,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null && node != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readNodeConnector(connector, false);
+                        .readNodeConnector(connector, false);
             }
         }
         logger.warn("Plugin unavailable");
@@ -257,7 +260,46 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readAllNodeConnector(node, true);
+                        .readAllNodeConnector(node, true);
+            }
+        }
+        logger.warn("Plugin unavailable");
+        return null;
+    }
+
+    @Override
+    public List<NodeTableStatistics> readNodeTable(Node node) {
+        if (pluginReader != null) {
+            if (this.pluginReader.get(node.getType()) != null) {
+                return this.pluginReader.get(node.getType())
+                        .readAllNodeTable(node, true);
+            }
+        }
+        logger.warn("Plugin unavailable");
+        return null;
+    }
+
+
+    @Override
+    public NodeTableStatistics nonCachedReadNodeTable(NodeTable table) {
+        Node node = table.getNode();
+        if (pluginReader != null && node != null) {
+            if (this.pluginReader.get(node.getType()) != null) {
+                return this.pluginReader.get(node.getType())
+                        .readNodeTable(table, false);
+            }
+        }
+        logger.warn("Plugin unavailable");
+        return null;
+    }
+
+    @Override
+    public NodeTableStatistics readNodeTable(NodeTable table) {
+        Node node = table.getNode();
+        if (pluginReader != null && node != null) {
+            if (this.pluginReader.get(node.getType()) != null) {
+                return this.pluginReader.get(node.getType())
+                        .readNodeTable(table, true);
             }
         }
         logger.warn("Plugin unavailable");
@@ -269,7 +311,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .readAllNodeConnector(node, false);
+                        .readAllNodeConnector(node, false);
             }
         }
         logger.warn("Plugin unavailable");
@@ -282,7 +324,7 @@ public class ReadService implements IReadService, CommandProvider {
         if (pluginReader != null && node != null) {
             if (this.pluginReader.get(node.getType()) != null) {
                 return this.pluginReader.get(node.getType())
-                    .getTransmitRate(connector);
+                        .getTransmitRate(connector);
             }
         }
         logger.warn("Plugin unavailable");
@@ -303,15 +345,15 @@ public class ReadService implements IReadService, CommandProvider {
         StringBuffer help = new StringBuffer();
         help.append("---SAL Reader testing commands---\n");
         help
-                .append("\t readflows <sid> <cached>  - Read all the (cached) flows from the openflow switch <sid>\n");
+        .append("\t readflows <sid> <cached>  - Read all the (cached) flows from the openflow switch <sid>\n");
         help
-                .append("\t readflow  <sid> <cached>  - Read the (cached) sample flow from the openflow switch <sid>\n");
+        .append("\t readflow  <sid> <cached>  - Read the (cached) sample flow from the openflow switch <sid>\n");
         help
-                .append("\t readdesc  <sid> <cached>  - Read the (cached) description from openflow switch <sid>\n");
+        .append("\t readdesc  <sid> <cached>  - Read the (cached) description from openflow switch <sid>\n");
         help
-                .append("\t           cached=true/false. If false or not specified, the protocol plugin cached info\n");
+        .append("\t           cached=true/false. If false or not specified, the protocol plugin cached info\n");
         help
-                .append("\t           is returned. If true, the info is directly retrieved from the switch\n");
+        .append("\t           is returned. If true, the info is directly retrieved from the switch\n");
         return help.toString();
     }
 
@@ -389,11 +431,11 @@ public class ReadService implements IReadService, CommandProvider {
         List<NodeConnectorStatistics> list = (cached) ? this
                 .readNodeConnectors(node) : this
                 .nonCachedReadNodeConnectors(node);
-        if (list != null) {
-            ci.println(list.toString());
-        } else {
-            ci.println("null");
-        }
+                if (list != null) {
+                    ci.println(list.toString());
+                } else {
+                    ci.println("null");
+                }
     }
 
     public void _readport(CommandInterpreter ci) {
@@ -417,11 +459,39 @@ public class ReadService implements IReadService, CommandProvider {
         NodeConnectorStatistics stats = (cached) ? this
                 .readNodeConnector(nodeConnector) : this
                 .nonCachedReadNodeConnector(nodeConnector);
-        if (stats != null) {
-            ci.println(stats.toString());
-        } else {
-            ci.println("null");
+                if (stats != null) {
+                    ci.println(stats.toString());
+                } else {
+                    ci.println("null");
+                }
+    }
+
+    public void _readtable(CommandInterpreter ci) {
+        String nodeId = ci.nextArgument();
+        String tableId = ci.nextArgument();
+        String cacheReq = ci.nextArgument();
+        boolean cached;
+        if (nodeId == null) {
+            ci.print("Node id not specified");
+            return;
+        }
+        if (tableId == null) {
+            ci.print("Table id not specified");
+            return;
         }
+        cached = (cacheReq == null) ? true : cacheReq.equals("true");
+        NodeTable nodeTable = null;
+        Node node = NodeCreator.createOFNode(Long.parseLong(nodeId));
+        nodeTable = NodeTableCreator.createNodeTable(Byte
+                .valueOf(tableId), node);
+        NodeTableStatistics stats = (cached) ? this
+                .readNodeTable(nodeTable) : this
+                .nonCachedReadNodeTable(nodeTable);
+                if (stats != null) {
+                    ci.println(stats.toString());
+                } else {
+                    ci.println("null");
+                }
     }
 
     public void _readdescr(CommandInterpreter ci) {
index 51771e5204b7cc35eecf3cca70dd96c97e845ad8..efb655ff1497f78ac843c92a43d9b2f061ec631c 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-api</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
index d9509e89b0563cd5abb950a7ef1541192444f005..9ba61667ed98a3e206798d24aacb678d02707a6b 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-impl</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
index 30207cc776cec82d22e829b0933e5c023d11665a..0618efc8aec7f8a0732a8daafaf14e1c11203bbc 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.sal.binding.yang.types;
 
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.resolveModuleFromSchemaPath;
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.*;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -65,7 +63,7 @@ public class TypeProviderImpl implements TypeProvider {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.type.provider.TypeProvider#
      * javaTypeForYangType(java.lang.String)
      */
@@ -95,8 +93,8 @@ public class TypeProviderImpl implements TypeProvider {
                     returnType = resolveEnumFromTypeDefinition(enumTypeDef,
                             typedefName);
                 } else {
-                    final Module module = resolveModuleFromSchemaPath(schemaContext, typeDefinition
-                                    .getPath());
+
+                    final Module module = resolveModuleFromTypePath(schemaContext, typeDefinition);
 
                     if (module != null) {
                         final Map<String, GeneratedTransferObject> genTOs = genTypeDefsContextMap
@@ -167,11 +165,11 @@ public class TypeProviderImpl implements TypeProvider {
                 if (strXPath.matches(".*//[.* | .*//].*")) {
                     returnType = Types.typeForClass(Object.class);
                 } else {
-                    final Module module = resolveModuleFromSchemaPath(schemaContext, leafrefType.getPath());
+                    final Module module = resolveModuleFromTypePath(schemaContext, leafrefType);
                     if (module != null) {
                         final DataSchemaNode dataNode;
                         if (xpath.isAbsolute()) {
-                            dataNode = findDataSchemaNode(schemaContext, 
+                            dataNode = findDataSchemaNode(schemaContext,
                                     module, xpath);
                         } else {
                             dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module,
@@ -229,7 +227,8 @@ public class TypeProviderImpl implements TypeProvider {
             final String enumerationName = BindingGeneratorUtil
                     .parseToClassName(enumName);
 
-            Module module = resolveModuleFromSchemaPath(schemaContext, enumTypeDef.getPath());
+            Module module = resolveModuleFromTypePath(schemaContext, enumTypeDef);
+
             final String basePackageName = BindingGeneratorUtil
                     .moduleNamespaceToPackageName(module);
             final String packageName = BindingGeneratorUtil
index 19dfd9577f8224c589a5db90a8abc9ae61adc0bc..448f610c49ba42265e080324c0ce0023c758b8f7 100644 (file)
@@ -158,19 +158,23 @@ public class AugmentedTypeTest {
 
         final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
         assertNotNull("networkLink2Methods is null", networkLink2Methods);
-//      FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
-//      MethodSignature getIfcMethod = null;
-//      for (MethodSignature method : networkLink2Methods) {
-//          if (method.getName().equals("getInterface")) {
-//              getIfcMethod = method;
-//              break;
-//          }
-//      }
-
-//      assertNotNull("getIfcMethod is null", getIfcMethod);
-//      assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
-//      assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));
-//      assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));
+
+//        FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
+//        MethodSignature getIfcMethod = null;
+//        for (MethodSignature method : networkLink2Methods) {
+//            if (method.getName().equals("getInterface")) {
+//                getIfcMethod = method;
+//                break;
+//            }
+//        }
+//
+//        assertNotNull("getIfcMethod is null", getIfcMethod);
+//        assertNotNull("getIfcMethod.getReturnType() is null",
+//                getIfcMethod.getReturnType());
+//        assertFalse("getIfcMethod.getReturnType() should not be Void",
+//                getIfcMethod.getReturnType().equals("java.lang.Void"));
+//        assertTrue("getIfcMethod.getReturnType().getName() must be String",
+//                getIfcMethod.getReturnType().getName().equals("String"));
     }
 
     @Test
index c1035c3b90e37dbc5e05c2607166268c14c02686..66c293eebc5beadf52cb7614dacf5f5bad2a5c4e 100644 (file)
@@ -7,20 +7,25 @@
  */
 package org.opendaylight.controller.sal.binding.generator.impl;
 
-import org.junit.Test;
-import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.*;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.model.api.Enumeration;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesTest {
 
@@ -138,119 +143,158 @@ public class GeneratedTypesTest {
         assertEquals(50, genTypes.size());
         assertTrue(genTypes != null);
 
-        int resolvedLeafrefCount = 0;
+        GeneratedTransferObject gtIfcKey = null;
+        GeneratedType gtIfc = null;
+        GeneratedType gtNetworkLink = null;
+        GeneratedType gtSource = null;
+        GeneratedType gtDest = null;
+        GeneratedType gtTunnel = null;
+        GeneratedTransferObject gtTunnelKey = null;
         for (final Type type : genTypes) {
-            if (type.getName().equals("InterfaceKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("InterfaceId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("String"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-
-            } else if (type.getName().equals("Interface")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-
-                assertTrue(methods != null);
-                for (final MethodSignature method : methods) {
-                    if (method.getName().equals("getInterfaceKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("InterfaceKey"));
-                        resolvedLeafrefCount++;
-                    } else if (method.getName().equals("getHigherLayerIf")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("List"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("NetworkLink")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getInterface")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("String"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if ((type.getName().equals("SourceNode") || type.getName()
-                    .equals("DestinationNode"))
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getId")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("Tunnel")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getTunnelKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("TunnelKey"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("TunnelKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
+            String name = type.getName();
+            if ("InterfaceKey".equals(name)) {
+                gtIfcKey = (GeneratedTransferObject) type;
+            } else if ("Interface".equals(name)) {
+                gtIfc = (GeneratedType) type;
+            } else if ("NetworkLink".equals(name)) {
+                gtNetworkLink = (GeneratedType) type;
+            } else if ("SourceNode".equals(name)) {
+                gtSource = (GeneratedType) type;
+            } else if ("DestinationNode".equals(name)) {
+                gtDest = (GeneratedType) type;
+            } else if ("Tunnel".equals(name)) {
+                gtTunnel = (GeneratedType) type;
+            } else if ("TunnelKey".equals(name)) {
+                gtTunnelKey = (GeneratedTransferObject) type;
+            }
+        }
 
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("TunnelId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedLeafrefCount++;
-                    }
-                }
+        assertNotNull(gtIfcKey);
+        assertNotNull(gtIfc);
+        assertNotNull(gtNetworkLink);
+        assertNotNull(gtSource);
+        assertNotNull(gtDest);
+        assertNotNull(gtTunnel);
+        assertNotNull(gtTunnelKey);
+
+        // InterfaceId
+        final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();
+        assertNotNull(gtIfcKeyProps);
+        GeneratedProperty ifcIdProp = null;
+        for (final GeneratedProperty property : gtIfcKeyProps) {
+            if (property.getName().equals("InterfaceId")) {
+                ifcIdProp = property;
+            }
+        }
+        assertNotNull(ifcIdProp);
+        Type ifcIdPropType = ifcIdProp.getReturnType();
+        assertNotNull(ifcIdPropType);
+        assertFalse(ifcIdPropType.equals("java.lang.Void"));
+        assertTrue(ifcIdPropType.getName().equals("String"));
+
+        // Interface
+        final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
+        assertNotNull(gtIfcMethods);
+        MethodSignature getIfcKey = null;
+        MethodSignature getHigherLayerIf = null;
+        for (final MethodSignature method : gtIfcMethods) {
+            if (method.getName().equals("getInterfaceKey")) {
+                getIfcKey = method;
+            } else if (method.getName().equals("getHigherLayerIf")) {
+                getHigherLayerIf = method;
+            }
+        }
+        assertNotNull(getIfcKey);
+        Type getIfcKeyType = getIfcKey.getReturnType();
+        assertNotNull(getIfcKeyType);
+        assertFalse(getIfcKeyType.equals("java.lang.Void"));
+        assertTrue(getIfcKeyType.getName().equals("InterfaceKey"));
+
+        assertNotNull(getHigherLayerIf);
+        Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
+        assertNotNull(getHigherLayerIfType);
+        assertFalse(getHigherLayerIfType.equals("java.lang.Void"));
+        assertTrue(getHigherLayerIfType.getName().equals("List"));
+
+        // NetworkLink
+        final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink
+                .getMethodDefinitions();
+        assertNotNull(gtNetworkLinkMethods);
+        MethodSignature getIfc = null;
+        for (MethodSignature method : gtNetworkLinkMethods) {
+            if (method.getName().equals("getInterface")) {
+                getIfc = method;
+            }
+        }
+        assertNotNull(getIfc);
+        Type getIfcType = getIfc.getReturnType();
+        assertNotNull(getIfcType);
+        assertFalse(getIfcType.equals("java.lang.Void"));
+        assertTrue(getIfcType.getName().equals("String"));
+
+        // SourceNode
+        final List<MethodSignature> gtSourceMethods = gtSource
+                .getMethodDefinitions();
+        assertNotNull(gtSourceMethods);
+        MethodSignature getIdSource = null;
+        for (MethodSignature method : gtSourceMethods) {
+            if (method.getName().equals("getId")) {
+                getIdSource = method;
+            }
+        }
+        assertNotNull(getIdSource);
+        Type getIdType = getIdSource.getReturnType();
+        assertNotNull(getIdType);
+        assertFalse(getIdType.equals("java.lang.Void"));
+        assertTrue(getIdType.getName().equals("Uri"));
+
+        // DestinationNode
+        final List<MethodSignature> gtDestMethods = gtDest
+                .getMethodDefinitions();
+        assertNotNull(gtDestMethods);
+        MethodSignature getIdDest = null;
+        for (MethodSignature method : gtDestMethods) {
+            if (method.getName().equals("getId")) {
+                getIdDest = method;
+            }
+        }
+        assertNotNull(getIdDest);
+        Type getIdDestType = getIdDest.getReturnType();
+        assertNotNull(getIdDestType);
+        assertFalse(getIdDestType.equals("java.lang.Void"));
+        assertTrue(getIdDestType.getName().equals("Uri"));
+
+        // Tunnel
+        final List<MethodSignature> gtTunnelMethods = gtTunnel
+                .getMethodDefinitions();
+        assertNotNull(gtTunnelMethods);
+        MethodSignature getTunnelKey = null;
+        for (MethodSignature method : gtTunnelMethods) {
+            if (method.getName().equals("getTunnelKey")) {
+                getTunnelKey = method;
+            }
+        }
+        assertNotNull(getTunnelKey);
+        Type getTunnelKeyType = getTunnelKey.getReturnType();
+        assertNotNull(getTunnelKeyType);
+        assertFalse(getTunnelKeyType.equals("java.lang.Void"));
+        assertTrue(getTunnelKeyType.getName().equals("TunnelKey"));
+
+        // TunnelKey
+        final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey
+                .getProperties();
+        assertNotNull(gtTunnelKeyProps);
+        GeneratedProperty tunnelId = null;
+        for (final GeneratedProperty property : gtTunnelKeyProps) {
+            if (property.getName().equals("TunnelId")) {
+                tunnelId = property;
             }
         }
-        assertEquals(10, resolvedLeafrefCount);
+        assertNotNull(tunnelId);
+        Type tunnelIdType = tunnelId.getReturnType();
+        assertNotNull(tunnelIdType);
+        assertFalse(tunnelIdType.equals("java.lang.Void"));
+        assertTrue(tunnelIdType.getName().equals("Uri"));
     }
 
     @Test
@@ -420,8 +464,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType &&
-                    !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 final GeneratedType genType = (GeneratedType) type;
                 if (genType.getName().equals("ListParentContainer")) {
                     assertEquals(2, genType.getMethodDefinitions().size());
@@ -504,8 +548,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType &&
-                    !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
@@ -552,7 +596,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType
+                    && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 genTOsCount++;
index ebaecde2059fee1f382752eb01e12907e036ba9f..2ec8845dde0f8fdcbfcd1751bcd30eaf4e6dd7bc 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-spi</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
index 44a3bc8bd7dc5106969378fc4dc01710261753c3..3fa8f3379aa609b7738834281c6240f6cbfeb8cc 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-generator-util</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
index a7d564909f8ab22baef38bda4d5db7fb76a7122c..1eb30d3d6e381485f217ecceca758ada8ae33ff5 100644 (file)
@@ -4,10 +4,9 @@
        <parent>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>binding-generator</artifactId>\r
-               <version>0.5-SNAPSHOT</version>\r
+               <version>0.5.1-SNAPSHOT</version>\r
        </parent>\r
        <artifactId>binding-java-api-generator</artifactId>\r
-    <version>${release.version}</version>\r
        <dependencies>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
index 076e2482ba4d9fdbf58ccc3f4b22007c37f8692f..bf539eb8fe43eb3149352501a10df2cec95cb385 100644 (file)
@@ -24,6 +24,7 @@ import javax.tools.ToolProvider;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
@@ -94,6 +95,7 @@ public class GeneratorJavaFileTest {
         assertTrue(filesList.contains("Type3.java"));
     }
 
+    @Ignore
     @Test
     public void compilationTest() throws Exception {
         final YangParserImpl parser = new YangParserImpl();
index de5e35a7fa86a610ea99d544cca17bbe33303d08..b00739d0fbd76356f5833cc8bd710362447eed60 100644 (file)
@@ -3,8 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>binding-generator</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>binding-model-api</artifactId>\r
-  <version>${release.version}</version>\r
 </project>
\ No newline at end of file
index 93c6a12cd1a52f3fc415b11593bfc392fb6eff11..d4c5b05731b51311bb2d0d102a98dcaf35dd4d93 100644 (file)
                <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
index 8ee48aaa3e4283ca674d02e477e6eb22d85b5ec1..207ed964d3bded70a0254b17ef6cb555b5839dee 100644 (file)
@@ -4,10 +4,9 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.5.1-SNAPSHOT</version>
     </parent>
     <artifactId>maven-sal-api-gen-plugin</artifactId>
-    <version>${release.version}</version>
 
     <dependencies>
         <dependency>
index 81ff631e9d24d7300b2be016485930f2978201d4..896827ee45414e0d0b2d0dd8b621f296ac583444 100644 (file)
@@ -4,11 +4,10 @@
     <parent>
         <artifactId>yang</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.5.1-SNAPSHOT</version>
         <relativePath>../../yang/pom.xml</relativePath>
     </parent>
     <artifactId>yang-maven-plugin-it</artifactId>
-    <version>${release.version}</version>
 
     <dependencies>
         <dependency>
index 1b10c641836c7cd80e007bf831928940063e3c85..353416d2ac0ddb2d12708e11f85f45a2c3a9e00f 100644 (file)
@@ -1,18 +1,16 @@
 <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>
-               <artifactId>binding-generator</artifactId>
-               <groupId>org.opendaylight.controller</groupId>
-               <version>0.5-SNAPSHOT</version>
-       </parent>
+
+        <groupId>org.opendaylight.controller</groupId>
+               <version>0.5.1-SNAPSHOT</version>
        <artifactId>test</artifactId>
 
        <dependencies>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>yang-maven-plugin-spi</artifactId>
-                       <version>0.5-SNAPSHOT</version>
+                       <version>0.5.1-SNAPSHOT</version>
                </dependency>
        </dependencies>
 
@@ -21,7 +19,7 @@
                        <plugin>
                                <groupId>org.opendaylight.controller</groupId>
                                <artifactId>yang-maven-plugin</artifactId>
-                               <version>0.5-SNAPSHOT</version>
+                               <version>0.5.1-SNAPSHOT</version>
                                <executions>
                                        <execution>
                                                <goals>
@@ -54,7 +52,7 @@
                                        <dependency>
                                                <groupId>org.opendaylight.controller</groupId>
                                                <artifactId>yang-maven-plugin-spi</artifactId>
-                                               <version>0.5-SNAPSHOT</version>
+                                               <version>0.5.1-SNAPSHOT</version>
                                                <type>test-jar</type>
                                        </dependency>
                                </dependencies>
index 5f51935191633fae9a61d038f75b6a5eba559948..356f1c6386dc5fd4fad68ef69dc009310756d158 100644 (file)
@@ -1,11 +1,10 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +12,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -39,7 +38,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index df213580d1a14c9d28e61fdcc33adea84a429383..fdef8ad5954d1708a7b585ddf1352f246ed1d424 100644 (file)
@@ -4,14 +4,14 @@
 
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>generator-test1</artifactId>
-       <version>0.5-SNAPSHOT</version>
+       <version>0.5.1-SNAPSHOT</version>
 
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.opendaylight.controller</groupId>
                                <artifactId>yang-maven-plugin</artifactId>
-                               <version>0.5-SNAPSHOT</version>
+                               <version>0.5.1-SNAPSHOT</version>
                                <executions>
                                        <execution>
                                                <goals>
@@ -41,7 +41,7 @@
                                        <dependency>
                                                <groupId>org.opendaylight.controller</groupId>
                                                <artifactId>yang-maven-plugin-spi</artifactId>
-                                               <version>0.5-SNAPSHOT</version>
+                                               <version>0.5.1-SNAPSHOT</version>
                                                <type>test-jar</type>
                                        </dependency>
                                </dependencies>
index 7948efc85bd92df444053f5e44dabcfec9ca6dec..2fcbd622845caf5700d832fbc266122238c01e7a 100644 (file)
@@ -3,16 +3,17 @@
        <modelVersion>4.0.0</modelVersion>
 
        <groupId>org.opendaylight.controller</groupId>
+       <version>0.5.1-SNAPSHOT</version>
        <artifactId>generator-test2</artifactId>
-       <version>0.5-SNAPSHOT</version>
+       
 
        <dependencies>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>generator-test1</artifactId>
-                       <version>0.5-SNAPSHOT</version>
+                       <version>0.5.1-SNAPSHOT</version>
                        <scope>system</scope>
-                       <systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-0.5-SNAPSHOT.jar</systemPath>
+                       <systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-0.5.1-SNAPSHOT.jar</systemPath>
                </dependency>
        </dependencies>
 
@@ -21,7 +22,7 @@
                        <plugin>
                                <groupId>org.opendaylight.controller</groupId>
                                <artifactId>yang-maven-plugin</artifactId>
-                               <version>0.5-SNAPSHOT</version>
+                               <version>0.5.1-SNAPSHOT</version>
                                <executions>
                                        <execution>
                                                <goals>
@@ -57,7 +58,7 @@
                                        <dependency>
                                                <groupId>org.opendaylight.controller</groupId>
                                                <artifactId>yang-maven-plugin-spi</artifactId>
-                                               <version>0.5-SNAPSHOT</version>
+                                               <version>0.5.1-SNAPSHOT</version>
                                                <type>test-jar</type>
                                        </dependency>
                                </dependencies>
index ab600924a8c0c7eb42fa29edc87fd0e0e126fe7f..5581882a31d68773f507db11774c30f480f9938b 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.5.1-SNAPSHOT</version>
     </parent>
     <artifactId>test</artifactId>
 
@@ -13,7 +13,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -49,7 +49,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 87844cd295fdcf696a0090bd52ef7fd6abd7bc16..7d3291a304da85723285b0212cae28d3ee055d57 100644 (file)
@@ -1,11 +1,9 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +11,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -40,7 +38,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 0d56c039e3ffed53d1c042d6e53cbada12ef21c6..90220bae4fb8fce00c21104cc9410bf7a60b7493 100644 (file)
@@ -1,11 +1,11 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +13,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -40,7 +40,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index de5f8cf7795711b30da621922ed64b94c598c832..00ddbdd344cffad03eda9f3dac81d1a2bff5f5eb 100644 (file)
@@ -1,11 +1,10 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +12,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -43,7 +42,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 70aa82aae5d90797624e47b301e2057703db7edc..1fc7ab34d60b3c8dc0dd1d161a1db0ed493eafeb 100644 (file)
@@ -1,11 +1,10 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +12,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -49,7 +48,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index ec5c606aa494c6b121336e96b8d6b382757c61c0..15f4322360fd9ec76cc4acb830e356c4cb01bcfc 100644 (file)
@@ -1,11 +1,10 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +12,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -57,7 +56,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index defae7e4b3bdb65a9c23f69ac50d798928ec9b3e..438ef945f63475c8473b308fa49fed3bdcf2fbe1 100644 (file)
@@ -1,11 +1,10 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +12,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -57,7 +56,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-maven-plugin-spi</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>test-jar</type>
                     </dependency>
                 </dependencies>
index 6208231c6feb9d42c01419b480ff87c7537aa169..9986438d0b71c842d845a0e989675589ace764dd 100644 (file)
@@ -1,11 +1,10 @@
 <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>
-        <artifactId>binding-generator</artifactId>
+
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
-    </parent>
+        <version>0.5.1-SNAPSHOT</version>
+
     <artifactId>test</artifactId>
 
     <build>
@@ -13,7 +12,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
index 188fb925ba05a22624a2a416ea05c17afc6a08e7..5afd588541382de8584324e028cd9f1a6d222ebb 100644 (file)
@@ -4,12 +4,11 @@
     <parent>
         <artifactId>yang</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.5.1-SNAPSHOT</version>
         <relativePath>../../yang/pom.xml</relativePath>
     </parent>
 
     <artifactId>yang-maven-plugin</artifactId>
-    <version>${release.version}</version>
     <packaging>maven-plugin</packaging>
     <description>
         This plugin is a wrapper for "yang to source code" generation.
@@ -61,7 +60,7 @@
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>yang-maven-plugin-spi</artifactId>
-            <version>${release.version}</version>
+            <version>${project.version}</version>
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
index 628e74348df396e02e76a51b3268db3edc6c1f10..ca7a320247d258e81c72d2556e0d0193c3c5ae40 100644 (file)
@@ -4,11 +4,10 @@
     <parent>
         <artifactId>yang</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.5.1-SNAPSHOT</version>
         <relativePath>../../yang/pom.xml</relativePath>
     </parent>
     <artifactId>yang-maven-plugin-spi</artifactId>
-    <version>${release.version}</version>
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
index a1962e52d5bc44b70b877148261f72ab013281d2..9edca3cd228b5cfd8caeead7dcd2b01a8d1376dd 100644 (file)
@@ -8,6 +8,7 @@
         <artifactId>yang-prototype</artifactId>
         <version>0.5-SNAPSHOT</version>
     </parent>
+    <version>0.5.1-SNAPSHOT</version>
 
     <artifactId>binding-generator</artifactId>
     <packaging>pom</packaging>
@@ -16,9 +17,7 @@
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <!-- version of YANG tools dependencies -->
-        <yang.version>0.5-SNAPSHOT</yang.version>
-        <!-- Version of all child artifacts -->
-        <release.version>0.5-SNAPSHOT</release.version>
+        <yang.version>0.5.1-SNAPSHOT</yang.version>
     </properties>
 
     <modules>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>binding-model-api</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>binding-generator-api</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>binding-generator-spi</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>binding-generator-util</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>binding-generator-impl</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>binding-java-api-generator</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>maven-sal-api-gen-plugin</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
index 8ee1bf0f33a51ae643a3829b9eccd1f1f342a2c7..03a2e8588e6d5e908b7bf32286d38614b5e0838a 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>binding-generator</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.5.1-SNAPSHOT</version>
     </parent>
     <artifactId>maven-code-gen-sample</artifactId>
 
@@ -13,7 +13,7 @@
             <plugin>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5-SNAPSHOT</version>
+                <version>0.5.1-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <goals>
@@ -41,7 +41,7 @@
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>maven-sal-api-gen-plugin</artifactId>
-                        <version>0.5-SNAPSHOT</version>
+                        <version>0.5.1-SNAPSHOT</version>
                         <type>jar</type>
                     </dependency>
                 </dependencies>
     <dependency>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>yang-binding</artifactId>
-    <version>0.5-SNAPSHOT</version>
+    <version>0.5.1-SNAPSHOT</version>
     </dependency>
     </dependencies>
 </project>
\ No newline at end of file
index cc2656405c858153d29f1e883ca0facc4151d7a1..b15c0e5122d87d9d9537f2bb877d77019b711b48 100644 (file)
@@ -1,3 +1,11 @@
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.network.rev2013520.ControllerNetworkData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.network.rev2013520.Network;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.network.rev2013520.network.topologies.Topology;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.network.rev2013520.network.topologies.topology.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.openflow.rev2013520.Node1;
+
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -9,4 +17,18 @@
 public class Example {
     
 
+    
+    void udpateTopology(ControllerNetworkData network) {
+        List<Topology> topologies = network.getNetwork().getTopologies().getTopology();
+        for (Topology topology : topologies) {
+            List<Node> nodes = topology.getNodes().getNode();
+            for (Node node : nodes) {
+                
+                
+                Node1 ofNode = node.getAugmentation(Node1.class);
+                ofNode.getDatapathId();
+            }
+        }
+        
+    }
 }
index 48ebb51f389571fd8d964e24760678409702250a..547d83adc8ed617db4d421e3835f1911b5bc5b39 100644 (file)
@@ -3,16 +3,14 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>yang</artifactId>
-    <version>0.5-SNAPSHOT</version>
+    <version>0.5.1-SNAPSHOT</version>
     <relativePath>../../yang/pom.xml</relativePath>
   </parent>
   <artifactId>yang-model-parser-api</artifactId>
-  
   <dependencies>
       <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>yang-model-api</artifactId>
-          <version>0.5-SNAPSHOT</version>
       </dependency>
   </dependencies>
 </project>
\ No newline at end of file
index 27ef15e1569cbf7365336184f1bfd63d58904298..16a746905e0fc2d5f192b05ee404aad18aa5ee44 100644 (file)
@@ -4,36 +4,26 @@
        <parent>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>yang</artifactId>\r
-               <version>0.5-SNAPSHOT</version>\r
+               <version>0.5.1-SNAPSHOT</version>\r
                <relativePath>../../yang/pom.xml</relativePath>\r
        </parent>\r
        <artifactId>yang-model-parser-impl</artifactId>\r
-\r
        <dependencies>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-common</artifactId>\r
-                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-model-api</artifactId>\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>0.5-SNAPSHOT</version>\r
                </dependency>\r
                <dependency>\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>yang-model-util</artifactId>\r
-                       <version>0.5-SNAPSHOT</version>\r
-               </dependency>\r
-               <dependency>\r
-                       <groupId>org.opendaylight.controller</groupId>\r
-                       <artifactId>binding-model-api</artifactId>\r
-                       <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
 \r
                <dependency>\r
index 1f4986cc9016ed2ced694c5e44df8ea02d62710d..559eedb6dc869dc3e7140879ca0d2e152724ccd1 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.parser.builder.api;
 
+import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 
 /**
@@ -15,6 +16,8 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
  */
 public interface TypeAwareBuilder extends Builder {
 
+    QName getQName();
+
     TypeDefinition<?> getType();
 
     TypeDefinitionBuilder getTypedef();
index 7d9e3ea8b72a4ff6a017999dfc234762e5d52522..ba1ea9c922e4222e4fcead053f9e20f6e2e38000 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class AnyXmlBuilder implements DataSchemaNodeBuilder {
+public final class AnyXmlBuilder implements DataSchemaNodeBuilder {
     private boolean built;
     private final int line;
     private final QName qname;
index a5db03b2e74b890e1944d7e3e9db584a307d1a5b..54f69c809ac9a97fcbe626f1ce61a530b8edd56c 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
+public final class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
     private boolean built;
     private final AugmentationSchemaImpl instance;
     private final int line;
index 04e7d33478b6a20cdfd0323336dcf393adbdf1a5..e3ab0834e0cea16cc088a0c64feed69a2a214e52 100644 (file)
@@ -30,8 +30,8 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
-        AugmentationTargetBuilder {
+public final class ChoiceBuilder implements DataSchemaNodeBuilder,
+        ChildNodeBuilder, AugmentationTargetBuilder {
     private boolean built;
     private final ChoiceNodeImpl instance;
     private final int line;
@@ -252,7 +252,7 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         return new HashSet<DataSchemaNodeBuilder>(cases);
     }
 
-    private class ChoiceNodeImpl implements ChoiceNode {
+    private final class ChoiceNodeImpl implements ChoiceNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
index a3b21b4abf5d83a94573fe7545bccea611c932e1..11a1b3114c7475d27d9e049600aa788b9d47783e 100644 (file)
@@ -171,7 +171,7 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
         return augmentations;
     }
 
-    private class ChoiceCaseNodeImpl implements ChoiceCaseNode {
+    private final class ChoiceCaseNodeImpl implements ChoiceCaseNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -265,6 +265,10 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
             }
         }
 
+        /**
+         * Always returns an empty set, because case node can not contains type
+         * definitions.
+         */
         @Override
         public Set<TypeDefinition<?>> getTypeDefinitions() {
             return Collections.emptySet();
index a6c37e34214d8d995d9ef2e7bcb49c155bcb1460..b1aa7de06a58fddcfad9884abeba13d651f47761 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 
-public class ConstraintsBuilder implements Builder {
+public final class ConstraintsBuilder implements Builder {
     private final ConstraintDefinitionImpl instance;
     private final int line;
     private final Set<MustDefinition> mustDefinitions;
@@ -93,7 +93,7 @@ public class ConstraintsBuilder implements Builder {
         this.mandatory = mandatory;
     }
 
-    private static class ConstraintDefinitionImpl implements
+    private final class ConstraintDefinitionImpl implements
             ConstraintDefinition {
         private RevisionAwareXPath whenCondition;
         private Set<MustDefinition> mustConstraints;
index e12a3a9f4de1ace8991ac80d69f54ec5e6dfb6de..7fcdb6f8ba14a98b9340d81975af950251e47dfd 100644 (file)
@@ -35,10 +35,10 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBu
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
+public final class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         implements TypeDefinitionAwareBuilder, AugmentationTargetBuilder,
         DataSchemaNodeBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final ContainerSchemaNodeImpl instance;
     private final int line;
     private final ConstraintsBuilder constraints;
@@ -64,7 +64,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
 
     @Override
     public ContainerSchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setReference(reference);
@@ -103,7 +103,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
 
             // AUGMENTATIONS
             final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-            for(AugmentationSchemaBuilder builder : addedAugmentations) {
+            for (AugmentationSchemaBuilder builder : addedAugmentations) {
                 augmentations.add(builder.build());
             }
             instance.setAvailableAugmentations(augmentations);
@@ -118,7 +118,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
             instance.setConstraints(constraints.build());
             instance.setAvailableAugmentations(augmentations);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
@@ -179,7 +179,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
@@ -233,7 +233,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class ContainerSchemaNodeImpl implements ContainerSchemaNode {
+    private final class ContainerSchemaNodeImpl implements ContainerSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -292,7 +292,7 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         }
 
         private void setStatus(Status status) {
-            if(status != null) {
+            if (status != null) {
                 this.status = status;
             }
         }
index e99f8280e0891a628b3be26ef4517aaa2abd32b8..239c0a5ed9a8da6c3a1682975f7a8b8258941e17 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class DeviationBuilder implements Builder {
+public final class DeviationBuilder implements Builder {
     private final DeviationImpl instance;
     private final int line;
 
@@ -54,7 +54,7 @@ public class DeviationBuilder implements Builder {
         instance.setReference(reference);
     }
 
-    private class DeviationImpl implements Deviation {
+    private final class DeviationImpl implements Deviation {
         private final SchemaPath targetPath;
         private Deviate deviate;
         private String reference;
index 2852a32aec45f193ac5919e828a2cf3f1f56aa1e..a04fc3c1a68b06fa0e1667265b50417fa4831488 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class ExtensionBuilder implements SchemaNodeBuilder {
+public final class ExtensionBuilder implements SchemaNodeBuilder {
+    private boolean isBuilt;
     private final ExtensionDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -34,14 +35,18 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
 
     @Override
     public ExtensionDefinition build() {
-        instance.setPath(schemaPath);
+        if(!isBuilt) {
+            instance.setPath(schemaPath);
 
-        // UNKNOWN NODES
-        final List<UnknownSchemaNode> extensions = new ArrayList<UnknownSchemaNode>();
-        for (UnknownSchemaNodeBuilder e : addedExtensions) {
-            extensions.add(e.build());
+            // UNKNOWN NODES
+            final List<UnknownSchemaNode> extensions = new ArrayList<UnknownSchemaNode>();
+            for (UnknownSchemaNodeBuilder e : addedExtensions) {
+                extensions.add(e.build());
+            }
+            instance.setUnknownSchemaNodes(extensions);
+
+            isBuilt = true;
         }
-        instance.setUnknownSchemaNodes(extensions);
 
         return instance;
     }
@@ -98,7 +103,7 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class ExtensionDefinitionImpl implements ExtensionDefinition {
+    private final class ExtensionDefinitionImpl implements ExtensionDefinition {
         private final QName qname;
         private String argument;
         private SchemaPath schemaPath;
index 0f2c7f1d09d3795b62b15b5a667b91204e8c0568..5418e09451eb087d4d6d19ea2c9b20e8f08f1474 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class FeatureBuilder implements SchemaNodeBuilder {
+public final class FeatureBuilder implements SchemaNodeBuilder {
+    private boolean isBuilt;
     private final FeatureDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -33,15 +34,18 @@ public class FeatureBuilder implements SchemaNodeBuilder {
 
     @Override
     public FeatureDefinitionImpl build() {
-        instance.setPath(schemaPath);
+        if(!isBuilt) {
+            instance.setPath(schemaPath);
 
-        // UNKNOWN NODES
-        final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
-        for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
-            unknownNodes.add(b.build());
-        }
-        instance.setUnknownSchemaNodes(unknownNodes);
+            // UNKNOWN NODES
+            final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+            for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+                unknownNodes.add(b.build());
+            }
+            instance.setUnknownSchemaNodes(unknownNodes);
 
+            isBuilt = true;
+        }
         return instance;
     }
 
@@ -85,7 +89,7 @@ public class FeatureBuilder implements SchemaNodeBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class FeatureDefinitionImpl implements FeatureDefinition {
+    private final class FeatureDefinitionImpl implements FeatureDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 759f54ec6fe817ca5a76c504fdb4c6932ca52006..cc7a05cd04b30ca0f683ff76cfc1319a48a84bb2 100644 (file)
@@ -28,8 +28,8 @@ import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class GroupingBuilderImpl implements GroupingBuilder {
-    private boolean built;
+public final class GroupingBuilderImpl implements GroupingBuilder {
+    private boolean isBuilt;
     private final GroupingDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -51,7 +51,7 @@ public class GroupingBuilderImpl implements GroupingBuilder {
 
     @Override
     public GroupingDefinition build() {
-        if (!built) {
+        if (!isBuilt) {
             instance.setPath(schemaPath);
             instance.setDescription(description);
             instance.setReference(reference);
@@ -92,7 +92,7 @@ public class GroupingBuilderImpl implements GroupingBuilder {
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
 
         return instance;
@@ -210,7 +210,7 @@ public class GroupingBuilderImpl implements GroupingBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
-    private static class GroupingDefinitionImpl implements GroupingDefinition {
+    private final class GroupingDefinitionImpl implements GroupingDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 408f6612ea8a3864e9851e84c66e55dbcebf609e..bbf94408059119307396394fdbbff5e8f681b693 100644 (file)
@@ -28,8 +28,8 @@ import org.opendaylight.controller.yang.parser.util.YangParseException;
  * When build is called, types in builder form will be built and add to resolved
  * types.
  */
-public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
-        TypeDefinitionBuilder {
+public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder
+        implements TypeDefinitionBuilder {
     private static final String NAME = "identityref";
 
     private final int line;
index 28f250f121a05c499285a3bef1863b8251dc3e33..b35ff4e9f1146f71241ae79dfe7a00edcb3d3d34 100644 (file)
@@ -22,9 +22,9 @@ import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuil
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
+public final class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         implements SchemaNodeBuilder, DataSchemaNodeBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final LeafListSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
@@ -50,7 +50,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
 
     @Override
     public LeafListSchemaNode build() {
-        if (!built) {
+        if (!isBuilt) {
             instance.setConstraints(constraints.build());
             instance.setPath(schemaPath);
             instance.setDescription(description);
@@ -73,7 +73,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
@@ -166,7 +166,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class LeafListSchemaNodeImpl implements LeafListSchemaNode {
+    private final class LeafListSchemaNodeImpl implements LeafListSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
index ee7b3b1c81f55454b1ba06db75c06030e7c6be57..99d4ffbe2480d7ff0783fa1bbfb68ab4382b0fca 100644 (file)
@@ -22,9 +22,9 @@ import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuil
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
-        DataSchemaNodeBuilder, SchemaNodeBuilder {
-    private boolean built;
+public final class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder
+        implements DataSchemaNodeBuilder, SchemaNodeBuilder {
+    private boolean isBuilt;
     private final LeafSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
@@ -51,7 +51,7 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public LeafSchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setPath(path);
             instance.setConstraints(constraints.build());
             instance.setDescription(description);
@@ -76,7 +76,7 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
@@ -152,8 +152,6 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         this.augmenting = augmenting;
     }
 
-
-
     public boolean isConfiguration() {
         return configuration;
     }
@@ -179,7 +177,7 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         this.unitsStr = unitsStr;
     }
 
-    private class LeafSchemaNodeImpl implements LeafSchemaNode {
+    private final class LeafSchemaNodeImpl implements LeafSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
index c9b1e7369b32fb995099753e340fb99b5a1a2382..db0e37b1e3d5983e69cb3b44a1018bb705a17be7 100644 (file)
@@ -35,10 +35,10 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBu
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
-        DataSchemaNodeBuilder, AugmentationTargetBuilder,
+public final class ListSchemaNodeBuilder extends AbstractChildNodeBuilder
+        implements DataSchemaNodeBuilder, AugmentationTargetBuilder,
         TypeDefinitionAwareBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final ListSchemaNodeImpl instance;
     private final int line;
     // SchemaNode args
@@ -69,7 +69,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
 
     @Override
     public ListSchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setKeyDefinition(keyDefinition);
             instance.setPath(schemaPath);
             instance.setDescription(description);
@@ -124,7 +124,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
             instance.setConstraints(constraints.build());
             instance.setAvailableAugmentations(augmentations);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
@@ -249,7 +249,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class ListSchemaNodeImpl implements ListSchemaNode {
+    private final class ListSchemaNodeImpl implements ListSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 4865178d27545aa30b7f78d30323e725ec78d70a..0d47d7a5fc5dbd391be57e032dd387b490c8da93 100644 (file)
@@ -594,19 +594,19 @@ public class ModuleBuilder implements Builder {
         parent.setType(type);
     }
 
-    public void addUnionType(final List<String> actualPath,
+    public UnionTypeBuilder addUnionType(final List<String> actualPath,
             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, line);
+        UnionTypeBuilder union = new UnionTypeBuilder(line);
         parent.setType(union);
 
         List<String> path = new ArrayList<String>(pathToUnion);
         path.add("union");
 
         moduleNodes.put(path, union);
+        return union;
     }
 
     public void addIdentityrefType(final String baseString,
@@ -669,7 +669,7 @@ public class ModuleBuilder implements Builder {
         return builder;
     }
 
-    private class ModuleImpl implements Module {
+    private final class ModuleImpl implements Module {
         private URI namespace;
         private final String name;
         private Date revision;
index 3e9b9307bc2a4d4c0ed8c28eb601d2066e2448d8..e058efc2fc4792bea0a48d127691cb3c0acacfe5 100644 (file)
@@ -33,9 +33,9 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBu
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
-public class NotificationBuilder extends AbstractChildNodeBuilder implements
-        TypeDefinitionAwareBuilder, SchemaNodeBuilder {
-    private boolean built;
+public final class NotificationBuilder extends AbstractChildNodeBuilder
+        implements TypeDefinitionAwareBuilder, SchemaNodeBuilder {
+    private boolean isBuilt;
     private final NotificationDefinitionImpl instance;
     private final int line;
     private SchemaPath schemaPath;
@@ -51,7 +51,7 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
 
     @Override
     public SchemaNode build() {
-        if(!built) {
+        if (!isBuilt) {
             instance.setPath(schemaPath);
 
             // CHILD NODES
@@ -89,7 +89,7 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
 
         return instance;
@@ -140,7 +140,7 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
         addedUnknownNodes.add(unknownNode);
     }
 
-    private class NotificationDefinitionImpl implements NotificationDefinition {
+    private final class NotificationDefinitionImpl implements NotificationDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 003ccced4ab2d72476ff8360efea25e9e3e62b73..914ebc764474b43dfe4c48e91c4bc8124730903d 100644 (file)
@@ -26,9 +26,9 @@ import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 
-public class RpcDefinitionBuilder implements SchemaNodeBuilder,
+public final class RpcDefinitionBuilder implements SchemaNodeBuilder,
         TypeDefinitionAwareBuilder {
-    private boolean built;
+    private boolean isBuilt;
     private final RpcDefinitionImpl instance;
     private final int line;
     private final QName qname;
@@ -47,7 +47,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
 
     @Override
     public RpcDefinition build() {
-        if(!built) {
+        if (!isBuilt) {
             final ContainerSchemaNode input = inputBuilder.build();
             final ContainerSchemaNode output = outputBuilder.build();
             instance.setInput(input);
@@ -76,7 +76,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
             }
             instance.setUnknownSchemaNodes(unknownNodes);
 
-            built = true;
+            isBuilt = true;
         }
         return instance;
     }
@@ -158,7 +158,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         return true;
     }
 
-    private class RpcDefinitionImpl implements RpcDefinition {
+    private final class RpcDefinitionImpl implements RpcDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 5345d0a1169055a484bbe3cea416f7f0e4c46ec6..a704d587ecfab2a7c7af7d0868803b0950817bb6 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuil
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.util.YangParseException;
 
-public class TypedefBuilder extends AbstractTypeAwareBuilder implements
+public final class TypedefBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder {
     private final int line;
     private final QName qname;
index 811b77566836b0f95ad9844562117bc239b569a1..61aec1a8c95702f36787f1770791467f36ad3082 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.yang.parser.builder.impl;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -31,30 +29,22 @@ import org.opendaylight.controller.yang.parser.util.YangParseException;
  * When build is called, types in builder form will be built and add to resolved
  * types.
  */
-public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
+public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder {
     private final static String NAME = "union";
 
     private final int line;
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
-    private final UnionType instance;
-    private boolean built;
+    private UnionType instance;
+    private boolean isBuilt;
 
-    private final List<String> actualPath;
-    private final URI namespace;
-    private final Date revision;
+    private SchemaPath path;
 
-    public UnionTypeBuilder(final List<String> actualPath, final URI namespace,
-            final Date revision, final int line) {
+    public UnionTypeBuilder(final int line) {
         this.line = line;
         types = new ArrayList<TypeDefinition<?>>();
         typedefs = new ArrayList<TypeDefinitionBuilder>();
-        instance = new UnionType(actualPath, namespace, revision, types);
-
-        this.actualPath = actualPath;
-        this.namespace = namespace;
-        this.revision = revision;
     }
 
     @Override
@@ -92,20 +82,19 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public UnionType build() {
-        if (built) {
-            return instance;
-        } else {
+        if (!isBuilt) {
+            instance = new UnionType(path, types);
             for (TypeDefinitionBuilder tdb : typedefs) {
                 types.add(tdb.build());
             }
-            built = true;
-            return instance;
+            isBuilt = true;
         }
+        return instance;
     }
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
-        throw new YangParseException(line, "Can not set path to " + NAME);
+        this.path = schemaPath;
     }
 
     @Override
@@ -221,18 +210,6 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         throw new YangParseException(line, "Can not set units to " + NAME);
     }
 
-    public List<String> getActualPath() {
-        return actualPath;
-    }
-
-    public URI getNamespace() {
-        return namespace;
-    }
-
-    public Date getRevision() {
-        return revision;
-    }
-
     @Override
     public String toString() {
         final StringBuilder result = new StringBuilder(
index 1c63002f347e0b55e6b2091bf8d4e0d652f09cb5..222290188e3ad019ad23300666c792aede587376 100644 (file)
@@ -17,7 +17,8 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 
-public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
+public final class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
+    private boolean isBuilt;
     private final UnknownSchemaNodeImpl instance;
     private final int line;
     private final QName qname;
@@ -34,16 +35,21 @@ public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
 
     @Override
     public UnknownSchemaNode build() {
-        instance.setPath(schemaPath);
-        instance.setNodeType(nodeType);
-        instance.setNodeParameter(nodeParameter);
+        if(!isBuilt) {
+            instance.setPath(schemaPath);
+            instance.setNodeType(nodeType);
+            instance.setNodeParameter(nodeParameter);
+
+            // UNKNOWN NODES
+            final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+            for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+                unknownNodes.add(b.build());
+            }
+            instance.setUnknownSchemaNodes(unknownNodes);
 
-        // UNKNOWN NODES
-        final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
-        for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
-            unknownNodes.add(b.build());
+            isBuilt = true;
         }
-        instance.setUnknownSchemaNodes(unknownNodes);
+
         return instance;
     }
 
@@ -103,7 +109,7 @@ public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
         this.nodeParameter = nodeParameter;
     }
 
-    private static class UnknownSchemaNodeImpl implements UnknownSchemaNode {
+    private final class UnknownSchemaNodeImpl implements UnknownSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 6943b661564302f337e2a525a51678f60c6819e2..dba747db1dd9bad3aa31a3d265279119d8434b85 100644 (file)
@@ -26,7 +26,7 @@ import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.RefineHolder;\r
 \r
 public final class UsesNodeBuilderImpl implements UsesNodeBuilder {\r
-    private boolean built;\r
+    private boolean isBuilt;\r
     private final UsesNodeImpl instance;\r
     private final int line;\r
     private final String groupingPathStr;\r
@@ -45,7 +45,7 @@ public final class UsesNodeBuilderImpl implements UsesNodeBuilder {
 \r
     @Override\r
     public UsesNode build() {\r
-        if (!built) {\r
+        if (!isBuilt) {\r
             instance.setAugmenting(augmenting);\r
 \r
             // AUGMENTATIONS\r
@@ -63,7 +63,7 @@ public final class UsesNodeBuilderImpl implements UsesNodeBuilder {
             }\r
             instance.setRefines(refineNodes);\r
 \r
-            built = true;\r
+            isBuilt = true;\r
         }\r
         return instance;\r
     }\r
index ec46831b4fba538f1a1359c917efc8311eac4db4..14ef4914d512f8c7775f5c622990246587063908 100644 (file)
@@ -79,7 +79,7 @@ import org.opendaylight.controller.yang.validator.YangModelBasicValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class YangParserImpl implements YangModelParser {
+public final class YangParserImpl implements YangModelParser {
 
     private static final Logger logger = LoggerFactory
             .getLogger(YangParserImpl.class);
@@ -361,15 +361,14 @@ public class YangParserImpl implements YangModelParser {
             final TypeDefinitionBuilder old, final boolean seekByTypedefBuilder) {
         if (old instanceof UnionTypeBuilder) {
             final UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
-            final UnionTypeBuilder newUnion = new UnionTypeBuilder(
-                    oldUnion.getActualPath(), oldUnion.getNamespace(),
-                    oldUnion.getRevision(), old.getLine());
+            final UnionTypeBuilder newUnion = new UnionTypeBuilder(old.getLine());
             for (TypeDefinition<?> td : oldUnion.getTypes()) {
                 newUnion.setType(td);
             }
             for (TypeDefinitionBuilder tdb : oldUnion.getTypedefs()) {
                 newUnion.setType(copyTypedefBuilder(tdb, true));
             }
+            newUnion.setPath(old.getPath());
             return newUnion;
         }
 
index 46265529daddb5897c4695017885cb2232b54433..b853dcf2a89b29827bd4478a99eb5516ae55182d 100644 (file)
@@ -73,6 +73,7 @@ import org.opendaylight.controller.yang.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.NotificationBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.RpcDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.TypedefBuilder;
+import org.opendaylight.controller.yang.parser.builder.impl.UnionTypeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.util.RefineHolder;
 import org.slf4j.Logger;
@@ -334,8 +335,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 moduleBuilder.setType(type, actualPath);
             } else {
                 if ("union".equals(typeName)) {
-                    moduleBuilder.addUnionType(actualPath, namespace, revision,
+                    List<String> typePath = new ArrayList<String>(actualPath);
+                    typePath.add(typeName);
+
+                    SchemaPath p = createActualSchemaPath(typePath, namespace, revision, yangModelPrefix);
+                    UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(actualPath, namespace, revision,
                             line);
+                    unionBuilder.setPath(p);
                 } else if ("identityref".equals(typeName)) {
                     SchemaPath path = createActualSchemaPath(actualPath,
                             namespace, revision, yangModelPrefix);
@@ -344,7 +350,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                             line);
                 } else {
                     List<String> typePath = new ArrayList<String>(actualPath);
-                    typePath.remove(0);
+                    typePath.add(typeName);
+
                     type = parseTypeBody(typeName, typeBody, typePath,
                             namespace, revision, yangModelPrefix);
                     moduleBuilder.setType(type, actualPath);
index 05f9c6519fba726579fbe7beffcec22dd0e3f282..b4e250d19f9e2df482e4421f5943a29e73e350d9 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.yang.parser.util;
 
 import java.lang.reflect.Method;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -16,12 +17,45 @@ import org.opendaylight.controller.yang.model.api.ModuleImport;
 import org.opendaylight.controller.yang.model.api.MustDefinition;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.BinaryTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.DecimalTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
+import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
+import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
+import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.controller.yang.model.util.BinaryType;
+import org.opendaylight.controller.yang.model.util.BitsType;
+import org.opendaylight.controller.yang.model.util.BooleanType;
+import org.opendaylight.controller.yang.model.util.Decimal64;
+import org.opendaylight.controller.yang.model.util.EmptyType;
+import org.opendaylight.controller.yang.model.util.EnumerationType;
+import org.opendaylight.controller.yang.model.util.IdentityrefType;
+import org.opendaylight.controller.yang.model.util.InstanceIdentifier;
+import org.opendaylight.controller.yang.model.util.Int16;
+import org.opendaylight.controller.yang.model.util.Int32;
+import org.opendaylight.controller.yang.model.util.Int64;
+import org.opendaylight.controller.yang.model.util.Int8;
+import org.opendaylight.controller.yang.model.util.Leafref;
+import org.opendaylight.controller.yang.model.util.StringType;
+import org.opendaylight.controller.yang.model.util.UnionType;
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.builder.api.ChildNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.parser.builder.api.TypeAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.impl.AnyXmlBuilder;
@@ -102,29 +136,170 @@ public final class ParserUtils {
             final ChildNodeBuilder target) {
         for (DataSchemaNodeBuilder builder : augment.getChildNodes()) {
             builder.setAugmenting(true);
-            correctPath(augment, target.getPath());
+            correctAugmentChildPath(augment, target.getPath());
             target.addChildNode(builder);
         }
     }
 
-    private static void correctPath(final ChildNodeBuilder node,
+    private static void correctAugmentChildPath(final ChildNodeBuilder node,
             final SchemaPath parentSchemaPath) {
         for (DataSchemaNodeBuilder builder : node.getChildNodes()) {
 
             // add correct path
-            SchemaPath targetNodeSchemaPath = parentSchemaPath;
             List<QName> targetNodePath = new ArrayList<QName>(
-                    targetNodeSchemaPath.getPath());
+                    parentSchemaPath.getPath());
             targetNodePath.add(builder.getQName());
             builder.setPath(new SchemaPath(targetNodePath, true));
 
             if (builder instanceof ChildNodeBuilder) {
                 ChildNodeBuilder cnb = (ChildNodeBuilder) builder;
-                correctPath(cnb, builder.getPath());
+                correctAugmentChildPath(cnb, builder.getPath());
             }
+
+            // if child can contains type, correct path for this type too
+            if(builder instanceof TypeAwareBuilder) {
+                TypeAwareBuilder nodeBuilder = (TypeAwareBuilder)builder;
+                QName nodeBuilderQName = nodeBuilder.getQName();
+                TypeDefinition<?> nodeBuilderType = nodeBuilder.getType();
+                if(nodeBuilderType != null) {
+                    TypeDefinition<?> newType = createCorrectTypeDefinition(parentSchemaPath, nodeBuilderQName, nodeBuilderType);
+                    nodeBuilder.setType(newType);
+                } else {
+                    TypeDefinitionBuilder nodeBuilderTypedef = nodeBuilder.getTypedef();
+                    SchemaPath newSchemaPath = createNewSchemaPath(nodeBuilderTypedef.getPath(), nodeBuilderQName, nodeBuilderTypedef.getQName());
+                    nodeBuilderTypedef.setPath(newSchemaPath);
+                }
+            }
+        }
+    }
+
+    private static TypeDefinition<?> createCorrectTypeDefinition(SchemaPath parentSchemaPath, QName nodeQName, TypeDefinition<?> nodeType) {
+        TypeDefinition<?> result = null;
+        SchemaPath newSchemaPath = null;
+        if(nodeType != null) {
+            if(nodeType instanceof BinaryTypeDefinition) {
+                BinaryTypeDefinition binType = (BinaryTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, binType.getQName());
+                List<Byte> bytes = (List<Byte>)binType.getDefaultValue();
+                result = new BinaryType(newSchemaPath, bytes, binType.getLengthConstraints(), binType.getUnits());
+            } else if(nodeType instanceof BitsTypeDefinition) {
+                BitsTypeDefinition bitsType = (BitsTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, nodeType.getQName());
+                result = new BitsType(newSchemaPath, bitsType.getBits(), bitsType.getUnits());
+            } else if(nodeType instanceof BooleanTypeDefinition) {
+                BooleanTypeDefinition booleanType = (BooleanTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, booleanType.getQName());
+                result = new BooleanType(newSchemaPath, (Boolean)booleanType.getDefaultValue(), booleanType.getUnits());
+            } else if(nodeType instanceof DecimalTypeDefinition) {
+                DecimalTypeDefinition decimalType = (DecimalTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, decimalType.getQName());
+                BigDecimal defaultValue = (BigDecimal)decimalType.getDefaultValue();
+                result = new Decimal64(newSchemaPath, decimalType.getUnits(), defaultValue, decimalType.getRangeStatements(), decimalType.getFractionDigits());
+            } else if(nodeType instanceof EmptyTypeDefinition) {
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, nodeType.getQName());
+                result = new EmptyType(newSchemaPath);
+            } else if(nodeType instanceof EnumTypeDefinition) {
+                EnumTypeDefinition enumType = (EnumTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, enumType.getQName());
+                result = new EnumerationType(newSchemaPath, (EnumPair)enumType.getDefaultValue(), enumType.getValues(), enumType.getUnits());
+            } else if(nodeType instanceof IdentityrefTypeDefinition) {
+                IdentityrefTypeDefinition idrefType = (IdentityrefTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, idrefType.getQName());
+                result = new IdentityrefType(idrefType.getIdentity(), newSchemaPath);
+            } else if(nodeType instanceof InstanceIdentifierTypeDefinition) {
+                InstanceIdentifierTypeDefinition instIdType = (InstanceIdentifierTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, instIdType.getQName());
+                return new InstanceIdentifier(newSchemaPath, instIdType.getPathStatement(), instIdType.requireInstance());
+            } else if(nodeType instanceof StringTypeDefinition) {
+                result = copyStringType(parentSchemaPath, nodeQName, (StringTypeDefinition)nodeType);
+            } else if(nodeType instanceof IntegerTypeDefinition) {
+                result = copyIntType(parentSchemaPath, nodeQName, (IntegerTypeDefinition)nodeType);
+            } else if(nodeType instanceof UnsignedIntegerTypeDefinition) {
+                result = copyUIntType(parentSchemaPath, nodeQName, (UnsignedIntegerTypeDefinition)nodeType);
+            } else if(nodeType instanceof LeafrefTypeDefinition) {
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, nodeType.getQName());
+                result = new Leafref(newSchemaPath, ((LeafrefTypeDefinition)nodeType).getPathStatement());
+            } else if(nodeType instanceof UnionTypeDefinition) {
+                UnionTypeDefinition unionType = (UnionTypeDefinition)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath, nodeQName, unionType.getQName());
+                return new UnionType(newSchemaPath, unionType.getTypes());
+            }
+        }
+        return result;
+    }
+
+    private static TypeDefinition<?> copyStringType(SchemaPath schemaPath, QName nodeQName, StringTypeDefinition nodeType) {
+        List<QName> path = schemaPath.getPath();
+        List<QName> newPath = new ArrayList<QName>(path);
+        newPath.add(nodeQName);
+        newPath.add(nodeType.getQName());
+        SchemaPath newSchemaPath = new SchemaPath(newPath, schemaPath.isAbsolute());
+
+        String newDefault = nodeType.getDefaultValue().toString();
+        String newUnits = nodeType.getUnits();
+        List<LengthConstraint> lengths = nodeType.getLengthStatements();
+        List<PatternConstraint> patterns = nodeType.getPatterns();
+
+        return new StringType(newSchemaPath, newDefault, lengths, patterns, newUnits);
+    }
+
+    private static TypeDefinition<?> copyIntType(SchemaPath schemaPath, QName nodeQName, IntegerTypeDefinition type) {
+        QName typeQName = type.getQName();
+        SchemaPath newSchemaPath = createNewSchemaPath(schemaPath, nodeQName, typeQName);
+
+        String localName = typeQName.getLocalName();
+        List<RangeConstraint> ranges = type.getRangeStatements();
+        String units = type.getUnits();
+
+        if("int8".equals(localName)) {
+            Byte defaultValue = (Byte)type.getDefaultValue();
+            return new Int8(newSchemaPath, ranges, units, defaultValue);
+        } else if("int16".equals(localName)) {
+            Short defaultValue = (Short)type.getDefaultValue();
+            return new Int16(newSchemaPath, ranges, units, defaultValue);
+        } else if("int32".equals(localName)) {
+            Integer defaultValue = (Integer)type.getDefaultValue();
+            return new Int32(newSchemaPath, ranges, units, defaultValue);
+        } else if("int64".equals(localName)) {
+            Long defaultValue = (Long)type.getDefaultValue();
+            return new Int64(newSchemaPath, ranges, units, defaultValue);
+        } else {
+            return null;
         }
     }
 
+    private static TypeDefinition<?> copyUIntType(SchemaPath schemaPath, QName nodeQName, UnsignedIntegerTypeDefinition type) {
+        QName typeQName = type.getQName();
+        SchemaPath newSchemaPath = createNewSchemaPath(schemaPath, nodeQName, typeQName);
+
+        String localName = typeQName.getLocalName();
+        List<RangeConstraint> ranges = type.getRangeStatements();
+        String units = type.getUnits();
+
+        if("uint8".equals(localName)) {
+            Byte defaultValue = (Byte)type.getDefaultValue();
+            return new Int8(newSchemaPath, ranges, units, defaultValue);
+        } else if("uint16".equals(localName)) {
+            Short defaultValue = (Short)type.getDefaultValue();
+            return new Int16(newSchemaPath, ranges, units, defaultValue);
+        } else if("uint32".equals(localName)) {
+            Integer defaultValue = (Integer)type.getDefaultValue();
+            return new Int32(newSchemaPath, ranges, units, defaultValue);
+        } else if("uint64".equals(localName)) {
+            Long defaultValue = (Long)type.getDefaultValue();
+            return new Int64(newSchemaPath, ranges, units, defaultValue);
+        } else {
+            return null;
+        }
+    }
+
+    private static SchemaPath createNewSchemaPath(SchemaPath schemaPath, QName currentQName, QName qname) {
+        List<QName> newPath = new ArrayList<QName>(schemaPath.getPath());
+        newPath.add(currentQName);
+        newPath.add(qname);
+        return new SchemaPath(newPath, schemaPath.isAbsolute());
+    }
+
     public static void refineLeaf(LeafSchemaNodeBuilder leaf,
             RefineHolder refine, int line) {
         String defaultStr = refine.getDefaultStr();
index 873e3842db0097cb17ec4d1fb6dbd5edd039451b..e63f12839dfa8d4d883806bccf6f5e226d45a5bc 100644 (file)
@@ -1008,60 +1008,51 @@ public final class YangModelBuilderUtil {
         List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(
                 typeBody, actualPath, namespace, revision, prefix);
 
+        SchemaPath schemaPath = createActualSchemaPath(actualPath, namespace,
+                revision, prefix);
+
         if ("decimal64".equals(typeName)) {
-            type = new Decimal64(actualPath, namespace, revision,
-                    fractionDigits);
+            type = new Decimal64(schemaPath, fractionDigits);
         } else if (typeName.startsWith("int")) {
             if ("int8".equals(typeName)) {
-                type = new Int8(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int8(schemaPath, rangeStatements, null, null);
             } else if ("int16".equals(typeName)) {
-                type = new Int16(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int16(schemaPath, rangeStatements, null, null);
             } else if ("int32".equals(typeName)) {
-                type = new Int32(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int32(schemaPath, rangeStatements, null, null);
             } else if ("int64".equals(typeName)) {
-                type = new Int64(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Int64(schemaPath, rangeStatements, null, null);
             }
         } else if (typeName.startsWith("uint")) {
             if ("uint8".equals(typeName)) {
-                type = new Uint8(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint8(schemaPath, rangeStatements, null, null);
             } else if ("uint16".equals(typeName)) {
-                type = new Uint16(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint16(schemaPath, rangeStatements, null, null);
             } else if ("uint32".equals(typeName)) {
-                type = new Uint32(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint32(schemaPath, rangeStatements, null, null);
             } else if ("uint64".equals(typeName)) {
-                type = new Uint64(actualPath, namespace, revision,
-                        rangeStatements, null, null);
+                type = new Uint64(schemaPath, rangeStatements, null, null);
             }
         } else if ("enumeration".equals(typeName)) {
-            type = new EnumerationType(actualPath, namespace, revision,
-                    enumConstants);
+            type = new EnumerationType(schemaPath, enumConstants);
         } else if ("string".equals(typeName)) {
-            type = new StringType(actualPath, namespace, revision,
-                    lengthStatements, patternStatements);
+            type = new StringType(schemaPath, lengthStatements,
+                    patternStatements);
         } else if ("bits".equals(typeName)) {
-            type = new BitsType(actualPath, namespace, revision, getBits(
-                    typeBody, actualPath, namespace, revision, prefix));
+            type = new BitsType(schemaPath, getBits(typeBody, actualPath,
+                    namespace, revision, prefix));
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
             RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path,
                     absolute);
-            type = new Leafref(actualPath, namespace, revision, xpath);
+            type = new Leafref(schemaPath, xpath);
         } else if ("binary".equals(typeName)) {
             List<Byte> bytes = Collections.emptyList();
-            type = new BinaryType(actualPath, namespace, revision, bytes,
-                    lengthStatements, null);
+            type = new BinaryType(schemaPath, bytes, lengthStatements, null);
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            type = new InstanceIdentifier(actualPath, namespace, revision,
-                    null, requireInstance);
+            type = new InstanceIdentifier(schemaPath, null, requireInstance);
         }
         return type;
     }
index 5aa620df8936383392ea25d7acea995a7b65fe55..babd0d06f6a7bb217bf12de36b863be569921c56 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.yang.parser.impl;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.net.URI;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -29,11 +30,14 @@ final class TestUtils {
     private TestUtils() {
     }
 
-    public static Set<Module> loadModules(String resourceDirectory) {
+    public static Set<Module> loadModules(String resourceDirectory) throws FileNotFoundException {
         YangModelParser parser = new YangParserImpl();
         final File testDir = new File(resourceDirectory);
         final String[] fileList = testDir.list();
         final List<File> testFiles = new ArrayList<File>();
+        if(fileList == null) {
+            throw new FileNotFoundException(resourceDirectory);
+        }
         for (int i = 0; i < fileList.length; i++) {
             String fileName = fileList[i];
             testFiles.add(new File(testDir, fileName));
index 8435ff683a08c32cef4656962cdc19347a16cea4..36c98c36e2a3928cded65ecdbad0ec11b850f2a4 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.yang.parser.impl;
 
 import static org.junit.Assert.*;
 
+import java.io.FileNotFoundException;
 import java.net.URI;
 import java.util.List;
 import java.util.Set;
@@ -37,7 +38,7 @@ public class TypesResolutionTest {
     private Set<Module> testedModules;
 
     @Before
-    public void init() {
+    public void init() throws FileNotFoundException {
         testedModules = TestUtils.loadModules("src/test/resources/types");
     }
 
index 910a360c9be920ecab6efe819656828e5d582b28..9463410af8395d3232f581920fc05b930527de13 100644 (file)
@@ -9,7 +9,10 @@ package org.opendaylight.controller.yang.parser.impl;
 
 import static org.junit.Assert.*;
 
+import java.io.FileNotFoundException;
 import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
@@ -32,6 +35,7 @@ import org.opendaylight.controller.yang.model.api.Deviation.Deviate;
 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
 import org.opendaylight.controller.yang.model.api.FeatureDefinition;
 import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.ListSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
@@ -52,6 +56,7 @@ import org.opendaylight.controller.yang.model.util.Decimal64;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.Int16;
 import org.opendaylight.controller.yang.model.util.Int32;
+import org.opendaylight.controller.yang.model.util.Leafref;
 import org.opendaylight.controller.yang.model.util.StringType;
 import org.opendaylight.controller.yang.model.util.Uint32;
 import org.opendaylight.controller.yang.model.util.UnionType;
@@ -60,7 +65,7 @@ public class YangParserTest {
     private Set<Module> modules;
 
     @Before
-    public void init() {
+    public void init() throws FileNotFoundException {
         modules = TestUtils.loadModules("src/test/resources/model");
         assertEquals(3, modules.size());
     }
@@ -167,8 +172,8 @@ public class YangParserTest {
         assertNull(constraints.getWhenCondition());
         assertEquals(0, constraints.getMustConstraints().size());
         assertFalse(constraints.isMandatory());
-        assertEquals(1, (int)constraints.getMinElements());
-        assertEquals(11, (int)constraints.getMaxElements());
+        assertEquals(1, (int) constraints.getMinElements());
+        assertEquals(11, (int) constraints.getMaxElements());
         // test AugmentationTarget args
         Set<AugmentationSchema> availableAugmentations = ifEntry
                 .getAvailableAugmentations();
@@ -564,14 +569,14 @@ public class YangParserTest {
             SchemaNode value = entry.getValue();
             if (value instanceof LeafSchemaNode) {
                 refineLeaf = (LeafSchemaNode) value;
-            } else if(value instanceof ContainerSchemaNode) {
+            } else if (value instanceof ContainerSchemaNode) {
                 refineContainer = (ContainerSchemaNode) value;
-            } else if(value instanceof ListSchemaNode) {
-                refineList = (ListSchemaNode)value;
-            } else if(value instanceof GroupingDefinition) {
-                refineGrouping = (GroupingDefinition)value;
-            } else if(value instanceof TypeDefinition<?>) {
-                typedef = (TypeDefinition<?>)value;
+            } else if (value instanceof ListSchemaNode) {
+                refineList = (ListSchemaNode) value;
+            } else if (value instanceof GroupingDefinition) {
+                refineGrouping = (GroupingDefinition) value;
+            } else if (value instanceof TypeDefinition<?>) {
+                typedef = (TypeDefinition<?>) value;
             }
         }
 
@@ -610,19 +615,25 @@ public class YangParserTest {
 
         // list addresses
         assertNotNull(refineList);
-        assertEquals("description of addresses defined by refine", refineList.getDescription());
-        assertEquals("addresses reference added by refine", refineList.getReference());
+        assertEquals("description of addresses defined by refine",
+                refineList.getDescription());
+        assertEquals("addresses reference added by refine",
+                refineList.getReference());
         assertFalse(refineList.isConfiguration());
-        assertEquals(2, (int)refineList.getConstraints().getMinElements());
-        assertEquals(12, (int)refineList.getConstraints().getMaxElements());
+        assertEquals(2, (int) refineList.getConstraints().getMinElements());
+        assertEquals(12, (int) refineList.getConstraints().getMaxElements());
 
         // grouping target-inner
         assertNotNull(refineGrouping);
-        Set<DataSchemaNode> refineGroupingChildren = refineGrouping.getChildNodes();
+        Set<DataSchemaNode> refineGroupingChildren = refineGrouping
+                .getChildNodes();
         assertEquals(1, refineGroupingChildren.size());
-        LeafSchemaNode refineGroupingLeaf = (LeafSchemaNode)refineGroupingChildren.iterator().next();
-        assertEquals("inner-grouping-id", refineGroupingLeaf.getQName().getLocalName());
-        assertEquals("new target-inner grouping description", refineGrouping.getDescription());
+        LeafSchemaNode refineGroupingLeaf = (LeafSchemaNode) refineGroupingChildren
+                .iterator().next();
+        assertEquals("inner-grouping-id", refineGroupingLeaf.getQName()
+                .getLocalName());
+        assertEquals("new target-inner grouping description",
+                refineGrouping.getDescription());
 
         // typedef group-type
         assertNotNull(typedef);
@@ -761,4 +772,43 @@ public class YangParserTest {
         assertEquals(5, children.size());
     }
 
+    @Test
+    public void testAugmentNodesTypesSchemaPath() throws Exception {
+        final DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Module testModule = TestUtils.findModule(modules, "types1");
+        Set<AugmentationSchema> augments = testModule.getAugmentations();
+        assertEquals(1, augments.size());
+        AugmentationSchema augment = augments.iterator().next();
+
+        LeafSchemaNode ifcId = (LeafSchemaNode) augment
+                .getDataChildByName("interface-id");
+        Leafref ifcIdType = (Leafref) ifcId.getType();
+        SchemaPath ifcIdTypeSchemaPath = ifcIdType.getPath();
+        List<QName> ifcIdTypePath = ifcIdTypeSchemaPath.getPath();
+        QName q0 = new QName(new URI("urn:simple.types.data.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "interfaces");
+        QName q1 = new QName(new URI("urn:simple.types.data.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "ifEntry");
+        QName q2 = new QName(new URI("urn:simple.container.demo.test"),
+                simpleDateFormat.parse("2013-02-27"), "data", "augment-holder");
+        QName q3 = new QName(new URI("urn:simple.container.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "interface-id");
+        assertEquals(q0, ifcIdTypePath.get(0));
+        assertEquals(q1, ifcIdTypePath.get(1));
+        assertEquals(q2, ifcIdTypePath.get(2));
+        assertEquals(q3, ifcIdTypePath.get(3));
+
+        LeafListSchemaNode higherLayer = (LeafListSchemaNode) augment
+                .getDataChildByName("higher-layer-if");
+        Leafref higherLayerType = (Leafref) higherLayer.getType();
+        SchemaPath higherLayerTypeSchemaPath = higherLayerType.getPath();
+        List<QName> higherLayerTypePath = higherLayerTypeSchemaPath.getPath();
+        assertEquals(q0, higherLayerTypePath.get(0));
+        assertEquals(q1, higherLayerTypePath.get(1));
+        assertEquals(q2, higherLayerTypePath.get(2));
+        q3 = new QName(new URI("urn:simple.container.demo"),
+                simpleDateFormat.parse("2013-02-27"), "data", "higher-layer-if");
+        assertEquals(q3, higherLayerTypePath.get(3));
+    }
+
 }
index 2f4355390bf65dc4b66cab51fb04ee45cf4ac06b..619a5c3e104a1ecd3dcc331ee235a3647cd47ebd 100644 (file)
@@ -31,9 +31,9 @@ module types1 {
     }
 
     leaf leaf-with-length {
-       type data:my-string-type {
-               length "7..max";
-       }
+        type data:my-string-type {
+            length "7..max";
+        }
     }
 
     leaf test-int-leaf {
@@ -55,7 +55,7 @@ module types1 {
     }
 
     leaf union-leaf {
-       type data:my-union-ext;
+        type data:my-union-ext;
     }
 
     deviation /data:system/data:user {
@@ -66,7 +66,7 @@ module types1 {
     }
 
     leaf nested-union-leaf {
-       type data:nested-union1;
+        type data:nested-union1;
     }
 
     leaf custom-union-leaf {
@@ -113,6 +113,16 @@ module types1 {
         leaf ds0ChannelNumber {
             type string;
         }
+        leaf interface-id {
+            type leafref {
+                path "/if:interfaces/if:interface/if:name";
+            }
+        }
+        leaf-list higher-layer-if {
+            type leafref {
+                path "/if:interfaces/if:interface/if:higher-layer-if";
+            }
+        }
     }
 
 }
index d75fc6329679b65224aca76be6cd7b3db1931e11..b779c3ca34c88bc1ee9b579a7a3878df943feeeb 100644 (file)
@@ -82,27 +82,27 @@ module types2 {
     }
 
     typedef my-union {
-       type union {
-               type int16 {
-                       range "1..100";
-               }
-               type int32;
-       }
+        type union {
+            type int16 {
+                range "1..100";
+            }
+            type int32;
+        }
     }
 
     typedef my-union-ext {
-       type my-union;
+        type my-union;
     }
 
     typedef nested-union1 {
-       type nested-union2;
+        type nested-union2;
     }
 
     typedef nested-union2 {
-       type union {
-               type my-union-ext;
-               type string;
-       }
+        type union {
+            type my-union-ext;
+            type string;
+        }
     }
 
     leaf if-name {
index b203124a9fb50c8c54d2df14fed8e4b3f82fe8a1..7aadc9a54fa36451f9b360ede8669e6a41cfa014 100644 (file)
@@ -42,14 +42,14 @@ module types3 {
 
     container network {
         mnt:mountpoint point {
-               mnt:target-ref target;
+            mnt:target-ref target;
         }
         
-           description "network-description";
-           reference "network-reference";
-           status obsolete;
-           config true;
-           presence "some presence text";
+        description "network-description";
+        reference "network-reference";
+        status obsolete;
+        config true;
+        presence "some presence text";
     }
 
     feature local-storage {
index 1ba93ea298e10afed761d20e7f0ce291757d66d8..cf931cb2451352a45ca19aeee5a0fa1da54c1ad0 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>yang-prototype</artifactId>
-       <version>0.5-SNAPSHOT</version>
-       <packaging>pom</packaging>
-       <modules>
-               <module>yang</module>
-               <module>code-generator</module>
-       </modules>
+    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>
+    <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>
+    <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>
+    <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>
-               </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>
+    <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>
+        </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> 
+                    <execution> 
+                          <id>attach-javadocs</id>
+                          <phase>deploy</phase>
+                          <goals><goal>jar</goal></goals> 
+                    </execution> 
+                </executions> 
+            </plugin>
+            <plugin>
+            <artifactId>maven-source-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <phase>deploy</phase>
+                        <goals><goal>jar-no-fork</goal></goals> 
+                    </execution>
+                 </executions>
+            </plugin>
+            <plugin> 
+                <!-- explicitly define maven-deploy-plugin after other to force exec order -->
+                <artifactId>maven-deploy-plugin</artifactId> 
+                <executions> 
+                    <execution> 
+                        <id>deploy</id>
+                        <phase>deploy</phase>
+                        <goals><goal>deploy</goal></goals> 
+                    </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 19d35997e3042ecfa359ed5be8c4148ba80ca258..e79e70028b6cdacdbd8ffc0130ad6a9669ab137c 100644 (file)
@@ -6,14 +6,13 @@
                <artifactId>yang-prototype</artifactId>
                <version>0.5-SNAPSHOT</version>
        </parent>
-
+       <version>0.5.1-SNAPSHOT</version>
        <artifactId>yang</artifactId>
        <packaging>pom</packaging>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <!-- Version of all child artifacts -->
-        <release.version>0.5-SNAPSHOT</release.version>
     </properties>
 
        <modules>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-common</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-data-api</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-data-util</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-model-api</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-model-util</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-binding</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-model-parser-api</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-model-parser-impl
                 </artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>yang-maven-plugin-spi</artifactId>
-                <version>${release.version}</version>
+                <version>${project.version}</version>
             </dependency>
         </dependencies>
     </dependencyManagement>
index 0836f749a4f16e05006b6e20fa8a245745f40a81..f7df24f53f9a69ecf3e709de1bdf608fe4eddf99 100644 (file)
@@ -3,8 +3,7 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-binding</artifactId>\r
-  <version>${release.version}</version>\r
 </project>
\ No newline at end of file
index fc3e21b9b9fa2e562f597df165664886b3ee92ce..987b9b11a18a11ffb901a2adff7e8e764e8ebc3a 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-common</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.slf4j</groupId>\r
index 2677e66f03e52c63962855b06435d34c28395d40..749c9c66f439eabddf25c5da6ad3798c02003132 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-data-api</artifactId>\r
-  <version>${release.version}</version>\r
   \r
   <dependencies>\r
        <dependency>\r
index 44c0ffbaa75bd97f0fd79d4fbab06c931fb095c8..15b391f5b896146565a785fa8e459435dfb43be4 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-data-util</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
        <dependency>\r
                <groupId>org.opendaylight.controller</groupId>\r
index 1798d5ea5cc33e8d4c4b77d19e22405545e74a6a..3eabd7ff9f4aec09ddb4964f7b8fce95187347e3 100644 (file)
@@ -3,10 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-model-api</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
        <dependency>\r
                <groupId>org.opendaylight.controller</groupId>\r
index ec4a9fab252d0ac9319abece4402eccfa7e19d40..3390837be919feae17cd0484802402b7fda0f0e9 100644 (file)
@@ -3,11 +3,9 @@
   <parent>\r
     <groupId>org.opendaylight.controller</groupId>\r
     <artifactId>yang</artifactId>\r
-    <version>0.5-SNAPSHOT</version>\r
-    <relativePath>../../yang/pom.xml</relativePath>\r
+    <version>0.5.1-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-model-util</artifactId>\r
-  <version>${release.version}</version>\r
   <dependencies>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
index c2ae7d304a8c1ca9bae54b109e94f3b46d023ef4..0af3c81c6ac3e570c716a3376cf3549d8f3f16fe 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -67,13 +65,12 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
      * @param maxRange
      * @param units
      */
-    public AbstractSignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractSignedInteger(final SchemaPath path, final QName name,
             final String description, final Number minRange,
             final Number maxRange, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = new ArrayList<RangeConstraint>();
         final String rangeDescription = "Integer values between " + minRange
@@ -89,13 +86,12 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
      * @param rangeStatements
      * @param units
      */
-    public AbstractSignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractSignedInteger(final SchemaPath path, final QName name,
             final String description,
             final List<RangeConstraint> rangeStatements, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = rangeStatements;
     }
index 31a62ececda6f4e2a652adac5b7c90449be0c837..013d80d79911c127ef4f3823a2fc996bf70c044f 100644 (file)
@@ -3,10 +3,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -68,13 +66,12 @@ public abstract class AbstractUnsignedInteger implements
      * @param maxRange
      * @param units
      */
-    public AbstractUnsignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractUnsignedInteger(final SchemaPath path, final QName name,
             final String description, final Number minRange,
             final Number maxRange, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = new ArrayList<RangeConstraint>();
         final String rangeDescription = "Integer values between " + minRange
@@ -90,13 +87,12 @@ public abstract class AbstractUnsignedInteger implements
      * @param rangeStatements
      * @param units
      */
-    public AbstractUnsignedInteger(final List<String> actualPath,
-            final URI namespace, final Date revision, final QName name,
+    public AbstractUnsignedInteger(final SchemaPath path, final QName name,
             final String description,
             final List<RangeConstraint> rangeStatements, final String units) {
         this.name = name;
         this.description = description;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.units = units;
         this.rangeStatements = rangeStatements;
     }
index 253fe484f0459a7f410014814a549166c5477dbd..74214dc0c77973a9f5b07777ea77d0735c33f9fc 100644 (file)
@@ -1,16 +1,14 @@
 /*
 * 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
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -25,7 +23,7 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
  *
  * @see BinaryTypeDefinition
  */
-public class BinaryType implements BinaryTypeDefinition {
+public final class BinaryType implements BinaryTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("binary");
     private final SchemaPath path;
@@ -40,22 +38,23 @@ public class BinaryType implements BinaryTypeDefinition {
         super();
 
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
+                ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
         this.path = BaseTypes.schemaPath(name);
         this.baseType = this;
     }
 
-    public BinaryType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BinaryType(final SchemaPath path) {
         super();
 
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
+                ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BinaryType();
     }
 
@@ -66,20 +65,21 @@ public class BinaryType implements BinaryTypeDefinition {
      * @param lengthConstraints
      * @param units
      */
-    public BinaryType(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<Byte> bytes,
+    public BinaryType(final SchemaPath path, final List<Byte> bytes,
             final List<LengthConstraint> lengthConstraints, final String units) {
         super();
 
         if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE,
+                    "", ""));
             this.lengthConstraints = Collections.unmodifiableList(constraints);
         } else {
-            this.lengthConstraints = Collections.unmodifiableList(lengthConstraints);
+            this.lengthConstraints = Collections
+                    .unmodifiableList(lengthConstraints);
         }
 
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.bytes = Collections.unmodifiableList(bytes);
         this.units = units;
         this.baseType = new BinaryType();
@@ -88,7 +88,8 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public BinaryTypeDefinition getBaseType() {
@@ -108,7 +109,9 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -138,7 +141,8 @@ public class BinaryType implements BinaryTypeDefinition {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
@@ -169,8 +173,8 @@ public class BinaryType implements BinaryTypeDefinition {
      * (non-Javadoc)
      *
      * @see
-     * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint
-     * ()
+     * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition
+     * #getLengthConstraint ()
      */
     @Override
     public List<LengthConstraint> getLengthConstraints() {
@@ -191,7 +195,8 @@ public class BinaryType implements BinaryTypeDefinition {
                 + ((description == null) ? 0 : description.hashCode());
         result = prime
                 * result
-                + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
+                + ((lengthConstraints == null) ? 0 : lengthConstraints
+                        .hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
         result = prime * result
index 717c24ed5083c2b89cc47fd0fa9a6b473aaa4d6d..51e0306e8b8737c1e7450c6fe60a8767b6c43280 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -23,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
  *
  * @see BitsTypeDefinition
  */
-public class BitsType implements BitsTypeDefinition {
+public final class BitsType implements BitsTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("bits");
     private final SchemaPath path;
@@ -47,11 +45,10 @@ public class BitsType implements BitsTypeDefinition {
         this.baseType = this;
     }
 
-    public BitsType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BitsType(final SchemaPath path) {
         super();
         this.bits = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
@@ -64,12 +61,11 @@ public class BitsType implements BitsTypeDefinition {
      * @param bits
      *            The bits assigned for Bits Type
      */
-    public BitsType(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<Bit> bits) {
+    public BitsType(final SchemaPath path, final List<Bit> bits) {
         super();
         this.bits = Collections.unmodifiableList(bits);
         this.units = "";
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
@@ -83,12 +79,11 @@ public class BitsType implements BitsTypeDefinition {
      * @param units
      *            units for bits type
      */
-    public BitsType(final List<String> actualPath, final URI namespace,
-            final Date revision, List<Bit> bits, String units) {
+    public BitsType(final SchemaPath path, List<Bit> bits, String units) {
         super();
         this.bits = Collections.unmodifiableList(bits);
         this.units = units;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BitsType();
     }
 
index f588bf425c9ae4ed2f6deabd91cf723bc6b9d2fd..0cda67c27fe2cf7158c8561bdb44281fb1f24b48 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -23,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
  *
  * @see BooleanTypeDefinition
  */
-public class BooleanType implements BooleanTypeDefinition {
+public final class BooleanType implements BooleanTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("boolean");
     private final SchemaPath path;
@@ -43,11 +41,10 @@ public class BooleanType implements BooleanTypeDefinition {
         this.baseType = this;
     }
 
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+    public BooleanType(final SchemaPath path) {
         super();
         this.defaultValue = false;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
@@ -57,11 +54,10 @@ public class BooleanType implements BooleanTypeDefinition {
      * @param defaultValue
      *            Default Value
      */
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision, final Boolean defaultValue) {
+    public BooleanType(final SchemaPath path, final Boolean defaultValue) {
         super();
         this.defaultValue = defaultValue;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
@@ -73,12 +69,11 @@ public class BooleanType implements BooleanTypeDefinition {
      * @param units
      *            Units
      */
-    public BooleanType(final List<String> actualPath, final URI namespace,
-            final Date revision, final Boolean defaultValue, final String units) {
+    public BooleanType(final SchemaPath path, final Boolean defaultValue, final String units) {
         super();
         this.defaultValue = defaultValue;
         this.units = units;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new BooleanType();
     }
 
index adb4c1a3cb00a21f6993c4de9e8140cc86d29674..6a070837bd8e9f3f79cec5c02639ffbdd7f0965b 100644 (file)
@@ -8,10 +8,8 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigDecimal;
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -27,7 +25,7 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  * @see DecimalTypeDefinition
  */
-public class Decimal64 implements DecimalTypeDefinition {
+public final class Decimal64 implements DecimalTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
@@ -73,8 +71,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         this.baseType = this;
     }
 
-    public Decimal64(final List<String> actualPath, final URI namespace,
-            final Date revision, final Integer fractionDigits) {
+    public Decimal64(final SchemaPath path, final Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
             throw new IllegalArgumentException(
@@ -82,7 +79,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         }
         this.fractionDigits = fractionDigits;
         rangeStatements = defaultRangeStatements();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
@@ -109,8 +106,7 @@ public class Decimal64 implements DecimalTypeDefinition {
      *            integer between 1 and 18 inclusively
      * @exception IllegalArgumentException
      */
-    public Decimal64(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
+    public Decimal64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
@@ -124,7 +120,7 @@ public class Decimal64 implements DecimalTypeDefinition {
                     .unmodifiableList(rangeStatements);
         }
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
@@ -153,8 +149,7 @@ public class Decimal64 implements DecimalTypeDefinition {
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
      */
-    public Decimal64(final List<String> actualPath, final URI namespace,
-            final Date revision, final String units,
+    public Decimal64(final SchemaPath path, final String units,
             final BigDecimal defaultValue,
             final List<RangeConstraint> rangeStatements,
             final Integer fractionDigits) {
@@ -174,7 +169,7 @@ public class Decimal64 implements DecimalTypeDefinition {
         this.units = units;
         this.defaultValue = defaultValue;
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(name);
+        this.path = path;
         this.baseType = new Decimal64(fractionDigits);
     }
 
index 1b5abb22093080657f00037ecd2e017324214c03..424f313efae6b20ccf35cf78e6b12057594114e0 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -18,7 +16,7 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
 
-public class EmptyType implements EmptyTypeDefinition {
+public final class EmptyType implements EmptyTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("empty");
     private final SchemaPath path;
@@ -31,9 +29,8 @@ public class EmptyType implements EmptyTypeDefinition {
         this.baseType = this;
     }
 
-    public EmptyType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+    public EmptyType(final SchemaPath path) {
+        this.path = path;
         this.baseType = new EmptyType();
     }
 
index c825390f38d98415c8fab8250a27f213816edbbc..175ea100ca0919c51f8f9a08e841bc9b13cffc9e 100644 (file)
@@ -7,9 +7,7 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -20,10 +18,10 @@ import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
 
 /**
  * The <code>default</code> implementation of Enumertaion Type Definition interface.
- * 
+ *
  * @see EnumTypeDefinition
  */
-public class EnumerationType implements EnumTypeDefinition {
+public final class EnumerationType implements EnumTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("enumeration");
     private final SchemaPath path;
@@ -34,29 +32,27 @@ public class EnumerationType implements EnumTypeDefinition {
     private final List<EnumPair> enums;
     private String units = "";
     private final EnumTypeDefinition baseType;
-    
+
     private EnumerationType(final List<EnumPair> enums) {
         this.path = BaseTypes.schemaPath(name);
         this.enums = Collections.unmodifiableList(enums);
         this.defaultEnum = null;
         baseType = this;
     }
-    
-    public EnumerationType(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<EnumPair> enums) {
+
+    public EnumerationType(final SchemaPath path, final List<EnumPair> enums) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.enums = Collections.unmodifiableList(enums);
         this.defaultEnum = null;
         baseType = new EnumerationType(enums);
     }
 
-    public EnumerationType(final List<String> actualPath, final URI namespace,
-            final Date revision, final EnumTypeDefinition baseType, final EnumPair defaultEnum,
+    public EnumerationType(final SchemaPath path, final EnumPair defaultEnum,
             final List<EnumPair> enums, final String units) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
-        this.baseType = baseType;
+        this.path = path;
+        baseType = new EnumerationType(enums);
         this.defaultEnum = defaultEnum;
         this.enums = Collections.unmodifiableList(enums);
         this.units = units;
@@ -64,7 +60,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
@@ -74,7 +70,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
@@ -84,7 +80,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
      */
     @Override
@@ -94,7 +90,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -104,7 +100,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -114,7 +110,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
@@ -124,7 +120,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
      */
     @Override
@@ -134,7 +130,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
      */
     @Override
@@ -144,7 +140,7 @@ public class EnumerationType implements EnumTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()
      */
     @Override
diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityType.java
deleted file mode 100644 (file)
index 0c180d7..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
-  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
-  *
-  * This program and the accompanying materials are made available under the
-  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
-  * and is available at http://www.eclipse.org/legal/epl-v10.html
-  */
-package org.opendaylight.controller.yang.model.util;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.Status;
-import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.controller.yang.model.api.type.IdentityTypeDefinition;
-
-/**
- * The <code>default</code> implementation of Identity Type Definition interface.
- * 
- * @see IdentityTypeDefinition
- */
-public class IdentityType implements IdentityTypeDefinition {
-
-    private final QName name = BaseTypes.constructQName("identity");
-    private final SchemaPath path = BaseTypes.schemaPath(name);
-    private final String description = "The 'identity' statement is used to define a new " +
-               "globally unique, abstract, and untyped identity.";
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-7.16";
-
-    private String units = "";
-    private final QName identityName;
-
-    public IdentityType(QName identityName) {
-        super();
-        this.identityName = identityName;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public IdentityTypeDefinition getBaseType() {
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
-     */
-    @Override
-    public String getUnits() {
-        return units;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
-     */
-    @Override
-    public QName getQName() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
-     */
-    @Override
-    public SchemaPath getPath() {
-        return path;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
-     */
-    @Override
-    public String getDescription() {
-        return description;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
-     */
-    @Override
-    public String getReference() {
-        return reference;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
-     */
-    @Override
-    public Status getStatus() {
-        return Status.CURRENT;
-    }
-
-    @Override
-    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
-        return Collections.emptyList();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opendaylight.controller.yang.model.base.type.api.IdentityTypeDefinition#getIdentityName
-     * ()
-     */
-    @Override
-    public QName getIdentityName() {
-        return identityName;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
-        result = prime * result
-                + ((identityName == null) ? 0 : identityName.hashCode());
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        IdentityType other = (IdentityType) obj;
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
-        if (identityName == null) {
-            if (other.identityName != null) {
-                return false;
-            }
-        } else if (!identityName.equals(other.identityName)) {
-            return false;
-        }
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
-            return false;
-        }
-        if (path == null) {
-            if (other.path != null) {
-                return false;
-            }
-        } else if (!path.equals(other.path)) {
-            return false;
-        }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("IdentityType [name=");
-        builder.append(name);
-        builder.append(", path=");
-        builder.append(path);
-        builder.append(", description=");
-        builder.append(description);
-        builder.append(", reference=");
-        builder.append(reference);
-        builder.append(", units=");
-        builder.append(units);
-        builder.append(", identityName=");
-        builder.append(identityName);
-        builder.append("]");
-        return builder.toString();
-    }
-}
index 533318e39e3c15e8ac5fc1fcde2ac5d36fb669f0..6c4598131e496b405e1183ae521b44e507fb00ce 100644 (file)
@@ -7,9 +7,7 @@
   */\r
 package org.opendaylight.controller.yang.model.util;\r
 \r
-import java.net.URI;\r
 import java.util.Collections;\r
-import java.util.Date;\r
 import java.util.List;\r
 \r
 import org.opendaylight.controller.yang.common.QName;\r
@@ -23,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition
  *\r
  * @see IdentityrefTypeDefinition\r
  */\r
-public class IdentityrefType implements IdentityrefTypeDefinition {\r
+public final class IdentityrefType implements IdentityrefTypeDefinition {\r
 \r
     private final QName name = BaseTypes.constructQName("identityref");\r
     private final SchemaPath path;\r
@@ -47,13 +45,6 @@ public class IdentityrefType implements IdentityrefTypeDefinition {
         this.baseType = new IdentityrefType(identity);\r
     }\r
 \r
-    public IdentityrefType(final List<String> actualPath,\r
-            final URI namespace, final Date revision, final QName identity) {\r
-        this.identity = identity;\r
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);\r
-        this.baseType = new IdentityrefType(identity);\r
-    }\r
-\r
     @Override\r
     public String getUnits() {\r
         return units;\r
index e39b1fa02646feec0263417e1e39e54ac4d5585c..4c17fa6154248fb711c7bd844feb60e65cfd4ba3 100644 (file)
@@ -7,9 +7,7 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -24,7 +22,7 @@ import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDef
  *
  * @see InstanceIdentifierTypeDefinition
  */
-public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
+public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
 
     private static final QName name = BaseTypes
             .constructQName("instance-identifier");
@@ -46,10 +44,9 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
         this.baseType = this;
     }
 
-    public InstanceIdentifier(final List<String> actualPath, final URI namespace,
-            final Date revision, RevisionAwareXPath xpath, boolean requireInstance) {
+    public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         this.requireInstance = requireInstance;
         this.baseType = new InstanceIdentifier(xpath, requireInstance);
index 0e100dc79077d846d2f0ae83ce3dd4768cefdcec..0a24bf2d059166a65345775cbd34734e83813005 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
@@ -22,12 +21,11 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  * @see AbstractSignedInteger
  */
-public class Int16 extends AbstractSignedInteger {
+public final class Int16 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int16");
     private Short defaultValue = null;
-    private static final String description =
-            "int16  represents integer values between -32768 and 32767, inclusively.";
+    private static final String description = "int16  represents integer values between -32768 and 32767, inclusively.";
     private final IntegerTypeDefinition baseType;
 
     private Int16() {
@@ -35,17 +33,16 @@ public class Int16 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int16(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Int16(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Int16();
 
     }
 
-    public Int16(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final Short defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Int16(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final Short defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.defaultValue = defaultValue;
         this.baseType = new Int16();
     }
index fb777c5992399aed543986684f2e94acd0531cd6..8d16e268c35c610750d6e129cbcc1d1ad6882e13 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
@@ -24,12 +23,11 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * @see AbstractSignedInteger
  *
  */
-public class Int32 extends AbstractSignedInteger {
+public final class Int32 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int32");
     private Integer defaultValue = null;
-    private static final String description =
-            "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
+    private static final String description = "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
     private final IntegerTypeDefinition baseType;
 
     private Int32() {
@@ -37,23 +35,21 @@ public class Int32 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int32(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int32(final SchemaPath path) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int32();
     }
 
-    public Int32(final List<String> actualPath, final URI namespace,
-            final Date revision, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int32(final SchemaPath path, final Integer defaultValue) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int32();
         this.defaultValue = defaultValue;
     }
 
-    public Int32(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Int32(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final Integer defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Int32();
         this.defaultValue = defaultValue;
     }
index b22412012b0e8d54c8bbe3819dd09ba1678f255d..92e92a94a276b8ee22b8c51932db82c5b40d4ea8 100644 (file)
@@ -7,11 +7,10 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
@@ -22,7 +21,7 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * {@link Long}.
  *
  */
-public class Int64 extends AbstractSignedInteger {
+public final class Int64 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int64");
     private Long defaultValue = null;
@@ -35,23 +34,20 @@ public class Int64 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int64(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int64(final SchemaPath path) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int64();
     }
 
-    public Int64(final List<String> actualPath, final URI namespace,
-            final Date revision, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+    public Int64(final SchemaPath path, final Long defaultValue) {
+        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
         this.baseType = new Int64();
         this.defaultValue = defaultValue;
     }
 
-    public Int64(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
+    public Int64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Int64();
         this.defaultValue = defaultValue;
     }
index 8b0fbe1fa7148197807db9ebbfc2e6b1b997091f..f77eebad5223cdc32476ccafa219c873e6d9329d 100644 (file)
@@ -1,34 +1,31 @@
 /*
 * 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
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
- * Implementation of Yang int8 built-in type.
- * <br>
- * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of
- * Yang int8 built-in type is {@link Byte}.
+ * Implementation of Yang int8 built-in type. <br>
+ * int8 represents integer values between -128 and 127, inclusively. The Java
+ * counterpart of Yang int8 built-in type is {@link Byte}.
  *
  * @see AbstractSignedInteger
  */
-public class Int8 extends AbstractSignedInteger {
+public final class Int8 extends AbstractSignedInteger {
 
     private static final QName name = BaseTypes.constructQName("int8");
     private Byte defaultValue = null;
-    private static final String description =
-            "represents integer values between -128 and 127, inclusively.";
+    private static final String description = "represents integer values between -128 and 127, inclusively.";
     private final IntegerTypeDefinition baseType;
 
     private Int8() {
@@ -36,23 +33,21 @@ public class Int8 extends AbstractSignedInteger {
         this.baseType = this;
     }
 
-    public Int8(final List<String> actualPath, final URI namespace,
-            final Date revision) {
-        super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
+    public Int8(final SchemaPath path) {
+        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
         this.baseType = new Int8();
     }
 
-    public Int8(final List<String> actualPath, final URI namespace,
-            final Date revision, final Byte defaultValue) {
-        super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
+    public Int8(final SchemaPath path, final Byte defaultValue) {
+        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
         this.baseType = new Int8();
         this.defaultValue = defaultValue;
     }
 
-    public Int8(final List<String> actualPath, final URI namespace,
-            final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final Byte defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Int8(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final Byte defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Int8();
         this.defaultValue = defaultValue;
     }
@@ -60,7 +55,8 @@ public class Int8 extends AbstractSignedInteger {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public IntegerTypeDefinition getBaseType() {
@@ -70,7 +66,9 @@ public class Int8 extends AbstractSignedInteger {
     /*
      * (non-Javadoc)
      *
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
index a143f5a629a90c8440b0bd850e927963bb19dbf9..d17843af898b44adb1d6a5b2c9d140e446e2675b 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -25,7 +23,7 @@ import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
  *
  * @see LeafrefTypeDefinition
  */
-public class Leafref implements LeafrefTypeDefinition {
+public final class Leafref implements LeafrefTypeDefinition {
     private static final QName name = BaseTypes.constructQName("leafref");
     private static final String description = "The leafref type is used to reference a "
             + "particular leaf instance in the data tree.";
@@ -41,23 +39,13 @@ public class Leafref implements LeafrefTypeDefinition {
         this.baseType = this;
     }
 
-    public Leafref(final List<String> actualPath, final URI namespace,
-            final Date revision, final RevisionAwareXPath xpath) {
+    public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.xpath = xpath;
         baseType = new Leafref(xpath);
     }
 
-    public Leafref(final List<String> actualPath, final URI namespace,
-            final Date revision, final LeafrefTypeDefinition baseType,
-            final RevisionAwareXPath xpath) {
-        super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
-        this.xpath = xpath;
-        this.baseType = baseType;
-    }
-
     /*
      * (non-Javadoc)
      *
index 39865a9ddf4e00eb3a9977687dfdfaa6411a7484..2d6a78988752de136af601dd70ab40713cfa9a9e 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang.model.api.SchemaNode;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
 
 public final class SchemaContextUtil {
 
@@ -32,7 +33,7 @@ public final class SchemaContextUtil {
     public static DataSchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
         if (schemaPath != null) {
             final Module module = resolveModuleFromSchemaPath(context, schemaPath);
-            final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath()); 
+            final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath());
 
             if ((module != null) && (prefixedPath != null)) {
                 return findSchemaNodeForGivenPath(context, module, prefixedPath);
@@ -54,7 +55,7 @@ public final class SchemaContextUtil {
                     final Queue<QName> qnamedPath = xpathToQNamePath(context, module,
                             strXPath);
                     if (qnamedPath != null) {
-                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
                                 module, qnamedPath);
                         return dataNode;
                     }
@@ -64,7 +65,7 @@ public final class SchemaContextUtil {
         return null;
     }
 
-    public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, 
+    public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context,
             final Module module, final SchemaNode actualSchemaNode,
             final RevisionAwareXPath relativeXPath) {
         if ((actualSchemaNode != null) && (relativeXPath != null)
@@ -72,11 +73,11 @@ public final class SchemaContextUtil {
 
             final SchemaPath actualNodePath = actualSchemaNode.getPath();
             if (actualNodePath != null) {
-                final Queue<QName> qnamePath = resolveRelativeXPath(context, module, 
+                final Queue<QName> qnamePath = resolveRelativeXPath(context, module,
                         relativeXPath, actualNodePath);
 
                 if (qnamePath != null) {
-                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
                             module, qnamePath);
                     return dataNode;
                 }
@@ -88,7 +89,8 @@ public final class SchemaContextUtil {
 
     public static Module resolveModuleFromSchemaPath(final SchemaContext context, final SchemaPath schemaPath) {
         if ((schemaPath != null) && (schemaPath.getPath() != null)) {
-            final QName qname = schemaPath.getPath().get(0);
+            List<QName> path = schemaPath.getPath();
+            final QName qname = path.get(path.size()-1);
 
             if ((qname != null) && (qname.getNamespace() != null)) {
                 return context.findModuleByNamespace(qname.getNamespace());
@@ -97,6 +99,30 @@ public final class SchemaContextUtil {
         return null;
     }
 
+    public static Module resolveModuleFromTypePath(final SchemaContext context, final TypeDefinition<?> type) {
+        final SchemaPath schemaPath = type.getPath();
+        if ((schemaPath != null) && (schemaPath.getPath() != null)) {
+            if(type instanceof ExtendedType) {
+                List<QName> path = schemaPath.getPath();
+                final QName qname = path.get(path.size()-1);
+
+                if ((qname != null) && (qname.getNamespace() != null)) {
+                    return context.findModuleByNamespace(qname.getNamespace());
+                }
+            } else {
+                LinkedList<QName> path = new LinkedList<QName>(schemaPath.getPath());
+                path.removeLast();
+                final QName qname = path.get(path.size()-1);
+
+                if ((qname != null) && (qname.getNamespace() != null)) {
+                    return context.findModuleByNamespace(qname.getNamespace());
+                }
+            }
+
+        }
+        return null;
+    }
+
     public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
         if (context == null) {
             throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
@@ -133,7 +159,7 @@ public final class SchemaContextUtil {
                 childNodeQName = qnamedPath.peek();
                 if (childNodeQName != null) {
                     final URI childNodeNamespace = childNodeQName.getNamespace();
-                    
+
                     schemaNode = nextNode.getDataChildByName(childNodeQName);
                     if (schemaNode != null) {
                         if (schemaNode instanceof ContainerSchemaNode) {
@@ -229,7 +255,7 @@ public final class SchemaContextUtil {
                     }
                     final List<QName> path = leafrefSchemaPath.getPath();
                     if (path != null) {
-                        int lenght = path.size() - colCount;
+                        int lenght = path.size() - colCount - 1;
                         for (int i = 0; i < lenght; ++i) {
                             absolutePath.add(path.get(i));
                         }
index b4e2d6b9ad867dd3e4c3fac226be78c0fdd7a774..018ba00042d7ec27e9ee9c182c74ea56effdb98b 100644 (file)
@@ -7,10 +7,8 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -26,9 +24,9 @@ import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
  *
  * @see StringTypeDefinition
  */
-public class StringType implements StringTypeDefinition {
+public final class StringType implements StringTypeDefinition {
 
-    private final QName name = BaseTypes.constructQName("string");;
+    private final QName name = BaseTypes.constructQName("string");
     private final SchemaPath path;
     private String defaultValue = "";
     private final String description = "";
@@ -51,10 +49,9 @@ public class StringType implements StringTypeDefinition {
     /**
      * Default Constructor.
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
+    public StringType(final SchemaPath path) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
         lengthStatements = Collections.unmodifiableList(constraints);
@@ -70,11 +67,10 @@ public class StringType implements StringTypeDefinition {
      * @param lengthStatements
      * @param patterns
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<LengthConstraint> lengthStatements,
+    public StringType(final SchemaPath path, final List<LengthConstraint> lengthStatements,
             final List<PatternConstraint> patterns) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         if(lengthStatements == null || lengthStatements.size() == 0) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
             constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
@@ -94,12 +90,11 @@ public class StringType implements StringTypeDefinition {
      * @param patterns
      * @param units
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision, final String defaultValue,
+    public StringType(final SchemaPath path, final String defaultValue,
             final List<LengthConstraint> lengthStatements,
             final List<PatternConstraint> patterns, final String units) {
         super();
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.defaultValue = defaultValue;
         if(lengthStatements == null || lengthStatements.size() == 0) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
index 5764cb26c7bd0d616ac0ce9575d3fa9f752189c0..95b438b509f8258c722aa403ee64a8ac08985411 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -21,7 +20,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * counterpart of Yang uint32 built-in type is {@link Integer}.
  *
  */
-public class Uint16 extends AbstractUnsignedInteger {
+public final class Uint16 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint16");
     private Integer defaultValue = null;
@@ -33,23 +32,20 @@ public class Uint16 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint16(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint16(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint16();
     }
 
-    public Uint16(final List<String> actualPath,
-            final URI namespace, final Date revision, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint16(final SchemaPath path, final Integer defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint16();
         this.defaultValue = defaultValue;
     }
 
-    public Uint16(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+    public Uint16(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Integer defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint16();
         this.defaultValue = defaultValue;
     }
index 47af1e1c986d4ad10680833690be31b645c9e06c..e530e02bbb79357518ccf67fe5fd968da500ac47 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -21,7 +20,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * Java counterpart of Yang uint32 built-in type is {@link Long}.
  *
  */
-public class Uint32 extends AbstractUnsignedInteger {
+public final class Uint32 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint32");
     private Long defaultValue = null;
@@ -33,23 +32,20 @@ public class Uint32 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint32(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint32(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint32();
     }
 
-    public Uint32(final List<String> actualPath,
-            final URI namespace, final Date revision, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint32(final SchemaPath path, final Long defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint32();
         this.defaultValue = defaultValue;
     }
 
-    public Uint32(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+    public Uint32(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Long defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint32();
         this.defaultValue = defaultValue;
     }
index f9c2aa3c90a15f41acb9700bae152aa953a237a9..a4aabb56c659bc939431fa8a581c83b091d7a63a 100644 (file)
@@ -8,11 +8,10 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigInteger;
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -23,13 +22,12 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  * {@link BigInteger}.
  *
  */
-public class Uint64 extends AbstractUnsignedInteger {
+public final class Uint64 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint64");
 
     private BigInteger defaultValue = null;
-    private static final String description =
-            "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
+    private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
     private Uint64() {
@@ -37,23 +35,21 @@ public class Uint64 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint64(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint64(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint64();
     }
 
-    public Uint64(final List<String> actualPath,
-            final URI namespace, final Date revision, final BigInteger defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint64(final SchemaPath path, final BigInteger defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint64();
         this.defaultValue = defaultValue;
     }
 
-    public Uint64(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
-            final String units, final BigInteger defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+    public Uint64(final SchemaPath path,
+            final List<RangeConstraint> rangeStatements, final String units,
+            final BigInteger defaultValue) {
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint64();
         this.defaultValue = defaultValue;
     }
index ece0eb5c3f37dba7d132160e47ecd9130e253c62..c369e037763c7ec821cac453dfe9a413d70d1901 100644 (file)
@@ -7,11 +7,10 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
@@ -23,7 +22,7 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  * @see AbstractUnsignedInteger
  */
-public class Uint8 extends AbstractUnsignedInteger {
+public final class Uint8 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint8");
     private Short defaultValue = null;
@@ -36,23 +35,20 @@ public class Uint8 extends AbstractUnsignedInteger {
         this.baseType = this;
     }
 
-    public Uint8(final List<String> actualPath,
-            final URI namespace, final Date revision) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint8(final SchemaPath path) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint8();
     }
 
-    public Uint8(final List<String> actualPath,
-            final URI namespace, final Date revision, final Short defaultValue) {
-        super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    public Uint8(final SchemaPath path, final Short defaultValue) {
+        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
         this.baseType = new Uint8();
         this.defaultValue = defaultValue;
     }
 
-    public Uint8(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+    public Uint8(final SchemaPath path, final List<RangeConstraint> rangeStatements,
             final String units, final Short defaultValue) {
-        super(actualPath, namespace, revision, name, description, rangeStatements, units);
+        super(path, name, description, rangeStatements, units);
         this.baseType = new Uint8();
         this.defaultValue = defaultValue;
     }
index 1063f3b22b6bfe4720af2539803f6296875c9c72..f68cb191dc0cab382f88a5df791b46edae6153e6 100644 (file)
@@ -1,15 +1,13 @@
 /*
 * 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
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -19,7 +17,7 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
 
-public class UnionType implements UnionTypeDefinition {
+public final class UnionType implements UnionTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("union");
     private final SchemaPath path;
@@ -29,20 +27,21 @@ public class UnionType implements UnionTypeDefinition {
     private final List<TypeDefinition<?>> types;
 
     private UnionType(List<TypeDefinition<?>> types) {
-        if(types == null) {
-            throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+        if (types == null) {
+            throw new NullPointerException(
+                    "When the type is 'union', the 'type' statement MUST be present.");
         }
         path = BaseTypes.schemaPath(name);
         this.types = types;
         this.baseType = this;
     }
 
-    public UnionType(final List<String> actualPath, final URI namespace,
-            final Date revision, List<TypeDefinition<?>> types) {
-        if(types == null) {
-            throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+    public UnionType(final SchemaPath path, List<TypeDefinition<?>> types) {
+        if (types == null) {
+            throw new NullPointerException(
+                    "When the type is 'union', the 'type' statement MUST be present.");
         }
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.types = types;
         this.baseType = new UnionType(types);
     }
@@ -135,8 +134,8 @@ public class UnionType implements UnionTypeDefinition {
         builder.append("UnionType [name=");
         builder.append(name);
         builder.append(", types=[");
-        for(TypeDefinition<?> td : types) {
-            builder.append(", "+ td.getQName().getLocalName());
+        for (TypeDefinition<?> td : types) {
+            builder.append(", " + td.getQName().getLocalName());
         }
         builder.append("]");
         builder.append("]");
index e4d176c12b1e62d45e4eb94e6ffe87e332c005a8..82849891f9b42b64c9043237598986b007d78403 100644 (file)
@@ -8,14 +8,17 @@
 package org.opendaylight.controller.yang.model.util;\r
 \r
 import java.net.URI;\r
+import java.util.ArrayList;\r
 import java.util.Date;\r
 import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Set;\r
 \r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
 \r
-public class YangTypesConverter {\r
+public final class YangTypesConverter {\r
     private static final Set<String> baseYangTypes = new HashSet<String>();\r
 \r
     static {\r
@@ -49,39 +52,48 @@ public class YangTypesConverter {
             String typeName) {\r
         TypeDefinition<?> type = null;\r
 \r
+        SchemaPath path = createSchemaPath(actualPath, namespace, revision);\r
         if (typeName.startsWith("int")) {\r
             if (typeName.equals("int8")) {\r
-                type = new Int8(actualPath, namespace, revision);\r
+                type = new Int8(path);\r
             } else if (typeName.equals("int16")) {\r
-                type = new Int16(actualPath, namespace, revision);\r
+                type = new Int16(path);\r
             } else if (typeName.equals("int32")) {\r
-                type = new Int32(actualPath, namespace, revision);\r
+                type = new Int32(path);\r
             } else if (typeName.equals("int64")) {\r
-                type = new Int64(actualPath, namespace, revision);\r
+                type = new Int64(path);\r
             }\r
         } else if (typeName.startsWith("uint")) {\r
             if (typeName.equals("uint8")) {\r
-                type = new Uint8(actualPath, namespace, revision);\r
+                type = new Uint8(path);\r
             } else if (typeName.equals("uint16")) {\r
-                type = new Uint16(actualPath, namespace, revision);\r
+                type = new Uint16(path);\r
             } else if (typeName.equals("uint32")) {\r
-                type = new Uint32(actualPath, namespace, revision);\r
+                type = new Uint32(path);\r
             } else if (typeName.equals("uint64")) {\r
-                type = new Uint64(actualPath, namespace, revision);\r
+                type = new Uint64(path);\r
             }\r
         } else if ("string".equals(typeName)) {\r
-            type = new StringType(actualPath, namespace, revision);\r
+            type = new StringType(path);\r
         } else if("binary".equals(typeName)) {\r
-            type = new BinaryType(actualPath, namespace, revision);\r
+            type = new BinaryType(path);\r
         } else if("boolean".equals(typeName)) {\r
-            type = new BooleanType(actualPath, namespace, revision);\r
+            type = new BooleanType(path);\r
         } else if("empty".equals(typeName)) {\r
-            type = new EmptyType(actualPath, namespace, revision);\r
+            type = new EmptyType(path);\r
         } else if("instance-identifier".equals(typeName)) {\r
-            type = new InstanceIdentifier(actualPath, namespace, revision, null, true);\r
+            type = new InstanceIdentifier(path, null, true);\r
         }\r
 \r
         return type;\r
     }\r
 \r
+    private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision) {\r
+        List<QName> path = new ArrayList<QName>();\r
+        for(String element : actualPath) {\r
+            path.add(new QName(namespace, revision, element));\r
+        }\r
+        return new SchemaPath(path, true);\r
+    }\r
+\r
 }\r
index db7489d47073c8e0a3423819aeab84cb8ef8a490..98977f6e91d15b6eee512d941365133cdb387697 100644 (file)
@@ -15,9 +15,11 @@ import java.util.Map;
 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 
 /**
  * Interface which defines the available methods for retrieving
@@ -79,4 +81,20 @@ public interface IStatisticsManager {
      * @return
      */
     List<NodeConnectorStatistics> getNodeConnectorStatistics(Node node);
+
+    /**
+     * Returns the statistics for the specified table of the node
+     *
+     * @param nodeTable
+     * @return
+     */
+    NodeTableStatistics getNodeTableStatistics(NodeTable nodeTable);
+
+    /**
+     * Returns the statistics for all the tables of the node
+     *
+     * @param nodeTable
+     * @return
+     */
+    List <NodeTableStatistics> getNodeTableStatistics(Node node);
 }
index f5f56fc70f887f3002c9f84a888d61a4e75476bc..9aef40c4134424a5cc955557c585e301dd279c68 100644 (file)
@@ -17,11 +17,13 @@ import java.util.Map;
 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeTable;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 import org.opendaylight.controller.sal.reader.IReadService;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 import org.opendaylight.controller.sal.reader.NodeDescription;
+import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -130,4 +132,14 @@ public class StatisticsManager implements IStatisticsManager {
     public List<NodeConnectorStatistics> getNodeConnectorStatistics(Node node) {
         return reader.readNodeConnectors(node);
     }
+
+    @Override
+    public NodeTableStatistics getNodeTableStatistics(NodeTable nodeTable) {
+        return reader.readNodeTable(nodeTable);
+    }
+
+    @Override
+    public List<NodeTableStatistics> getNodeTableStatistics(Node node){
+        return reader.readNodeTable(node);
+    }
 }
index 6ba78deaded8b817ee4fc382dc8560f1d3a74d10..eae01a6487cd5351783eb0e24292a3e947a9da7d 100644 (file)
@@ -28,7 +28,7 @@ public class Switch implements Serializable {
     private static final long serialVersionUID = 1L;
     private byte[] dataLayerAddress;
     private Set<NodeConnector> nodeConnectors;
-    private List<NodeConnector> spanPorts;
+    private final List<NodeConnector> spanPorts;
     private Node node;
 
     /*
@@ -44,7 +44,7 @@ public class Switch implements Serializable {
         this.node = node;
         this.nodeConnectors = new HashSet<NodeConnector>();
         this.spanPorts = new ArrayList<NodeConnector>(2);
-        this.dataLayerAddress = deriveMacAddress();
+        this.dataLayerAddress = null;
     }
 
     /**
@@ -98,18 +98,6 @@ public class Switch implements Serializable {
         this.node = node;
     }
 
-    private byte[] deriveMacAddress() {
-        long dpid = (Long) this.node.getID();
-        byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-        for (short i = 0; i < 6; i++) {
-            mac[5 - i] = (byte) dpid;
-            dpid >>= 8;
-        }
-
-        return mac;
-    }
-
     public void addSpanPorts(List<NodeConnector> portList) {
         for (NodeConnector port : portList) {
             spanPorts.add(port);
@@ -137,30 +125,40 @@ public class Switch implements Serializable {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         Switch other = (Switch) obj;
-        if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress))
+        if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress)) {
             return false;
+        }
         if (node == null) {
-            if (other.node != null)
+            if (other.node != null) {
                 return false;
-        } else if (!node.equals(other.node))
+            }
+        } else if (!node.equals(other.node)) {
             return false;
+        }
         if (nodeConnectors == null) {
-            if (other.nodeConnectors != null)
+            if (other.nodeConnectors != null) {
                 return false;
-        } else if (!nodeConnectors.equals(other.nodeConnectors))
+            }
+        } else if (!nodeConnectors.equals(other.nodeConnectors)) {
             return false;
+        }
         if (spanPorts == null) {
-            if (other.spanPorts != null)
+            if (other.spanPorts != null) {
                 return false;
-        } else if (!spanPorts.equals(other.spanPorts))
+            }
+        } else if (!spanPorts.equals(other.spanPorts)) {
             return false;
+        }
         return true;
     }
 
index 4ef841643691bdb145c377c85199fa1635f49d29..2937fe7e14710c3655cf99e954bcc6cd4aefa05c 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.sal.core.Bandwidth;
 import org.opendaylight.controller.sal.core.Config;
 import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.MacAddress;
 import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -51,10 +52,10 @@ import org.opendaylight.controller.sal.core.Tier;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.inventory.IInventoryService;
 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
+import org.opendaylight.controller.sal.utils.HexEncode;
 import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.IObjectReader;
-import org.opendaylight.controller.sal.utils.NodeCreator;
 import org.opendaylight.controller.sal.utils.ObjectReader;
 import org.opendaylight.controller.sal.utils.ObjectWriter;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
@@ -82,16 +83,16 @@ import org.slf4j.LoggerFactory;
  * are maintained in the default container only.
  */
 public class SwitchManagerImpl implements ISwitchManager,
-        IConfigurationContainerAware, IObjectReader,
-        ICacheUpdateAware<Long, String>, IListenInventoryUpdates,
-        CommandProvider {
+IConfigurationContainerAware, IObjectReader,
+ICacheUpdateAware<Long, String>, IListenInventoryUpdates,
+CommandProvider {
     private static Logger log = LoggerFactory
             .getLogger(SwitchManagerImpl.class);
     private static String ROOT = GlobalConstants.STARTUPHOME.toString();
     private static final String SAVE = "Save";
     private String subnetFileName = null, spanFileName = null,
             switchConfigFileName = null;
-    private List<NodeConnector> spanNodeConnectors = new CopyOnWriteArrayList<NodeConnector>();
+    private final List<NodeConnector> spanNodeConnectors = new CopyOnWriteArrayList<NodeConnector>();
     private ConcurrentMap<InetAddress, Subnet> subnets; // set of Subnets keyed by the InetAddress
     private ConcurrentMap<String, SubnetConfig> subnetsConfigList;
     private ConcurrentMap<Integer, SpanConfig> spanConfigList;
@@ -101,11 +102,11 @@ public class SwitchManagerImpl implements ISwitchManager,
     private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps; // properties are maintained in global container only
     private ConcurrentMap<Node, Map<String, NodeConnector>> nodeConnectorNames;
     private IInventoryService inventoryService;
-    private Set<ISwitchManagerAware> switchManagerAware = Collections
+    private final Set<ISwitchManagerAware> switchManagerAware = Collections
             .synchronizedSet(new HashSet<ISwitchManagerAware>());
-    private Set<IInventoryListener> inventoryListeners = Collections
+    private final Set<IInventoryListener> inventoryListeners = Collections
             .synchronizedSet(new HashSet<IInventoryListener>());
-    private Set<ISpanAware> spanAware = Collections
+    private final Set<ISpanAware> spanAware = Collections
             .synchronizedSet(new HashSet<ISpanAware>());
     private byte[] MAC;
     private static boolean hostRefresh = true;
@@ -117,14 +118,15 @@ public class SwitchManagerImpl implements ISwitchManager,
     public enum ReasonCode {
         SUCCESS("Success"), FAILURE("Failure"), INVALID_CONF(
                 "Invalid Configuration"), EXIST("Entry Already Exist"), CONFLICT(
-                "Configuration Conflict with Existing Entry");
+                        "Configuration Conflict with Existing Entry");
 
-        private String name;
+        private final String name;
 
         private ReasonCode(String name) {
             this.name = name;
         }
 
+        @Override
         public String toString() {
             return name;
         }
@@ -185,12 +187,15 @@ public class SwitchManagerImpl implements ISwitchManager,
          * Read startup and build database if we have not already gotten the
          * configurations synced from another node
          */
-        if (subnetsConfigList.isEmpty())
+        if (subnetsConfigList.isEmpty()) {
             loadSubnetConfiguration();
-        if (spanConfigList.isEmpty())
+        }
+        if (spanConfigList.isEmpty()) {
             loadSpanConfiguration();
-        if (nodeConfigList.isEmpty())
+        }
+        if (nodeConfigList.isEmpty()) {
             loadSwitchConfiguration();
+        }
 
         MAC = getHardwareMAC();
     }
@@ -315,12 +320,13 @@ public class SwitchManagerImpl implements ISwitchManager,
         clusterContainerService.destroyCache("switchmanager.configSaveEvent");
         clusterContainerService.destroyCache("switchmanager.nodeProps");
         clusterContainerService
-                .destroyCache("switchmanager.nodeConnectorProps");
+        .destroyCache("switchmanager.nodeConnectorProps");
         clusterContainerService
-                .destroyCache("switchmanager.nodeConnectorNames");
+        .destroyCache("switchmanager.nodeConnectorNames");
         nonClusterObjectCreate();
     }
 
+    @Override
     public List<SubnetConfig> getSubnetsConfigList() {
         return new ArrayList<SubnetConfig>(subnetsConfigList.values());
     }
@@ -345,6 +351,7 @@ public class SwitchManagerImpl implements ISwitchManager,
         return new ArrayList<SwitchConfig>(nodeConfigList.values());
     }
 
+    @Override
     public SwitchConfig getSwitchConfig(String switchId) {
         return nodeConfigList.get(switchId);
     }
@@ -352,7 +359,11 @@ public class SwitchManagerImpl implements ISwitchManager,
     public Switch getSwitchByNode(Node node) {
         Switch sw = new Switch(node);
         sw.setNode(node);
-
+        MacAddress mac = (MacAddress) this.getNodeProp(node,
+                MacAddress.name);
+        if (mac != null) {
+            sw.setDataLayerAddress(mac.getMacAddress());
+        }
         Set<NodeConnector> ncSet = getPhysicalNodeConnectors(node);
         sw.setNodeConnectors(ncSet);
 
@@ -367,6 +378,7 @@ public class SwitchManagerImpl implements ISwitchManager,
         return sw;
     }
 
+    @Override
     public List<Switch> getNetworkDevices() {
         Set<Node> nodeSet = getNodes();
         List<Switch> swList = new ArrayList<Switch>();
@@ -401,8 +413,9 @@ public class SwitchManagerImpl implements ISwitchManager,
             }
             subnets.put(conf.getIPnum(), subnet);
         } else { // This is the deletion of the whole subnet
-            if (subnet == null)
+            if (subnet == null) {
                 return;
+            }
             subnets.remove(conf.getIPnum());
         }
     }
@@ -455,6 +468,7 @@ public class SwitchManagerImpl implements ISwitchManager,
     /**
      * Adds Subnet configured in GUI or API3
      */
+    @Override
     public Status addSubnet(SubnetConfig conf) {
         return this.addRemoveSubnet(conf, true);
     }
@@ -869,26 +883,11 @@ public class SwitchManagerImpl implements ISwitchManager,
                 : null;
     }
 
-    /*
-     * test utility function which assumes all nodes are OF nodes
-     */
-    private Node getNode(Long id) {
-        Set<Node> nodes = getNodes();
-        if (nodes != null) {
-            for (Node node : nodes) {
-                if (id.equals((Long) node.getID())) {
-                    return node;
-                }
-            }
-        }
-        return null;
-    }
-
     /*
      * Returns a copy of a list of properties for a given node
-     * 
+     *
      * (non-Javadoc)
-     * 
+     *
      * @see
      * org.opendaylight.controller.switchmanager.ISwitchManager#getNodeProps
      * (org.opendaylight.controller.sal.core.Node)
@@ -924,8 +923,9 @@ public class SwitchManagerImpl implements ISwitchManager,
     public void setNodeProp(Node node, Property prop) {
         /* Get a copy of the property map */
         Map<String, Property> propMap = getNodeProps(node);
-        if (propMap == null)
+        if (propMap == null) {
             return;
+        }
 
         propMap.put(prop.getName(), prop);
         this.nodeProps.put(node, propMap);
@@ -949,16 +949,18 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     @Override
     public Set<NodeConnector> getUpNodeConnectors(Node node) {
-        if (nodeConnectorProps == null)
+        if (nodeConnectorProps == null) {
             return null;
+        }
 
         Set<NodeConnector> nodeConnectorSet = new HashSet<NodeConnector>();
         for (NodeConnector nodeConnector : nodeConnectorProps.keySet()) {
-            if (((Long) nodeConnector.getNode().getID()).longValue() != (Long) node
-                    .getID())
+            if (!nodeConnector.getNode().equals(node)) {
                 continue;
-            if (isNodeConnectorEnabled(nodeConnector))
+            }
+            if (isNodeConnectorEnabled(nodeConnector)) {
                 nodeConnectorSet.add(nodeConnector);
+            }
         }
 
         return nodeConnectorSet;
@@ -966,14 +968,15 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     @Override
     public Set<NodeConnector> getNodeConnectors(Node node) {
-        if (nodeConnectorProps == null)
+        if (nodeConnectorProps == null) {
             return null;
+        }
 
         Set<NodeConnector> nodeConnectorSet = new HashSet<NodeConnector>();
         for (NodeConnector nodeConnector : nodeConnectorProps.keySet()) {
-            if (((Long) nodeConnector.getNode().getID()).longValue() != (Long) node
-                    .getID())
+            if (!nodeConnector.getNode().equals(node)) {
                 continue;
+            }
             nodeConnectorSet.add(nodeConnector);
         }
 
@@ -982,8 +985,9 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     @Override
     public Set<NodeConnector> getPhysicalNodeConnectors(Node node) {
-        if (nodeConnectorProps == null)
+        if (nodeConnectorProps == null) {
             return null;
+        }
 
         Set<NodeConnector> nodeConnectorSet = new HashSet<NodeConnector>();
         for (NodeConnector nodeConnector : nodeConnectorProps.keySet()) {
@@ -997,24 +1001,6 @@ public class SwitchManagerImpl implements ISwitchManager,
         return nodeConnectorSet;
     }
 
-    /*
-     * testing utility function which assumes we are dealing with OF Node
-     * nodeconnectors only
-     */
-    @SuppressWarnings("unused")
-    private Set<Long> getEnabledNodeConnectorIds(Node node) {
-        Set<Long> ids = new HashSet<Long>();
-        Set<NodeConnector> nodeConnectors = getUpNodeConnectors(node);
-
-        if (nodeConnectors != null) {
-            for (NodeConnector nodeConnector : nodeConnectors) {
-                ids.add((Long) nodeConnector.getID());
-            }
-        }
-
-        return ids;
-    }
-
     @Override
     public Map<String, Property> getNodeConnectorProps(
             NodeConnector nodeConnector) {
@@ -1083,19 +1069,21 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     @Override
     public NodeConnector getNodeConnector(Node node, String nodeConnectorName) {
-        if (nodeConnectorNames == null)
+        if (nodeConnectorNames == null) {
             return null;
+        }
 
         Map<String, NodeConnector> map = nodeConnectorNames.get(node);
-        if (map == null)
+        if (map == null) {
             return null;
+        }
 
         return map.get(nodeConnectorName);
     }
 
     /**
      * Adds a node connector and its property if any
-     * 
+     *
      * @param nodeConnector
      *            {@link org.opendaylight.controller.sal.core.NodeConnector}
      * @param propName
@@ -1139,7 +1127,7 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     /**
      * Removes one property of a node connector
-     * 
+     *
      * @param nodeConnector
      *            {@link org.opendaylight.controller.sal.core.NodeConnector}
      * @param propName
@@ -1177,7 +1165,7 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     /**
      * Removes all the properties of a node connector
-     * 
+     *
      * @param nodeConnector
      *            {@link org.opendaylight.controller.sal.core.NodeConnector}
      * @return success or failed reason
@@ -1204,7 +1192,7 @@ public class SwitchManagerImpl implements ISwitchManager,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init(Component c) {
         Dictionary<?, ?> props = c.getServiceProperties();
@@ -1225,7 +1213,7 @@ public class SwitchManagerImpl implements ISwitchManager,
      * 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() {
         shutDown();
@@ -1234,7 +1222,7 @@ public class SwitchManagerImpl implements ISwitchManager,
     /**
      * 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() {
         // OSGI console
@@ -1253,7 +1241,7 @@ public class SwitchManagerImpl implements ISwitchManager,
      * 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() {
     }
@@ -1427,8 +1415,9 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     @Override
     public Boolean isNodeConnectorEnabled(NodeConnector nodeConnector) {
-        if (nodeConnector == null)
+        if (nodeConnector == null) {
             return false;
+        }
 
         Config config = (Config) getNodeConnectorProp(nodeConnector,
                 Config.ConfigPropName);
@@ -1453,7 +1442,7 @@ public class SwitchManagerImpl implements ISwitchManager,
     }
 
     public void _pns(CommandInterpreter ci) {
-        ci.println("           Node                       Type             Name             Tier");
+        ci.println("           Node               Type           MAC            Name      Tier");
         if (nodeProps == null) {
             return;
         }
@@ -1466,9 +1455,12 @@ public class SwitchManagerImpl implements ISwitchManager,
                     Description.propertyName));
             Tier tier = ((Tier) getNodeProp(node, Tier.TierPropName));
             String nodeName = (desc == null) ? "" : desc.getValue();
+            MacAddress mac = (MacAddress) getNodeProp(node,
+                    MacAddress.name);
             int tierNum = (tier == null) ? 0 : tier.getValue();
-            ci.println(node + "            " + node.getType() + "            "
-                    + nodeName + "            " + tierNum);
+            ci.println(node + "     " + node.getType() + "     "
+                    + HexEncode.bytesToHexStringFormat(mac.getMacAddress())
+                    + "     " + nodeName + "     " + tierNum  );
         }
         ci.println("Total number of Nodes: " + nodeSet.size());
     }
@@ -1620,17 +1612,19 @@ public class SwitchManagerImpl implements ISwitchManager,
             ci.println("expecting on/off/?");
             return;
         }
-        if (mode.toLowerCase().equals("on"))
+        if (mode.toLowerCase().equals("on")) {
             hostRefresh = true;
-        else if (mode.toLowerCase().equals("off"))
+        } else if (mode.toLowerCase().equals("off")) {
             hostRefresh = false;
-        else if (mode.equals("?")) {
-            if (hostRefresh)
+        else if (mode.equals("?")) {
+            if (hostRefresh) {
                 ci.println("host refresh is ON");
-            else
+            } else {
                 ci.println("host refresh is OFF");
-        } else
+            }
+        } else {
             ci.println("expecting on/off/?");
+        }
         return;
     }
 
@@ -1651,17 +1645,8 @@ public class SwitchManagerImpl implements ISwitchManager,
 
     @Override
     public byte[] getNodeMAC(Node node) {
-        if (node.getType().equals(Node.NodeIDType.OPENFLOW)) {
-            byte[] gmac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-            long dpid = (Long) node.getID();
-
-            for (short i = 0; i < 6; i++) {
-                gmac[5 - i] = (byte) dpid;
-                dpid >>= 8;
-            }
-            return gmac;
-        }
-        return null;
+        MacAddress mac = (MacAddress) nodeProps.get(MacAddress.name);
+        return (mac != null) ? mac.getMacAddress() : null;
     }
 
     @Override
@@ -1756,7 +1741,7 @@ public class SwitchManagerImpl implements ISwitchManager,
     /**
      * Creates a Name/Tier/Bandwidth Property object based on given property
      * name and value. Other property types are not supported yet.
-     * 
+     *
      * @param propName
      *            Name of the Property
      * @param propValue
index 8d869fc7f5dbadfb4b14ed9569e3386d34c21117..9bb231fb0398b1bcbf1fcaae96f606d596374676 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -29,81 +28,90 @@ import org.opendaylight.controller.switchmanager.SubnetConfig;
 
 public class SwitchManagerImplTest {
 
-       @Test
-       public void testSwitchManagerAddRemoveSubnet() {
-               SwitchManagerImpl switchmgr = new SwitchManagerImpl();
-               switchmgr.nonClusterObjectCreate();
-               
-               ArrayList<String>portList = new ArrayList<String>();
-               portList.add("1/1");
-               portList.add("1/2");
-               portList.add("1/3");
-
-               
-               SubnetConfig subnet = new SubnetConfig("subnet", "10.0.0.254/16", portList);
-               //System.out.println("*" + switchmgr.addSubnet(subnet) + "*");
-               Status addResult = (switchmgr.addSubnet(subnet));
-               Assert.assertTrue(addResult.isSuccess());
-               
-               Status removeResult = (switchmgr.removeSubnet(subnet.getName()));
-               Assert.assertTrue(removeResult.isSuccess());
-
-               SubnetConfig subnetConfigResult = switchmgr.getSubnetConfig(subnet.getName());
-               Assert.assertTrue(subnetConfigResult == null);
-               
-       }
-       
-       @Test
-       public void testSwitchManagerNodeConnectors() {
-               SwitchManagerImpl switchmgr = new SwitchManagerImpl();
-               switchmgr.nonClusterObjectCreate();
-               
-               State state;
-               Bandwidth bw;
-               Latency l;
-               
-               NodeConnector[] headnc = new NodeConnector[5];
-               NodeConnector[] tailnc = new NodeConnector[5];
-
-               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 + 1)) {
-
-                               headnc[i - 1] = NodeConnectorCreator.createOFNodeConnector(i, NodeCreator.createOFNode((long)i));
-                               tailnc[i - 1] = NodeConnectorCreator.createOFNodeConnector((short)(i+10), NodeCreator.createOFNode((long)(i+10)));
-                               switchmgr.updateNode(headnc[i - 1].getNode(), UpdateType.ADDED, props);
-                               switchmgr.updateNode(tailnc[i - 1].getNode(), UpdateType.ADDED, props);
-
-                               switchmgr.updateNodeConnector(headnc[i - 1], UpdateType.ADDED, props);
-                               switchmgr.updateNodeConnector(tailnc[i - 1], UpdateType.ADDED, props);
-               }
-               
-               for (int i = 0; i < 5; i++) {
-                       Property bwProp = switchmgr.getNodeConnectorProp(headnc[i], Bandwidth.BandwidthPropName);
-                       Assert.assertTrue(bwProp.equals(bw));
-                       Property latencyProp = switchmgr.getNodeConnectorProp(tailnc[i], Latency.LatencyPropName);
-                       Assert.assertEquals(latencyProp, l);
-                       
-                       byte[] headNodeMac = switchmgr.getNodeMAC(headnc[i].getNode());
-                       Assert.assertTrue(headNodeMac[headNodeMac.length - 1] == (byte)(i + 1));
-               }
-               
-               Set<Node> nodes = switchmgr.getNodes();
-               for (int i = 0; i < 5; i++) {
-                       if (nodes.contains(headnc[i].getNode()) == true) 
-                                       nodes.remove(headnc[i].getNode());
-                       
-                       if (nodes.contains(tailnc[i].getNode()) == true) 
-                                       nodes.remove(tailnc[i].getNode());
-                       
-               }
-               Assert.assertTrue(nodes.isEmpty());
-       }
-       
+    @Test
+    public void testSwitchManagerAddRemoveSubnet() {
+        SwitchManagerImpl switchmgr = new SwitchManagerImpl();
+        switchmgr.nonClusterObjectCreate();
+
+        ArrayList<String> portList = new ArrayList<String>();
+        portList.add("1/1");
+        portList.add("1/2");
+        portList.add("1/3");
+
+        SubnetConfig subnet = new SubnetConfig("subnet", "10.0.0.254/16",
+                portList);
+        // System.out.println("*" + switchmgr.addSubnet(subnet) + "*");
+        Status addResult = (switchmgr.addSubnet(subnet));
+        Assert.assertTrue(addResult.isSuccess());
+
+        Status removeResult = (switchmgr.removeSubnet(subnet.getName()));
+        Assert.assertTrue(removeResult.isSuccess());
+
+        SubnetConfig subnetConfigResult = switchmgr.getSubnetConfig(subnet
+                .getName());
+        Assert.assertTrue(subnetConfigResult == null);
+
+    }
+
+    @Test
+    public void testSwitchManagerNodeConnectors() {
+        SwitchManagerImpl switchmgr = new SwitchManagerImpl();
+        switchmgr.nonClusterObjectCreate();
+
+        State state;
+        Bandwidth bw;
+        Latency l;
+
+        NodeConnector[] headnc = new NodeConnector[5];
+        NodeConnector[] tailnc = new NodeConnector[5];
+
+        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 + 1)) {
+
+            headnc[i - 1] = NodeConnectorCreator.createOFNodeConnector(i,
+                    NodeCreator.createOFNode((long) i));
+            tailnc[i - 1] = NodeConnectorCreator
+                    .createOFNodeConnector((short) (i + 10),
+                            NodeCreator.createOFNode((long) (i + 10)));
+            switchmgr.updateNode(headnc[i - 1].getNode(), UpdateType.ADDED,
+                    props);
+            switchmgr.updateNode(tailnc[i - 1].getNode(), UpdateType.ADDED,
+                    props);
+
+            switchmgr.updateNodeConnector(headnc[i - 1], UpdateType.ADDED,
+                    props);
+            switchmgr.updateNodeConnector(tailnc[i - 1], UpdateType.ADDED,
+                    props);
+        }
+
+        for (int i = 0; i < 5; i++) {
+            Property bwProp = switchmgr.getNodeConnectorProp(headnc[i],
+                    Bandwidth.BandwidthPropName);
+            Assert.assertTrue(bwProp.equals(bw));
+            Property latencyProp = switchmgr.getNodeConnectorProp(tailnc[i],
+                    Latency.LatencyPropName);
+            Assert.assertEquals(latencyProp, l);
+        }
+
+        Set<Node> nodes = switchmgr.getNodes();
+        for (int i = 0; i < 5; i++) {
+            if (nodes.contains(headnc[i].getNode()) == true) {
+                nodes.remove(headnc[i].getNode());
+            }
+
+            if (nodes.contains(tailnc[i].getNode()) == true) {
+                nodes.remove(tailnc[i].getNode());
+            }
+
+        }
+        Assert.assertTrue(nodes.isEmpty());
+    }
+
 }
index bec194bf1cc67432a53320cd8fc4911af98977f2..188be8aee6f1ee4865b159d1f2225ec6f1534021 100644 (file)
@@ -36,7 +36,6 @@ import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Tier;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.controller.sal.utils.Status;
@@ -118,6 +117,7 @@ public class Devices implements IDaylightWeb {
                         .getNodeConnectors();
                 if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
                     Map<Short, String> portList = new HashMap<Short, String>();
+                    List<String> intfList = new ArrayList<String>();
                     for (NodeConnector nodeConnector : nodeConnectorSet) {
                         String nodeConnectorNumberToStr = nodeConnector.getID()
                                 .toString();
@@ -142,17 +142,29 @@ public class Devices implements IDaylightWeb {
                             }
                         }
 
-                        portList.put(
-                                Short.parseShort(nodeConnectorNumberToStr),
-                                nodeConnectorName);
+                        Class<?> idClass = nodeConnector.getID().getClass();
+                        if (idClass.equals(Short.class)) {
+                            portList.put(
+                                    Short.parseShort(nodeConnectorNumberToStr),
+                                    nodeConnectorName);
+                        } else {
+                            intfList.add(nodeConnectorName);
+                        }
                     }
 
-                    Map<Short, String> sortedPortList = new TreeMap<Short, String>(
-                            portList);
+                    if (portList.size() > 0) {
+                        Map<Short, String> sortedPortList = new TreeMap<Short, String>(
+                                portList);
 
-                    for (Entry<Short, String> e : sortedPortList.entrySet()) {
-                        sb1.append(e.getValue());
-                        sb1.append("<br>");
+                        for (Entry<Short, String> e : sortedPortList.entrySet()) {
+                            sb1.append(e.getValue());
+                            sb1.append("<br>");
+                        }
+                    } else if (intfList.size() > 0) {
+                        for (String intf : intfList) {
+                            sb1.append(intf);
+                            sb1.append("<br>");
+                        }
                     }
                 }
                 nodeDatum.put("ports", sb1.toString());
@@ -624,7 +636,7 @@ public class Devices implements IDaylightWeb {
 
     /**
      * Is the operation permitted for the given level
-     * 
+     *
      * @param level
      */
     private boolean authorize(UserLevel level, HttpServletRequest request) {
@@ -657,10 +669,10 @@ public class Devices implements IDaylightWeb {
          * IUserManager userManager = (IUserManager) ServiceHelper
          * .getGlobalInstance(IUserManager.class, this); if (userManager ==
          * null) { return "User Manager is not available"; }
-         * 
+         *
          * String username = request.getUserPrincipal().getName();
-         * 
-         * 
+         *
+         *
          * model.addAttribute("username", username); model.addAttribute("role",
          * userManager.getUserLevel(username).toNumber());
          */