From 4c46166efff66fb7c608fd4ea0ba48ab0abb07ec Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 10 Dec 2015 14:07:12 +0100 Subject: [PATCH] BUG-1014: convert IMDS This patch fixes the IMDS to properly pass down the TreeType. Change-Id: I724fac68e62c58ed71eefbf03d50c82fb8d4a4e7 Signed-off-by: Robert Varga --- ...InMemoryConfigDataStoreProviderModule.java | 11 ++++---- ...oryOperationalDataStoreProviderModule.java | 11 ++++---- .../dom/store/impl/InMemoryDOMDataStore.java | 21 ++++++++++++--- .../impl/InMemoryDOMDataStoreFactory.java | 26 +++++++++++++++++-- 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java index 3f26266fef..ada7488061 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java @@ -1,5 +1,6 @@ package org.opendaylight.controller.config.yang.inmemory_datastore_provider; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory; @@ -22,11 +23,11 @@ public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.cont @Override public java.lang.AutoCloseable createInstance() { - InMemoryDOMDataStore dataStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", getSchemaServiceDependency(), - getDebugTransactions(), - InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(), - getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize(), - getMaxDataStoreExecutorQueueSize())); + InMemoryDOMDataStore dataStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", + LogicalDatastoreType.CONFIGURATION, getSchemaServiceDependency(), getDebugTransactions(), + InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(), + getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize(), + getMaxDataStoreExecutorQueueSize())); InMemoryDataStoreStats statsBean = new InMemoryDataStoreStats("InMemoryConfigDataStore", dataStore); dataStore.setCloseable(statsBean); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java index c91c53aba4..0271072abf 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java @@ -1,5 +1,6 @@ package org.opendaylight.controller.config.yang.inmemory_datastore_provider; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory; @@ -22,11 +23,11 @@ public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight @Override public java.lang.AutoCloseable createInstance() { - InMemoryDOMDataStore dataStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", getSchemaServiceDependency(), - getDebugTransactions(), InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(), - getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize(), - getMaxDataStoreExecutorQueueSize())); - + InMemoryDOMDataStore dataStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", + LogicalDatastoreType.OPERATIONAL, getSchemaServiceDependency(), getDebugTransactions(), + InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(), + getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize(), + getMaxDataStoreExecutorQueueSize())); InMemoryDataStoreStats statsBean = new InMemoryDataStoreStats("InMemoryOperationalDataStore", dataStore); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index a85d8ac3fb..1ba5015371 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -14,6 +14,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree; import org.opendaylight.controller.sal.core.spi.data.DOMStore; @@ -39,6 +40,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; +import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; @@ -69,7 +71,7 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl } }; - private final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(); + private final DataTree dataTree; private final ListenerTree listenerTree = ListenerTree.create(); private final AtomicLong txCounter = new AtomicLong(0); @@ -82,10 +84,12 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl private volatile AutoCloseable closeable; public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor) { - this(name, dataChangeListenerExecutor, InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false); + this(name, LogicalDatastoreType.OPERATIONAL, dataChangeListenerExecutor, + InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false); } - public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor, + public InMemoryDOMDataStore(final String name, final LogicalDatastoreType type, + final ExecutorService dataChangeListenerExecutor, final int maxDataChangeListenerQueueSize, final boolean debugTransactions) { this.name = Preconditions.checkNotNull(name); this.dataChangeListenerExecutor = Preconditions.checkNotNull(dataChangeListenerExecutor); @@ -96,6 +100,17 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl DCL_NOTIFICATION_MGR_INVOKER, maxDataChangeListenerQueueSize, "DataChangeListenerQueueMgr"); changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor, maxDataChangeListenerQueueSize); + + switch (type) { + case CONFIGURATION: + dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); + break; + case OPERATIONAL: + dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); + break; + default: + throw new IllegalArgumentException("Data store " + type + " not supported"); + } } public void setCloseable(final AutoCloseable closeable) { 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 00af3dfdd7..6423544aad 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 @@ -9,6 +9,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; 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.yangtools.util.concurrent.SpecialExecutors; @@ -39,7 +40,7 @@ public final class InMemoryDOMDataStoreFactory { public static InMemoryDOMDataStore create(final String name, @Nullable final SchemaService schemaService, @Nullable final InMemoryDOMDataStoreConfigProperties properties) { - return create(name, schemaService, false, properties); + return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties); } /** @@ -51,10 +52,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, SchemaService, boolean, InMemoryDOMDataStoreConfigProperties)} + * instead. */ + @Deprecated public static InMemoryDOMDataStore create(final String name, @Nullable final SchemaService schemaService, final boolean debugTransactions, @Nullable final InMemoryDOMDataStoreConfigProperties properties) { + return create(name, LogicalDatastoreType.OPERATIONAL, 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 SchemaService schemaService, final boolean debugTransactions, + @Nullable final InMemoryDOMDataStoreConfigProperties properties) { InMemoryDOMDataStoreConfigProperties actualProperties = properties; if (actualProperties == null) { @@ -71,7 +93,7 @@ public final class InMemoryDOMDataStoreFactory { ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool( dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL" ); - final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, dataChangeListenerExecutor, + final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor, actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions); if (schemaService != null) { -- 2.36.6