* 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;
/*
}
private boolean isInstalled(Feature feature) {
- List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
- return installedFeatures.contains(feature);
+ for(int retries=0;retries<MAX_RETRIES;retries++) {
+ try {
+ List<Feature> 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);
+ } else {
+ 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);
+ }
+ }
+ 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<FeatureConfigSnapshotHolder> pushConfig(LinkedHashSet<FeatureConfigSnapshotHolder> configs) throws InterruptedException {