Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -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 | 6d697f1 | 2015-03-08 20:59:50 -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 | */ |
| 16 | package org.onosproject.cfg.impl; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableSet; |
| 19 | import com.google.common.collect.Maps; |
| 20 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; |
| 22 | import org.apache.felix.scr.annotations.Deactivate; |
| 23 | import org.apache.felix.scr.annotations.Reference; |
| 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 25 | import org.apache.felix.scr.annotations.Service; |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 26 | import org.onlab.util.AbstractAccumulator; |
| 27 | import org.onlab.util.Accumulator; |
| 28 | import org.onlab.util.SharedExecutors; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 29 | import org.onosproject.cfg.ComponentConfigEvent; |
| 30 | import org.onosproject.cfg.ComponentConfigService; |
| 31 | import org.onosproject.cfg.ComponentConfigStore; |
| 32 | import org.onosproject.cfg.ComponentConfigStoreDelegate; |
| 33 | import org.onosproject.cfg.ConfigProperty; |
| 34 | import org.osgi.service.cm.Configuration; |
| 35 | import org.osgi.service.cm.ConfigurationAdmin; |
| 36 | import org.slf4j.Logger; |
| 37 | |
| 38 | import java.io.IOException; |
| 39 | import java.io.InputStream; |
| 40 | import java.util.Dictionary; |
| 41 | import java.util.Enumeration; |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 42 | import java.util.HashSet; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 43 | import java.util.Hashtable; |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 44 | import java.util.List; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 45 | import java.util.Map; |
| 46 | import java.util.Set; |
| 47 | |
| 48 | import static com.google.common.base.Preconditions.checkArgument; |
| 49 | import static com.google.common.base.Preconditions.checkNotNull; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 50 | import static org.onosproject.security.AppGuard.checkPermission; |
Thomas Vachuska | 92af89f | 2015-06-22 15:16:23 -0700 | [diff] [blame] | 51 | import static org.slf4j.LoggerFactory.getLogger; |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 52 | import static org.onosproject.security.AppPermission.Type.*; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 53 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Implementation of the centralized component configuration service. |
| 57 | */ |
| 58 | @Component(immediate = true) |
| 59 | @Service |
| 60 | public class ComponentConfigManager implements ComponentConfigService { |
| 61 | |
| 62 | private static final String COMPONENT_NULL = "Component name cannot be null"; |
| 63 | private static final String PROPERTY_NULL = "Property name cannot be null"; |
Brian O'Connor | 57e83e8 | 2015-09-22 15:45:37 -0700 | [diff] [blame] | 64 | private static final String COMPONENT_MISSING = "Component %s is not registered"; |
| 65 | private static final String PROPERTY_MISSING = "Property %s does not exist for %s"; |
| 66 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 67 | |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 68 | //Symbolic constants for use with the accumulator |
| 69 | private static final int MAX_ITEMS = 100; |
| 70 | private static final int MAX_BATCH_MILLIS = 1000; |
| 71 | private static final int MAX_IDLE_MILLIS = 250; |
| 72 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 73 | private static final String RESOURCE_EXT = ".cfgdef"; |
| 74 | |
| 75 | private final Logger log = getLogger(getClass()); |
| 76 | |
| 77 | private final ComponentConfigStoreDelegate delegate = new InternalStoreDelegate(); |
Thomas Vachuska | 92af89f | 2015-06-22 15:16:23 -0700 | [diff] [blame] | 78 | private final InternalAccumulator accumulator = new InternalAccumulator(); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 79 | |
| 80 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 81 | protected ComponentConfigStore store; |
| 82 | |
| 83 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 84 | protected ConfigurationAdmin cfgAdmin; |
| 85 | |
| 86 | // Locally maintained catalog of definitions. |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 87 | private final Map<String, Map<String, ConfigProperty>> properties = |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 88 | Maps.newConcurrentMap(); |
| 89 | |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 90 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 91 | @Activate |
| 92 | public void activate() { |
| 93 | store.setDelegate(delegate); |
| 94 | log.info("Started"); |
| 95 | } |
| 96 | |
| 97 | @Deactivate |
| 98 | public void deactivate() { |
| 99 | store.unsetDelegate(delegate); |
| 100 | log.info("Stopped"); |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public Set<String> getComponentNames() { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 105 | checkPermission(CONFIG_READ); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 106 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 107 | return ImmutableSet.copyOf(properties.keySet()); |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public void registerProperties(Class<?> componentClass) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 112 | checkPermission(CONFIG_WRITE); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 113 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 114 | String componentName = componentClass.getName(); |
| 115 | String resourceName = componentClass.getSimpleName() + RESOURCE_EXT; |
| 116 | try (InputStream ris = componentClass.getResourceAsStream(resourceName)) { |
| 117 | checkArgument(ris != null, "Property definitions not found at resource %s", |
| 118 | resourceName); |
| 119 | |
| 120 | // Read the definitions |
| 121 | Set<ConfigProperty> defs = ConfigPropertyDefinitions.read(ris); |
| 122 | |
| 123 | // Produce a new map of the properties and register it. |
| 124 | Map<String, ConfigProperty> map = Maps.newConcurrentMap(); |
| 125 | defs.forEach(p -> map.put(p.name(), p)); |
| 126 | |
| 127 | properties.put(componentName, map); |
| 128 | loadExistingValues(componentName); |
| 129 | } catch (IOException e) { |
| 130 | log.error("Unable to read property definitions from resource " + resourceName, e); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public void unregisterProperties(Class<?> componentClass, boolean clear) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 136 | checkPermission(CONFIG_WRITE); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 137 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 138 | String componentName = componentClass.getName(); |
| 139 | checkNotNull(componentName, COMPONENT_NULL); |
| 140 | Map<String, ConfigProperty> cps = properties.remove(componentName); |
Thomas Vachuska | fc52fec | 2015-05-18 19:13:56 -0700 | [diff] [blame] | 141 | if (clear && cps != null) { |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 142 | cps.keySet().forEach(name -> store.unsetProperty(componentName, name)); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 143 | clearExistingValues(componentName); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Clears any existing values that may have been set. |
| 148 | private void clearExistingValues(String componentName) { |
| 149 | triggerUpdate(componentName); |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public Set<ConfigProperty> getProperties(String componentName) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 154 | checkPermission(CONFIG_READ); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 155 | |
Brian O'Connor | 85c2926 | 2015-03-10 20:53:43 -0700 | [diff] [blame] | 156 | Map<String, ConfigProperty> map = properties.get(componentName); |
| 157 | return map != null ? ImmutableSet.copyOf(map.values()) : null; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public void setProperty(String componentName, String name, String value) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 162 | checkPermission(CONFIG_WRITE); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 163 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 164 | checkNotNull(componentName, COMPONENT_NULL); |
| 165 | checkNotNull(name, PROPERTY_NULL); |
Brian O'Connor | 57e83e8 | 2015-09-22 15:45:37 -0700 | [diff] [blame] | 166 | |
| 167 | checkArgument(properties.containsKey(componentName), |
| 168 | COMPONENT_MISSING, componentName); |
| 169 | checkArgument(properties.get(componentName).containsKey(name), |
| 170 | PROPERTY_MISSING, name, componentName); |
sivachidambaram subramanian | 8c9a701 | 2017-04-26 14:59:02 +0530 | [diff] [blame] | 171 | checkValidity(componentName, name, value); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 172 | store.setProperty(componentName, name, value); |
| 173 | } |
| 174 | |
| 175 | @Override |
andrea | dd106a6 | 2015-10-02 13:39:48 -0700 | [diff] [blame] | 176 | public void preSetProperty(String componentName, String name, String value) { |
| 177 | |
| 178 | checkPermission(CONFIG_WRITE); |
| 179 | |
| 180 | checkNotNull(componentName, COMPONENT_NULL); |
| 181 | checkNotNull(name, PROPERTY_NULL); |
sivachidambaram subramanian | 8c9a701 | 2017-04-26 14:59:02 +0530 | [diff] [blame] | 182 | checkValidity(componentName, name, value); |
andrea | dd106a6 | 2015-10-02 13:39:48 -0700 | [diff] [blame] | 183 | store.setProperty(componentName, name, value); |
| 184 | } |
| 185 | |
| 186 | @Override |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 187 | public void unsetProperty(String componentName, String name) { |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 188 | checkPermission(CONFIG_WRITE); |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 189 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 190 | checkNotNull(componentName, COMPONENT_NULL); |
| 191 | checkNotNull(name, PROPERTY_NULL); |
Brian O'Connor | 57e83e8 | 2015-09-22 15:45:37 -0700 | [diff] [blame] | 192 | |
| 193 | checkArgument(properties.containsKey(componentName), |
| 194 | COMPONENT_MISSING, componentName); |
| 195 | checkArgument(properties.get(componentName).containsKey(name), |
| 196 | PROPERTY_MISSING, name, componentName); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 197 | store.unsetProperty(componentName, name); |
| 198 | } |
| 199 | |
| 200 | private class InternalStoreDelegate implements ComponentConfigStoreDelegate { |
| 201 | |
| 202 | @Override |
| 203 | public void notify(ComponentConfigEvent event) { |
| 204 | String componentName = event.subject(); |
| 205 | String name = event.name(); |
| 206 | String value = event.value(); |
| 207 | |
| 208 | switch (event.type()) { |
| 209 | case PROPERTY_SET: |
| 210 | set(componentName, name, value); |
| 211 | break; |
| 212 | case PROPERTY_UNSET: |
| 213 | reset(componentName, name); |
| 214 | break; |
| 215 | default: |
| 216 | break; |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
Thomas Vachuska | 92af89f | 2015-06-22 15:16:23 -0700 | [diff] [blame] | 221 | // Buffers multiple subsequent configuration updates into one notification. |
| 222 | private class InternalAccumulator extends AbstractAccumulator<String> |
| 223 | implements Accumulator<String> { |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 224 | |
Thomas Vachuska | 92af89f | 2015-06-22 15:16:23 -0700 | [diff] [blame] | 225 | protected InternalAccumulator() { |
| 226 | super(SharedExecutors.getTimer(), MAX_ITEMS, MAX_BATCH_MILLIS, MAX_IDLE_MILLIS); |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | @Override |
Thomas Vachuska | 92af89f | 2015-06-22 15:16:23 -0700 | [diff] [blame] | 230 | public void processItems(List<String> items) { |
| 231 | // Conversion to set removes duplicates |
| 232 | Set<String> componentSet = new HashSet<>(items); |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 233 | componentSet.forEach(ComponentConfigManager.this::triggerUpdate); |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 237 | // Locates the property in the component map and replaces it with an |
| 238 | // updated copy. |
| 239 | private void set(String componentName, String name, String value) { |
| 240 | Map<String, ConfigProperty> map = properties.get(componentName); |
| 241 | if (map != null) { |
| 242 | ConfigProperty prop = map.get(name); |
| 243 | if (prop != null) { |
| 244 | map.put(name, ConfigProperty.setProperty(prop, value)); |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 245 | accumulator.add(componentName); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 246 | return; |
| 247 | } |
| 248 | } |
Naoki Shiota | 6bc04be | 2016-01-08 12:02:38 -0800 | [diff] [blame] | 249 | |
| 250 | // If definition doesn't exist in local catalog, cache the property. |
| 251 | preSet(componentName, name, value); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | // Locates the property in the component map and replaces it with an |
| 255 | // reset copy. |
| 256 | private void reset(String componentName, String name) { |
| 257 | Map<String, ConfigProperty> map = properties.get(componentName); |
| 258 | if (map != null) { |
| 259 | ConfigProperty prop = map.get(name); |
| 260 | if (prop != null) { |
| 261 | map.put(name, ConfigProperty.resetProperty(prop)); |
Aaron Kruglikov | 6685521 | 2015-06-22 12:29:02 -0700 | [diff] [blame] | 262 | accumulator.add(componentName); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 263 | return; |
| 264 | } |
Thomas Vachuska | db320ab | 2015-04-22 09:03:33 -0700 | [diff] [blame] | 265 | log.warn("Unable to reset non-existent property {} for component {}", |
| 266 | name, componentName); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 267 | } |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Naoki Shiota | 6bc04be | 2016-01-08 12:02:38 -0800 | [diff] [blame] | 270 | // Stores non-existent property so that loadExistingValues() can load in future. |
| 271 | private void preSet(String componentName, String name, String value) { |
| 272 | try { |
Naoki Shiota | 4ce97ff | 2016-01-14 18:45:22 -0800 | [diff] [blame] | 273 | Configuration config = cfgAdmin.getConfiguration(componentName, null); |
Naoki Shiota | 6bc04be | 2016-01-08 12:02:38 -0800 | [diff] [blame] | 274 | Dictionary<String, Object> property = config.getProperties(); |
| 275 | if (property == null) { |
| 276 | property = new Hashtable<>(); |
| 277 | } |
| 278 | property.put(name, value); |
| 279 | config.update(property); |
| 280 | } catch (IOException e) { |
| 281 | log.error("Failed to preset configuration for {}", componentName); |
| 282 | } |
| 283 | } |
| 284 | |
sivachidambaram subramanian | 8c9a701 | 2017-04-26 14:59:02 +0530 | [diff] [blame] | 285 | // Checks whether the value of the specified configuration property is a valid one or not. |
| 286 | private void checkValidity(String componentName, String name, String newValue) { |
| 287 | Map<String, ConfigProperty> map = properties.get(componentName); |
| 288 | if (map == null) { |
| 289 | return; |
| 290 | } |
| 291 | ConfigProperty prop = map.get(name); |
| 292 | ConfigProperty.Type type = prop.type(); |
| 293 | try { |
| 294 | switch (type) { |
| 295 | case INTEGER: |
| 296 | Integer.parseInt(newValue); |
| 297 | break; |
| 298 | case LONG: |
| 299 | Long.parseLong(newValue); |
| 300 | break; |
| 301 | case FLOAT: |
| 302 | Float.parseFloat(newValue); |
| 303 | break; |
| 304 | case DOUBLE: |
| 305 | Double.parseDouble(newValue); |
| 306 | break; |
| 307 | case BOOLEAN: |
| 308 | if (!((newValue != null) && (newValue.equalsIgnoreCase("true") || |
| 309 | newValue.equalsIgnoreCase("false")))) { |
| 310 | throw new IllegalArgumentException("Invalid " + type + " value"); |
| 311 | } |
| 312 | break; |
| 313 | case STRING: |
| 314 | case BYTE: |
| 315 | //do nothing |
| 316 | break; |
| 317 | default: |
| 318 | log.warn("Not a valid config property type"); |
| 319 | break; |
| 320 | |
| 321 | } |
| 322 | } catch (NumberFormatException e) { |
| 323 | throw new NumberFormatException("Invalid " + type + " value"); |
| 324 | } |
| 325 | } |
| 326 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 327 | // Loads existing property values that may have been set. |
| 328 | private void loadExistingValues(String componentName) { |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 329 | try { |
Thomas Vachuska | 6519e6f | 2015-03-11 02:29:31 -0700 | [diff] [blame] | 330 | Configuration cfg = cfgAdmin.getConfiguration(componentName, null); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 331 | Map<String, ConfigProperty> map = properties.get(componentName); |
| 332 | Dictionary<String, Object> props = cfg.getProperties(); |
| 333 | if (props != null) { |
| 334 | Enumeration<String> it = props.keys(); |
| 335 | while (it.hasMoreElements()) { |
| 336 | String name = it.nextElement(); |
| 337 | ConfigProperty p = map.get(name); |
sivachidambaram subramanian | 8c9a701 | 2017-04-26 14:59:02 +0530 | [diff] [blame] | 338 | try { |
| 339 | if (p != null) { |
| 340 | checkValidity(componentName, name, (String) props.get(name)); |
| 341 | map.put(name, ConfigProperty.setProperty(p, (String) props.get(name))); |
| 342 | } |
| 343 | } catch (IllegalArgumentException e) { |
| 344 | log.warn("Default values will be applied " + |
| 345 | "since presetted value is not a valid " + p.type()); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | } |
| 349 | } catch (IOException e) { |
| 350 | log.error("Unable to get configuration for " + componentName, e); |
| 351 | } |
| 352 | |
| 353 | } |
| 354 | |
| 355 | // FIXME: This should be a slightly deferred execution to allow changing |
| 356 | // values just once per component when a number of updates arrive shortly |
| 357 | // after each other. |
| 358 | private void triggerUpdate(String componentName) { |
| 359 | try { |
Thomas Vachuska | 6519e6f | 2015-03-11 02:29:31 -0700 | [diff] [blame] | 360 | Configuration cfg = cfgAdmin.getConfiguration(componentName, null); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 361 | Map<String, ConfigProperty> map = properties.get(componentName); |
| 362 | Dictionary<String, Object> props = new Hashtable<>(); |
| 363 | map.values().forEach(p -> props.put(p.name(), p.value())); |
| 364 | cfg.update(props); |
| 365 | } catch (IOException e) { |
| 366 | log.warn("Unable to update configuration for " + componentName, e); |
| 367 | } |
| 368 | } |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 369 | } |