X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fstore%2Finmemory%2FInMemoryDOMDataStoreFactory.java;h=0db38fe3aa3df5c1188640391edf05c15507544c;hb=819aef314ba0fc931ca46c0f39d4f70ff49d3540;hp=947137c43faff84549be83a2a1283ee0a740166b;hpb=8d19626640b8f6cab9ed3e0f9908fa3c416956e5;p=mdsal.git diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStoreFactory.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStoreFactory.java index 947137c43f..0db38fe3aa 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStoreFactory.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataStoreFactory.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; import java.util.concurrent.ExecutorService; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; @@ -17,62 +18,36 @@ import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; * * @author Thomas Pantelis */ +@NonNullByDefault public final class InMemoryDOMDataStoreFactory { private InMemoryDOMDataStoreFactory() { } - public static InMemoryDOMDataStore create(final String name, - @Nullable final DOMSchemaService schemaService) { - return create(name, schemaService, null); - } - /** - * Creates an InMemoryDOMDataStore instance. + * Creates an InMemoryDOMDataStore instance with default properties. * * @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, schemaService, false, properties); + public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService) { + return create(name, InMemoryDOMDataStoreConfigProperties.getDefault(), schemaService); } /** * Creates an InMemoryDOMDataStore instance. * * @param name the name of the data store + * @param properties configuration properties for the InMemoryDOMDataStore instance. * @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, - @Nullable final DOMSchemaService schemaService, final boolean debugTransactions, - @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 = actualProperties.getMaxDataChangeExecutorQueueSize(); - int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize(); - - ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool( - dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL", InMemoryDOMDataStore.class); - + public static InMemoryDOMDataStore create(final String name, final InMemoryDOMDataStoreConfigProperties properties, + @Nullable final DOMSchemaService schemaService) { + final ExecutorService dataChangeListenerExecutor = createExecutorService(name, properties); final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, dataChangeListenerExecutor, - actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions); + properties.getMaxDataChangeListenerQueueSize(), properties.getDebugTransactions()); if (schemaService != null) { schemaService.registerSchemaContextListener(dataStore); @@ -80,4 +55,15 @@ public final class InMemoryDOMDataStoreFactory { return dataStore; } + + private static ExecutorService createExecutorService(final String name, + final InMemoryDOMDataStoreConfigProperties props) { + // 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. + return SpecialExecutors.newBlockingBoundedFastThreadPool( + props.getMaxDataChangeExecutorPoolSize(), props.getMaxDataChangeExecutorQueueSize(), + name + "-DCL", InMemoryDOMDataStoreFactory.class); + } }