X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-feature-adapter%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfigpusherfeature%2Finternal%2FFeatureConfigPusher.java;h=2e24fa9013b06363339f681535b3c33598842d5e;hb=b6d6f433f22283fc5b078c1129bd24ff459fd799;hp=7b90580a660cac0a03a4b90c0c0f8d40a1d2eb68;hpb=e316a0ef36279a72767703d190f38a39d7d49395;p=controller.git diff --git a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java index 7b90580a66..2e24fa9013 100644 --- a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java +++ b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.configpusherfeature.internal; +import com.google.common.base.Optional; import com.google.common.collect.LinkedHashMultimap; import java.util.ArrayList; import java.util.Arrays; @@ -16,6 +17,7 @@ import org.apache.karaf.features.Feature; import org.apache.karaf.features.FeaturesService; import org.opendaylight.controller.config.persist.api.ConfigPusher; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; +import org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,25 +59,32 @@ public class FeatureConfigPusher { * If a Feature is not in the returned LinkedHashMultimap then we couldn't push its configs * (Ususally because it was not yet installed) */ - public LinkedHashMultimap pushConfigs(final List features) throws Exception, InterruptedException { - LinkedHashMultimap pushedFeatures = LinkedHashMultimap.create(); - for(Feature feature: features) { + public LinkedHashMultimap pushConfigs(final List features) throws Exception { + LinkedHashMultimap pushedFeatures = LinkedHashMultimap.create(); + for (Feature feature : features) { + + LinkedHashSet configSnapShots = pushConfig(feature); - if(!configSnapShots.isEmpty()) { - pushedFeatures.putAll(feature,configSnapShots); + if (!configSnapShots.isEmpty()) { + pushedFeatures.putAll(feature, configSnapShots); } } return pushedFeatures; } - private LinkedHashSet pushConfig(final Feature feature) throws Exception, InterruptedException { - LinkedHashSet configs = new LinkedHashSet(); + private LinkedHashSet pushConfig(final Feature feature) throws Exception { + LinkedHashSet configs = new LinkedHashSet<>(); if(isInstalled(feature)) { - ChildAwareFeatureWrapper wrappedFeature = new ChildAwareFeatureWrapper(feature,featuresService); - configs = wrappedFeature.getFeatureConfigSnapshotHolders(); - if(!configs.isEmpty()) { - configs = pushConfig(configs); - feature2configs.putAll(feature, configs); + // FIXME Workaround for BUG-2836, features service returns null for feature: standard-condition-webconsole_0_0_0, 3.0.1 + if(featuresService.getFeature(feature.getName(), feature.getVersion()) == null) { + LOG.warn("Feature: {}, {} is missing from features service. Skipping", feature.getName(), feature.getVersion()); + } else { + ChildAwareFeatureWrapper wrappedFeature = new ChildAwareFeatureWrapper(feature, featuresService); + configs = wrappedFeature.getFeatureConfigSnapshotHolders(); + if (!configs.isEmpty()) { + configs = pushConfig(configs, feature); + feature2configs.putAll(feature, configs); + } } } return configs; @@ -108,11 +117,21 @@ public class FeatureConfigPusher { return false; } - private LinkedHashSet pushConfig(final LinkedHashSet configs) throws InterruptedException { + private LinkedHashSet pushConfig(final LinkedHashSet configs, final Feature feature) throws InterruptedException { LinkedHashSet configsToPush = new LinkedHashSet(configs); configsToPush.removeAll(pushedConfigs); - if(!configsToPush.isEmpty()) { - pusher.pushConfigs(new ArrayList(configsToPush)); + if (!configsToPush.isEmpty()) { + + // Ignore features that are present in persisted current config + final Optional currentCfgPusher = XmlFileStorageAdapter.getInstance(); + if (currentCfgPusher.isPresent() && + currentCfgPusher.get().getPersistedFeatures().contains(feature.getId())) { + LOG.warn("Ignoring default configuration {} for feature {}, the configuration is present in {}", + configsToPush, feature.getId(), currentCfgPusher.get()); + } else { + pusher.pushConfigs(new ArrayList(configsToPush)); + } + pushedConfigs.addAll(configsToPush); } LinkedHashSet configsPushed = new LinkedHashSet(pushedConfigs);