Committed by
Gerrit Code Review
Put configs back to pending state when the config factory is removed.
Addresses one of the causes of ONOS-4605 - not sure if there are others. Change-Id: I2897e84a10b13ac00d5a03c31b7a08daae57d8cb
Showing
1 changed file
with
12 additions
and
0 deletions
| ... | @@ -166,10 +166,22 @@ public class DistributedNetworkConfigStore | ... | @@ -166,10 +166,22 @@ public class DistributedNetworkConfigStore |
| 166 | @Override | 166 | @Override |
| 167 | public void removeConfigFactory(ConfigFactory configFactory) { | 167 | public void removeConfigFactory(ConfigFactory configFactory) { |
| 168 | factoriesByConfig.remove(configFactory.configClass().getName()); | 168 | factoriesByConfig.remove(configFactory.configClass().getName()); |
| 169 | + processExistingConfigs(configFactory); | ||
| 169 | notifyDelegate(new NetworkConfigEvent(CONFIG_UNREGISTERED, configFactory.configKey(), | 170 | notifyDelegate(new NetworkConfigEvent(CONFIG_UNREGISTERED, configFactory.configKey(), |
| 170 | configFactory.configClass())); | 171 | configFactory.configClass())); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| 174 | + // Sweep through any configurations for the config factory, set back to pending state. | ||
| 175 | + private void processExistingConfigs(ConfigFactory configFactory) { | ||
| 176 | + ImmutableSet.copyOf(configs.keySet()).forEach(k -> { | ||
| 177 | + if (Objects.equals(configFactory.configClass().getName(), k.configClass)) { | ||
| 178 | + JsonNode json = configs.remove(k).value(); | ||
| 179 | + configs.put(key(k.subject, configFactory.configKey()), json); | ||
| 180 | + log.debug("Set config pending: {}, {}", k.subject, k.configClass); | ||
| 181 | + } | ||
| 182 | + }); | ||
| 183 | + } | ||
| 184 | + | ||
| 173 | @Override | 185 | @Override |
| 174 | @SuppressWarnings("unchecked") | 186 | @SuppressWarnings("unchecked") |
| 175 | public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) { | 187 | public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) { | ... | ... |
-
Please register or login to post a comment