From d70f76a3626eb1b3786a5cfac4528a449b476583 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Mon, 23 May 2016 09:26:27 +0200 Subject: HONEYCOMB-61: Fix outstanding issues Change-Id: I2dec6bbd8db656663029ad0f59da1b583c890565 Signed-off-by: Maros Marsalek --- .../v3po/vpp/data/init/RestoringInitializer.java | 21 ++++++++++++--------- v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'v3po/vpp-cfg-init/src') 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 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); diff --git a/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang b/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang index 8d305685e..52750d926 100644 --- a/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang +++ b/v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang @@ -98,6 +98,7 @@ module vpp-cfg-init { leaf persist-file-path { type string; + mandatory true; } leaf restoration-type { @@ -108,6 +109,7 @@ module vpp-cfg-init { leaf datastore-type { type dapi:datatree-type; + mandatory true; } } } -- cgit 1.2.3-korg