Retrofit DOMSchemaService into SchemaService 92/57592/15
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 21 May 2017 14:34:21 +0000 (16:34 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 21 Jun 2017 11:32:46 +0000 (11:32 +0000)
For migration purposes we need to retrofit SchemaService so that
in extends MDSAL's DOMSchemaService. Also allow datastores to
be instantiated with DOMSchemaService.

Change-Id: Ie71732fb09f4da6dbc2d0819931d5ade2356d6f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java

index b62cd3d..4fd0991 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -21,10 +22,25 @@ import org.slf4j.LoggerFactory;
 public class DistributedDataStoreFactory {
     private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class);
 
+    /**
+     * Create a data store instance.
+     *
+     * @deprecated Use {@link #createInstance(DOMSchemaService, DatastoreContext, DatastoreSnapshotRestore,
+     *                        ActorSystemProvider, BundleContext)} instead.
+     */
+    @Deprecated
     public static AbstractDataStore createInstance(final SchemaService schemaService,
             final DatastoreContext initialDatastoreContext, final DatastoreSnapshotRestore datastoreSnapshotRestore,
             final ActorSystemProvider actorSystemProvider, final BundleContext bundleContext) {
 
+        return createInstance((DOMSchemaService) schemaService, initialDatastoreContext, datastoreSnapshotRestore,
+            actorSystemProvider, bundleContext);
+    }
+
+    public static AbstractDataStore createInstance(final DOMSchemaService schemaService,
+            final DatastoreContext initialDatastoreContext, final DatastoreSnapshotRestore datastoreSnapshotRestore,
+            final ActorSystemProvider actorSystemProvider, final BundleContext bundleContext) {
+
         final String datastoreName = initialDatastoreContext.getDataStoreName();
         LOG.info("Create data store instance of type : {}", datastoreName);
 
index 57817ab..a1d9d88 100644 (file)
@@ -10,7 +10,7 @@
     </cm:default-properties>
   </cm:property-placeholder>
 
-  <odl:static-reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+  <odl:static-reference id="schemaService" interface="org.opendaylight.mdsal.dom.api.DOMSchemaService" />
 
   <!-- ActorSystemProvider -->
 
     </interfaces>
   </service>
 
-</blueprint>
\ No newline at end of file
+</blueprint>
index de37cf8..a56a468 100644 (file)
@@ -8,16 +8,17 @@
 package org.opendaylight.controller.sal.core.api.model;
 
 import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 
 /**
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMSchemaService} instead.
+ * @deprecated Use {@link DOMSchemaService} instead.
  */
 @Deprecated
-public interface SchemaService extends BrokerService {
+public interface SchemaService extends BrokerService, DOMSchemaService {
 
     /**
      * Registers a YANG module to session and global context
@@ -32,11 +33,13 @@ public interface SchemaService extends BrokerService {
     /**
      * Returns session specific YANG schema context
      */
+    @Override
     SchemaContext getSessionContext();
 
     /**
      * Returns global schema context
      */
+    @Override
     SchemaContext getGlobalContext();
 
     /**
@@ -45,5 +48,6 @@ public interface SchemaService extends BrokerService {
      * @param listener Listener which should be registered
      * @return Listener registration handle
      */
+    @Override
     ListenerRegistration<SchemaContextListener> registerSchemaContextListener(SchemaContextListener listener);
 }
index 6423544..d2297f2 100644 (file)
@@ -11,6 +11,7 @@ import java.util.concurrent.ExecutorService;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
 
 /**
@@ -23,8 +24,17 @@ public final class InMemoryDOMDataStoreFactory {
     private InMemoryDOMDataStoreFactory() {
     }
 
+    /**
+     * @deprecated Use {@link #create(String, DOMSchemaService)} instead.
+     */
+    @Deprecated
     public static InMemoryDOMDataStore create(final String name,
             @Nullable final SchemaService schemaService) {
+        return create(name, (DOMSchemaService)schemaService);
+    }
+
+    public static InMemoryDOMDataStore create(final String name,
+            @Nullable final DOMSchemaService schemaService) {
         return create(name, schemaService, null);
     }
 
@@ -36,10 +46,28 @@ public final class InMemoryDOMDataStoreFactory {
      * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
      *                   default property values are used.
      * @return an InMemoryDOMDataStore instance
+     *
+     * @deprecated Use {@link #create(String, DOMSchemaService, InMemoryDOMDataStoreConfigProperties)} instead.
      */
+    @Deprecated
     public static InMemoryDOMDataStore create(final String name,
             @Nullable final SchemaService schemaService,
             @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
+        return create(name, (DOMSchemaService) schemaService, properties);
+    }
+
+    /**
+     * Creates an InMemoryDOMDataStore instance.
+     *
+     * @param name the name of the data store
+     * @param schemaService the SchemaService to which to register the data store.
+     * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
+     *                   default property values are used.
+     * @return an InMemoryDOMDataStore instance
+     */
+    public static InMemoryDOMDataStore create(final String name,
+            @Nullable final DOMSchemaService schemaService,
+            @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
         return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties);
     }
 
@@ -73,10 +101,31 @@ public final class InMemoryDOMDataStoreFactory {
      * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
      *                   default property values are used.
      * @return an InMemoryDOMDataStore instance
+     *
+     * @deprecated Use {@link #create(String, LogicalDatastoreType, DOMSchemaService, boolean,
+     *                                InMemoryDOMDataStoreConfigProperties)} instead.
      */
+    @Deprecated
     public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
             @Nullable final SchemaService schemaService, final boolean debugTransactions,
             @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
+        return create(name, type, (DOMSchemaService) schemaService, debugTransactions, properties);
+    }
+
+    /**
+     * Creates an InMemoryDOMDataStore instance.
+     *
+     * @param name the name of the data store
+     * @param type Data store type
+     * @param schemaService the SchemaService to which to register the data store.
+     * @param debugTransactions enable transaction debugging
+     * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
+     *                   default property values are used.
+     * @return an InMemoryDOMDataStore instance
+     */
+    public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
+            @Nullable final DOMSchemaService schemaService, final boolean debugTransactions,
+            @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
 
         InMemoryDOMDataStoreConfigProperties actualProperties = properties;
         if (actualProperties == null) {

©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.