summaryrefslogtreecommitdiffstats
path: root/v3po/data-impl
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-04-10 23:45:43 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-04-12 11:00:37 +0200
commit8764f31fa74942d963dc85dd53227e980ceadf44 (patch)
treecf4a05617adbe8ef445e6220d40f4b65b6fa6eec /v3po/data-impl
parentc806dc87185ee3a994685561ea024cad45210036 (diff)
HONEYCOMB-34: Configurable ConfigDataTree dependency
Change-Id: I17a93835541e66835398391e2a127b25767b774a Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/data-impl')
-rw-r--r--v3po/data-impl/pom.xml4
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java19
-rw-r--r--v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java64
-rw-r--r--v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModuleFactory.java13
-rw-r--r--v3po/data-impl/src/main/yang/data-impl.yang68
5 files changed, 123 insertions, 45 deletions
diff --git a/v3po/data-impl/pom.xml b/v3po/data-impl/pom.xml
index 0df4f4cf9..954d25c30 100644
--- a/v3po/data-impl/pom.xml
+++ b/v3po/data-impl/pom.xml
@@ -17,10 +17,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>api-parent</artifactId>
+ <artifactId>impl-parent</artifactId>
<groupId>io.fd.honeycomb.common</groupId>
<version>1.0.0-SNAPSHOT</version>
- <relativePath>../../common/api-parent</relativePath>
+ <relativePath>../../common/impl-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java
index f636e6708..59a555fda 100644
--- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java
+++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java
@@ -57,7 +57,7 @@ public final class ConfigDataTree implements ModifiableDataTree {
private final BindingNormalizedNodeSerializer serializer;
private final DataTree dataTree;
- private final WriterRegistry writer;
+ private final WriterRegistry writerRegistry;
public static final ReadableDataTree EMPTY_OPERATIONAL = new ReadableDataTree() {
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
@@ -69,16 +69,17 @@ public final class ConfigDataTree implements ModifiableDataTree {
/**
* Creates configuration data tree instance.
*
- * @param serializer service for serialization between Java Binding Data representation and NormalizedNode
- * representation.
- * @param dataTree data tree for configuration data representation
- * @param writer service for translation between Java Binding Data and data provider.
+ * @param serializer service for serialization between Java Binding Data representation and NormalizedNode
+ * representation.
+ * @param dataTree data tree for configuration data representation
+ * @param writerRegistry service for translation between Java Binding Data and data provider, capable of performing
+ * bulk updates.
*/
public ConfigDataTree(@Nonnull final BindingNormalizedNodeSerializer serializer,
- @Nonnull final DataTree dataTree, @Nonnull final WriterRegistry writer) {
+ @Nonnull final DataTree dataTree, @Nonnull final WriterRegistry writerRegistry) {
this.serializer = checkNotNull(serializer, "serializer should not be null");
this.dataTree = checkNotNull(dataTree, "dataTree should not be null");
- this.writer = checkNotNull(writer, "writer should not be null");
+ this.writerRegistry = checkNotNull(writerRegistry, "writerRegistry should not be null");
}
@Override
@@ -110,8 +111,8 @@ public final class ConfigDataTree implements ModifiableDataTree {
final DOMDataReadOnlyTransaction beforeTx = new ReadOnlyTransaction(EMPTY_OPERATIONAL, takeSnapshot());
final ConfigSnapshot modificationSnapshot = new ConfigSnapshot(modification);
final DOMDataReadOnlyTransaction afterTx = new ReadOnlyTransaction(EMPTY_OPERATIONAL, modificationSnapshot);
- try(final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx)) {
- writer.update(nodesBefore, nodesAfter, ctx);
+ try (final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx)) {
+ writerRegistry.update(nodesBefore, nodesAfter, ctx);
} catch (io.fd.honeycomb.v3po.translate.write.WriterRegistry.BulkUpdateException e) {
LOG.warn("Failed to apply all changes", e);
LOG.info("Trying to revert successful changes for current transaction");
diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java
new file mode 100644
index 000000000..88e87956b
--- /dev/null
+++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java
@@ -0,0 +1,64 @@
+package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;
+
+import io.fd.honeycomb.v3po.data.DataTreeSnapshot;
+import io.fd.honeycomb.v3po.data.ModifiableDataTree;
+import io.fd.honeycomb.v3po.data.impl.ConfigDataTree;
+import io.fd.honeycomb.v3po.translate.TranslationException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
+
+public class ConfigDataTreeModule extends
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractConfigDataTreeModule {
+ public ConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public ConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.ConfigDataTreeModule oldModule,
+ java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
+ dataTree.setSchemaContext(getSchemaServiceDependency().getGlobalContext());
+ return new CloseableConfigDataTree(new ConfigDataTree(getBindingNormalizedNodeSerializerDependency(), dataTree,
+ getWriterRegistryDependency()));
+ }
+
+ private static final class CloseableConfigDataTree implements ModifiableDataTree, AutoCloseable {
+
+ private final ConfigDataTree delegate;
+
+ CloseableConfigDataTree(final ConfigDataTree delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void close() throws Exception {
+ // NOP
+ }
+
+ @Override
+ public void modify(final DataTreeModification modification)
+ throws DataValidationFailedException, TranslationException {
+ delegate.modify(modification);
+ }
+
+ @Override
+ public DataTreeSnapshot takeSnapshot() {
+ return delegate.takeSnapshot();
+ }
+ }
+}
diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModuleFactory.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModuleFactory.java
new file mode 100644
index 000000000..19baab13a
--- /dev/null
+++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModuleFactory.java
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: data-impl yang module local name: config-data-tree
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Apr 10 22:07:29 CEST 2016
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;
+public class ConfigDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractConfigDataTreeModuleFactory {
+
+}
diff --git a/v3po/data-impl/src/main/yang/data-impl.yang b/v3po/data-impl/src/main/yang/data-impl.yang
index 093e1725b..841cdb3df 100644
--- a/v3po/data-impl/src/main/yang/data-impl.yang
+++ b/v3po/data-impl/src/main/yang/data-impl.yang
@@ -1,59 +1,59 @@
-module translate-utils {
+module data-impl {
yang-version 1;
- namespace "urn:honeycomb:params:xml:ns:yang:translate:utils";
+ namespace "urn:honeycomb:params:xml:ns:yang:data:impl";
prefix "tutils";
import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+ import opendaylight-md-sal-dom { prefix dom; revision-date 2013-10-28;}
+ import data-api { prefix dapi; revision-date 2016-04-11; }
import translate-api { prefix tapi; revision-date 2016-04-06; }
description
- "This module contains translation layer utilities";
+ "This module contains YANG module definitions
+ for honeycomd data layer";
- revision "2016-04-06" {
+ revision "2016-04-11" {
description
"Initial revision.";
}
- identity delegating-reader-registry {
+ identity honeycomb-config-data-tree {
base config:module-type;
- config:provided-service tapi:honeycomb-reader-registry;
- config:java-name-prefix DelegatingReaderRegistry;
+ config:provided-service dapi:honeycomb-modifiable-data-tree;
+ config:java-name-prefix ConfigDataTree;
}
augment "/config:modules/config:module/config:configuration" {
- case delegating-reader-registry {
- when "/config:modules/config:module/config:type = 'delegating-reader-registry'";
-
- list root-readers {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tapi:honeycomb-reader;
- }
+ case honeycomb-config-data-tree {
+ when "/config:modules/config:module/config:type = 'honeycomb-config-data-tree'";
+
+ container schema-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity dom:schema-service;
}
}
+ }
- }
- }
-
- identity delegating-writer-registry {
- base config:module-type;
- config:provided-service tapi:honeycomb-writer-registry;
- config:java-name-prefix DelegatingWriterRegistry;
- }
+ container binding-normalized-node-serializer {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-binding:binding-normalized-node-serializer;
+ }
+ }
+ }
- augment "/config:modules/config:module/config:configuration" {
- case delegating-writer-registry {
- when "/config:modules/config:module/config:type = 'delegating-writer-registry'";
-
- list root-writers {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tapi:honeycomb-writer;
- }
+ container writer-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity tapi:honeycomb-writer-registry;
}
}
+ }
}
}