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.controller.sal.core.api.model.SchemaService;
14 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
15 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
18 * A factory for creating InMemoryDOMDataStore instances.
20 * @author Thomas Pantelis
22 public final class InMemoryDOMDataStoreFactory {
24 private InMemoryDOMDataStoreFactory() {
30 * @deprecated Use {@link #create(String, DOMSchemaService)} instead.
33 public static InMemoryDOMDataStore create(final String name,
34 @Nullable final SchemaService schemaService) {
35 return create(name, (DOMSchemaService)schemaService);
38 public static InMemoryDOMDataStore create(final String name,
39 @Nullable final DOMSchemaService schemaService) {
40 return create(name, schemaService, null);
44 * Creates an InMemoryDOMDataStore instance.
46 * @param name the name of the data store
47 * @param schemaService the SchemaService to which to register the data store.
48 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
49 * default property values are used.
50 * @return an InMemoryDOMDataStore instance
52 * @deprecated Use {@link #create(String, DOMSchemaService, InMemoryDOMDataStoreConfigProperties)} instead.
55 public static InMemoryDOMDataStore create(final String name,
56 @Nullable final SchemaService schemaService,
57 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
58 return create(name, (DOMSchemaService) schemaService, properties);
62 * Creates an InMemoryDOMDataStore instance.
64 * @param name the name of the data store
65 * @param schemaService the SchemaService to which to register the data store.
66 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
67 * default property values are used.
68 * @return an InMemoryDOMDataStore instance
70 public static InMemoryDOMDataStore create(final String name,
71 @Nullable final DOMSchemaService schemaService,
72 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
73 return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties);
77 * Creates an InMemoryDOMDataStore instance.
79 * @param name the name of the data store
80 * @param schemaService the SchemaService to which to register the data store.
81 * @param debugTransactions enable transaction debugging
82 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
83 * default property values are used.
84 * @return an InMemoryDOMDataStore instance
86 * @deprecated Use {@link #create(String, LogicalDatastoreType, SchemaService, boolean,
87 * InMemoryDOMDataStoreConfigProperties)} instead.
90 public static InMemoryDOMDataStore create(final String name,
91 @Nullable final SchemaService schemaService, final boolean debugTransactions,
92 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
93 return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, debugTransactions, properties);
97 * Creates an InMemoryDOMDataStore instance.
99 * @param name the name of the data store
100 * @param type Data store type
101 * @param schemaService the SchemaService to which to register the data store.
102 * @param debugTransactions enable transaction debugging
103 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
104 * default property values are used.
105 * @return an InMemoryDOMDataStore instance
107 * @deprecated Use {@link #create(String, LogicalDatastoreType, DOMSchemaService, boolean,
108 * InMemoryDOMDataStoreConfigProperties)} instead.
111 public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
112 @Nullable final SchemaService schemaService, final boolean debugTransactions,
113 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
114 return create(name, type, (DOMSchemaService) schemaService, debugTransactions, properties);
118 * Creates an InMemoryDOMDataStore instance.
120 * @param name the name of the data store
121 * @param type Data store type
122 * @param schemaService the SchemaService to which to register the data store.
123 * @param debugTransactions enable transaction debugging
124 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
125 * default property values are used.
126 * @return an InMemoryDOMDataStore instance
128 public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
129 @Nullable final DOMSchemaService schemaService, final boolean debugTransactions,
130 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
132 InMemoryDOMDataStoreConfigProperties actualProperties = properties;
133 if (actualProperties == null) {
134 actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault();
137 // For DataChangeListener notifications we use an executor that provides the fastest
138 // task execution time to get higher throughput as DataChangeListeners typically provide
139 // much of the business logic for a data model. If the executor queue size limit is reached,
140 // subsequent submitted notifications will block the calling thread.
141 int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize();
142 int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize();
144 ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
145 dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL", InMemoryDOMDataStore.class);
147 final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor,
148 actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions);
150 if (schemaService != null) {
151 schemaService.registerSchemaContextListener(dataStore);