Merge "Bug 8223: Fixed incorrect enable-flow-removed-notification check."
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / OpenFlowPluginConfigurationService.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.api.openflow;
10
11 import com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13 import javax.annotation.Nonnull;
14
15 /**
16  * Manages OpenFlowPlugin configuration
17  */
18 public interface OpenFlowPluginConfigurationService {
19
20     /**
21      * Enum of property keys. All keys from OpenFlowPlugin configuration file are parsed to this enum.
22      * Each enum value represents one working configuration key in format
23      * ENUM.name().toLowerCase().replace('_', '-'), so for example PropertyType.IS_STATISTICS_POLLING_ON
24      * represents 'is-statistics-polling-on' configuration key.
25      */
26     enum PropertyType {
27         /**
28          * Is statistics polling on property type.
29          */
30         IS_STATISTICS_POLLING_ON,
31         /**
32          * Barrier count limit property type.
33          */
34         BARRIER_COUNT_LIMIT,
35         /**
36          * Barrier interval timeout limit property type.
37          */
38         BARRIER_INTERVAL_TIMEOUT_LIMIT,
39         /**
40          * Echo reply timeout property type.
41          */
42         ECHO_REPLY_TIMEOUT,
43         /**
44          * Enable flow removed notification property type.
45          */
46         ENABLE_FLOW_REMOVED_NOTIFICATION,
47         /**
48          * Skip table features property type.
49          */
50         SKIP_TABLE_FEATURES,
51         /**
52          * Basic timer delay property type.
53          */
54         BASIC_TIMER_DELAY,
55         /**
56          * Maximum timer delay property type.
57          */
58         MAXIMUM_TIMER_DELAY,
59         /**
60          * Switch features mandatory property type.
61          */
62         SWITCH_FEATURES_MANDATORY,
63         /**
64          * Is statistics rpc enabled property type.
65          */
66         @Deprecated
67         IS_STATISTICS_RPC_ENABLED,
68         /**
69          * Use single layer serialization property type.
70          */
71         USE_SINGLE_LAYER_SERIALIZATION,
72         /**
73          * Rpc requests quota property type.
74          */
75         RPC_REQUESTS_QUOTA,
76         /**
77          * Global notification quota property type.
78          */
79         GLOBAL_NOTIFICATION_QUOTA,
80         /**
81          * Thread pool min threads property type.
82          */
83         THREAD_POOL_MIN_THREADS,
84         /**
85          * Thread pool max threads property type.
86          */
87         THREAD_POOL_MAX_THREADS,
88         /**
89          * Thread pool timeout property type.
90          */
91         THREAD_POOL_TIMEOUT;
92
93         private static final Map<String, PropertyType> KEY_VALUE_MAP;
94
95         /**
96          * Get property type from property key
97          *
98          * @param key the property key
99          * @return the property type
100          */
101         public static PropertyType forValue(final String key) {
102             return KEY_VALUE_MAP.get(key);
103         }
104
105         static {
106             final PropertyType[] values = values();
107             final ImmutableMap.Builder<String, PropertyType> builder = ImmutableMap.builder();
108
109             for (final PropertyType value : values) {
110                 builder.put(value.toString(), value);
111             }
112
113             KEY_VALUE_MAP = builder.build();
114         }
115
116         /**
117          * Converts enum name to property key
118          *
119          * @return the property key
120          */
121         @Override
122         public String toString() {
123             return this.name().toLowerCase().replace('_', '-');
124         }
125
126     }
127
128     /**
129      * Parses key-value pairs of properties read from OpenFlowPlugin configuration file and processes them
130      *
131      * @param properties properties
132      */
133     void update(@Nonnull Map<String,Object> properties);
134
135     /**
136      * Parse and process single property key-value pair
137      *
138      * @see org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginConfigurationService.PropertyType
139      * @param key   property type
140      * @param value property value
141      */
142     void updateProperty(@Nonnull PropertyType key, @Nonnull Object value);
143
144 }