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 2951610..651c919 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 a756676..5975502 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

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.