From efbeac00372d85440d46e2e5e04b124036ad3721 Mon Sep 17 00:00:00 2001 From: tpantelis Date: Fri, 8 Aug 2014 22:38:04 -0400 Subject: [PATCH] Bug 1430: Obtain config params from config system This is a follow-up patch to obtain the various data store executor config params from the config system intsead of system properties. Change-Id: Ib7fa03f053d6165fdcb52300be9add8ebe80b2c2 Signed-off-by: tpantelis --- .../datastore/DistributedDataStore.java | 6 +- .../DistributedDataStoreFactory.java | 15 ++-- .../controller/cluster/datastore/Shard.java | 14 ++-- .../cluster/datastore/ShardManager.java | 15 +++- ...tributedConfigDataStoreProviderModule.java | 7 +- ...tedOperationalDataStoreProviderModule.java | 8 +- .../yang/distributed-datastore-provider.yang | 70 ++++++++++++---- .../datastore/BasicIntegrationTest.java | 2 +- .../DistributedDataStoreIntegrationTest.java | 4 +- .../datastore/DistributedDataStoreTest.java | 2 +- .../cluster/datastore/ShardManagerTest.java | 12 +-- .../cluster/datastore/ShardTest.java | 8 +- .../ShardTransactionFailureTest.java | 16 ++-- .../datastore/ShardTransactionTest.java | 21 ++--- .../dom/impl/DomInmemoryDataBrokerModule.java | 25 +----- .../yang/opendaylight-dom-broker-impl.yang | 18 ++++ ...InMemoryConfigDataStoreProviderModule.java | 5 +- ...oryOperationalDataStoreProviderModule.java | 5 +- .../dom/store/impl/InMemoryDOMDataStore.java | 18 ++-- .../InMemoryDOMDataStoreConfigProperties.java | 83 +++++++++++++++++++ .../impl/InMemoryDOMDataStoreFactory.java | 32 +++---- ...ndaylight-inmemory-datastore-provider.yang | 68 +++++++++++---- 22 files changed, 315 insertions(+), 139 deletions(-) create mode 100644 opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java index 40e045f18e..4fa26ffb20 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java @@ -21,6 +21,7 @@ import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; @@ -72,7 +73,8 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au EXECUTOR_MAX_QUEUE_SIZE_PROP, DEFAULT_EXECUTOR_MAX_QUEUE_SIZE), "DistDataStore")); - public DistributedDataStore(ActorSystem actorSystem, String type, ClusterWrapper cluster, Configuration configuration) { + public DistributedDataStore(ActorSystem actorSystem, String type, ClusterWrapper cluster, + Configuration configuration, InMemoryDOMDataStoreConfigProperties dataStoreProperties) { Preconditions.checkNotNull(actorSystem, "actorSystem should not be null"); Preconditions.checkNotNull(type, "type should not be null"); Preconditions.checkNotNull(cluster, "cluster should not be null"); @@ -84,7 +86,7 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au LOG.info("Creating ShardManager : {}", shardManagerId); this.actorContext = new ActorContext(actorSystem, actorSystem - .actorOf(ShardManager.props(type, cluster, configuration), + .actorOf(ShardManager.props(type, cluster, configuration, dataStoreProperties), shardManagerId ), cluster, configuration); } 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 6d87271f00..a1a3e87510 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 @@ -9,19 +9,22 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorSystem; + import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.controller.sal.core.api.model.SchemaService; public class DistributedDataStoreFactory { - public static DistributedDataStore createInstance(String name, SchemaService schemaService){ + public static DistributedDataStore createInstance(String name, SchemaService schemaService, + InMemoryDOMDataStoreConfigProperties dataStoreProperties) { + ActorSystem actorSystem = ActorSystemFactory.getInstance(); Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf"); final DistributedDataStore dataStore = - new DistributedDataStore(actorSystem, name, new ClusterWrapperImpl(actorSystem),config ); - ShardStrategyFactory.setConfiguration(config); - schemaService - .registerSchemaContextListener(dataStore); + new DistributedDataStore(actorSystem, name, new ClusterWrapperImpl(actorSystem), + config, dataStoreProperties ); + ShardStrategyFactory.setConfiguration(config); + schemaService.registerSchemaContextListener(dataStore); return dataStore; - } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index 63b26331a5..c329a10c04 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -41,6 +41,7 @@ import org.opendaylight.controller.cluster.raft.RaftActor; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; 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; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; @@ -92,7 +93,8 @@ public class Shard extends RaftActor { private final List dataChangeListeners = new ArrayList<>(); - private Shard(ShardIdentifier name, Map peerAddresses) { + private Shard(ShardIdentifier name, Map peerAddresses, + InMemoryDOMDataStoreConfigProperties dataStoreProperties) { super(name.toString(), mapPeerAddresses(peerAddresses), Optional.of(configParams)); this.name = name; @@ -103,7 +105,7 @@ public class Shard extends RaftActor { LOG.info("Shard created : {} persistent : {}", name, persistent); - store = InMemoryDOMDataStoreFactory.create(name.toString(), null); + store = InMemoryDOMDataStoreFactory.create(name.toString(), null, dataStoreProperties); shardMBean = ShardMBeanFactory.getShardStatsMBean(name.toString()); @@ -119,11 +121,9 @@ public class Shard extends RaftActor { return map; } - - - public static Props props(final ShardIdentifier name, - final Map peerAddresses) { + final Map peerAddresses, + final InMemoryDOMDataStoreConfigProperties dataStoreProperties) { Preconditions.checkNotNull(name, "name should not be null"); Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null"); @@ -131,7 +131,7 @@ public class Shard extends RaftActor { @Override public Shard create() throws Exception { - return new Shard(name, peerAddresses); + return new Shard(name, peerAddresses, dataStoreProperties); } }); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java index 6162a0327c..5fce64e248 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java @@ -30,6 +30,8 @@ import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolve import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; + import scala.concurrent.duration.Duration; import java.util.ArrayList; @@ -68,15 +70,19 @@ public class ShardManager extends AbstractUntypedActor { private ShardManagerInfoMBean mBean; + private final InMemoryDOMDataStoreConfigProperties dataStoreProperties; + /** * @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be * configuration or operational */ - private ShardManager(String type, ClusterWrapper cluster, Configuration configuration) { + private ShardManager(String type, ClusterWrapper cluster, Configuration configuration, + InMemoryDOMDataStoreConfigProperties dataStoreProperties) { this.type = Preconditions.checkNotNull(type, "type should not be null"); this.cluster = Preconditions.checkNotNull(cluster, "cluster should not be null"); this.configuration = Preconditions.checkNotNull(configuration, "configuration should not be null"); + this.dataStoreProperties = dataStoreProperties; // Subscribe this actor to cluster member events cluster.subscribeToMemberEvents(getSelf()); @@ -88,7 +94,8 @@ public class ShardManager extends AbstractUntypedActor { public static Props props(final String type, final ClusterWrapper cluster, - final Configuration configuration) { + final Configuration configuration, + final InMemoryDOMDataStoreConfigProperties dataStoreProperties) { Preconditions.checkNotNull(type, "type should not be null"); Preconditions.checkNotNull(cluster, "cluster should not be null"); @@ -98,7 +105,7 @@ public class ShardManager extends AbstractUntypedActor { @Override public ShardManager create() throws Exception { - return new ShardManager(type, cluster, configuration); + return new ShardManager(type, cluster, configuration, dataStoreProperties); } }); } @@ -243,7 +250,7 @@ public class ShardManager extends AbstractUntypedActor { ShardIdentifier shardId = getShardIdentifier(memberName, shardName); Map peerAddresses = getPeerAddresses(shardName); ActorRef actor = getContext() - .actorOf(Shard.props(shardId, peerAddresses), + .actorOf(Shard.props(shardId, peerAddresses, dataStoreProperties), shardId.toString()); localShardActorNames.add(shardId.toString()); localShards.put(shardName, new ShardInformation(shardName, actor, peerAddresses)); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java index 87a621f9d3..592bc49d9e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java @@ -1,6 +1,7 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_provider; import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; public class DistributedConfigDataStoreProviderModule extends org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedConfigDataStoreProviderModule { @@ -25,8 +26,10 @@ public class DistributedConfigDataStoreProviderModule extends @Override public java.lang.AutoCloseable createInstance() { - return DistributedDataStoreFactory - .createInstance("config", getConfigSchemaServiceDependency()); + return DistributedDataStoreFactory.createInstance("config", getConfigSchemaServiceDependency(), + InMemoryDOMDataStoreConfigProperties.create(getMaxShardDataChangeExecutorPoolSize(), + getMaxShardDataChangeExecutorQueueSize(), + getMaxShardDataChangeListenerQueueSize())); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java index 6af2748a8f..9eb72d64d0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java @@ -1,6 +1,7 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_provider; import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties; public class DistributedOperationalDataStoreProviderModule extends org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModule { @@ -25,8 +26,11 @@ public class DistributedOperationalDataStoreProviderModule extends @Override public java.lang.AutoCloseable createInstance() { - return DistributedDataStoreFactory - .createInstance("operational", getOperationalSchemaServiceDependency()); + return DistributedDataStoreFactory.createInstance("operational", + getOperationalSchemaServiceDependency(), + InMemoryDOMDataStoreConfigProperties.create(getMaxShardDataChangeExecutorPoolSize(), + getMaxShardDataChangeExecutorQueueSize(), + getMaxShardDataChangeListenerQueueSize())); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang index 6f355cbe63..ecb823e624 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang @@ -41,28 +41,64 @@ module distributed-datastore-provider { case distributed-config-datastore-provider { when "/config:modules/config:module/config:type = 'distributed-config-datastore-provider'"; container config-schema-service { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity sal:schema-service; - } - } - } + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:schema-service; + } + } + } + + leaf max-shard-data-change-executor-queue-size { + default 1000; + type uint16; + description "The maximum queue size for each shard's data store data change notification executor."; + } + + leaf max-shard-data-change-executor-pool-size { + default 20; + type uint16; + description "The maximum thread pool size for each shard's data store data change notification executor."; + } + + leaf max-shard-data-change-listener-queue-size { + default 1000; + type uint16; + description "The maximum queue size for each shard's data store data change listeners."; + } } } // Augments the 'configuration' choice node under modules/module. - augment "/config:modules/config:module/config:configuration" { - case distributed-operational-datastore-provider { - when "/config:modules/config:module/config:type = 'distributed-operational-datastore-provider'"; + augment "/config:modules/config:module/config:configuration" { + case distributed-operational-datastore-provider { + when "/config:modules/config:module/config:type = 'distributed-operational-datastore-provider'"; container operational-schema-service { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity sal:schema-service; - } - } - } + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:schema-service; + } + } + } + + leaf max-shard-data-change-executor-queue-size { + default 1000; + type uint16; + description "The maximum queue size for each shard's data store data change notification executor."; + } + + leaf max-shard-data-change-executor-pool-size { + default 20; + type uint16; + description "The maximum thread pool size for each shard's data store data change notification executor."; + } + + leaf max-shard-data-change-listener-queue-size { + default 1000; + type uint16; + description "The maximum queue size for each shard's data store data change listeners."; + } } } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java index 319451f8f0..036b00a4c9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java @@ -58,7 +58,7 @@ public class BasicIntegrationTest extends AbstractActorTest { ShardIdentifier.builder().memberName("member-1") .shardName("inventory").type("config").build(); - final Props props = Shard.props(identifier, Collections.EMPTY_MAP); + final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null); final ActorRef shard = getSystem().actorOf(props); new Within(duration("5 seconds")) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java index fc527b6bff..49408b7410 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java @@ -72,7 +72,7 @@ public class DistributedDataStoreIntegrationTest { protected void run() { try { final DistributedDataStore distributedDataStore = - new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration); + new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration, null); distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext()); @@ -154,7 +154,7 @@ public class DistributedDataStoreIntegrationTest { try { final DistributedDataStore distributedDataStore = new DistributedDataStore(getSystem(), "config", - new MockClusterWrapper(), configuration); + new MockClusterWrapper(), configuration, null); distributedDataStore.onGlobalContextUpdated( SchemaContextHelper.full()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java index 406f0ffd9e..69590e62fb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java @@ -68,7 +68,7 @@ public class DistributedDataStoreTest extends AbstractActorTest{ ActorSystem actorSystem = mock(ActorSystem.class); new DistributedDataStore(actorSystem, "config", - mock(ClusterWrapper.class), mock(Configuration.class)); + mock(ClusterWrapper.class), mock(Configuration.class), null); verify(actorSystem).actorOf(any(Props.class), eq("shardmanager-config")); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java index e9ad450ed8..499b4e1f31 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java @@ -42,7 +42,7 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), null); final TestActorRef subject = TestActorRef.create(system, props); @@ -66,7 +66,7 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), null); final TestActorRef subject = TestActorRef.create(system, props); @@ -89,7 +89,7 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), null); final TestActorRef subject = TestActorRef.create(system, props); @@ -124,7 +124,7 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", mockClusterWrapper, - new MockConfiguration()); + new MockConfiguration(), null); final TestActorRef subject = TestActorRef.create(system, props); @@ -158,7 +158,7 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), null); final TestActorRef subject = TestActorRef.create(system, props); @@ -196,7 +196,7 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), null); final TestActorRef subject = TestActorRef.create(system, props); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index 0d86ffb844..7740b8e667 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -40,7 +40,7 @@ public class ShardTest extends AbstractActorTest { ShardIdentifier.builder().memberName("member-1") .shardName("inventory").type("config").build(); - final Props props = Shard.props(identifier, Collections.EMPTY_MAP); + final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null); final ActorRef subject = getSystem().actorOf(props, "testCreateTransactionChain"); @@ -96,7 +96,7 @@ public class ShardTest extends AbstractActorTest { ShardIdentifier.builder().memberName("member-1") .shardName("inventory").type("config").build(); - final Props props = Shard.props(identifier, Collections.EMPTY_MAP); + final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null); final ActorRef subject = getSystem().actorOf(props, "testRegisterChangeListener"); @@ -154,7 +154,7 @@ public class ShardTest extends AbstractActorTest { ShardIdentifier.builder().memberName("member-1") .shardName("inventory").type("config").build(); - final Props props = Shard.props(identifier, Collections.EMPTY_MAP); + final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null); final ActorRef subject = getSystem().actorOf(props, "testCreateTransaction"); @@ -216,7 +216,7 @@ public class ShardTest extends AbstractActorTest { .shardName("inventory").type("config").build(); peerAddresses.put(identifier, null); - final Props props = Shard.props(identifier, peerAddresses); + final Props props = Shard.props(identifier, peerAddresses, null); final ActorRef subject = getSystem().actorOf(props, "testPeerAddressResolved"); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java index 02ceee82e0..2c23afca12 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java @@ -60,7 +60,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { throws Throwable { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, TestModel.createTestContext()); @@ -95,7 +95,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { throws Throwable { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); @@ -129,7 +129,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { throws Throwable { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); @@ -164,7 +164,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard, TestModel.createTestContext()); @@ -203,7 +203,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); @@ -241,7 +241,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); @@ -279,7 +279,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = - getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); @@ -308,6 +308,4 @@ public class ShardTransactionFailureTest extends AbstractActorTest { } - - } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java index 78895b2366..8f5d0c28d6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java @@ -62,7 +62,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testReadData"); @@ -104,7 +104,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadDataWhenDataNotFound() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props( store.newReadOnlyTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testReadDataWhenDataNotFound"); @@ -147,7 +147,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveDataExistsPositive() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testDataExistsPositive"); @@ -189,7 +189,8 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveDataExistsNegative() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, + Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext); final ActorRef subject = getSystem().actorOf(props, "testDataExistsNegative"); @@ -266,7 +267,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveWriteData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = @@ -306,7 +307,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveMergeData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext); final ActorRef subject = @@ -347,7 +348,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveDeleteData() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props( store.newWriteOnlyTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = @@ -386,7 +387,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadyTransaction() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props( store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = @@ -424,7 +425,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveCloseTransaction() throws Exception { new JavaTestKit(getSystem()) {{ - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext()); final ActorRef subject = @@ -479,7 +480,7 @@ public class ShardTransactionTest extends AbstractActorTest { public void testNegativePerformingWriteOperationOnReadTransaction() throws Exception { try { - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP)); + final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null)); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, TestModel.createTestContext()); final TestActorRef subject = TestActorRef.apply(props,getSystem()); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java index 948f3c8d8b..8664e8910b 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java @@ -16,8 +16,6 @@ import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFac import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; -import org.opendaylight.yangtools.util.PropertyUtils; - import com.google.common.collect.ImmutableMap; /** @@ -26,17 +24,6 @@ import com.google.common.collect.ImmutableMap; public final class DomInmemoryDataBrokerModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomInmemoryDataBrokerModule { - private static final String FUTURE_CALLBACK_EXECUTOR_MAX_QUEUE_SIZE_PROP = - "mdsal.datastore-future-callback-queue.size"; - private static final int DEFAULT_FUTURE_CALLBACK_EXECUTOR_MAX_QUEUE_SIZE = 1000; - - private static final String FUTURE_CALLBACK_EXECUTOR_MAX_POOL_SIZE_PROP = - "mdsal.datastore-future-callback-pool.size"; - private static final int DEFAULT_FUTURE_CALLBACK_EXECUTOR_MAX_POOL_SIZE = 20; - private static final String COMMIT_EXECUTOR_MAX_QUEUE_SIZE_PROP = - "mdsal.datastore-commit-queue.size"; - private static final int DEFAULT_COMMIT_EXECUTOR_MAX_QUEUE_SIZE = 5000; - public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); @@ -81,9 +68,7 @@ public final class DomInmemoryDataBrokerModule extends * system it's running on. */ ExecutorService commitExecutor = SpecialExecutors.newBoundedSingleThreadExecutor( - PropertyUtils.getIntSystemProperty( - COMMIT_EXECUTOR_MAX_QUEUE_SIZE_PROP, - DEFAULT_COMMIT_EXECUTOR_MAX_QUEUE_SIZE), "WriteTxCommit"); + getMaxDataBrokerCommitQueueSize(), "WriteTxCommit"); /* * We use an executor for commit ListenableFuture callbacks that favors reusing available @@ -94,12 +79,8 @@ public final class DomInmemoryDataBrokerModule extends * reached, subsequent submitted tasks will block the caller. */ Executor listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool( - PropertyUtils.getIntSystemProperty( - FUTURE_CALLBACK_EXECUTOR_MAX_POOL_SIZE_PROP, - DEFAULT_FUTURE_CALLBACK_EXECUTOR_MAX_POOL_SIZE), - PropertyUtils.getIntSystemProperty( - FUTURE_CALLBACK_EXECUTOR_MAX_QUEUE_SIZE_PROP, - DEFAULT_FUTURE_CALLBACK_EXECUTOR_MAX_QUEUE_SIZE), "CommitFutures"); + getMaxDataBrokerFutureCallbackPoolSize(), getMaxDataBrokerFutureCallbackQueueSize(), + "CommitFutures"); DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, new DeadlockDetectingListeningExecutorService(commitExecutor, diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang b/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang index a0ee5c50c9..b1df7efcdb 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang +++ b/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang @@ -108,6 +108,24 @@ module opendaylight-sal-dom-broker-impl { } } } + + leaf max-data-broker-future-callback-queue-size { + default 1000; + type uint16; + description "The maximum queue size for the data broker's commit future callback executor."; + } + + leaf max-data-broker-future-callback-pool-size { + default 20; + type uint16; + description "The maximum thread pool size for the data broker's commit future callback executor."; + } + + leaf max-data-broker-commit-queue-size { + default 5000; + type uint16; + description "The maximum queue size for the data broker's commit executor."; + } } } 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 39a448ff6c..fd1627c6f9 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.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory; public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModule { @@ -19,7 +20,9 @@ public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.cont @Override public java.lang.AutoCloseable createInstance() { - return InMemoryDOMDataStoreFactory.create("DOM-CFG", getSchemaServiceDependency()); + return InMemoryDOMDataStoreFactory.create("DOM-CFG", getSchemaServiceDependency(), + InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(), + getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize())); } } 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 615fe0211c..7026b03022 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.dom.store.impl.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory; public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModule { @@ -19,7 +20,9 @@ public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight @Override public java.lang.AutoCloseable createInstance() { - return InMemoryDOMDataStoreFactory.create("DOM-OPER", getOperationalSchemaServiceDependency()); + return InMemoryDOMDataStoreFactory.create("DOM-OPER", getOperationalSchemaServiceDependency(), + InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(), + getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize())); } } 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 b61b367103..d0d3fe9e6a 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 @@ -21,7 +21,6 @@ import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedEx import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction.TransactionReadyPrototype; import org.opendaylight.yangtools.util.ExecutorServiceUtil; -import org.opendaylight.yangtools.util.PropertyUtils; import org.opendaylight.yangtools.util.concurrent.NotificationManager; import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager; import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException; @@ -85,11 +84,6 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch } }; - private static final String DCL_NOTIFICATION_MGR_MAX_QUEUE_SIZE_PROP = - "mdsal.datastore-dcl-notification-queue.size"; - - private static final int DEFAULT_DCL_NOTIFICATION_MGR_MAX_QUEUE_SIZE = 1000; - private final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(); private final ListenerTree listenerTree = ListenerTree.create(); private final AtomicLong txCounter = new AtomicLong(0); @@ -104,17 +98,21 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch public InMemoryDOMDataStore(final String name, final ListeningExecutorService listeningExecutor, final ExecutorService dataChangeListenerExecutor) { + this(name, listeningExecutor, dataChangeListenerExecutor, + InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE); + } + + public InMemoryDOMDataStore(final String name, final ListeningExecutorService listeningExecutor, + final ExecutorService dataChangeListenerExecutor, int maxDataChangeListenerQueueSize) { this.name = Preconditions.checkNotNull(name); this.listeningExecutor = Preconditions.checkNotNull(listeningExecutor); this.dataChangeListenerExecutor = Preconditions.checkNotNull(dataChangeListenerExecutor); - int maxDCLQueueSize = PropertyUtils.getIntSystemProperty( - DCL_NOTIFICATION_MGR_MAX_QUEUE_SIZE_PROP, DEFAULT_DCL_NOTIFICATION_MGR_MAX_QUEUE_SIZE ); - dataChangeListenerNotificationManager = new QueuedNotificationManager<>(this.dataChangeListenerExecutor, - DCL_NOTIFICATION_MGR_INVOKER, maxDCLQueueSize, "DataChangeListenerQueueMgr"); + DCL_NOTIFICATION_MGR_INVOKER, maxDataChangeListenerQueueSize, + "DataChangeListenerQueueMgr"); } @Override diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java new file mode 100644 index 0000000000..6e451ba12b --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.md.sal.dom.store.impl; + +/** + * Holds configuration properties when creating an {@link InMemoryDOMDataStore} instance via the + * {@link InMemoryDOMDataStoreFactory} + * + * @author Thomas Pantelis + * @see InMemoryDOMDataStoreFactory + */ +public class InMemoryDOMDataStoreConfigProperties { + + public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000; + public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20; + public static final int DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE = 1000; + + private static final InMemoryDOMDataStoreConfigProperties DEFAULT = + create(DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, + DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, + DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE); + + private final int maxDataChangeExecutorQueueSize; + private final int maxDataChangeExecutorPoolSize; + private final int maxDataChangeListenerQueueSize; + + /** + * Constructs an instance with the given property values. + * + * @param maxDataChangeExecutorPoolSize + * maximum thread pool size for the data change notification executor. + * @param maxDataChangeExecutorQueueSize + * maximum queue size for the data change notification executor. + * @param maxDataChangeListenerQueueSize + * maximum queue size for the data change listeners. + */ + public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize, + int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) { + return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize, + maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize); + } + + /** + * Returns the InMemoryDOMDataStoreConfigProperties instance with default values. + */ + public static InMemoryDOMDataStoreConfigProperties getDefault() { + return DEFAULT; + } + + private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize, + int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) { + this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize; + this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize; + this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize; + } + + /** + * Returns the maximum queue size for the data change notification executor. + */ + public int getMaxDataChangeExecutorQueueSize() { + return maxDataChangeExecutorQueueSize; + } + + /** + * Returns the maximum thread pool size for the data change notification executor. + */ + public int getMaxDataChangeExecutorPoolSize() { + return maxDataChangeExecutorPoolSize; + } + + /** + * Returns the maximum queue size for the data change listeners. + */ + public int getMaxDataChangeListenerQueueSize() { + return maxDataChangeListenerQueueSize; + } +} 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 c853a132de..a3512743ed 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 @@ -15,7 +15,6 @@ import javax.annotation.Nullable; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; -import org.opendaylight.yangtools.util.PropertyUtils; import com.google.common.util.concurrent.MoreExecutors; /** @@ -25,43 +24,46 @@ import com.google.common.util.concurrent.MoreExecutors; */ public final class InMemoryDOMDataStoreFactory { - private static final String DCL_EXECUTOR_MAX_QUEUE_SIZE_PROP = - "mdsal.datastore-dcl-notification-queue.size"; - private static final int DEFAULT_DCL_EXECUTOR_MAX_QUEUE_SIZE = 1000; - - private static final String DCL_EXECUTOR_MAX_POOL_SIZE_PROP = - "mdsal.datastore-dcl-notification-pool.size"; - private static final int DEFAULT_DCL_EXECUTOR_MAX_POOL_SIZE = 20; - private InMemoryDOMDataStoreFactory() { } + public static InMemoryDOMDataStore create(final String name, + @Nullable final SchemaService schemaService) { + return create(name, schemaService, null); + } + /** * 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 SchemaService schemaService) { + @Nullable final SchemaService schemaService, + @Nullable final InMemoryDOMDataStoreConfigProperties properties) { + + InMemoryDOMDataStoreConfigProperties actualProperties = properties; + if(actualProperties == null) { + actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault(); + } // For DataChangeListener notifications we use an executor that provides the fastest // task execution time to get higher throughput as DataChangeListeners typically provide // much of the business logic for a data model. If the executor queue size limit is reached, // subsequent submitted notifications will block the calling thread. - int dclExecutorMaxQueueSize = PropertyUtils.getIntSystemProperty( - DCL_EXECUTOR_MAX_QUEUE_SIZE_PROP, DEFAULT_DCL_EXECUTOR_MAX_QUEUE_SIZE); - int dclExecutorMaxPoolSize = PropertyUtils.getIntSystemProperty( - DCL_EXECUTOR_MAX_POOL_SIZE_PROP, DEFAULT_DCL_EXECUTOR_MAX_POOL_SIZE); + int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize(); + int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize(); ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool( dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL" ); InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), - dataChangeListenerExecutor); + dataChangeListenerExecutor, actualProperties.getMaxDataChangeListenerQueueSize()); if(schemaService != null) { schemaService.registerSchemaContextListener(dataStore); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang index d4f57b53fe..1292d3772a 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang @@ -41,34 +41,68 @@ module opendaylight-inmemory-datastore-provider { when "/config:modules/config:module/config:type = 'inmemory-config-datastore-provider'"; container schema-service { - uses config:service-ref { + uses config:service-ref { refine type { mandatory false; config:required-identity sal:schema-service; } - } + } + } + + leaf max-data-change-executor-queue-size { + default 1000; + type uint16; + description "The maximum queue size for the data change notification executor."; + } + + leaf max-data-change-executor-pool-size { + default 20; + type uint16; + description "The maximum thread pool size for the data change notification executor."; + } + + leaf max-data-change-listener-queue-size { + default 1000; + type uint16; + description "The maximum queue size for the data change listeners."; } } } + // Augments the 'configuration' choice node under modules/module. + augment "/config:modules/config:module/config:configuration" { + case inmemory-operational-datastore-provider { + when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'"; + // Yang does not allow two cases from same namespaces with same children + // Schema-service dependency renamed to operational-schema-service + // to prevent conflict with schema-service container from inmemory-config-datastore-provider + container operational-schema-service { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:schema-service; + } + } + } + + leaf max-data-change-executor-queue-size { + default 1000; + type uint16; + description "The maximum queue size for the data change notification executor."; + } - // Augments the 'configuration' choice node under modules/module. - augment "/config:modules/config:module/config:configuration" { - case inmemory-operational-datastore-provider { - when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'"; + leaf max-data-change-executor-pool-size { + default 20; + type uint16; + description "The maximum thread pool size for the data change notification executor."; + } - // Yang does not allow two cases from same namespaces with same children - // Schema-service dependency renamed to operational-schema-service - // to prevent conflict with schema-service container from inmemory-config-datastore-provider - container operational-schema-service { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity sal:schema-service; - } - } - } + leaf max-data-change-listener-queue-size { + default 1000; + type uint16; + description "The maximum queue size for the data change listeners."; } } + } } -- 2.36.6