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;fp=opendaylight%2Fconfig%2Fconfig-persister-feature-adapter%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfigpusherfeature%2Finternal%2FFeatureConfigPusher.java;h=50757fb7b90961df577d1dc1d7675bbf56ea8bb5;hb=8b1ea7f69a0183c988d3861a8b6c90e465d687ae;hp=f11da079c6da920bebf75ddc98800be2ae8de8b6;hpb=a110503f173ba4fbeb07a61d3c7ebf1688dfc9d6;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 f11da079c6..50757fb7b9 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 @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.apache.karaf.features.Feature; import org.apache.karaf.features.FeaturesService; import org.opendaylight.controller.config.persist.api.ConfigPusher; @@ -36,7 +37,7 @@ public class FeatureConfigPusher { * chains. Also, preserves the *original* Feature chain for which we pushed the config. * (which is handy for logging). */ - LinkedHashSet pushedConfigs = new LinkedHashSet<>(); + Set pushedConfigs = new LinkedHashSet<>(); /* * LinkedHashMultimap to track which configs we pushed for each Feature installation * For future use @@ -64,7 +65,7 @@ public class FeatureConfigPusher { for (Feature feature : features) { - LinkedHashSet configSnapShots = pushConfig(feature); + Set configSnapShots = pushConfig(feature); if (!configSnapShots.isEmpty()) { pushedFeatures.putAll(feature, configSnapShots); } @@ -72,8 +73,8 @@ public class FeatureConfigPusher { return pushedFeatures; } - private LinkedHashSet pushConfig(final Feature feature) throws Exception { - LinkedHashSet configs = new LinkedHashSet<>(); + private Set pushConfig(final Feature feature) throws Exception { + Set configs = new LinkedHashSet<>(); if(isInstalled(feature)) { // 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) { @@ -91,7 +92,7 @@ public class FeatureConfigPusher { } private boolean isInstalled(final Feature feature) { - for(int retries=0;retries installedFeatures = Arrays.asList(featuresService.listInstalledFeatures()); if(installedFeatures.contains(feature)) { @@ -100,12 +101,7 @@ public class FeatureConfigPusher { LOG.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion()); } } catch (Exception e) { - if(retries < MAX_RETRIES) { - LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e); - } else { - LOG.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}", retries, e); - throw e; - } + LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e); } try { Thread.sleep(RETRY_PAUSE_MILLIS); @@ -117,8 +113,9 @@ public class FeatureConfigPusher { return false; } - private LinkedHashSet pushConfig(final LinkedHashSet configs, final Feature feature) throws InterruptedException { - LinkedHashSet configsToPush = new LinkedHashSet<>(configs); + private Set pushConfig(final Set configs, final Feature feature) + throws InterruptedException { + Set configsToPush = new LinkedHashSet<>(configs); configsToPush.removeAll(pushedConfigs); if (!configsToPush.isEmpty()) { @@ -134,7 +131,7 @@ public class FeatureConfigPusher { pushedConfigs.addAll(configsToPush); } - LinkedHashSet configsPushed = new LinkedHashSet<>(pushedConfigs); + Set configsPushed = new LinkedHashSet<>(pushedConfigs); configsPushed.retainAll(configs); return configsPushed; }