Merge "Bug 1430: Obtain config params from config system"
[controller.git] / opendaylight / md-sal / sal-inmemory-datastore / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / InMemoryDOMDataStoreConfigProperties.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
9 package org.opendaylight.controller.md.sal.dom.store.impl;
10
11 /**
12  * Holds configuration properties when creating an {@link InMemoryDOMDataStore} instance via the
13  * {@link InMemoryDOMDataStoreFactory}
14  *
15  * @author Thomas Pantelis
16  * @see InMemoryDOMDataStoreFactory
17  */
18 public class InMemoryDOMDataStoreConfigProperties {
19
20     public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
21     public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
22     public static final int DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE = 1000;
23
24     private static final InMemoryDOMDataStoreConfigProperties DEFAULT =
25             create(DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE,
26                     DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE,
27                     DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE);
28
29     private final int maxDataChangeExecutorQueueSize;
30     private final int maxDataChangeExecutorPoolSize;
31     private final int maxDataChangeListenerQueueSize;
32
33     /**
34      * Constructs an instance with the given property values.
35      *
36      * @param maxDataChangeExecutorPoolSize
37      *            maximum thread pool size for the data change notification executor.
38      * @param maxDataChangeExecutorQueueSize
39      *            maximum queue size for the data change notification executor.
40      * @param maxDataChangeListenerQueueSize
41      *            maximum queue size for the data change listeners.
42      */
43     public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
44             int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) {
45         return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
46                 maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize);
47     }
48
49     /**
50      * Returns the InMemoryDOMDataStoreConfigProperties instance with default values.
51      */
52     public static InMemoryDOMDataStoreConfigProperties getDefault() {
53         return DEFAULT;
54     }
55
56     private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize,
57             int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) {
58         this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize;
59         this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize;
60         this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize;
61     }
62
63     /**
64      * Returns the maximum queue size for the data change notification executor.
65      */
66     public int getMaxDataChangeExecutorQueueSize() {
67         return maxDataChangeExecutorQueueSize;
68     }
69
70     /**
71      * Returns the maximum thread pool size for the data change notification executor.
72      */
73     public int getMaxDataChangeExecutorPoolSize() {
74         return maxDataChangeExecutorPoolSize;
75     }
76
77     /**
78      * Returns the maximum queue size for the data change listeners.
79      */
80     public int getMaxDataChangeListenerQueueSize() {
81         return maxDataChangeListenerQueueSize;
82     }
83 }