HONEYCOMB-61: Make InmemoryDataTree module type configurable
authorMaros Marsalek <[email protected]>
Fri, 13 May 2016 09:24:15 +0000 (11:24 +0200)
committerMaros Marsalek <[email protected]>
Mon, 23 May 2016 09:23:53 +0000 (09:23 +0000)
Change-Id: Ie73eac8960a76ebcc578d3b44c50492f29908e24
Signed-off-by: Maros Marsalek <[email protected]>
v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModule.java [moved from v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java with 61% similarity]
v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModuleFactory.java [moved from v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java with 56% similarity]
v3po/data-impl/src/main/yang/data-impl.yang
v3po/impl/src/main/config/default-config.xml

@@ -1,26 +1,21 @@
 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;
 
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.*;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class InMemoryConfigDataTreeModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryConfigDataTreeModule {
+public class InMemoryDataTreeModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryDataTreeModule {
 
-    private static final Logger LOG = LoggerFactory.getLogger(InMemoryConfigDataTreeModule.class);
+    private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeModule.class);
 
-    public InMemoryConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public InMemoryDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public InMemoryConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.InMemoryConfigDataTreeModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public InMemoryDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.InMemoryDataTreeModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
@@ -32,14 +27,17 @@ public class InMemoryConfigDataTreeModule extends org.opendaylight.yang.gen.v1.u
     @Override
     public java.lang.AutoCloseable createInstance() {
         LOG.debug("InMemoryConfigDataTreeModule.createInstance()");
-        return new CloseableConfigDataTree(getSchemaServiceDependency().getGlobalContext());
+        return new CloseableConfigDataTree(getSchemaServiceDependency().getGlobalContext(), getType());
     }
 
-    private static class CloseableConfigDataTree implements AutoCloseable, DataTree {
-        private final DataTree dataTree;
+    private static class CloseableConfigDataTree implements AutoCloseable,
+        org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree {
+        private final org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree dataTree;
 
-        public CloseableConfigDataTree(final SchemaContext schemaContext) {
-            this.dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
+        public CloseableConfigDataTree(final SchemaContext schemaContext, final DatatreeType type) {
+            this.dataTree = InMemoryDataTreeFactory.getInstance().create(
+                type == DatatreeType.Config ? TreeType.CONFIGURATION : TreeType.OPERATIONAL
+            );
             dataTree.setSchemaContext(schemaContext);
         }
 
@@ -1,13 +1,13 @@
 /*
 * Generated file
 *
-* Generated from: yang module name: data-impl yang module local name: inmemory-config-data-tree
+* Generated from: yang module name: data-impl yang module local name: inmemory-data-tree
 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Apr 12 07:26:54 CEST 2016
+* Generated at: Fri May 13 11:10:56 CEST 2016
 *
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;
-public class InMemoryConfigDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryConfigDataTreeModuleFactory {
+public class InMemoryDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryDataTreeModuleFactory {
 
 }
index fa6c6f0..da1c023 100644 (file)
@@ -23,15 +23,22 @@ module data-impl {
         config:java-class org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
     }
 
-    identity inmemory-config-data-tree {
+    identity inmemory-data-tree {
         base config:module-type;
         config:provided-service data-tree;
-        config:java-name-prefix InMemoryConfigDataTree;
+        config:java-name-prefix InMemoryDataTree;
+    }
+
+    typedef datatree-type {
+        type enumeration {
+             enum config;
+             enum oper;
+         }
     }
 
     augment "/config:modules/config:module/config:configuration" {
-        case inmemory-config-data-tree {
-            when "/config:modules/config:module/config:type = 'inmemory-config-data-tree'";
+        case inmemory-data-tree {
+            when "/config:modules/config:module/config:type = 'inmemory-data-tree'";
 
             container schema-service {
                 uses config:service-ref {
@@ -41,6 +48,10 @@ module data-impl {
                     }
                 }
             }
+
+            leaf type {
+                type datatree-type;
+            }
         }
     }
 
index ca09d6e..61fe1c6 100644 (file)
 
         <!-- In-memory data tree for HC config data tree -->
         <module>
-          <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:inmemory-config-data-tree</type>
+          <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:inmemory-data-tree</type>
           <name>inmemory-config-data-tree</name>
           <schema-service>
             <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
             <name>yang-schema-service</name>
           </schema-service>
+          <type xmlns="urn:honeycomb:params:xml:ns:yang:data:impl">config</type>
         </module>
 
         <!-- DataTree adapter with persistence for config DT -->
           <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:data-tree</type>
           <instance>
             <name>inmemory-config-data-tree</name>
-            <provider>/modules/module[type='inmemory-config-data-tree'][name='inmemory-config-data-tree']
+            <provider>/modules/module[type='inmemory-data-tree'][name='inmemory-config-data-tree']
             </provider>
           </instance>
           <instance>