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
| ... | @@ -164,10 +164,22 @@ public class DistributedNetworkConfigStore | ... | @@ -164,10 +164,22 @@ public class DistributedNetworkConfigStore |
| 164 | @Override | 164 | @Override |
| 165 | public void removeConfigFactory(ConfigFactory configFactory) { | 165 | public void removeConfigFactory(ConfigFactory configFactory) { |
| 166 | factoriesByConfig.remove(configFactory.configClass().getName()); | 166 | factoriesByConfig.remove(configFactory.configClass().getName()); |
| 167 | + processExistingConfigs(configFactory); | ||
| 167 | notifyDelegate(new NetworkConfigEvent(CONFIG_UNREGISTERED, configFactory.configKey(), | 168 | notifyDelegate(new NetworkConfigEvent(CONFIG_UNREGISTERED, configFactory.configKey(), |
| 168 | configFactory.configClass())); | 169 | configFactory.configClass())); |
| 169 | } | 170 | } |
| 170 | 171 | ||
| 172 | + // Sweep through any configurations for the config factory, set back to pending state. | ||
| 173 | + private void processExistingConfigs(ConfigFactory configFactory) { | ||
| 174 | + ImmutableSet.copyOf(configs.keySet()).forEach(k -> { | ||
| 175 | + if (Objects.equals(configFactory.configClass().getName(), k.configClass)) { | ||
| 176 | + JsonNode json = configs.remove(k).value(); | ||
| 177 | + configs.put(key(k.subject, configFactory.configKey()), json); | ||
| 178 | + log.debug("Set config pending: {}, {}", k.subject, k.configClass); | ||
| 179 | + } | ||
| 180 | + }); | ||
| 181 | + } | ||
| 182 | + | ||
| 171 | @Override | 183 | @Override |
| 172 | @SuppressWarnings("unchecked") | 184 | @SuppressWarnings("unchecked") |
| 173 | public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) { | 185 | public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) { | ... | ... |
-
Please register or login to post a comment