Merge "Initial implementation of netconf monitoring module according to http://tools...
authorEd Warnicke <eaw@cisco.com>
Fri, 6 Dec 2013 16:08:15 +0000 (16:08 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 6 Dec 2013 16:08:15 +0000 (16:08 +0000)
54 files changed:
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.conf
opendaylight/forwardingrulesmanager/api/pom.xml
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java
opendaylight/forwardingrulesmanager/api/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java
opendaylight/forwardingrulesmanager/implementation/pom.xml
opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FlowConsumerImpl.java
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/GroupConsumerImpl.java
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/MeterConsumerImpl.java
opendaylight/md-sal/model/model-flow-base/src/main/yang/group-types.yang
opendaylight/md-sal/model/model-flow-base/src/main/yang/meter-types.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/table-service.yang
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/ClassLoaderUtils.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-dom-it/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java [moved from opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java with 100% similarity]
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java [moved from opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java with 94% similarity]
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java [moved from opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java with 100% similarity]
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java [moved from opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java with 100% similarity]
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java [moved from opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java with 100% similarity]
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java [moved from opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java with 100% similarity]
opendaylight/md-sal/sal-binding-it/pom.xml
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.xtend
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlMapper.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyRpcResult.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonChoiceCaseTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonIdentityrefTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ToJsonLeafrefType.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlProvidersTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/invoke-rpc-module.yang [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java
opendaylight/netconf/netconf-ssh/pom.xml
opendaylight/northbound/flowprogrammer/pom.xml
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TableStatisticsConverter.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Enqueue.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeTableStatistics.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/Status.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/StatusCode.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/reader/NodeTableStatisticsTest.java
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java

index 07c21261bb4d9fad5d4ecbd002119a07d2f0163b..430a278a6061b332e885df89094b3ac4271b7ac8 100644 (file)
@@ -7,12 +7,18 @@
                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
                <name>hash-map-data-store</name>
        </module>
+       <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store">prefix:dom-clustered-store-impl</type>
+        <name>cluster-data-store</name>
+    </module>
        <module>
                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
                <name>dom-broker</name>
                <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
                        <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-                       <name>ref_hash-map-data-store</name>
+            <!-- to switch to the clustered data store, comment out the ref_hash-map-data-store <name> and uncomment the ref_cluster-data-store one -->
+            <name>ref_hash-map-data-store</name>
+            <!-- <name>ref_cluster-data-store</name> -->
                </data-store>
        </module>
        <module>
                        <name>ref_hash-map-data-store</name>
                        <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
                </instance>
+               <instance>
+            <name>ref_cluster-data-store</name>
+            <provider>/config/modules/module[name='dom-clustered-store-impl']/instance[name='cluster-data-store']</provider>
+        </instance>
        </service>
        <service>
                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
@@ -124,3 +134,4 @@ urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
 urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
 urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
 urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store?module=odl-sal-dom-clustered-store-cfg&revision=2013-10-28
index f25756cc115eb9ed61c40361b9b3d4d18ce6e7d1..499b98c28ad1c04dd8512af4501b799e4a3e0124 100644 (file)
@@ -87,7 +87,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.5.1-SNAPSHOT</version>
+      <version>0.7.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
index 43b0252df7b5c8aa83df94866632887286b44252..de7597730f9062a85d7071b3986044c4874a4e7a 100644 (file)
@@ -13,7 +13,6 @@ import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -26,6 +25,7 @@ import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.ActionType;
 import org.opendaylight.controller.sal.action.Controller;
 import org.opendaylight.controller.sal.action.Drop;
+import org.opendaylight.controller.sal.action.Enqueue;
 import org.opendaylight.controller.sal.action.Flood;
 import org.opendaylight.controller.sal.action.HwPath;
 import org.opendaylight.controller.sal.action.Loopback;
@@ -609,25 +609,13 @@ public class FlowConfig implements Serializable {
         return true;
     }
 
-    public boolean isPortValid(Switch sw, Short port) {
-        if (port < 1) {
-            log.debug("port {} is not valid", port);
-            return false;
-        }
-
+    public boolean isPortValid(Switch sw, String port) {
         if (sw == null) {
             log.debug("switch info is not available. Skip checking if port is part of a switch or not.");
             return true;
         }
-
-        Set<NodeConnector> nodeConnectorSet = sw.getNodeConnectors();
-        for (NodeConnector nodeConnector : nodeConnectorSet) {
-            if (((Short) nodeConnector.getID()).equals(port)) {
-                return true;
-            }
-        }
-        log.debug("port {} is not a valid port of node {}", port, sw.getNode());
-        return false;
+        NodeConnector nc = NodeConnectorCreator.createNodeConnector(port, sw.getNode());
+        return sw.getNodeConnectors().contains(nc);
     }
 
     public boolean isVlanIdValid(String vlanId) {
@@ -735,9 +723,8 @@ public class FlowConfig implements Serializable {
             }
 
             if (ingressPort != null) {
-                Short port = Short.decode(ingressPort);
-                if (isPortValid(sw, port) == false) {
-                    String msg = String.format("Ingress port %d is not valid for the Switch", port);
+                if (!isPortValid(sw, ingressPort)) {
+                    String msg = String.format("Ingress port %s is not valid for the Switch", ingressPort);
                     if (!containerName.equals(GlobalConstants.DEFAULT.toString())) {
                         msg += " in Container " + containerName;
                     }
@@ -850,10 +837,33 @@ public class FlowConfig implements Serializable {
                 if (sstr.matches()) {
                     for (String t : sstr.group(1).split(",")) {
                         Matcher n = Pattern.compile("(?:(\\d+))").matcher(t);
+                        if (n.matches()) {
+                            String port = n.group(1);
+                            if (port != null) {
+                                if (!isPortValid(sw, port)) {
+                                    String msg = String.format("Output port %s is not valid for this switch", port);
+                                    if (!containerName.equals(GlobalConstants.DEFAULT.toString())) {
+                                        msg += " in Container " + containerName;
+                                    }
+                                    return new Status(StatusCode.BADREQUEST, msg);
+                                }
+                            }
+                        } else {
+                            String msg = String.format("Output port %s is not valid", t);
+                            return new Status(StatusCode.BADREQUEST, msg);
+                        }
+                    }
+                    continue;
+                }
+                // check enqueue
+                sstr = Pattern.compile("ENQUEUE=(.*)").matcher(actiongrp);
+                if (sstr.matches()) {
+                    for (String t : sstr.group(1).split(",")) {
+                        Matcher n = Pattern.compile("(?:(\\d+:\\d+))").matcher(t);
                         if (n.matches()) {
                             if (n.group(1) != null) {
-                                Short port = Short.parseShort(n.group(1));
-                                if (isPortValid(sw, port) == false) {
+                                String port = n.group(1).split(":")[0];
+                                if (!isPortValid(sw, port)) {
                                     String msg = String.format("Output port %d is not valid for this switch", port);
                                     if (!containerName.equals(GlobalConstants.DEFAULT.toString())) {
                                         msg += " in Container " + containerName;
@@ -862,7 +872,7 @@ public class FlowConfig implements Serializable {
                                 }
                             }
                         } else {
-                            String msg = String.format("Output port %s is not valid", t);
+                            String msg = String.format("Enqueue port %s is not valid", t);
                             return new Status(StatusCode.BADREQUEST, msg);
                         }
                     }
@@ -990,7 +1000,7 @@ public class FlowConfig implements Serializable {
 
         if (this.ingressPort != null) {
             match.setField(MatchType.IN_PORT,
-                    NodeConnectorCreator.createOFNodeConnector(Short.parseShort(ingressPort), getNode()));
+                    NodeConnector.fromString(String.format("%s|%s@%s", node.getType(), ingressPort, node.toString())));
         }
         if (this.dlSrc != null) {
             match.setField(MatchType.DL_SRC, HexEncode.bytesFromHexString(this.dlSrc));
@@ -1095,9 +1105,28 @@ public class FlowConfig implements Serializable {
                         Matcher n = Pattern.compile("(?:(\\d+))").matcher(t);
                         if (n.matches()) {
                             if (n.group(1) != null) {
-                                short ofPort = Short.parseShort(n.group(1));
-                                actionList.add(new Output(NodeConnectorCreator.createOFNodeConnector(ofPort,
-                                        this.getNode())));
+                                String nc = String.format("%s|%s@%s", node.getType(), n.group(1), node.toString());
+                                actionList.add(new Output(NodeConnector.fromString(nc)));
+                            }
+                        }
+                    }
+                    continue;
+                }
+
+                sstr = Pattern.compile(ActionType.ENQUEUE + "=(.*)").matcher(actiongrp);
+                if (sstr.matches()) {
+                    for (String t : sstr.group(1).split(",")) {
+                        Matcher n = Pattern.compile("(?:(\\d+:\\d+))").matcher(t);
+                        if (n.matches()) {
+                            if (n.group(1) != null) {
+                                String parts[] = n.group(1).split(":");
+                                String nc = String.format("%s|%s@%s", node.getType(), parts[0], node.toString());
+                                if (parts.length == 1) {
+                                    actionList.add(new Enqueue(NodeConnector.fromString(nc)));
+                                } else {
+                                    actionList
+                                            .add(new Enqueue(NodeConnector.fromString(nc), Integer.parseInt(parts[1])));
+                                }
                             }
                         }
                     }
index 406970711ccf5cc8e93071f3fec172c6582f23cf..48e1f07716ec267ddb52340e3ea21ef64ac8cebd 100644 (file)
@@ -546,11 +546,6 @@ public class frmTest {
         fc.setCookie("100");
         Assert.assertTrue(fc.validate(null).isSuccess());
 
-        fc.setIngressPort("-1");
-        status = fc.validate(null);
-        Assert.assertFalse(status.isSuccess());
-        Assert.assertTrue(status.getDescription().contains("is not valid for the Switch"));
-
         fc.setIngressPort("100");
         Assert.assertTrue(fc.validate(null).isSuccess());
 
index 23c36a37528b671829584177ac0f9ed4e5498f94..6b3f5347adb58e7bb31f28d4dae6de262a15db65 100644 (file)
@@ -93,7 +93,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.5.1-SNAPSHOT</version>
+      <version>0.7.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 968f87a40200c1bbf86ef7a196f92b8d96f9e8f4..176ab6cbe0138a5ae9cecdf4877bb5a4ebeaa5d1 100644 (file)
 
     <artifactId>clustered-datastore.integrationtest</artifactId>
     <version>0.4.0-SNAPSHOT</version>
-    <dependencies>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>xml-apis</groupId>
+                <artifactId>xml-apis</artifactId>
+                <version>1.4.01</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-binding-broker-impl</artifactId>
             <version>1.0-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>xml-apis</artifactId>
+                    <groupId>xml-apis</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>reflections</artifactId>
+                    <groupId>org.reflections</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>config-netconf-connector</artifactId>
             <version>${netconf.version}</version>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <artifactId>xml-apis</artifactId>
+                    <groupId>xml-apis</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
index 2710104fcfac524ea9cd71cb023f151b81f98c90..19c366d014b66d5d33af1e84003c1c8f8daee256 100644 (file)
@@ -29,9 +29,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -50,8 +57,7 @@ import org.slf4j.LoggerFactory;
 
 public class FlowConsumerImpl implements IForwardingRulesManager {
     protected static final Logger logger = LoggerFactory.getLogger(FlowConsumerImpl.class);
-    // private final FlowEventListener flowEventListener = new
-    // FlowEventListener();
+    private final FlowEventListener flowEventListener = new FlowEventListener();
     private Registration<NotificationListener> listener1Reg;
     private SalFlowService flowService;
     // private FlowDataListener listener;
@@ -96,8 +102,7 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
         // }
 
         // For switch events
-        // listener1Reg =
-        // FRMConsumerImpl.getNotificationService().registerNotificationListener(flowEventListener);
+        listener1Reg = FRMConsumerImpl.getNotificationService().registerNotificationListener(flowEventListener);
 
         if (null == listener1Reg) {
             logger.error("Listener to listen on flow data modifcation events");
@@ -153,7 +158,7 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
             input1.setNode(nodeOne);
             AddFlowInput firstMsg = input1.build();
 
-            if (null != flowService) {
+            if (null == flowService) {
                 logger.error("ConsumerFlowService is NULL");
             }
             @SuppressWarnings("unused")
@@ -446,6 +451,47 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
         }
     }
 
+    final class FlowEventListener implements SalFlowListener {
+
+        List<FlowAdded> addedFlows = new ArrayList<>();
+        List<FlowRemoved> removedFlows = new ArrayList<>();
+        List<FlowUpdated> updatedFlows = new ArrayList<>();
+
+        @Override
+        public void onFlowAdded(FlowAdded notification) {
+            addedFlows.add(notification);
+        }
+
+        @Override
+        public void onFlowRemoved(FlowRemoved notification) {
+            removedFlows.add(notification);
+        }
+
+        @Override
+        public void onFlowUpdated(FlowUpdated notification) {
+            updatedFlows.add(notification);
+        }
+
+        @Override
+        public void onNodeErrorNotification(NodeErrorNotification notification) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+        public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
+            // TODO Auto-generated method stub
+
+        }
+
+    }
+
     // Commented out DataChangeListene - to be used by Stats
 
     // final class FlowDataListener implements DataChangeListener {
@@ -626,4 +672,4 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
 
         return new NodeRef(path);
     }
-}
+}
\ No newline at end of file
index 7d16cb5b428452dfa25e110ebbc7ad795c298a18..d28e8e1fd18994979d211821680eb2ff7339eec9 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Sal
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
@@ -269,6 +270,7 @@ public class GroupConsumerImpl implements IForwardingRulesManager {
         
         UpdateGroupInputBuilder groupData = new UpdateGroupInputBuilder();
         updateGroupBuilder = new UpdatedGroupBuilder();
+        updateGroupBuilder.setGroupId(new GroupId(groupUpdateDataObject.getId()));
         updateGroupBuilder.fieldsFrom(groupUpdateDataObject);
         groupData.setUpdatedGroup(updateGroupBuilder.build());        
         groupService.updateGroup(groupData.build());
@@ -293,7 +295,7 @@ public class GroupConsumerImpl implements IForwardingRulesManager {
         AddGroupInputBuilder groupData = new AddGroupInputBuilder();
         groupData.setBuckets(groupAddDataObject.getBuckets());
         groupData.setContainerName(groupAddDataObject.getContainerName());
-        groupData.setGroupId(groupAddDataObject.getGroupId());
+        groupData.setGroupId(new GroupId(groupAddDataObject.getId()));
         groupData.setGroupType(groupAddDataObject.getGroupType());
         groupData.setNode(groupAddDataObject.getNode());    
         groupService.addGroup(groupData.build());
@@ -318,7 +320,7 @@ public class GroupConsumerImpl implements IForwardingRulesManager {
         RemoveGroupInputBuilder groupData = new RemoveGroupInputBuilder();
         groupData.setBuckets(groupRemoveDataObject.getBuckets());
         groupData.setContainerName(groupRemoveDataObject.getContainerName());
-        groupData.setGroupId(groupRemoveDataObject.getGroupId());
+        groupData.setGroupId(new GroupId(groupRemoveDataObject.getId()));
         groupData.setGroupType(groupRemoveDataObject.getGroupType());
         groupData.setNode(groupRemoveDataObject.getNode());    
         groupService.removeGroup(groupData.build());  
@@ -336,7 +338,7 @@ public class GroupConsumerImpl implements IForwardingRulesManager {
 
         for (Entry<InstanceIdentifier<?>, Group> entry : transaction.updates.entrySet()) {
 
-            if (!updateGroup(entry.getKey(), entry.getValue()).isSuccess()) {
+            if (!addGroup(entry.getKey(), entry.getValue()).isSuccess()) {
                 transaction.updates.remove(entry.getKey());
                 return Rpcs.getRpcResult(false, null, Collections.<RpcError>emptySet());
             }
index aa9d572d79724b27031b3aaa31193ec6d9d2577c..42d0897fb11ae85182f6a87e83f3015e191f716c 100644 (file)
@@ -242,6 +242,8 @@ public class MeterConsumerImpl implements IForwardingRulesManager {
         if (null != meterKey && validateMeter(meterUpdateDataObject, FRMUtil.operation.UPDATE).isSuccess()) {                UpdateMeterInputBuilder updateMeterInputBuilder = new UpdateMeterInputBuilder();
             updateMeterBuilder = new UpdatedMeterBuilder();
             updateMeterBuilder.fieldsFrom(meterUpdateDataObject);
+            updateMeterBuilder.setMeterId(new MeterId(meterUpdateDataObject.getId()));
+            
             updateMeterInputBuilder.setUpdatedMeter(updateMeterBuilder.build());
             meterService.updateMeter(updateMeterInputBuilder.build());
         } else {
@@ -267,7 +269,7 @@ public class MeterConsumerImpl implements IForwardingRulesManager {
             meterBuilder.setNode(meterRemoveDataObject.getNode());
             meterBuilder.setFlags(meterRemoveDataObject.getFlags());
             meterBuilder.setMeterBandHeaders(meterRemoveDataObject.getMeterBandHeaders());
-            meterBuilder.setMeterId(meterRemoveDataObject.getMeterId());
+            meterBuilder.setMeterId(new MeterId(meterRemoveDataObject.getId()));
             meterBuilder.setNode(meterRemoveDataObject.getNode());        
             meterService.removeMeter(meterBuilder.build());
         } else {
index aca70a94c720f93608f68e16b77c6ae4b4a6a3d1..f03e28b1108a1dee502b3550fbdfa241d0467d41 100644 (file)
@@ -14,6 +14,10 @@ module opendaylight-group-types {
         type uint32;
     }
     
+    typedef bucket-id {
+       type uint32;
+    }
+    
     typedef group-types {        
         type enumeration {
             enum group-all;
@@ -108,9 +112,9 @@ module opendaylight-group-types {
         
         container buckets {
             list bucket {
-                key "order";
-                leaf order {
-                    type int32;
+                key "bucket-id";
+                leaf bucket-id {
+                    type bucket-id;
                 }
                 
                 leaf weight {
@@ -133,7 +137,7 @@ module opendaylight-group-types {
     grouping group-statistics {
             
         leaf group-id {
-            type int32;
+            type group-id;
         }
         
         leaf ref-count {
@@ -159,9 +163,9 @@ module opendaylight-group-types {
         
         container buckets {
             list bucket-counter {
-                key "order";
-                leaf order {
-                    type int32;
+                key "bucket-id";
+                leaf bucket-id {
+                    type bucket-id;
                 }
                 
                 leaf packet-count {
@@ -205,9 +209,8 @@ module opendaylight-group-types {
     grouping group-statistics-request {
         list group-stats {
             key "group-id";         
-            
             leaf group-id {
-                type int32;
+                type group-id;
             }           
         }
     }
@@ -216,11 +219,7 @@ module opendaylight-group-types {
     grouping group-statistics-reply {
        
         list group-stats {
-            key "group-stats-order";
-            leaf group-stats-order {
-                type int32;
-            }
-            
+            key "group-id";
             uses group-statistics;
         }
     }
@@ -228,11 +227,7 @@ module opendaylight-group-types {
     grouping group-desc-stats-reply {
        
         list group-desc-stats {
-            key "order-id";         
-            leaf order-id {
-                type int32;
-            }
-            
+            key "group-id";         
             uses group;
         }
     }
index 0548890a00bcd87637d564002c7754780fa6821c..b380af22129c44f068bb02d50aa57283e8bfbac0 100644 (file)
@@ -11,7 +11,10 @@ module opendaylight-meter-types {
     }
 
     typedef meter-id {
-            type uint32;
+        type uint32;
+    }
+    typedef band-id {
+       type uint32;
     }
     
     typedef meter-flags {        
@@ -132,9 +135,9 @@ module opendaylight-meter-types {
         
         container meter-band-headers {
             list meter-band-header {
-                key "order";
-                leaf order {
-                    type int32;
+                key "band-id";
+                leaf band-id {
+                    type band-id;
                 }
                 
                 container meter-band-types {
@@ -158,7 +161,7 @@ module opendaylight-meter-types {
     grouping meter-statistics {
             
         leaf meter-id {
-            type int32;
+            type meter-id;
         }
         
         leaf flow-count {
@@ -184,9 +187,9 @@ module opendaylight-meter-types {
         
         container meter-band-stats {
             list band-stat {
-                key "order";
-                leaf order {
-                    type int32;
+                key "band-id";
+                leaf band-id {
+                    type band-id;
                 }
             
                 leaf packet-band-count {
@@ -230,30 +233,22 @@ module opendaylight-meter-types {
     grouping meter-stats-config-request {
         list meter-stats {
             key "meter-id";         
-            
             leaf meter-id {
-                type int32;
+                type meter-id;
             }           
         }
     }
     
     grouping meter-statistics-reply {
         list meter-stats {
-            key "meter-stats-order";
-            leaf meter-stats-order {
-                type int32;
-            }
+            key "meter-id";
             uses meter-statistics;
         }
     }
     
     grouping meter-config-stats-reply {
         list meter-config-stats {
-            key "meter-config-order";
-            leaf meter-config-order {
-                type int32;
-            }
-            
+            key "meter-id";
             uses meter;
         } 
     }
index 3a6f20f77d9554dda1812311e7510414d1a6658a..02a63cb2b214e98c2c603d71173a2ba35a3f3bd8 100644 (file)
@@ -30,5 +30,14 @@ module sal-table {
         output {
             uses tr:transaction-aware;
         }
-    }     
+    }
+    
+    notification table-updated {
+        uses "inv:node-context-ref";
+        uses tr:transaction-aware;
+        leaf moreReplies {
+            type boolean;
+        }
+        uses table-type:table-features;
+    }
 }
\ No newline at end of file
index 94c31dd0411eb041fc11fd61adcab23dd369a105..0e78598c1137a339c7368be40b0b7a7e39427b9a 100644 (file)
@@ -29,6 +29,7 @@
         <module>sal-binding-broker</module>
 
         <module>sal-binding-util</module>
+        <module>sal-binding-dom-it</module>
 
         <!-- Samples -->
         <module>samples</module>
 
     <dependencyManagement>
         <dependencies>
-
-
-
+            <dependency>
+                <groupId>xml-apis</groupId>
+                <artifactId>xml-apis</artifactId>
+                <version>1.4.01</version>
+            </dependency>
 
             <!-- YANG Tools Dependencies -->
             <dependency>
index 89bb1e8502570ee901d5e0f5f6052ce450140120..ac84aab977783edbebc416d4755379967f70e84c 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
             <groupId>org.reflections</groupId>
             <artifactId>reflections</artifactId>
             <version>0.9.9-RC1</version>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.javassist</groupId>
             <groupId>org.eclipse.xtend</groupId>
             <artifactId>org.eclipse.xtend.lib</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.eclipse.xtend</groupId>
-            <artifactId>org.eclipse.xtend.standalone</artifactId>
-            <version>2.4.3</version>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-binding-config</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.model</groupId>
-            <artifactId>model-flow-service</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.model</groupId>
-            <artifactId>model-flow-management</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-impl</artifactId>
             <version>${slf4j.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.model</groupId>
-            <artifactId>model-flow-statistics</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.reflections</groupId>
-            <artifactId>reflections</artifactId>
-            <version>0.9.9-RC1</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>
index de6836489e6a6b970fb96a409e832876d02e82a7..d33272d6413bfa90628f49a459671eab756ef2d0 100644 (file)
@@ -91,7 +91,7 @@ public class LazyGeneratedCodecRegistry implements //
     Map<Type, WeakReference<Class>> typeToClass = new ConcurrentHashMap<>();
 
     @SuppressWarnings("rawtypes")
-    private ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseNodes = new ConcurrentHashMap<>();
+    private ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseCodecs = new ConcurrentHashMap<>();
 
     private CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
 
@@ -136,15 +136,14 @@ public class LazyGeneratedCodecRegistry implements //
         }
         return weakRef.get();
     }
-    
+
     @Override
-    public void putPathToClass(List<QName> names,Class<?> cls) {
+    public void putPathToClass(List<QName> names, Class<?> cls) {
         Type reference = Types.typeForClass(cls);
-        pathToInstantiatedType.put(names, reference );
+        pathToInstantiatedType.put(names, reference);
         bindingClassEncountered(cls);
     }
 
-
     @Override
     public IdentifierCodec<?> getKeyCodecForPath(List<QName> names) {
         @SuppressWarnings("unchecked")
@@ -297,10 +296,12 @@ public class LazyGeneratedCodecRegistry implements //
             return potential;
         }
         ConcreteType typeref = Types.typeForClass(caseClass);
-        ChoiceCaseCodecImpl caseCodec = typeToCaseNodes.get(typeref);
+        ChoiceCaseCodecImpl caseCodec = typeToCaseCodecs.get(typeref);
 
+        checkState(caseCodec != null, "Case Codec was not created proactivelly for %s", caseClass.getName());
+        checkState(caseCodec.getSchema() != null, "Case schema is not available for %s", caseClass.getName());
         @SuppressWarnings("unchecked")
-        Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.schema);
+        Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.getSchema());
         BindingCodec newInstance = newInstanceOf(newCodec);
         caseCodec.setDelegate(newInstance);
         caseCodecs.put(caseClass, caseCodec);
@@ -322,17 +323,23 @@ public class LazyGeneratedCodecRegistry implements //
         for (Entry<SchemaPath, GeneratedTypeBuilder> caseNode : cases.entrySet()) {
             ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode
                     .getValue().getName());
+
+            LOG.info("Case path: {} Type : {}", caseNode.getKey(), caseNode.getValue().getFullyQualifiedName());
+            pathToType.put(caseNode.getKey(), caseNode.getValue());
+
             ChoiceCaseNode node = (ChoiceCaseNode) SchemaContextUtil.findDataSchemaNode(module, caseNode.getKey());
+
             if (node == null) {
                 LOG.error("YANGTools Bug: SchemaNode for {}, with path {} was not found in context.",
                         typeref.getFullyQualifiedName(), caseNode.getKey());
+                @SuppressWarnings("rawtypes")
+                ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl();
+                typeToCaseCodecs.putIfAbsent(typeref, value);
                 continue;
             }
-
-            pathToType.put(caseNode.getKey(), caseNode.getValue());
             @SuppressWarnings("rawtypes")
             ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
-            typeToCaseNodes.putIfAbsent(typeref, value);
+            typeToCaseCodecs.putIfAbsent(typeref, value);
         }
     }
 
@@ -352,18 +359,24 @@ public class LazyGeneratedCodecRegistry implements //
         choiceCodecs.put(choiceClass, newCodec);
         CodecMapping.setClassToCaseMap(choiceCodec, (Map<Class<?>, BindingCodec<?, ?>>) classToCaseRawCodec);
         CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
-        
+
         tryToCreateCasesCodecs(schema);
 
     }
 
     private void tryToCreateCasesCodecs(ChoiceNode schema) {
-        for(ChoiceCaseNode caseNode : schema.getCases()) {
+        for (ChoiceCaseNode caseNode : schema.getCases()) {
             SchemaPath path = caseNode.getPath();
             GeneratedTypeBuilder type;
-            if(path != null && (type = pathToType.get(path)) != null) {
+            if (path != null && (type = pathToType.get(path)) != null) {
+                ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
+                ChoiceCaseCodecImpl partialCodec = typeToCaseCodecs.get(typeref);
+                if(partialCodec.getSchema() == null ) {
+                    partialCodec.setSchema(caseNode);
+                }
+                
                 Class<?> caseClass = ClassLoaderUtils.tryToLoadClassWithTCCL(type.getFullyQualifiedName());
-                if(caseClass != null) {
+                if (caseClass != null) {
                     getCaseCodecFor(caseClass);
                 }
             }
@@ -381,8 +394,7 @@ public class LazyGeneratedCodecRegistry implements //
     }
 
     @Override
-    public void onDataContainerCodecCreated(Class<?> dataClass,
-            Class<? extends BindingCodec<?,?>> dataCodec) {
+    public void onDataContainerCodecCreated(Class<?> dataClass, Class<? extends BindingCodec<?, ?>> dataCodec) {
         if (Augmentable.class.isAssignableFrom(dataClass)) {
             AugmentableCompositeCodec augmentableCodec = getAugmentableCodec(dataClass);
             CodecMapping.setAugmentationCodec(dataCodec, augmentableCodec);
@@ -471,15 +483,15 @@ public class LazyGeneratedCodecRegistry implements //
     @SuppressWarnings("rawtypes")
     private static class ChoiceCaseCodecImpl<T extends DataContainer> implements ChoiceCaseCodec<T>, //
             Delegator<BindingCodec> {
-        private final boolean augmenting;
+        private boolean augmenting;
         private BindingCodec delegate;
 
-        private final Set<String> validNames;
-        private final Set<QName> validQNames;
+        private Set<String> validNames;
+        private Set<QName> validQNames;
         private ChoiceCaseNode schema;
 
-        public ChoiceCaseCodecImpl(ChoiceCaseNode caseNode) {
-            this.delegate = NOT_READY_CODEC;
+        public void setSchema(ChoiceCaseNode caseNode) {
+            this.schema = schema;
             this.schema = caseNode;
             validNames = new HashSet<>();
             validQNames = new HashSet<>();
@@ -491,6 +503,15 @@ public class LazyGeneratedCodecRegistry implements //
             augmenting = caseNode.isAugmenting();
         }
 
+        public ChoiceCaseCodecImpl() {
+            this.delegate = NOT_READY_CODEC;
+        }
+
+        public ChoiceCaseCodecImpl(ChoiceCaseNode caseNode) {
+            this.delegate = NOT_READY_CODEC;
+            setSchema(caseNode);
+        }
+
         @Override
         public ValueWithQName<T> deserialize(Node<?> input) {
             throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
index 7eb473ce3401a6774ed31f9690db658f24e4a576..cb25f4da8bb9247845c251ed95b67ee6ffeca4d5 100644 (file)
@@ -78,7 +78,7 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         for (entry : newBinding.moduleContexts.entrySet) {
 
             registry.onModuleContextAdded(schemaContext, entry.key, entry.value);
-
+            binding.pathToType.putAll(entry.value.childNodes)
             //val module = entry.key;
             val context = entry.value;
             updateBindingFor(context.childNodes, schemaContext);
@@ -174,16 +174,18 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
     }
 
     private def void updateBindingFor(Map<SchemaPath, GeneratedTypeBuilder> map, SchemaContext module) {
+        
         for (entry : map.entrySet) {
             val schemaNode = SchemaContextUtil.findDataSchemaNode(module, entry.key);
 
             //LOG.info("{} : {}",entry.key,entry.value.fullyQualifiedName)
+            val typeRef = new ReferencedTypeImpl(entry.value.packageName,entry.value.name)
+            typeToDefinition.put(typeRef, entry.value);
             if (schemaNode != null) {
-                val typeRef = new ReferencedTypeImpl(entry.value.packageName,entry.value.name)
                 typeToSchemaNode.put(typeRef, schemaNode);
-                typeToDefinition.put(typeRef, entry.value);
                 updatePromisedSchemas(typeRef, schemaNode);
             }
+            
         }
     }
 
index a732f152b25675612a21a3a6aad503c5971dbdaa..0316614aa1269a93eb8d6aa3f7d2e3fd2a4438a7 100644 (file)
@@ -49,6 +49,8 @@ import static extension org.opendaylight.controller.sal.binding.impl.util.YangSc
 import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl
 import org.opendaylight.yangtools.yang.model.util.ExtendedType
 import org.opendaylight.yangtools.yang.model.util.EnumerationType
+import static com.google.common.base.Preconditions.*
+import org.opendaylight.yangtools.yang.model.api.SchemaPath
 
 class TransformerGenerator {
 
@@ -78,6 +80,9 @@ class TransformerGenerator {
     @Property
     var Map<Type, GeneratedTypeBuilder> typeToDefinition = new ConcurrentHashMap();
 
+    @Property
+    var Map<SchemaPath, GeneratedTypeBuilder> pathToType = new ConcurrentHashMap();
+
     @Property
     var Map<Type, SchemaNode> typeToSchemaNode = new ConcurrentHashMap();
 
@@ -105,6 +110,27 @@ class TransformerGenerator {
             val ref = Types.typeForClass(inputType)
             val node = typeToSchemaNode.get(ref)
             val typeSpecBuilder = typeToDefinition.get(ref)
+            checkState(typeSpecBuilder !== null, "Could not find typedefinition for %s", inputType.name);
+            val typeSpec = typeSpecBuilder.toInstance();
+            val newret = generateTransformerFor(inputType, typeSpec, node);
+            listener.onClassProcessed(inputType);
+            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
+        ]
+    }
+
+    def Class<? extends BindingCodec<Map<QName, Object>, Object>> transformerFor(Class<?> inputType, DataSchemaNode node) {
+        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
+            val ret = getGeneratedClass(inputType)
+            if (ret !== null) {
+                listener.onClassProcessed(inputType);
+                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
+            }
+            val ref = Types.typeForClass(inputType)
+            var typeSpecBuilder = typeToDefinition.get(ref)
+            if (typeSpecBuilder == null) {
+                typeSpecBuilder = pathToType.get(node.path);
+            }
+            checkState(typeSpecBuilder !== null, "Could not find TypeDefinition for %s, $s", inputType.name, node);
             val typeSpec = typeSpecBuilder.toInstance();
             val newret = generateTransformerFor(inputType, typeSpec, node);
             listener.onClassProcessed(inputType);
@@ -205,11 +231,9 @@ class TransformerGenerator {
         keyTransformerFor(cls, type, node);
     }
 
-    private def serializer(Type type) {
+    private def serializer(Type type, DataSchemaNode node) {
         val cls = loadClassWithTCCL(type.resolvedName);
-
-        transformerFor(cls);
-
+        transformerFor(cls, node);
     }
 
     private def Class<?> getValueSerializer(GeneratedTransferObject type) {
@@ -367,7 +391,7 @@ class TransformerGenerator {
             ]
 
             val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)  as Class<? extends BindingCodec<Object, Object>>
-            listener?.onDataContainerCodecCreated(inputType,ret);
+            listener?.onDataContainerCodecCreated(inputType, ret);
             log.info("DOM Codec for {} was generated {}", inputType, ret)
             return ret;
         } catch (Exception e) {
@@ -710,7 +734,7 @@ class TransformerGenerator {
                 Object _listItem = _iterator.next();
                 _is_empty = false;
                 //System.out.println("  item" + _listItem);
-                Object _value = Â«type.actualTypeArguments.get(0).serializer.resolvedName».fromDomStatic(_localQName,_listItem);
+                Object _value = Â«type.actualTypeArguments.get(0).serializer(schema).resolvedName».fromDomStatic(_localQName,_listItem);
                 //System.out.println("  value" + _value);
                 Â«propertyName».add(_value);
                 _hasNext = _iterator.hasNext();
@@ -762,12 +786,12 @@ class TransformerGenerator {
         if(_dom_«propertyName»_list != null && _dom_«propertyName»_list.size() > 0) {
             _is_empty = false;
             java.util.Map _dom_«propertyName» = (java.util.Map) _dom_«propertyName»_list.get(0);
-            Â«propertyName» =  Â«type.serializer.resolvedName».fromDomStatic(_localQName,_dom_«propertyName»);
+            Â«propertyName» =  Â«type.serializer(schema).resolvedName».fromDomStatic(_localQName,_dom_«propertyName»);
         }
     '''
 
     private def dispatch CharSequence deserializeProperty(ChoiceNode schema, Type type, String propertyName) '''
-        Â«type.resolvedName» Â«propertyName» = Â«type.serializer.resolvedName».fromDomStatic(_localQName,_compositeNode);
+        Â«type.resolvedName» Â«propertyName» = Â«type.serializer(schema).resolvedName».fromDomStatic(_localQName,_compositeNode);
         if(«propertyName» != null) {
             _is_empty = false;
         }
@@ -1140,7 +1164,7 @@ class TransformerGenerator {
             boolean _hasNext = _iterator.hasNext();
             while(_hasNext) {
                 Object _listItem = _iterator.next();
-                Object _domValue = Â«type.actualTypeArguments.get(0).serializer.resolvedName».toDomStatic(_resultName,_listItem);
+                Object _domValue = Â«type.actualTypeArguments.get(0).serializer(schema).resolvedName».toDomStatic(_resultName,_listItem);
                 _childNodes.add(_domValue);
                 _hasNext = _iterator.hasNext();
             }
@@ -1193,7 +1217,7 @@ class TransformerGenerator {
         String propertyName) '''
         Â«type.resolvedName» Â«propertyName» = value.«propertyName»();
         if(«propertyName» != null) {
-            java.util.List domValue = Â«type.serializer.resolvedName».toDomStatic(_resultName,«propertyName»);
+            java.util.List domValue = Â«type.serializer(container).resolvedName».toDomStatic(_resultName,«propertyName»);
             _childNodes.addAll(domValue);
         }
     '''
@@ -1219,7 +1243,7 @@ class TransformerGenerator {
         String propertyName) '''
         Â«type.resolvedName» Â«propertyName» = value.«propertyName»();
         if(«propertyName» != null) {
-            Object domValue = Â«type.serializer.resolvedName».toDomStatic(_resultName,«propertyName»);
+            Object domValue = Â«type.serializer(container).resolvedName».toDomStatic(_resultName,«propertyName»);
             _childNodes.add(domValue);
         }
     '''
index 596329e07b1cdb23b2642d3f97e943aebcbf579a..d230fd17f9475c24bd920094a233734291593901 100644 (file)
@@ -7,9 +7,10 @@ import static com.google.common.base.Preconditions.*;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
 
 public final class ClassLoaderUtils {
@@ -56,15 +57,28 @@ public final class ClassLoaderUtils {
         if ("byte[]".equals(name)) {
             return byte[].class;
         }
-
-        return Thread.currentThread().getContextClassLoader().loadClass(name);
+        try {
+            return Thread.currentThread().getContextClassLoader().loadClass(name);
+        } catch (ClassNotFoundException e) {
+            String[] components = name.split("\\.");
+            String potentialOuter;
+            int length = components.length;
+            if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) {
+                
+                    String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
+                    String innerName = outerName + "$" + components[length-1];
+                    return Thread.currentThread().getContextClassLoader().loadClass(innerName);
+            } else {
+                throw e;
+            }
+        }
     }
 
     public static Class<?> tryToLoadClassWithTCCL(String fullyQualifiedName) {
         try {
             return loadClassWithTCCL(fullyQualifiedName);
         } catch (ClassNotFoundException e) {
-            
+
         }
         return null;
     }
index c67a0176d2de550ed6287607b14b546df64d71f7..a7a70c2839ca848bae7a0e45adc702c620ec4bcb 100644 (file)
@@ -14,6 +14,8 @@ import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentDataServiceConnector;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
+import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
 import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
 import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
@@ -37,117 +39,34 @@ public abstract class AbstractDataServiceTest {
 
     protected org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
     protected DataProviderService baDataService;
-
-    /**
-     * Workaround for JUNIT sharing classloaders
-     * 
-     */
-    protected static final ClassPool POOL = new ClassPool();
-
-    protected RuntimeGeneratedMappingServiceImpl mappingServiceImpl;
     protected BindingIndependentMappingService mappingService;
-    protected DataBrokerImpl baDataImpl;
-    protected org.opendaylight.controller.sal.dom.broker.DataBrokerImpl biDataImpl;
-    protected ListeningExecutorService executor;
-    protected BindingIndependentDataServiceConnector connectorServiceImpl;
-    protected HashMapDataStore rawDataStore;
-    protected SchemaAwareDataStoreAdapter schemaAwareDataStore;
     private DataStoreStatsWrapper dataStoreStats;
-
     protected DataStore dataStore;
+    protected BindingTestContext testContext;
 
     @Before
     public void setUp() {
-        executor = MoreExecutors.sameThreadExecutor();
-        baDataImpl = new DataBrokerImpl();
-        baDataService = baDataImpl;
-        baDataImpl.setExecutor(executor);
-
-        biDataImpl = new org.opendaylight.controller.sal.dom.broker.DataBrokerImpl();
-        biDataService = biDataImpl;
-        biDataImpl.setExecutor(executor);
-
-        rawDataStore = new HashMapDataStore();
-        schemaAwareDataStore = new SchemaAwareDataStoreAdapter();
-        schemaAwareDataStore.changeDelegate(rawDataStore);
-        dataStoreStats = new DataStoreStatsWrapper(schemaAwareDataStore);
-        dataStore = dataStoreStats;
-
-        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier treeRoot = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-                .builder().toInstance();
-        biDataImpl.registerConfigurationReader(treeRoot, dataStore);
-        biDataImpl.registerOperationalReader(treeRoot, dataStore);
-        biDataImpl.registerCommitHandler(treeRoot, dataStore);
-
-        mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl();
-        mappingServiceImpl.setPool(POOL);
-        mappingService = mappingServiceImpl;
-        File pathname = new File("target/gen-classes-debug");
-        // System.out.println("Generated classes are captured in " +
-        // pathname.getAbsolutePath());
-        mappingServiceImpl.start(null);
-        // mappingServiceImpl.getBinding().setClassFileCapturePath(pathname);
-
-        connectorServiceImpl = new BindingIndependentDataServiceConnector();
-        connectorServiceImpl.setBaDataService(baDataService);
-        connectorServiceImpl.setBiDataService(biDataService);
-        connectorServiceImpl.setMappingService(mappingServiceImpl);
-        connectorServiceImpl.start();
-
-        String[] yangFiles = getModelFilenames();
-        if (yangFiles != null && yangFiles.length > 0) {
-            SchemaContext context = getContext(yangFiles);
-            mappingServiceImpl.onGlobalContextUpdated(context);
-            schemaAwareDataStore.onGlobalContextUpdated(context);
-        }
+        ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
+        BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
+        factory.setExecutor(executor);
+        factory.setStartWithParsedSchema(getStartWithSchema());
+        testContext = factory.getTestContext();
+        testContext.start();
+        
+        baDataService = testContext.getBindingDataBroker();
+        biDataService = testContext.getDomDataBroker();
+        dataStore = testContext.getDomDataStore();
+        mappingService = testContext.getBindingToDomMappingService();
     }
 
-    protected String[] getModelFilenames() {
-        return getAllModelFilenames();
-    }
-
-    public static String[] getAllModelFilenames() {
-        Predicate<String> predicate = new Predicate<String>() {
-            @Override
-            public boolean apply(String input) {
-                return input.endsWith(".yang");
-            }
-        };
-        Reflections reflection = new Reflections("META-INF.yang", new ResourcesScanner());
-        Set<String> result = reflection.getResources(predicate);
-        return (String[]) result.toArray(new String[result.size()]);
-    }
-
-    public static SchemaContext getContext(String[] yangFiles) {
-
-        ClassLoader loader = AbstractDataServiceTest.class.getClassLoader();
-
-        List<InputStream> streams = new ArrayList<>();
-        for (String string : yangFiles) {
-            InputStream stream = loader.getResourceAsStream(string);
-            streams.add(stream);
-
-        }
-        YangParserImpl parser = new YangParserImpl();
-
-        Set<Module> modules = parser.parseYangModelsFromStreams(streams);
-        return parser.resolveSchemaContext(modules);
+    protected boolean getStartWithSchema() {
+        return true;
     }
 
     @After
     public void afterTest() {
 
-        log.info("BIDataStore Statistics: Configuration Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
-                dataStoreStats.getConfigurationReadCount(), dataStoreStats.getConfigurationReadTotalTime(),
-                dataStoreStats.getConfigurationReadAverageTime());
-
-        log.info("BIDataStore Statistics: Operational Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
-                dataStoreStats.getOperationalReadCount(), dataStoreStats.getOperationalReadTotalTime(),
-                dataStoreStats.getOperationalReadAverageTime());
-
-        log.info("BIDataStore Statistics: Request Commit Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
-                dataStoreStats.getRequestCommitCount(), dataStoreStats.getRequestCommitTotalTime(),
-                dataStoreStats.getRequestCommitAverageTime());
+        testContext.logDataStoreStatistics();
 
     }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java
new file mode 100644 (file)
index 0000000..bad485e
--- /dev/null
@@ -0,0 +1,59 @@
+package org.opendaylight.controller.sal.binding.test.util;
+
+import java.util.concurrent.ExecutorService;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
+import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+public class BindingBrokerTestFactory {
+
+    private static final ClassPool CLASS_POOL = new ClassPool();
+    private boolean startWithParsedSchema = true;
+    private ExecutorService executor;
+    private ClassPool classPool;
+
+    
+    public boolean isStartWithParsedSchema() {
+        return startWithParsedSchema;
+    }
+
+    public void setStartWithParsedSchema(boolean startWithParsedSchema) {
+        this.startWithParsedSchema = startWithParsedSchema;
+    }
+
+    public ExecutorService getExecutor() {
+        return executor;
+    }
+
+    public void setExecutor(ExecutorService executor) {
+        this.executor = executor;
+    }
+
+
+    public BindingTestContext getTestContext() {
+        Preconditions.checkState(executor != null, "Executor is not set.");
+        ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor);
+        return new BindingTestContext(listenableExecutor, getClassPool(),startWithParsedSchema);
+    }
+
+    public ClassPool getClassPool() {
+        if(classPool == null) {
+            return CLASS_POOL;
+        }
+        
+        return classPool;
+    }
+
+    public void setClassPool(ClassPool classPool) {
+        this.classPool = classPool;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java
new file mode 100644 (file)
index 0000000..4e611c5
--- /dev/null
@@ -0,0 +1,199 @@
+package org.opendaylight.controller.sal.binding.test.util;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentDataServiceConnector;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
+import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.reflections.Reflections;
+import org.reflections.scanners.ResourcesScanner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Predicate;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+import static com.google.common.base.Preconditions.*;
+
+public class BindingTestContext {
+    
+    
+    public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier TREE_ROOT = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+            .builder().toInstance();
+
+    private static final Logger LOG = LoggerFactory.getLogger(BindingTestContext.class);
+    
+    private RuntimeGeneratedMappingServiceImpl mappingServiceImpl;
+    private DataBrokerImpl baDataImpl;
+    private org.opendaylight.controller.sal.dom.broker.DataBrokerImpl biDataImpl;
+    
+    private BindingIndependentDataServiceConnector connectorServiceImpl;
+    private HashMapDataStore rawDataStore;
+    private SchemaAwareDataStoreAdapter schemaAwareDataStore;
+    private DataStoreStatsWrapper dataStoreStats;
+    private DataStore dataStore;
+
+    
+    private boolean dataStoreStatisticsEnabled = false;
+    
+    private final ListeningExecutorService executor;
+    private final ClassPool classPool;
+
+    private final boolean startWithSchema;
+    
+    protected BindingTestContext(ListeningExecutorService executor, ClassPool classPool, boolean startWithSchema) {
+        this.executor = executor;
+        this.classPool = classPool;
+        this.startWithSchema = startWithSchema;
+    }
+
+    public void startDomDataStore() {
+        checkState(dataStore == null, "DataStore already started.");
+        checkState(biDataImpl != null, "Dom Data Broker not present");
+        rawDataStore = new HashMapDataStore();
+        schemaAwareDataStore = new SchemaAwareDataStoreAdapter();
+        schemaAwareDataStore.changeDelegate(rawDataStore);
+        if(dataStoreStatisticsEnabled) {
+        dataStoreStats = new DataStoreStatsWrapper(schemaAwareDataStore);
+        dataStore = dataStoreStats;
+        } else {
+            dataStore = schemaAwareDataStore;
+        }
+        
+        biDataImpl.registerConfigurationReader(TREE_ROOT, dataStore);
+        biDataImpl.registerOperationalReader(TREE_ROOT, dataStore);
+        biDataImpl.registerCommitHandler(TREE_ROOT, dataStore);
+    }
+    
+    public void startDomDataBroker() {
+        checkState(executor != null,"Executor needs to be set");
+        biDataImpl = new org.opendaylight.controller.sal.dom.broker.DataBrokerImpl();
+        biDataImpl.setExecutor(executor);
+    }
+    
+    public void startBindingDataBroker() {
+        checkState(executor != null,"Executor needs to be set");
+        baDataImpl = new DataBrokerImpl();
+        baDataImpl.setExecutor(executor);
+    }
+    
+    public void startBindingToDomDataConnector() {
+        checkState(baDataImpl != null,"Binding Data Broker needs to be started");
+        checkState(biDataImpl != null,"DOM Data Broker needs to be started.");
+        checkState(mappingServiceImpl != null,"DOM Mapping Service needs to be started.");
+        connectorServiceImpl = new BindingIndependentDataServiceConnector();
+        connectorServiceImpl.setBaDataService(baDataImpl);
+        connectorServiceImpl.setBiDataService(biDataImpl);
+        connectorServiceImpl.setMappingService(mappingServiceImpl);
+        connectorServiceImpl.start();
+    }
+    
+    public void startBindingToDomMappingService() {
+        checkState(classPool != null,"ClassPool needs to be present");
+        mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl();
+        mappingServiceImpl.setPool(classPool);
+        mappingServiceImpl.start(null);
+    }
+    
+    
+    public void updateYangSchema(String[] files) {
+        SchemaContext context = getContext(files);
+        if(schemaAwareDataStore != null) {
+            schemaAwareDataStore.onGlobalContextUpdated(context);
+        }
+        if(mappingServiceImpl != null) {
+            mappingServiceImpl.onGlobalContextUpdated(context);
+        }
+    }
+    
+    
+    public static String[] getAllYangFilesOnClasspath() {
+        Predicate<String> predicate = new Predicate<String>() {
+            @Override
+            public boolean apply(String input) {
+                return input.endsWith(".yang");
+            }
+        };
+        Reflections reflection = new Reflections("META-INF.yang", new ResourcesScanner());
+        Set<String> result = reflection.getResources(predicate);
+        return (String[]) result.toArray(new String[result.size()]);
+    }
+    
+    private static SchemaContext getContext(String[] yangFiles) {
+        ClassLoader loader = BindingTestContext.class.getClassLoader();
+        List<InputStream> streams = new ArrayList<>();
+        for (String string : yangFiles) {
+            InputStream stream = loader.getResourceAsStream(string);
+            streams.add(stream);
+        }
+        YangParserImpl parser = new YangParserImpl();
+        Set<Module> modules = parser.parseYangModelsFromStreams(streams);
+        return parser.resolveSchemaContext(modules);
+    }
+    
+    public void start() {
+        startBindingDataBroker();
+        startDomDataBroker();
+        startDomDataStore();
+        startBindingToDomMappingService();
+        startBindingToDomDataConnector();
+        if(startWithSchema) {
+            loadYangSchemaFromClasspath();
+        }
+    }
+
+    public void loadYangSchemaFromClasspath() {
+        String[] files = getAllYangFilesOnClasspath();
+        updateYangSchema(files);
+    }
+
+    public DataProviderService getBindingDataBroker() {
+        return baDataImpl;
+    }
+
+    public org.opendaylight.controller.sal.core.api.data.DataProviderService getDomDataBroker() {
+        return biDataImpl;
+    }
+
+    public DataStore getDomDataStore() {
+        return dataStore;
+    }
+
+    public BindingIndependentMappingService getBindingToDomMappingService() {
+        return mappingServiceImpl;
+    }
+
+    public void logDataStoreStatistics() {
+        if(dataStoreStats == null) {
+            return;
+        }
+        
+        LOG.info("BIDataStore Statistics: Configuration Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
+                dataStoreStats.getConfigurationReadCount(), dataStoreStats.getConfigurationReadTotalTime(),
+                dataStoreStats.getConfigurationReadAverageTime());
+
+        LOG.info("BIDataStore Statistics: Operational Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
+                dataStoreStats.getOperationalReadCount(), dataStoreStats.getOperationalReadTotalTime(),
+                dataStoreStats.getOperationalReadAverageTime());
+
+        LOG.info("BIDataStore Statistics: Request Commit Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
+                dataStoreStats.getRequestCommitCount(), dataStoreStats.getRequestCommitTotalTime(),
+                dataStoreStats.getRequestCommitAverageTime());
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-dom-it/pom.xml b/opendaylight/md-sal/sal-binding-dom-it/pom.xml
new file mode 100644 (file)
index 0000000..9a143d3
--- /dev/null
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>sal-binding-dom-it</artifactId>
+    <packaging>bundle</packaging>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.eclipse.xtend</groupId>
+                <artifactId>xtend-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <configuration>
+                    <includes>org.opendaylight.controller.*</includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>pre-test</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>post-test</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+    <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
@@ -53,11 +53,6 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
             .toInstance();
     private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
 
-    @Override
-    protected String[] getModelFilenames() {
-        return null;
-    }
-
     /**
      * 
      * 
@@ -79,9 +74,7 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
             }
         });
         
-        SchemaContext ctx = getContext(getAllModelFilenames());
-        schemaAwareDataStore.onGlobalContextUpdated(ctx);
-        mappingServiceImpl.onGlobalContextUpdated(ctx);
+        testContext.loadYangSchemaFromClasspath();
         RpcResult<TransactionStatus> result = future.get().get();
         assertEquals(TransactionStatus.COMMITED, result.getResult());
         
@@ -95,5 +88,10 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
         return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
 
     }
+    
+    @Override
+    protected boolean getStartWithSchema() {
+        return false;
+    }
 
 }
index c050c034b896f266bb2826ed63d970a45783b949..235e6ac51efcafa22dd8b6e18368d71eaff07a7f 100644 (file)
         </pluginManagement>
     </build>
 
+
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.yangtools.thirdparty</groupId>
index da47438a6bb4a282045bb3fe44cd15863b9c3b03..32e59b869e20de484e4f1c27028698e1d8b05a49 100644 (file)
@@ -345,10 +345,19 @@ public abstract class AbstractDataTransaction<P extends Path<P>, D> extends Abst
     }\r
 \r
     override readConfigurationData(P path) {\r
+        val local = this.updatedConfigurationData.get(path);\r
+        if(local != null) {\r
+            return local;\r
+        }\r
+        \r
         return broker.readConfigurationData(path);\r
     }\r
 \r
     override readOperationalData(P path) {\r
+        val local = this.updatedOperationalData.get(path);\r
+        if(local != null) {\r
+            return local;\r
+        }\r
         return broker.readOperationalData(path);\r
     }\r
 \r
index 39525f85994966c71dae3ba2f186a7ebcdf9707f..c0de0d80a8c0f04fbb5a322c822acf4ca5e91661 100644 (file)
@@ -22,12 +22,16 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.YangNode;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import com.google.common.base.Preconditions;
 
 public class XmlMapper {
+    
+    private final Logger logger = LoggerFactory.getLogger(XmlMapper.class); 
 
     public Document write(CompositeNode data, DataNodeContainer schema) throws UnsupportedDataTypeException {
         Preconditions.checkNotNull(data);
@@ -70,9 +74,11 @@ public class XmlMapper {
         } else { // CompositeNode
             for (Node<?> child : ((CompositeNode) data).getChildren()) {
                 DataSchemaNode childSchema = findFirstSchemaForNode(child, ((DataNodeContainer) schema).getChildNodes());
-                if (childSchema == null) {
-                    throw new UnsupportedDataTypeException("Probably the data node \""
-                            + child.getNodeType().getLocalName() + "\" is not conform to schema");
+                if (logger.isDebugEnabled()) {
+                    if (childSchema == null) {
+                        logger.debug("Probably the data node \"" + ((child == null) ? "" : child.getNodeType().getLocalName())
+                                + "\" is not conform to schema");
+                    }
                 }
                 itemEl.appendChild(translateToXmlAndReturnRootElement(doc, child, childSchema));
             }
@@ -97,14 +103,16 @@ public class XmlMapper {
     }
 
     private DataSchemaNode findFirstSchemaForNode(Node<?> node, Set<DataSchemaNode> dataSchemaNode) {
-        for (DataSchemaNode dsn : dataSchemaNode) {
-            if (node.getNodeType().getLocalName().equals(dsn.getQName().getLocalName())) {
-                return dsn;
-            } else if (dsn instanceof ChoiceNode) {
-                for (ChoiceCaseNode choiceCase : ((ChoiceNode) dsn).getCases()) {
-                    DataSchemaNode foundDsn = findFirstSchemaForNode(node, choiceCase.getChildNodes());
-                    if (foundDsn != null) {
-                        return foundDsn;
+        if (dataSchemaNode != null && node != null) {
+            for (DataSchemaNode dsn : dataSchemaNode) {
+                if (node.getNodeType().getLocalName().equals(dsn.getQName().getLocalName())) {
+                    return dsn;
+                } else if (dsn instanceof ChoiceNode) {
+                    for (ChoiceCaseNode choiceCase : ((ChoiceNode) dsn).getCases()) {
+                        DataSchemaNode foundDsn = findFirstSchemaForNode(node, choiceCase.getChildNodes());
+                        if (foundDsn != null) {
+                            return foundDsn;
+                        }
                     }
                 }
             }
index 5ab4f99fdc07a20c78d65343b1b2dba0f3afd210..7f23776a84bf903171ce1df059b1976d5ba12c2a 100644 (file)
@@ -2,31 +2,25 @@ package org.opendaylight.controller.sal.restconf.impl.test;
 
 import java.util.Collection;
 
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.*;
+
+public class DummyRpcResult<T> implements RpcResult<T> {
 
-public class DummyRpcResult implements RpcResult<TransactionStatus> {
-    
     private final boolean isSuccessful;
-    private final TransactionStatus result;
+    private final T result;
     private final Collection<RpcError> errors;
-    
+
     public DummyRpcResult() {
         isSuccessful = false;
         result = null;
         errors = null;
     }
-    
-    private DummyRpcResult(Builder builder) {
+
+    private DummyRpcResult(Builder<T> builder) {
         isSuccessful = builder.isSuccessful;
         result = builder.result;
         errors = builder.errors;
     }
-    
-    public static Builder builder() {
-        return new DummyRpcResult.Builder();
-    }
 
     @Override
     public boolean isSuccessful() {
@@ -34,7 +28,7 @@ public class DummyRpcResult implements RpcResult<TransactionStatus> {
     }
 
     @Override
-    public TransactionStatus getResult() {
+    public T getResult() {
         return result;
     }
 
@@ -42,31 +36,31 @@ public class DummyRpcResult implements RpcResult<TransactionStatus> {
     public Collection<RpcError> getErrors() {
         return errors;
     }
-    
-    public static class Builder {
+
+    public static class Builder<T> {
         private boolean isSuccessful;
-        private TransactionStatus result;
+        private T result;
         private Collection<RpcError> errors;
-        
-        public Builder isSuccessful(boolean isSuccessful) {
+
+        public Builder<T> isSuccessful(boolean isSuccessful) {
             this.isSuccessful = isSuccessful;
             return this;
         }
-        
-        public Builder result(TransactionStatus result) {
+
+        public Builder<T> result(T result) {
             this.result = result;
             return this;
         }
-        
-        public Builder errors(Collection<RpcError> errors) {
+
+        public Builder<T> errors(Collection<RpcError> errors) {
             this.errors = errors;
             return this;
         }
-        
-        public RpcResult<TransactionStatus> build() {
-            return new DummyRpcResult(this);
+
+        public RpcResult<T> build() {
+            return new DummyRpcResult<T>(this);
         }
-        
+
     }
 
 }
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
new file mode 100644 (file)
index 0000000..103c9ed
--- /dev/null
@@ -0,0 +1,96 @@
+package org.opendaylight.controller.sal.restconf.impl.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.*;
+import java.util.*;
+
+import org.junit.*;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.sal.restconf.impl.*;
+import org.opendaylight.yangtools.yang.common.*;
+import org.opendaylight.yangtools.yang.data.api.*;
+import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
+import org.opendaylight.yangtools.yang.model.api.Module;
+
+public class InvokeRpcMethodTest {
+
+    private static Set<Module> modules;
+
+    private class AnswerImpl implements Answer<RpcResult<CompositeNode>> {
+        @Override
+        public RpcResult<CompositeNode> answer(InvocationOnMock invocation) throws Throwable {
+            CompositeNode compNode = (CompositeNode) invocation.getArguments()[1];
+            return new DummyRpcResult.Builder<CompositeNode>().result(compNode).build();
+        }
+    }
+
+    @BeforeClass
+    public static void initialization() {
+        modules = TestUtils.resolveModules("/invoke-rpc");
+        assertEquals(1, modules.size());
+        Module module = TestUtils.resolveModule("invoke-rpc-module", modules);
+        assertNotNull(module);
+    }
+
+    /**
+     * Test method invokeRpc in RestconfImpl class tests if composite node as
+     * input parameter of method invokeRpc (second argument) is wrapped to
+     * parent composite node which has QName equals to QName of rpc (resolved
+     * from string - first argument).
+     */
+    @Test
+    public void invokeRpcMethodTest() {
+        ControllerContext contContext = ControllerContext.getInstance();
+        contContext.onGlobalContextUpdated(TestUtils.loadSchemaContext(modules));
+        try {
+            contContext.findModuleByNamespace(new URI("invoke:rpc:module"));
+        } catch (URISyntaxException e) {
+            assertTrue("Uri wasn't created sucessfuly", false);
+        }
+
+        BrokerFacade mockedBrokerFacade = mock(BrokerFacade.class);
+
+        RestconfImpl restconf = RestconfImpl.getInstance();
+        restconf.setBroker(mockedBrokerFacade);
+        restconf.setControllerContext(contContext);
+
+        when(mockedBrokerFacade.invokeRpc(any(QName.class), any(CompositeNode.class))).thenAnswer(new AnswerImpl());
+
+        StructuredData structData = restconf.invokeRpc("invoke-rpc-module:rpc-test", preparePayload());
+
+        CompositeNode rpcCompNode = structData.getData();
+        CompositeNode cont = null;
+        assertEquals("invoke:rpc:module", rpcCompNode.getNodeType().getNamespace().toString());
+        assertEquals("rpc-test", rpcCompNode.getNodeType().getLocalName());
+
+        for (Node<?> node : rpcCompNode.getChildren()) {
+            if (node.getNodeType().getLocalName().equals("cont")
+                    && node.getNodeType().getNamespace().toString().equals("nmspc")) {
+                if (node instanceof CompositeNode) {
+                    cont = (CompositeNode) node;
+                }
+            }
+        }
+        assertNotNull(cont);
+
+    }
+
+    private CompositeNode preparePayload() {
+        MutableCompositeNode cont = NodeFactory.createMutableCompositeNode(
+                TestUtils.buildQName("cont", "nmspc", "2013-12-04"), null, null, ModifyAction.CREATE, null);
+        MutableSimpleNode<?> lf = NodeFactory.createMutableSimpleNode(
+                TestUtils.buildQName("lf", "nmspc", "2013-12-04"), cont, "any value", ModifyAction.CREATE, null);
+        cont.getChildren().add(lf);
+        cont.init();
+
+        return cont;
+    }
+
+}
index 61942e81a6e5918689cb4e77d1c9758b94b85911..20dfb31dab3362261fb1496dd1da9246fbc8052a 100644 (file)
@@ -205,14 +205,14 @@ final class TestUtils {
 
         ControllerContext contContext = ControllerContext.getInstance();
         contContext.setSchemas(loadSchemaContext(modules));
-        
+
         StructuredDataToJsonProvider structuredDataToJsonProvider = StructuredDataToJsonProvider.INSTANCE;
         structuredDataToJsonProvider.writeTo(new StructuredData(compositeNode, dataSchemaNode), null, null, null, null,
                 null, byteArrayOS);
 
         jsonResult = byteArrayOS.toString();
         if (outputPath != null) {
-            try {            
+            try {
                 outputToFile(byteArrayOS, outputPath);
             } catch (IOException e) {
                 System.out.println("Output file wasn't cloased sucessfuly.");
@@ -343,7 +343,8 @@ final class TestUtils {
         ControllerContext controllerContext = mock(ControllerContext.class);
         BrokerFacade broker = mock(BrokerFacade.class);
 
-        RpcResult<TransactionStatus> rpcResult = DummyRpcResult.builder().result(TransactionStatus.COMMITED).build();
+        RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+                TransactionStatus.COMMITED).build();
         Future<RpcResult<TransactionStatus>> future = DummyFuture.builder().rpcResult(rpcResult).build();
         when(controllerContext.toInstanceIdentifier(any(String.class))).thenReturn(instIdAndSchema);
         when(broker.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(
index 8e3ff1d2ed4a998997181a897a1c8ff648099aaa..c5682cb5cc1381eb31c66716a06118aa2e557e48 100644 (file)
@@ -1,27 +1,18 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.util.Set;
 
-import javax.activation.UnsupportedDataTypeException;
 import javax.ws.rs.WebApplicationException;
 
 import org.junit.*;
-import org.opendaylight.yangtools.yang.model.api.*;
 
-public class ToJsonChoiceCaseTest {
-
-    private static Set<Module> modules;
-    private static DataSchemaNode dataSchemaNode;
+public class ToJsonChoiceCaseTest extends YangAndXmlAndDataSchemaLoader {
 
     @BeforeClass
     public static void initialization() {
-        modules = TestUtils.resolveModules("/yang-to-json-conversion/choice");
-        Module module = TestUtils.resolveModule(null, modules);
-        dataSchemaNode = TestUtils.resolveDataSchemaNode(module, null);
-
+        dataLoad("/yang-to-json-conversion/choice");
     }
 
     /**
@@ -44,9 +35,9 @@ public class ToJsonChoiceCaseTest {
 
     /**
      * Test when some data are in one case node and other in another.
-     * Additionally data are loadef from various choices. This isn't
-     * correct. Next Json validator should return error because nodes has to be
-     * from one case below concrete choice.
+     * Additionally data are loadef from various choices. This isn't correct.
+     * Next Json validator should return error because nodes has to be from one
+     * case below concrete choice.
      * 
      */
     @Test
index c9ac042ff1b60655a89d9eb31a326d2cd3e6039d..ce1b4afababd1841f0718410b74158d43ef9d6ac 100644 (file)
@@ -1,9 +1,9 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.util.Set;
 import java.util.regex.*;
 
 import javax.ws.rs.WebApplicationException;
@@ -11,22 +11,12 @@ import javax.ws.rs.WebApplicationException;
 import org.junit.*;
 import org.opendaylight.yangtools.yang.data.api.*;
 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
-import org.opendaylight.yangtools.yang.model.api.*;
 
-public class ToJsonIdentityrefTest {
-
-    private static Set<Module> modules;
-    private static DataSchemaNode dataSchemaNode;
+public class ToJsonIdentityrefTest extends YangAndXmlAndDataSchemaLoader {
 
     @BeforeClass
     public static void initialization() {
-        modules = TestUtils.resolveModules("/yang-to-json-conversion/identityref");
-        assertEquals(2, modules.size());
-        Module module = TestUtils.resolveModule("identityref-module", modules);
-        assertNotNull(module);
-        dataSchemaNode = TestUtils.resolveDataSchemaNode(module, "cont");
-        assertNotNull(dataSchemaNode);
-
+        dataLoad("/yang-to-json-conversion/identityref", 2, "identityref-module", "cont");
     }
 
     @Test
index a5cc02e9f26e26fb934311b221f1e4574efa9592..b4b8b4b3e3bc8d144fde73d51090354ecbefe0a4 100644 (file)
@@ -1,31 +1,20 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.util.Set;
 import java.util.regex.Matcher;
 
 import javax.ws.rs.WebApplicationException;
 
 import org.junit.*;
-import org.opendaylight.yangtools.yang.model.api.*;
 
-public class ToJsonLeafrefType {
-    private static Set<Module> modules;
-    private static DataSchemaNode dataSchemaNode;
+public class ToJsonLeafrefType extends YangAndXmlAndDataSchemaLoader {
 
     @BeforeClass
     public static void initialization() {
-        modules = TestUtils.resolveModules("/yang-to-json-conversion/leafref");
-        assertEquals(2, modules.size());
-        Module module = TestUtils.resolveModule("main-module", modules);
-        assertNotNull(module);
-        dataSchemaNode = TestUtils.resolveDataSchemaNode(module, "cont");
-        assertNotNull(dataSchemaNode);
-
+        dataLoad("/yang-to-json-conversion/leafref", 2, "main-module", "cont");
     }
 
     @Test
index 10885b642b8a75de219a2e997e95d362fbf43085..5b0eea32126e5f85dc5c95d2c7b0ef52624c9a9d 100644 (file)
@@ -54,7 +54,8 @@ public class XmlProvidersTest extends JerseyTest {
 
     @BeforeClass
     public static void init() throws FileNotFoundException {
-        Set<Module> allModules = TestUtils.loadModules(RestconfImplTest.class.getResource("/full-versions/yangs").getPath());
+        Set<Module> allModules = TestUtils.loadModules(RestconfImplTest.class.getResource("/full-versions/yangs")
+                .getPath());
         SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
         controllerContext = ControllerContext.getInstance();
         controllerContext.setSchemas(schemaContext);
@@ -75,11 +76,11 @@ public class XmlProvidersTest extends JerseyTest {
     @Test
     public void testStructuredDataToXmlProvider() throws FileNotFoundException, UnsupportedEncodingException {
         String uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
-        
+
         InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
         CompositeNode loadedCompositeNode = TestUtils.loadCompositeNode(xmlStream);
         when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
-        
+
         Response response = target(uri).request(MEDIA_TYPE).get();
         assertEquals(200, response.getStatus());
     }
@@ -87,94 +88,100 @@ public class XmlProvidersTest extends JerseyTest {
     @Test
     public void testBadFormatXmlToCompositeNodeProvider() throws UnsupportedEncodingException, URISyntaxException {
         String uri = createUri("/operations/", "ietf-interfaces:interfaces/interface/eth0");
-        
+
         Response response = target(uri).request(Draft01.MediaTypes.DATA + RestconfService.XML).post(
                 Entity.entity("<SimpleNode/>", MEDIA_TYPE));
         assertEquals(400, response.getStatus());
-        
+
         response = target(uri).request(Draft01.MediaTypes.DATA + RestconfService.XML).post(
                 Entity.entity("<SimpleNode>", MEDIA_TYPE));
         assertEquals(400, response.getStatus());
     }
-    
+
     @Test
     public void testXmlToCompositeNode404NotFound() throws UnsupportedEncodingException, URISyntaxException {
         String uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
-        
+
         when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(null);
-        
-        Response response = target(uri).request(Draft01.MediaTypes.DATA+RestconfService.XML).get();
+
+        Response response = target(uri).request(Draft01.MediaTypes.DATA + RestconfService.XML).get();
         assertEquals(404, response.getStatus());
     }
-    
+
     @Test
     public void testXmlToCompositeNode400() throws UnsupportedEncodingException, URISyntaxException {
         String uri = createUri("/datastore/", "simple-nodes:user/name");
-        
+
         when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(null);
-        
-        Response response = target(uri).request(Draft01.MediaTypes.DATA+RestconfService.XML).get();
+
+        Response response = target(uri).request(Draft01.MediaTypes.DATA + RestconfService.XML).get();
         assertEquals(400, response.getStatus());
     }
-    
+
     @Test
     public void testRpcResultCommitedToStatusCodes() throws UnsupportedEncodingException {
         InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
         String xml = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
         Entity<String> entity = Entity.entity(xml, MEDIA_TYPE_DRAFT02);
-        RpcResult<TransactionStatus> rpcResult = DummyRpcResult.builder().result(TransactionStatus.COMMITED).build();
+        RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+                TransactionStatus.COMMITED).build();
         Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
-        when(brokerFacade.commitOperationalDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
-        when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
-        
+        when(brokerFacade.commitOperationalDataPut(any(InstanceIdentifier.class), any(CompositeNode.class)))
+                .thenReturn(dummyFuture);
+        when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class)))
+                .thenReturn(dummyFuture);
+
         String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
         Response response = target(uri).request(MEDIA_TYPE_DRAFT02).put(entity);
         assertEquals(204, response.getStatus());
         response = target(uri).request(MEDIA_TYPE_DRAFT02).post(entity);
         assertEquals(200, response.getStatus());
-        
+
         uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
         response = target(uri).request(MEDIA_TYPE_DRAFT02).put(entity);
         assertEquals(204, response.getStatus());
         response = target(uri).request(MEDIA_TYPE_DRAFT02).post(entity);
         assertEquals(200, response.getStatus());
-        
+
         uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
         response = target(uri).request(MEDIA_TYPE).put(entity);
         assertEquals(204, response.getStatus());
         response = target(uri).request(MEDIA_TYPE).post(entity);
         assertEquals(200, response.getStatus());
     }
-    
+
     @Test
     public void testRpcResultOtherToStatusCodes() throws UnsupportedEncodingException {
         InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
         String xml = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
         Entity<String> entity = Entity.entity(xml, MEDIA_TYPE_DRAFT02);
-        RpcResult<TransactionStatus> rpcResult = DummyRpcResult.builder().result(TransactionStatus.FAILED).build();
+        RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+                TransactionStatus.FAILED).build();
         Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
-        when(brokerFacade.commitOperationalDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
-        when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
-        
+        when(brokerFacade.commitOperationalDataPut(any(InstanceIdentifier.class), any(CompositeNode.class)))
+                .thenReturn(dummyFuture);
+        when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class)))
+                .thenReturn(dummyFuture);
+
         String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
         Response response = target(uri).request(MEDIA_TYPE_DRAFT02).put(entity);
         assertEquals(500, response.getStatus());
         response = target(uri).request(MEDIA_TYPE_DRAFT02).post(entity);
         assertEquals(500, response.getStatus());
-        
+
         uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
         response = target(uri).request(MEDIA_TYPE_DRAFT02).put(entity);
         assertEquals(500, response.getStatus());
         response = target(uri).request(MEDIA_TYPE_DRAFT02).post(entity);
         assertEquals(500, response.getStatus());
-        
+
         uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
         response = target(uri).request(MEDIA_TYPE).put(entity);
         assertEquals(500, response.getStatus());
         response = target(uri).request(MEDIA_TYPE).post(entity);
         assertEquals(500, response.getStatus());
     }
-    
+
     private String createUri(String prefix, String encodedPart) throws UnsupportedEncodingException {
         return URI.create(prefix + URLEncoder.encode(encodedPart, Charsets.US_ASCII.name()).toString()).toASCIIString();
     }
@@ -185,9 +192,10 @@ public class XmlProvidersTest extends JerseyTest {
         enable(TestProperties.DUMP_ENTITY);
         enable(TestProperties.RECORD_LOG_LEVEL);
         set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
-        
+
         ResourceConfig resourceConfig = new ResourceConfig();
-        resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE);
+        resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
+                XmlToCompositeNodeProvider.INSTANCE);
         return resourceConfig;
     }
 
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java
new file mode 100644 (file)
index 0000000..7e3da0e
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.controller.sal.restconf.impl.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.*;
+
+public abstract class YangAndXmlAndDataSchemaLoader {
+
+    protected static Set<Module> modules;
+    protected static DataSchemaNode dataSchemaNode;
+
+    protected static void dataLoad(String yangPath) {
+        dataLoad(yangPath, 1, null, null);
+    }
+
+    protected static void dataLoad(String yangPath, int modulesNumber, String moduleName, String dataSchemaName) {
+        modules = TestUtils.resolveModules(yangPath);
+        assertEquals(modulesNumber, modules.size());
+        Module module = TestUtils.resolveModule(moduleName, modules);
+        assertNotNull(module);
+        dataSchemaNode = TestUtils.resolveDataSchemaNode(module, dataSchemaName);
+        assertNotNull(dataSchemaNode);
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/invoke-rpc-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/invoke-rpc-module.yang
new file mode 100644 (file)
index 0000000..ba06645
--- /dev/null
@@ -0,0 +1,20 @@
+module invoke-rpc-module {
+  namespace "invoke:rpc:module";  
+
+  prefix "inrpcmod";
+         
+  revision 2013-12-3 {
+  
+  }
+
+  rpc rpc-test {
+    input {
+        container cont {
+            leaf lf {
+                type string;
+            }
+        }
+    }
+  }  
+  
+}
\ No newline at end of file
index af56a84db5611974d0537d65b914df6acbf4adc0..f22ca00b2ab4d0dc20d551aa08d58522848923a7 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.xtext.xbase.lib.Exceptions;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
@@ -130,12 +131,11 @@ public class StatisticsProvider implements AutoCloseable {
             return;
 
         for (Node targetNode : targetNodes){
-            
-            
-            //We need to add check, so see if groups/meters are supported
-            //by the target node. Below check doesn't look good.
-            if(targetNode.getId().getValue().contains("openflow:")){
+
+            if(targetNode.getAugmentation(FlowCapableNode.class) != null){
+
                 spLogger.info("Send request for stats collection to node : {})",targetNode.getId());
+                
                 InstanceIdentifier<Node> targetInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class,targetNode.getKey()).toInstance();
                 NodeRef targetNodeRef = new NodeRef(targetInstanceId);
                 
index d1bfe1e972a6b0273cfe002a4ee3eb1a8549f677..86e6114b5f67a9df25f02e8ae98677d0d842cc54 100644 (file)
@@ -146,7 +146,7 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         
         //Update augmented data
         nodeData.addAugmentation(NodeGroupDescStats.class, groupDesc.build());
-        
+
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
         it.putOperationalData(refValue, nodeData.build());
         it.commit();
@@ -168,7 +168,7 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         DataModificationTransaction it = this.statisticsManager.startChange();
         NodeKey key = new NodeKey(notification.getId());
         NodeRef ref = getNodeRef(key);
-        
+
         final NodeBuilder nodeData = new NodeBuilder(); 
         nodeData.setKey(key);
         
@@ -176,13 +176,21 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         GroupStatisticsBuilder stats = new GroupStatisticsBuilder();
         stats.setGroupStats(notification.getGroupStats());
         groupStats.setGroupStatistics(stats.build());
-        
+                
         //Update augmented data
         nodeData.addAugmentation(NodeGroupStatistics.class, groupStats.build());
-        
+
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
         it.putOperationalData(refValue, nodeData.build());
         it.commit();
+
+//        for (GroupStats groupstat : notification.getGroupStats()) {
+//        
+//            GroupStatsKey groupKey = groupstat.getKey();
+//            InstanceIdentifier<? extends Object> id = InstanceIdentifier.builder(Nodes.class).child(Node.class, key).augmentation(NodeGroupStatistics.class).child(GroupStatistics.class).child(GroupStats.class,groupKey).toInstance();
+//            it.putOperationalData(id, groupstat);
+//            it.commit();
+//        }
     }
     
     @Override
index 794bb16605fc1b0d572ac3b08b2f3a26ba607831..f60b4b02f5edb571c15313139ce32895fb4843a8 100644 (file)
                         </Export-Package>
                         <Import-Package>
                             com.google.common.base,
-                            com.google.common.collect,
                             ch.ethz.ssh2,
                             ch.ethz.ssh2.signature,
-                            io.netty.buffer,
-                            io.netty.channel,
-                            io.netty.channel.nio,
-                            io.netty.channel.socket,
-                            io.netty.util,
-                            io.netty.util.concurrent,
-                            javax.annotation,
                             java.net,
-                            javax.net.ssl,
-                            javax.xml.namespace,
-                            javax.xml.parsers,
-                            javax.xml.xpath,
+                            javax.annotation,
                             org.apache.commons.io,
-                            org.opendaylight.controller.netconf.api,
-                            org.opendaylight.controller.netconf.client,
                             org.opendaylight.controller.netconf.util,
                             org.opendaylight.controller.netconf.util.osgi,
-                            org.opendaylight.controller.netconf.util.xml,
                             org.opendaylight.protocol.framework,
                             org.osgi.framework,
-                            org.slf4j,
-                            org.w3c.dom,
-                            org.xml.sax
+                            org.slf4j
                         </Import-Package>
                     </instructions>
                 </configuration>
index af2c18a217a676c142c73040e29fe52aab80b586..1b81ccb450f71a9050739830c3e57758e0a43fc4 100644 (file)
@@ -88,7 +88,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
-      <version>0.5.1-SNAPSHOT</version>
+      <version>0.7.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.enunciate</groupId>
index 05cb500273c2bca5c2012b251ebea9db02344ebe..5338849a62626ed740c6d930d72064efa1dca4d2 100644 (file)
@@ -844,7 +844,8 @@ public class StatisticsNorthbound {
      *                     },
      *                     "activeCount": "11",
      *                     "lookupCount": "816",
-     *                     "matchedCount": "220"
+     *                     "matchedCount": "220",
+     *                     "maximumEntries": "1000"
      *                 },
      *                 {
      *                     ...another table
@@ -876,6 +877,7 @@ public class StatisticsNorthbound {
      *          &lt;activeCount&gt;12&lt;/activeCount&gt;
      *          &lt;lookupCount&gt;10935&lt;/lookupCount&gt;
      *          &lt;matchedCount&gt;10084&lt;/matchedCount&gt;
+     *          &lt;maximumEntries&gt;1000&lt;/maximumEntries&gt;
      *      &lt;/tableStatistic&gt;
      *      &lt;tableStatistic&gt;
      *          &lt;nodeTable&gt;
@@ -888,6 +890,7 @@ public class StatisticsNorthbound {
      *          &lt;activeCount&gt;0&lt;/activeCount&gt;
      *          &lt;lookupCount&gt;0&lt;/lookupCount&gt;
      *          &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *          &lt;maximumEntries&gt;0&lt;/maximumEntries&gt;
      *      &lt;/tableStatistic&gt;
      *      &lt;tableStatistic&gt;
      *          &lt;nodeTable&gt;
@@ -900,6 +903,7 @@ public class StatisticsNorthbound {
      *          &lt;activeCount&gt;0&lt;/activeCount&gt;
      *          &lt;lookupCount&gt;0&lt;/lookupCount&gt;
      *          &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *          &lt;maximumEntries&gt;0&lt;/maximumEntries&gt;
      *      &lt;/tableStatistic&gt;
      *  &lt;/tableStatistics&gt;
      *  &lt;tableStatistics&gt;
@@ -987,7 +991,8 @@ public class StatisticsNorthbound {
      *             },
      *             "activeCount": "12",
      *             "lookupCount": "11382",
-     *             "matchedCount": "10524"
+     *             "matchedCount": "10524",
+     *             "maximumEntries": "1000"
      *         },
      *         {
      *             "nodeTable": {
@@ -999,7 +1004,8 @@ public class StatisticsNorthbound {
      *             },
      *             "activeCount": "0",
      *             "lookupCount": "0",
-     *             "matchedCount": "0"
+     *             "matchedCount": "0",
+     *             "maximumEntries": "0"
      *         }
      *    ]
      * }
@@ -1022,6 +1028,7 @@ public class StatisticsNorthbound {
      *         &lt;activeCount&gt;12&lt;/activeCount&gt;
      *         &lt;lookupCount&gt;10935&lt;/lookupCount&gt;
      *         &lt;matchedCount&gt;10084&lt;/matchedCount&gt;
+     *         &lt;maximumEntries&gt;1000&lt;/maximumEntries&gt;
      *     &lt;/tableStatistic&gt;
      *     &lt;tableStatistic&gt;
      *         &lt;nodeTable&gt;
@@ -1034,6 +1041,7 @@ public class StatisticsNorthbound {
      *         &lt;activeCount&gt;0&lt;/activeCount&gt;
      *         &lt;lookupCount&gt;0&lt;/lookupCount&gt;
      *         &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *         &lt;maximumEntries&gt;0&lt;/maximumEntries&gt;
      *     &lt;/tableStatistic&gt;
      *     &lt;tableStatistic&gt;
      *         &lt;nodeTable&gt;
@@ -1046,6 +1054,7 @@ public class StatisticsNorthbound {
      *         &lt;activeCount&gt;0&lt;/activeCount&gt;
      *         &lt;lookupCount&gt;0&lt;/lookupCount&gt;
      *         &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *         &lt;maximumEntries&gt;0&lt;/maximumEntries&gt;
      *     &lt;/tableStatistic&gt;
      * &lt;/nodeTableStatistics&gt;
      *
index 8fa4941b88771c94dbf3b578a3f89717339f899e..361f977b2c2c547697b46c6cf8b76d18dbd1bafd 100644 (file)
@@ -57,6 +57,7 @@ import org.openflow.protocol.action.OFAction;
 import org.openflow.protocol.action.OFActionDataLayer;
 import org.openflow.protocol.action.OFActionDataLayerDestination;
 import org.openflow.protocol.action.OFActionDataLayerSource;
+import org.openflow.protocol.action.OFActionEnqueue;
 import org.openflow.protocol.action.OFActionNetworkLayerAddress;
 import org.openflow.protocol.action.OFActionNetworkLayerDestination;
 import org.openflow.protocol.action.OFActionNetworkLayerSource;
@@ -280,6 +281,15 @@ public class FlowConverter {
                     actionsLength += OFActionOutput.MINIMUM_LENGTH;
                     continue;
                 }
+                if (action.getType() == ActionType.ENQUEUE) {
+                    Enqueue a = (Enqueue) action;
+                    OFActionEnqueue ofAction = new OFActionEnqueue();
+                    ofAction.setPort(PortConverter.toOFPort(a.getPort()));
+                    ofAction.setQueueId(a.getQueue());
+                    actionsList.add(ofAction);
+                    actionsLength += OFActionEnqueue.MINIMUM_LENGTH;
+                    continue;
+                }
                 if (action.getType() == ActionType.DROP) {
                     continue;
                 }
@@ -683,6 +693,10 @@ public class FlowConverter {
                                     NodeConnectorCreator.createOFNodeConnector(
                                             ofPort, node));
                         }
+                    } else if (ofAction instanceof OFActionEnqueue) {
+                        salAction = new Enqueue(NodeConnectorCreator.createOFNodeConnector(
+                                ((OFActionEnqueue) ofAction).getPort(), node),
+                                ((OFActionEnqueue) ofAction).getQueueId());
                     } else if (ofAction instanceof OFActionVirtualLanIdentifier) {
                         salAction = new SetVlanId(
                                 ((OFActionVirtualLanIdentifier) ofAction)
index bcc2445808a677573892b299b16a3a2d6a5beed8..35a763869b20f2e73c2c773d748930970212820c 100644 (file)
@@ -54,6 +54,7 @@ public class TableStatisticsConverter {
                 ntStat.setActiveCount(ofTableStat.getActiveCount());
                 ntStat.setLookupCount(ofTableStat.getLookupCount());
                 ntStat.setMatchedCount(ofTableStat.getMatchedCount());
+                ntStat.setMaximumEntries(ofTableStat.getMaximumEntries());
                 this.ntStatsList.add(ntStat);
             }
         }
index b3891c8337b1f2bba4012f378a65f6d3e5e5c7ca..c711e67f9ee33d91831194f05837094c8552de4e 100644 (file)
@@ -21,6 +21,8 @@ public class Enqueue extends Action {
     private static final long serialVersionUID = 1L;
     @XmlElement
     private NodeConnector port;
+    @XmlElement
+    private int queue;
 
     /* Dummy constructor for JAXB */
     @SuppressWarnings("unused")
@@ -30,9 +32,25 @@ public class Enqueue extends Action {
     public Enqueue(NodeConnector port) {
         type = ActionType.ENQUEUE;
         this.port = port;
+        this.queue = 0;
+    }
+
+    public Enqueue(NodeConnector port, int queue) {
+        type = ActionType.ENQUEUE;
+        this.port = port;
+        this.queue = queue;
     }
 
     public NodeConnector getPort() {
         return port;
     }
+
+    public int getQueue() {
+        return queue;
+    }
+
+    @Override
+    public String toString() {
+        return String.format("%s[%s:%s]", type, port, queue);
+    }
 }
index 7c404178cfc195edd206500c90ba4155c7e02f73..eb33ad67995f2621fd95024c0736e897fb6f18ee 100644 (file)
@@ -37,6 +37,8 @@ public class NodeTableStatistics implements Serializable {
     private long lookupCount;
     @XmlElement
     private long matchedCount;
+    @XmlElement
+    private int maximumEntries;
 
 
     @Override
@@ -164,6 +166,20 @@ public class NodeTableStatistics implements Serializable {
         this.matchedCount = matchedCount;
     }
 
+    /**
+     * @return the maximumEntries
+     */
+    public long getMaximumEntries() {
+        return maximumEntries;
+    }
+
+    /**
+     * @param maximumEntries the maximumEntries to set
+     */
+    public void setMaximumEntries(int maximumEntries) {
+        this.maximumEntries = maximumEntries;
+    }
+
     @Override
     public String toString() {
         return "NodeTableStats[tableId = " + nodeTable
index cbf3f95b2a776dc616ebd8606697b7b46aa06f2d..da4cd5388380f81f69fd9dc9a431da61093a67a6 100644 (file)
@@ -40,7 +40,7 @@ public abstract class NodeConnectorCreator {
         if (node.getType().equals(NodeIDType.OPENFLOW)) {
             try {
                 return new NodeConnector(NodeConnectorIDType.OPENFLOW,
-                        (Short) portId, node);
+                        portId, node);
             } catch (ConstructionException e1) {
                 logger.error("",e1);
                 return null;
@@ -49,6 +49,18 @@ public abstract class NodeConnectorCreator {
         return null;
     }
 
+    /**
+     * Generic NodeConnector creator
+     * The nodeConnector type is inferred from the node type
+     *
+     * @param portId The string representing the port id
+     * @param node The network node as {@link org.opendaylight.controller.sal.core.Node Node} object
+     * @return The corresponding {@link org.opendaylight.controller.sal.core.NodeConnector NodeConnector} object
+     */
+    public static NodeConnector createNodeConnector(String portId, Node node) {
+        return NodeConnector.fromString(String.format("%s|%s@%s", node.getType(), portId, node.toString()));
+    }
+
     /**
      * NodeConnector creator where NodeConnector type can be specified
      * Needed to create special internal node connectors (like software stack)
index 00ac84fcc1ef54ee515ac4421bba972e13c0ea56..0387f72f382da08bc1ec395e73158d11545e253c 100644 (file)
@@ -101,7 +101,7 @@ public class Status implements Serializable {
      * @return true if the Status code is {@code StatusCode.SUCCESS}
      */
     public boolean isSuccess() {
-        return code == StatusCode.SUCCESS;
+        return code == StatusCode.SUCCESS || code == StatusCode.CREATED;
     }
 
     /**
@@ -130,15 +130,19 @@ public class Status 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;
+        }
         Status other = (Status) obj;
-        if (code != other.code)
+        if (code != other.code) {
             return false;
+        }
         return true;
     }
 }
index 86b0d53fba70a797dac4059102f007a1d4805137..f8882bbd2f81663023c95dd2b8b980d2e9754687 100644 (file)
@@ -15,6 +15,7 @@ package org.opendaylight.controller.sal.utils;
  */
 public enum StatusCode {
         SUCCESS("Success"),
+        CREATED("Created"),
 
         BADREQUEST("Bad Request"),
         UNAUTHORIZED("UnAuthorized"),
index c0d6bb698a7b0cf9112bcfa51b8e95ce2e20cf5b..a29d4268dab2c02f55006ff948a1735ee65125ea 100644 (file)
@@ -24,12 +24,14 @@ public class NodeTableStatisticsTest {
         ntStats.setActiveCount(100);
         ntStats.setLookupCount(200);
         ntStats.setMatchedCount(500);
+        ntStats.setMaximumEntries(1000);
         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.getMaximumEntries() == 1000);
         Assert.assertTrue(ntStats.getName().equals("Test"));
     }
 }
index 043fdc08c1858153a16fbd0bfe49f9337888ac98..a34cbb5db80f8f7232bf8dac7c2c41e7aba42c01 100644 (file)
@@ -634,7 +634,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                 po = e.getValue();
                 if (po != null) {
                     // Populate the Policy field now
-                    Status poStatus = this.frm.installFlowEntry(po);
+                    Status poStatus = this.frm.modifyOrAddFlowEntry(po);
                     if (!poStatus.isSuccess()) {
                         log.error("Failed to install policy: "
                                 + po.getGroupName() + " ("
@@ -842,8 +842,9 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
     @Override
     public void notifyNode(Node node, UpdateType type,
             Map<String, Property> propMap) {
-        if (node == null)
+        if (node == null) {
             return;
+        }
 
         switch (type) {
         case REMOVED:
@@ -858,8 +859,9 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
     @Override
     public void notifyNodeConnector(NodeConnector nodeConnector,
             UpdateType type, Map<String, Property> propMap) {
-        if (nodeConnector == null)
+        if (nodeConnector == null) {
             return;
+        }
 
         boolean up = false;
         switch (type) {