diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-05-23 09:26:27 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-05-24 12:53:23 +0200 |
commit | d70f76a3626eb1b3786a5cfac4528a449b476583 (patch) | |
tree | 661742089f924c8bdda61c391917de85333b7708 /v3po/vpp-cfg-init/src/main/java | |
parent | 3af5cb9926238ba0fa802e0e067451a8e19f1c6a (diff) |
HONEYCOMB-61: Fix outstanding issues
Change-Id: I2dec6bbd8db656663029ad0f59da1b583c890565
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/vpp-cfg-init/src/main/java')
-rw-r--r-- | v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java index eed22313c..ff3dc1087 100644 --- a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java +++ b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java @@ -33,9 +33,13 @@ import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.vpp.data.in import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RestoringInitializer implements DataTreeInitializer { + private static final Logger LOG = LoggerFactory.getLogger(InitializerRegistryImpl.class); + private final SchemaService schemaService; private final Path path; private final DOMDataBroker dataTree; @@ -55,15 +59,9 @@ public class RestoringInitializer implements DataTreeInitializer { } private Path checkStorage(final Path path) { - try { - if(Files.exists(path)) { - checkArgument(!Files.isDirectory(path), "File %s is a directory", path); - checkArgument(Files.isReadable(path), "File %s is not readable", path); - } else { - return checkStorage(Files.createFile(path)); - } - } catch (IOException e) { - throw new IllegalArgumentException("Cannot use " + path + " for restoring data", e); + if (Files.exists(path)) { + checkArgument(!Files.isDirectory(path), "File %s is a directory", path); + checkArgument(Files.isReadable(path), "File %s is not readable", path); } return path; @@ -71,7 +69,9 @@ public class RestoringInitializer implements DataTreeInitializer { @Override public void initialize() throws InitializeException { + LOG.debug("Starting restoration of {} from {} using {}", dataTree, path, restorationType); if(!Files.exists(path)) { + LOG.debug("Persist file {} does not exist. Skipping restoration", path); return; } @@ -83,6 +83,8 @@ public class RestoringInitializer implements DataTreeInitializer { for (DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataContainerChild : containerNode .getValue()) { final YangInstanceIdentifier iid = YangInstanceIdentifier.create(dataContainerChild.getIdentifier()); + LOG.trace("Restoring {} from {}", iid, path); + switch (restorationType) { case Merge: domDataWriteTransaction.merge(datastoreType, iid, dataContainerChild); @@ -98,6 +100,7 @@ public class RestoringInitializer implements DataTreeInitializer { // Block here to prevent subsequent initializers processing before context is fully restored domDataWriteTransaction.submit().checkedGet(); + LOG.debug("Data from {} restored successfully", path); } catch (IOException | TransactionCommitFailedException e) { throw new InitializeException("Unable to restore data from " + path, e); |