X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2FPersisterAggregator.java;h=7e9dce67bd78586459b8d8d2c40e248b392ecf01;hb=de12565a7795af98788f8150eb0072f9c985f4a1;hp=e109ebec887b8e3c2a1579e5e2292fc970b25f1e;hpb=8ca41be0336a1a9c02fb46ee0961a66f0ab40bf8;p=controller.git diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java index e109ebec88..7e9dce67bd 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.netconf.persist.impl; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.config.persist.api.Persister; import org.opendaylight.controller.config.persist.api.StorageAdapter; @@ -20,6 +19,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.ListIterator; @@ -48,7 +48,7 @@ import java.util.ListIterator; * During server startup {@link ConfigPersisterNotificationHandler} requests last snapshot from underlying storages. * Each storage can respond by giving snapshot or absent response. - * The {@link #loadLastConfig()} will search for first non-absent response from storages ordered backwards as user + * The {@link #loadLastConfigs()} will search for first non-absent response from storages ordered backwards as user * specified (first '3', then '2'). * * When a commit notification is received, '2' will be omitted because readonly flag is set to true, so @@ -154,19 +154,29 @@ public final class PersisterAggregator implements Persister { } } + /** + * @return last non-empty result from input persisters + */ @Override - public Optional loadLastConfig() throws IOException { + public List loadLastConfigs() { // iterate in reverse order ListIterator li = persisterWithConfigurations.listIterator(persisterWithConfigurations.size()); while(li.hasPrevious()) { PersisterWithConfiguration persisterWithConfiguration = li.previous(); - Optional configSnapshotHolderOptional = persisterWithConfiguration.storage.loadLastConfig(); - if (configSnapshotHolderOptional.isPresent()) { - return configSnapshotHolderOptional; + List configs = null; + try { + configs = persisterWithConfiguration.storage.loadLastConfigs(); + } catch (IOException e) { + throw new RuntimeException("Error while calling loadLastConfig on " + persisterWithConfiguration, e); + } + if (configs.isEmpty() == false) { + logger.debug("Found non empty configs using {}:{}", persisterWithConfiguration, configs); + return configs; } } // no storage had an answer - return Optional.absent(); + logger.debug("No non-empty list of configuration snapshots found"); + return Collections.emptyList(); } @VisibleForTesting