BUG-1014: pass proper TreeType to DataTreeFactory 69/29669/12
authorRobert Varga <rovarga@cisco.com>
Fri, 13 Nov 2015 17:28:54 +0000 (18:28 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 15 Dec 2015 16:41:19 +0000 (16:41 +0000)
Convert the LogicalStoreType into a TreeType and pass it down to the
DataTreeFactory, thus ensuring the resulting DataTree is aware of which
YANG store (CONFIG or OPER) it should enforce.

Change-Id: Ibe9d16161db11f564823df2bf1e73b78f21c4f98
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java

index f5b9f4c08d6413d845344df44a49edcf9f1ffca9..f7b3461d333f9c157dbeb06208eed276080c297d 100644 (file)
@@ -70,6 +70,7 @@ 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.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
@@ -134,8 +135,7 @@ public class Shard extends RaftActor {
 
         LOG.info("Shard created : {}, persistent : {}", name, datastoreContext.isPersistent());
 
-        // FIXME: BUG-1014: pass down the proper TreeType
-        store = new ShardDataTree(builder.getSchemaContext());
+        store = new ShardDataTree(builder.getSchemaContext(), builder.getTreeType());
 
         shardMBean = ShardMBeanFactory.getShardStatsMBean(name.toString(),
                 datastoreContext.getDataStoreMXBeanType());
@@ -813,6 +813,17 @@ public class Shard extends RaftActor {
             return restoreFromSnapshot;
         }
 
+        public TreeType getTreeType() {
+            switch (datastoreContext.getLogicalStoreType()) {
+            case CONFIGURATION:
+                return TreeType.CONFIGURATION;
+            case OPERATIONAL:
+                return TreeType.OPERATIONAL;
+            }
+
+            throw new IllegalStateException("Unhandled logical store type " + datastoreContext.getLogicalStoreType());
+        }
+
         protected void verify() {
             Preconditions.checkNotNull(id, "id should not be null");
             Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");