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() {
28 * @deprecated Use {@link #create(String, DOMSchemaService)} instead.
31 public static InMemoryDOMDataStore create(final String name,
32 @Nullable final SchemaService schemaService) {
33 return create(name, (DOMSchemaService)schemaService);
36 public static InMemoryDOMDataStore create(final String name,
37 @Nullable final DOMSchemaService schemaService) {
38 return create(name, schemaService, null);
42 * Creates an InMemoryDOMDataStore instance.
44 * @param name the name of the data store
45 * @param schemaService the SchemaService to which to register the data store.
46 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
47 * default property values are used.
48 * @return an InMemoryDOMDataStore instance
50 * @deprecated Use {@link #create(String, DOMSchemaService, InMemoryDOMDataStoreConfigProperties)} instead.
53 public static InMemoryDOMDataStore create(final String name,
54 @Nullable final SchemaService schemaService,
55 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
56 return create(name, (DOMSchemaService) schemaService, properties);
60 * Creates an InMemoryDOMDataStore instance.
62 * @param name the name of the data store
63 * @param schemaService the SchemaService to which to register the data store.
64 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
65 * default property values are used.
66 * @return an InMemoryDOMDataStore instance
68 public static InMemoryDOMDataStore create(final String name,
69 @Nullable final DOMSchemaService schemaService,
70 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
71 return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties);
75 * Creates an InMemoryDOMDataStore instance.
77 * @param name the name of the data store
78 * @param schemaService the SchemaService to which to register the data store.
79 * @param debugTransactions enable transaction debugging
80 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
81 * default property values are used.
82 * @return an InMemoryDOMDataStore instance
84 * @deprecated Use {@link #create(String, LogicalDatastoreType, SchemaService, boolean, InMemoryDOMDataStoreConfigProperties)}
88 public static InMemoryDOMDataStore create(final String name,
89 @Nullable final SchemaService schemaService, final boolean debugTransactions,
90 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
91 return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, debugTransactions, properties);
95 * Creates an InMemoryDOMDataStore instance.
97 * @param name the name of the data store
98 * @param type Data store type
99 * @param schemaService the SchemaService to which to register the data store.
100 * @param debugTransactions enable transaction debugging
101 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
102 * default property values are used.
103 * @return an InMemoryDOMDataStore instance
105 * @deprecated Use {@link #create(String, LogicalDatastoreType, DOMSchemaService, boolean,
106 * InMemoryDOMDataStoreConfigProperties)} instead.
109 public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
110 @Nullable final SchemaService schemaService, final boolean debugTransactions,
111 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
112 return create(name, type, (DOMSchemaService) schemaService, debugTransactions, properties);
116 * Creates an InMemoryDOMDataStore instance.
118 * @param name the name of the data store
119 * @param type Data store type
120 * @param schemaService the SchemaService to which to register the data store.
121 * @param debugTransactions enable transaction debugging
122 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
123 * default property values are used.
124 * @return an InMemoryDOMDataStore instance
126 public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
127 @Nullable final DOMSchemaService schemaService, final boolean debugTransactions,
128 @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
130 InMemoryDOMDataStoreConfigProperties actualProperties = properties;
131 if (actualProperties == null) {
132 actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault();
135 // For DataChangeListener notifications we use an executor that provides the fastest
136 // task execution time to get higher throughput as DataChangeListeners typically provide
137 // much of the business logic for a data model. If the executor queue size limit is reached,
138 // subsequent submitted notifications will block the calling thread.
139 int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize();
140 int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize();
142 ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
143 dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL" );
145 final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor,
146 actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions);
148 if (schemaService != null) {
149 schemaService.registerSchemaContextListener(dataStore);