From de73a66ea7e017d2a3c4805fb7714b93ca7c9285 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 21 May 2017 16:34:21 +0200 Subject: [PATCH] Retrofit DOMSchemaService into SchemaService 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 --- .../DistributedDataStoreFactory.java | 16 ++++++ .../blueprint/clustered-datastore.xml | 4 +- .../sal/core/api/model/SchemaService.java | 8 ++- .../impl/InMemoryDOMDataStoreFactory.java | 49 +++++++++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java index b62cd3d6d3..4fd09914cd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java @@ -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); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml index 57817abaf6..a1d9d88258 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml @@ -10,7 +10,7 @@ - + @@ -143,4 +143,4 @@ - \ No newline at end of file + diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java index de37cf8b77..a56a468e20 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java @@ -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 registerSchemaContextListener(SchemaContextListener listener); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java index 6423544aad..d2297f28c9 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java @@ -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) { -- 2.36.6