Construct IMDS delegate with proper type 66/76266/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Sep 2018 08:35:47 +0000 (10:35 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 19 Sep 2018 13:22:11 +0000 (13:22 +0000)
This patch makes sure we do not ignore the datastore type, but
pass it down to MD-SAL's IMDS.

Since we are converting from controller to mdsal LogicalDatastoreType
in multiple places, centralize this via LogicalDatastoreType.toMdsal().

JIRA: MDSAL-370
Change-Id: I5e027fd439e325ff91344de98511e503fc801992
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0425ce4501aec2d8f96d6379baa1116a5350fba2)

opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/LogicalDatastoreType.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java

index 2951610e414ab2231a277ff29b12566334c94e41..651c9194571f74e2512248ce7c2120199d1e1867 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.md.sal.common.api.data;
 
-public enum LogicalDatastoreType {
+import org.eclipse.jdt.annotation.NonNullByDefault;
 
+@NonNullByDefault
+public enum LogicalDatastoreType {
     /**
      * Logical atastore representing operational state of the system
      * and it's components
@@ -18,7 +20,12 @@ public enum LogicalDatastoreType {
      * the system and it's operation related data.
      *
      */
-    OPERATIONAL,
+    OPERATIONAL {
+        @Override
+        public org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal() {
+            return org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
+        }
+    },
     /**
      * Logical Datastore representing configuration state of the system
      * and it's components.
@@ -28,5 +35,17 @@ public enum LogicalDatastoreType {
      * the system and intended operation mode.
      *
      */
-    CONFIGURATION
+    CONFIGURATION {
+        @Override
+        public org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal() {
+            return org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
+        }
+    };
+
+    /**
+     * Convert this logical datastore type to its MD-SAL counterpart.
+     *
+     * @return MD-SAL counterpart of this type.
+     */
+    public abstract org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal();
 }
index a756676de0dc63f1f7b04eed445a8dfa5661b7d4..59755020b0fffd3c632a81f36ee94361262f99fe 100644 (file)
@@ -35,8 +35,8 @@ public class InMemoryDOMDataStore
     public InMemoryDOMDataStore(final String name, final LogicalDatastoreType type,
             final ExecutorService dataChangeListenerExecutor,
             final int maxDataChangeListenerQueueSize, final boolean debugTransactions) {
-        delegate = new org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore(name, dataChangeListenerExecutor,
-            maxDataChangeListenerQueueSize, debugTransactions);
+        delegate = new org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore(name, type.toMdsal(),
+            dataChangeListenerExecutor, maxDataChangeListenerQueueSize, debugTransactions);
     }
 
     @Override