Jonathan Hart
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
......@@ -166,10 +166,22 @@ public class DistributedNetworkConfigStore
@Override
public void removeConfigFactory(ConfigFactory configFactory) {
factoriesByConfig.remove(configFactory.configClass().getName());
processExistingConfigs(configFactory);
notifyDelegate(new NetworkConfigEvent(CONFIG_UNREGISTERED, configFactory.configKey(),
configFactory.configClass()));
}
// Sweep through any configurations for the config factory, set back to pending state.
private void processExistingConfigs(ConfigFactory configFactory) {
ImmutableSet.copyOf(configs.keySet()).forEach(k -> {
if (Objects.equals(configFactory.configClass().getName(), k.configClass)) {
JsonNode json = configs.remove(k).value();
configs.put(key(k.subject, configFactory.configKey()), json);
log.debug("Set config pending: {}, {}", k.subject, k.configClass);
}
});
}
@Override
@SuppressWarnings("unchecked")
public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) {
......