X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fimpl%2FConfigPusherImpl.java;h=90f71ca51aa1fc338fdae21aaacdff0a665196ca;hp=77f355e0b25c27530c0d36e20bf6e46c5ebfd04b;hb=edc7fa3aa93bf109acb36c6f2c69a19cf8e38af2;hpb=6998123adad9e88cd20f285dd48e433f71e90071 diff --git a/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/ConfigPusherImpl.java b/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/ConfigPusherImpl.java index 77f355e0b2..90f71ca51a 100644 --- a/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/ConfigPusherImpl.java +++ b/opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/ConfigPusherImpl.java @@ -69,13 +69,15 @@ public class ConfigPusherImpl implements ConfigPusher { this.facade = facade; } - public void process(List autoCloseables, MBeanServerConnection platformMBeanServer, Persister persisterAggregator) throws InterruptedException { - while(true) { - processSingle(autoCloseables, platformMBeanServer, persisterAggregator); + public void process(List autoCloseables, MBeanServerConnection platformMBeanServer, + Persister persisterAggregator, boolean propagateExceptions) throws InterruptedException { + while(processSingle(autoCloseables, platformMBeanServer, persisterAggregator, propagateExceptions)) { + ; } } - void processSingle(final List autoCloseables, final MBeanServerConnection platformMBeanServer, final Persister persisterAggregator) throws InterruptedException { + boolean processSingle(final List autoCloseables, final MBeanServerConnection platformMBeanServer, + final Persister persisterAggregator, boolean propagateExceptions) throws InterruptedException { final List configs = queue.take(); try { internalPushConfigs(configs); @@ -90,10 +92,22 @@ public class ConfigPusherImpl implements ConfigPusher { } LOG.debug("ConfigPusher has pushed configs {}", configs); - } catch (DocumentedException e) { - LOG.error("Error pushing configs {}",configs); - throw new IllegalStateException(e); + } catch (Exception e) { + // Exceptions are logged to error downstream + LOG.debug("Failed to push some of configs: {}", configs, e); + + if(propagateExceptions) { + if(e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new IllegalStateException(e); + } + } else { + return false; + } } + + return true; } @Override @@ -109,15 +123,21 @@ public class ConfigPusherImpl implements ConfigPusher { // start pushing snapshots for (ConfigSnapshotHolder configSnapshotHolder : configs) { if (configSnapshotHolder != null) { + LOG.info("Pushing configuration snapshot {}", configSnapshotHolder); boolean pushResult = false; try { pushResult = pushConfigWithConflictingVersionRetries(configSnapshotHolder); } catch (ConfigSnapshotFailureException e) { - LOG.warn("Failed to apply configuration snapshot: {}. Config snapshot is not semantically correct and will be IGNORED. " + + LOG.error("Failed to apply configuration snapshot: {}. Config snapshot is not semantically correct and will be IGNORED. " + "for detailed information see enclosed exception.", e.getConfigIdForReporting(), e); throw new IllegalStateException("Failed to apply configuration snapshot " + e.getConfigIdForReporting(), e); + } catch (Exception e) { + String msg = String.format("Failed to apply configuration snapshot: %s", configSnapshotHolder); + LOG.error(msg, e); + throw new IllegalStateException(msg, e); } - LOG.debug("Config snapshot pushed successfully: {}, result: {}", configSnapshotHolder, result); + + LOG.info("Successfully pushed configuration snapshot {}", configSnapshotHolder); result.put(configSnapshotHolder, pushResult); } }