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=5c5061277b62f28c98e163f17c7fc1c721a91cd9;hb=139937c2e646894af6a9b2b8a8a1047c6ef82485;hp=57052f9d6003fc14a84761acc146d1bf678e0f7a;hpb=879a57936375ca3dec48c5bf52b0b5988c807bae;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 57052f9d60..5c5061277b 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 @@ -25,8 +25,9 @@ import com.google.common.collect.LinkedHashMultimap; * Simple class to push configs to the config subsystem from Feature's configfiles */ public class FeatureConfigPusher { - private static final Logger logger = LoggerFactory.getLogger(FeatureConfigPusher.class); + private static final Logger LOGGER = LoggerFactory.getLogger(FeatureConfigPusher.class); private static final int MAX_RETRIES=100; + private static final int RETRY_PAUSE_MILLIS=1; private FeaturesService featuresService = null; private ConfigPusher pusher = null; /* @@ -83,30 +84,30 @@ public class FeatureConfigPusher { } private boolean isInstalled(Feature feature) { - List installedFeatures= null; - boolean cont = true; - int retries = 0; - while(cont) { + for(int retries=0;retries installedFeatures = Arrays.asList(featuresService.listInstalledFeatures()); + if(installedFeatures.contains(feature)) { + return true; + } else { + LOGGER.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion()); + } } catch (Exception e) { if(retries < MAX_RETRIES) { - logger.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e); - try { - Thread.sleep(1); - } catch (InterruptedException e1) { - throw new IllegalStateException(e1); - } - retries++; - continue; + LOGGER.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e); } else { - logger.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e); + LOGGER.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e); throw e; } } + try { + Thread.sleep(RETRY_PAUSE_MILLIS); + } catch (InterruptedException e1) { + throw new IllegalStateException(e1); + } } - return installedFeatures.contains(feature); + LOGGER.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",MAX_RETRIES,feature.getName(),feature.getVersion()); + return false; } private LinkedHashSet pushConfig(LinkedHashSet configs) throws InterruptedException {