Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Ray Milkey | a412236 | 2015-08-18 15:19:08 -0700 | [diff] [blame] | 16 | package org.onosproject.net.config; |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 0a400ea | 2015-09-04 11:25:03 -0700 | [diff] [blame] | 18 | import com.fasterxml.jackson.databind.JsonNode; |
Thomas Vachuska | e2b7e7e | 2015-05-20 11:11:31 -0700 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 20 | import org.onosproject.event.ListenerService; |
Thomas Vachuska | e2b7e7e | 2015-05-20 11:11:31 -0700 | [diff] [blame] | 21 | |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 22 | import java.util.Set; |
| 23 | |
| 24 | /** |
| 25 | * Service for tracking network configurations which specify how the discovered |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 26 | * network information should be interpreted and how the core or applications |
| 27 | * should act on or configure the network. |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 28 | */ |
Thomas Vachuska | e2b7e7e | 2015-05-20 11:11:31 -0700 | [diff] [blame] | 29 | @Beta |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 30 | public interface NetworkConfigService |
Thomas Vachuska | d894b5d | 2015-07-30 11:59:07 -0700 | [diff] [blame] | 31 | extends ListenerService<NetworkConfigEvent, NetworkConfigListener> { |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 34 | * Returns the set of subject classes for which configuration may be |
| 35 | * available. |
| 36 | * |
| 37 | * @return set of subject classes |
| 38 | */ |
| 39 | Set<Class> getSubjectClasses(); |
| 40 | |
| 41 | /** |
| 42 | * Returns the subject factory with the specified key. |
| 43 | * |
Thomas Vachuska | ea5adc6 | 2015-10-07 11:52:30 -0700 | [diff] [blame] | 44 | * @param subjectClassKey subject class key |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 45 | * @return subject class |
| 46 | */ |
Thomas Vachuska | ea5adc6 | 2015-10-07 11:52:30 -0700 | [diff] [blame] | 47 | SubjectFactory getSubjectFactory(String subjectClassKey); |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Returns the subject factory for the specified class. |
| 51 | * |
| 52 | * @param subjectClass subject class |
Thomas Vachuska | ea5adc6 | 2015-10-07 11:52:30 -0700 | [diff] [blame] | 53 | * @return subject class factory |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 54 | */ |
| 55 | SubjectFactory getSubjectFactory(Class subjectClass); |
| 56 | |
| 57 | /** |
| 58 | * Returns the configuration class with the specified key. |
| 59 | * |
Thomas Vachuska | ea5adc6 | 2015-10-07 11:52:30 -0700 | [diff] [blame] | 60 | * @param subjectClassKey subject class key |
| 61 | * @param configKey subject class name |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 62 | * @return subject class |
| 63 | */ |
Thomas Vachuska | ea5adc6 | 2015-10-07 11:52:30 -0700 | [diff] [blame] | 64 | Class<? extends Config> getConfigClass(String subjectClassKey, String configKey); |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 67 | * Returns the set of subjects for which some configuration is available. |
| 68 | * |
| 69 | * @param subjectClass subject class |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 70 | * @param <S> type of subject |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 71 | * @return set of configured subjects |
| 72 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 73 | <S> Set<S> getSubjects(Class<S> subjectClass); |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Returns the set of subjects for which the specified configuration is |
| 77 | * available. |
| 78 | * |
| 79 | * @param subjectClass subject class |
| 80 | * @param configClass configuration class |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 81 | * @param <S> type of subject |
| 82 | * @param <C> type of configuration |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 83 | * @return set of configured subjects |
| 84 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 85 | <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass); |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Returns all configurations for the specified subject. |
| 89 | * |
| 90 | * @param subject configuration subject |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 91 | * @param <S> type of subject |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 92 | * @return set of configurations |
| 93 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 94 | <S> Set<? extends Config<S>> getConfigs(S subject); |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Returns the configuration for the specified subject and configuration |
| 98 | * class if one is available; null otherwise. |
| 99 | * |
| 100 | * @param subject configuration subject |
| 101 | * @param configClass configuration class |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 102 | * @param <S> type of subject |
| 103 | * @param <C> type of configuration |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 104 | * @return configuration or null if one is not available |
| 105 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 106 | <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass); |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 107 | |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Creates a new configuration for the specified subject and configuration |
| 110 | * class. If one already exists, it is simply returned. |
| 111 | * |
| 112 | * @param subject configuration subject |
| 113 | * @param configClass configuration class |
| 114 | * @param <S> type of subject |
| 115 | * @param <C> type of configuration |
| 116 | * @return configuration or null if one is not available |
| 117 | */ |
| 118 | <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass); |
| 119 | |
| 120 | /** |
| 121 | * Applies configuration for the specified subject and configuration |
Thomas Vachuska | ce0bbb3 | 2015-11-18 16:56:10 -0800 | [diff] [blame] | 122 | * class using the raw JSON node. If configuration already exists, it |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 123 | * will be updated. |
| 124 | * |
| 125 | * @param subject configuration subject |
| 126 | * @param configClass configuration class |
| 127 | * @param json raw JSON node containing the configuration data |
| 128 | * @param <S> type of subject |
| 129 | * @param <C> type of configuration |
| 130 | * @return configuration or null if one is not available |
Thomas Vachuska | ce0bbb3 | 2015-11-18 16:56:10 -0800 | [diff] [blame] | 131 | * @throws IllegalArgumentException if the supplied JSON node contains |
| 132 | * invalid data |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 133 | */ |
| 134 | <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass, |
Thomas Vachuska | 0a400ea | 2015-09-04 11:25:03 -0700 | [diff] [blame] | 135 | JsonNode json); |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
Thomas Vachuska | 6f350ed | 2016-01-08 09:53:03 -0800 | [diff] [blame] | 138 | * Applies configuration for the specified subject and configuration |
| 139 | * key using the raw JSON object. If configuration already exists, it |
| 140 | * will be updated. If the specified configuration key does not yet have |
| 141 | * a registered class associated with it, the configuration will be pending |
| 142 | * and null value will be returned. Once the backing configuration class is |
| 143 | * registered, the configuration will be validated and accepted. |
| 144 | * |
| 145 | * @param subjectClassKey subject class key |
| 146 | * @param subject configuration subject |
| 147 | * @param configKey configuration class key |
| 148 | * @param json raw JSON node containing the configuration data |
| 149 | * @param <S> type of subject |
| 150 | * @param <C> type of configuration |
| 151 | * @return configuration object or null if configuration key does not have |
| 152 | * a registered class yet |
| 153 | * @throws IllegalArgumentException if the supplied JSON node contains |
| 154 | * invalid data |
| 155 | */ |
| 156 | <S, C extends Config<S>> C applyConfig(String subjectClassKey, S subject, |
| 157 | String configKey, JsonNode json); |
| 158 | |
| 159 | /** |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 160 | * Clears any configuration for the specified subject and configuration |
| 161 | * class. If one does not exist, this call has no effect. |
| 162 | * |
| 163 | * @param subject configuration subject |
| 164 | * @param configClass configuration class |
| 165 | * @param <S> type of subject |
| 166 | * @param <C> type of configuration |
| 167 | */ |
| 168 | <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass); |
| 169 | |
Thomas Vachuska | 6f350ed | 2016-01-08 09:53:03 -0800 | [diff] [blame] | 170 | /** |
| 171 | * Clears any configuration for the specified subject and configuration |
| 172 | * key. If one does not exist, this call has no effect. |
| 173 | * |
Jian Li | dfba739 | 2016-01-22 16:46:58 -0800 | [diff] [blame] | 174 | * @param subjectClassKey subject class key |
| 175 | * @param subject configuration subject |
| 176 | * @param configKey configuration key |
| 177 | * @param <S> type of subject |
Thomas Vachuska | 6f350ed | 2016-01-08 09:53:03 -0800 | [diff] [blame] | 178 | */ |
| 179 | <S> void removeConfig(String subjectClassKey, S subject, String configKey); |
Deepa Vaddireddy | 0c49b60 | 2016-06-02 12:19:07 +0530 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Clears the configuration including queued based on the subject. |
| 183 | * If does not exists this call has no effect. |
| 184 | * |
Ray Milkey | bb23e0b | 2016-08-02 17:00:21 -0700 | [diff] [blame] | 185 | * @param <S> type of subject |
Deepa Vaddireddy | 0c49b60 | 2016-06-02 12:19:07 +0530 | [diff] [blame] | 186 | * @param subject configuration subject |
| 187 | */ |
| 188 | <S> void removeConfig(S subject); |
| 189 | |
| 190 | /** |
| 191 | * Clears the complete configuration including queued. |
| 192 | * If does not exists this call has no effect. |
| 193 | * |
Ray Milkey | bb23e0b | 2016-08-02 17:00:21 -0700 | [diff] [blame] | 194 | * @param <S> type of subject |
Deepa Vaddireddy | 0c49b60 | 2016-06-02 12:19:07 +0530 | [diff] [blame] | 195 | */ |
| 196 | <S> void removeConfig(); |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 197 | } |