2 * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl;
10 import java.util.concurrent.ExecutorService;
11 import javax.annotation.Nullable;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
17 * A factory for creating InMemoryDOMDataStore instances.
19 * @author Thomas Pantelis
21 public final class InMemoryDOMDataStoreFactory {
23 private InMemoryDOMDataStoreFactory() {
26 public static InMemoryDOMDataStore create(final String name,
27 @Nullable final DOMSchemaService schemaService) {
28 return create(name, schemaService, null);
32 * Creates an InMemoryDOMDataStore instance.
34 * @param name the name of the data store
35 * @param schemaService the SchemaService to which to register the data store.
36 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
37 * default property values are used.
38 * @return an InMemoryDOMDataStore instance
40 public static InMemoryDOMDataStore create(final String name,
41 @Nullable final DOMSchemaService schemaService,
42 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
43 return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties);
47 * Creates an InMemoryDOMDataStore instance.
49 * @param name the name of the data store
50 * @param type Data store type
51 * @param schemaService the SchemaService to which to register the data store.
52 * @param debugTransactions enable transaction debugging
53 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
54 * default property values are used.
55 * @return an InMemoryDOMDataStore instance
57 public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
58 @Nullable final DOMSchemaService schemaService, final boolean debugTransactions,
59 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
61 InMemoryDOMDataStoreConfigProperties actualProperties = properties;
62 if (actualProperties == null) {
63 actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault();
66 // For DataChangeListener notifications we use an executor that provides the fastest
67 // task execution time to get higher throughput as DataChangeListeners typically provide
68 // much of the business logic for a data model. If the executor queue size limit is reached,
69 // subsequent submitted notifications will block the calling thread.
70 int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize();
71 int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize();
73 ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
74 dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL", InMemoryDOMDataStore.class);
76 final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor,
77 actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions);
79 if (schemaService != null) {
80 schemaService.registerSchemaContextListener(dataStore);