summaryrefslogtreecommitdiffstats
path: root/v3po/vpp-cfg-init/src
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/vpp-cfg-init/src')
-rw-r--r--v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java21
-rw-r--r--v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang2
2 files changed, 14 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);
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;
}
}
}