Proxy over MDSAL-provided IMDS
[controller.git] / opendaylight / md-sal / sal-inmemory-datastore / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / InMemoryDOMDataStoreFactory.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl;
9
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;
15
16 /**
17  * A factory for creating InMemoryDOMDataStore instances.
18  *
19  * @author Thomas Pantelis
20  *
21  * @deprecated Use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreFactory} instead.
22  */
23 @Deprecated
24 public final class InMemoryDOMDataStoreFactory {
25
26     private InMemoryDOMDataStoreFactory() {
27     }
28
29     public static InMemoryDOMDataStore create(final String name,
30             @Nullable final DOMSchemaService schemaService) {
31         return create(name, schemaService, null);
32     }
33
34     /**
35      * Creates an InMemoryDOMDataStore instance.
36      *
37      * @param name the name of the data store
38      * @param schemaService the SchemaService to which to register the data store.
39      * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
40      *                   default property values are used.
41      * @return an InMemoryDOMDataStore instance
42      */
43     public static InMemoryDOMDataStore create(final String name,
44             @Nullable final DOMSchemaService schemaService,
45             @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
46         return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties);
47     }
48
49     /**
50      * Creates an InMemoryDOMDataStore instance.
51      *
52      * @param name the name of the data store
53      * @param type Data store type
54      * @param schemaService the SchemaService to which to register the data store.
55      * @param debugTransactions enable transaction debugging
56      * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
57      *                   default property values are used.
58      * @return an InMemoryDOMDataStore instance
59      */
60     public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
61             @Nullable final DOMSchemaService schemaService, final boolean debugTransactions,
62             @Nullable final InMemoryDOMDataStoreConfigProperties properties) {
63
64         InMemoryDOMDataStoreConfigProperties actualProperties = properties;
65         if (actualProperties == null) {
66             actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault();
67         }
68
69         // For DataChangeListener notifications we use an executor that provides the fastest
70         // task execution time to get higher throughput as DataChangeListeners typically provide
71         // much of the business logic for a data model. If the executor queue size limit is reached,
72         // subsequent submitted notifications will block the calling thread.
73         int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize();
74         int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize();
75
76         ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
77                 dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL", InMemoryDOMDataStore.class);
78
79         final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor,
80                 actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions);
81
82         if (schemaService != null) {
83             schemaService.registerSchemaContextListener(dataStore);
84         }
85
86         return dataStore;
87     }
88 }