summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-04-11 21:23:57 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-04-12 11:05:25 +0200
commit6bad7a88fa8b0be4f371897447f78abe7c52f805 (patch)
tree2eedfc7c1fcc3d255e3f03011845e46a2ce0832f
parentf93415dd8b3719b380b4295ab364420b9bf3d927 (diff)
HONEYCOMB-34: Config tree initialization using binding data broker
Change-Id: I070aca2cc35dd10ea5bde19c8cbf4cad1c50f468 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--v3po/data-api/src/main/java/io/fd/honeycomb/v3po/data/ModifiableDataTree.java8
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java8
-rw-r--r--v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java17
-rw-r--r--v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java81
-rw-r--r--v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java13
-rw-r--r--v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java4
-rw-r--r--v3po/data-impl/src/main/yang/data-impl.yang31
-rw-r--r--v3po/impl/src/main/config/default-config.xml161
-rw-r--r--v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java21
-rw-r--r--v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java30
-rw-r--r--v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/DataBrokerModule.java4
-rw-r--r--v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java5
-rw-r--r--v3po/impl/src/main/yang/v3po-impl.yang31
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java17
-rw-r--r--v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java15
-rw-r--r--v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/CloseableWriterRegistry.java65
-rw-r--r--v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterRegistry.java61
-rw-r--r--v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingWriterRegistryModule.java46
-rw-r--r--v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java25
-rw-r--r--v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModuleFactory.java13
-rw-r--r--v3po/translate-utils/src/main/yang/translate-utils.yang11
-rw-r--r--v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/AbstractDataTreeConverter.java99
-rw-r--r--v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/VppInitializer.java11
-rw-r--r--v3po/vpp-cfg-init/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/vpp/data/init/rev160407/VppConfigurationInitializerModule.java12
-rw-r--r--v3po/vpp-cfg-init/src/main/yang/vpp-cfg-init.yang25
-rw-r--r--v3po/vpp-cfg-init/src/test/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImplTest.java9
26 files changed, 497 insertions, 326 deletions
diff --git a/v3po/data-api/src/main/java/io/fd/honeycomb/v3po/data/ModifiableDataTree.java b/v3po/data-api/src/main/java/io/fd/honeycomb/v3po/data/ModifiableDataTree.java
index a3b5c9c34..8b21ddf24 100644
--- a/v3po/data-api/src/main/java/io/fd/honeycomb/v3po/data/ModifiableDataTree.java
+++ b/v3po/data-api/src/main/java/io/fd/honeycomb/v3po/data/ModifiableDataTree.java
@@ -36,14 +36,6 @@ public interface ModifiableDataTree {
void modify(final DataTreeModification modification) throws DataValidationFailedException, TranslationException;
/**
- * Initializes data tree using supplied modification.
- *
- * @param modification data tree modification
- * @throws DataValidationFailedException if modification data is not valid
- */
- void initialize(final DataTreeModification modification) throws DataValidationFailedException;
-
- /**
* Creates read-only snapshot of a ModifiableDataTree.
*
* @return Data tree snapshot.
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 b90a57acd..ab4cf6446 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
@@ -137,14 +137,6 @@ public final class ConfigDataTree implements ModifiableDataTree {
dataTree.commit(candidate);
}
- @Override
- public void initialize(final DataTreeModification modification) throws DataValidationFailedException {
- LOG.debug("ConfigDataTree.initialize");
- dataTree.validate(modification);
- final DataTreeCandidate candidate = dataTree.prepare(modification);
- dataTree.commit(candidate);
- }
-
private Map<InstanceIdentifier<?>, DataObject> extractNetconfData(
final Optional<NormalizedNode<?, ?>> parentOptional) {
if (parentOptional.isPresent()) {
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
index 19267b1bd..86a3f9db4 100644
--- 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
@@ -4,11 +4,8 @@ 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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,11 +33,9 @@ public class ConfigDataTreeModule extends
@Override
public java.lang.AutoCloseable createInstance() {
- LOG.info("ConfigDataTreeModule.createInstance()");
- final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
- dataTree.setSchemaContext(getSchemaServiceDependency().getGlobalContext());
+ LOG.debug("ConfigDataTreeModule.createInstance()");
return new CloseableConfigDataTree(
- new ConfigDataTree(getSerializerDependency(), dataTree, getWriterRegistryDependency()));
+ new ConfigDataTree(getSerializerDependency(), getDataTreeDependency(), getWriterRegistryDependency()));
}
private static final class CloseableConfigDataTree implements ModifiableDataTree, AutoCloseable {
@@ -53,7 +48,7 @@ public class ConfigDataTreeModule extends
@Override
public void close() throws Exception {
- LOG.info("CloseableConfigDataTree.close()");
+ LOG.debug("CloseableConfigDataTree.close()");
// NOP
}
@@ -65,12 +60,6 @@ public class ConfigDataTreeModule extends
}
@Override
- public void initialize(final DataTreeModification modification) throws DataValidationFailedException {
- LOG.trace("CloseableConfigDataTree.initialize modification={}", modification);
- delegate.initialize(modification);
- }
-
- @Override
public DataTreeSnapshot takeSnapshot() {
LOG.trace("CloseableConfigDataTree.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/InMemoryConfigDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java
new file mode 100644
index 000000000..9ae8a01f5
--- /dev/null
+++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java
@@ -0,0 +1,81 @@
+package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;
+
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+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;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InMemoryConfigDataTreeModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryConfigDataTreeModule {
+
+ private static final Logger LOG = LoggerFactory.getLogger(InMemoryConfigDataTreeModule.class);
+
+ public InMemoryConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public InMemoryConfigDataTreeModule(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.InMemoryConfigDataTreeModule 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() {
+ LOG.debug("InMemoryConfigDataTreeModule.createInstance()");
+ return new CloseableConfigDataTree(getSchemaServiceDependency().getGlobalContext());
+ }
+
+ private static class CloseableConfigDataTree implements AutoCloseable, DataTree {
+ private final DataTree dataTree;
+
+ public CloseableConfigDataTree(final SchemaContext schemaContext) {
+ this.dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
+ dataTree.setSchemaContext(schemaContext);
+ }
+
+ @Override
+ public void close() throws Exception {
+ // NOP
+ }
+
+ @Override
+ public DataTreeSnapshot takeSnapshot() {
+ return dataTree.takeSnapshot();
+ }
+
+ @Override
+ public void setSchemaContext(final SchemaContext newSchemaContext) {
+ dataTree.setSchemaContext(newSchemaContext);
+ }
+
+ @Override
+ public void commit(final DataTreeCandidate candidate) {
+ dataTree.commit(candidate);
+ }
+
+ @Override
+ public YangInstanceIdentifier getRootPath() {
+ return dataTree.getRootPath();
+ }
+
+ @Override
+ public void validate(final DataTreeModification modification) throws DataValidationFailedException {
+ dataTree.validate(modification);
+ }
+
+ @Override
+ public DataTreeCandidate prepare(final DataTreeModification modification) {
+ return dataTree.prepare(modification);
+ }
+ }
+}
diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java
new file mode 100644
index 000000000..504e007c0
--- /dev/null
+++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: data-impl yang module local name: inmemory-config-data-tree
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Apr 12 07:26:54 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 InMemoryConfigDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryConfigDataTreeModuleFactory {
+
+}
diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java
index 0034b12c5..24a1ca519 100644
--- a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java
+++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java
@@ -35,7 +35,7 @@ public class OperationalDataTreeModule extends
@Override
public java.lang.AutoCloseable createInstance() {
- LOG.info("OperationalDataTreeModule.createInstance()");
+ LOG.debug("OperationalDataTreeModule.createInstance()");
return new CloseableOperationalDataTree(
new OperationalDataTree(getSerializerDependency(), getSchemaServiceDependency().getGlobalContext(),
getReaderRegistryDependency()));
@@ -51,7 +51,7 @@ public class OperationalDataTreeModule extends
@Override
public void close() throws Exception {
- LOG.info("CloseableOperationalDataTree.close()");
+ LOG.debug("CloseableOperationalDataTree.close()");
// NOP
}
diff --git a/v3po/data-impl/src/main/yang/data-impl.yang b/v3po/data-impl/src/main/yang/data-impl.yang
index a1dfee301..43201a084 100644
--- a/v3po/data-impl/src/main/yang/data-impl.yang
+++ b/v3po/data-impl/src/main/yang/data-impl.yang
@@ -18,6 +18,32 @@ module data-impl {
"Initial revision.";
}
+ identity data-tree {
+ base "config:service-type";
+ config:java-class org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+ }
+
+ identity inmemory-config-data-tree {
+ base config:module-type;
+ config:provided-service data-tree;
+ config:java-name-prefix InMemoryConfigDataTree;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case inmemory-config-data-tree {
+ when "/config:modules/config:module/config:type = 'inmemory-config-data-tree'";
+
+ container schema-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity dom:schema-service;
+ }
+ }
+ }
+ }
+ }
+
identity honeycomb-config-data-tree {
base config:module-type;
config:provided-service dapi:honeycomb-modifiable-data-tree;
@@ -28,11 +54,11 @@ module data-impl {
case honeycomb-config-data-tree {
when "/config:modules/config:module/config:type = 'honeycomb-config-data-tree'";
- container schema-service {
+ container data-tree {
uses config:service-ref {
refine type {
mandatory true;
- config:required-identity dom:schema-service;
+ config:required-identity data-tree;
}
}
}
@@ -97,5 +123,4 @@ module data-impl {
}
}
-
} \ No newline at end of file
diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml
index 328d00204..518a6fa58 100644
--- a/v3po/impl/src/main/config/default-config.xml
+++ b/v3po/impl/src/main/config/default-config.xml
@@ -37,13 +37,25 @@
<name>write-registry</name>
</module>
+ <!-- In-memory data tree for HC config data tree -->
<module>
- <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:honeycomb-config-data-tree</type>
- <name>config-data-tree</name>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:inmemory-config-data-tree</type>
+ <name>inmemory-config-data-tree</name>
<schema-service>
<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
<name>yang-schema-service</name>
</schema-service>
+ </module>
+
+
+ <!-- HC config data tree -->
+ <module>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:honeycomb-config-data-tree</type>
+ <name>config-data-tree</name>
+ <data-tree>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:data-tree</type>
+ <name>inmemory-config-data-tree</name>
+ </data-tree>
<serializer>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
<name>runtime-mapping-singleton</name>
@@ -54,6 +66,7 @@
</writer-registry>
</module>
+ <!-- HC operational data tree -->
<module>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:honeycomb-operational-data-tree</type>
<name>operational-data-tree</name>
@@ -71,6 +84,7 @@
</reader-registry>
</module>
+ <!-- DOM data broker which provides transaction functionality for HC using BI format-->
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:v3po:impl">prefix:honeycomb-dom-data-broker</type>
<name>honeycomb-dom-data-broker</name>
@@ -84,6 +98,7 @@
</operational-data-tree>
</module>
+ <!-- Binding data broker which provides transaction functionality for HC using BA format -->
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
<name>honeycomb-binding-data-broker</name>
@@ -119,45 +134,81 @@
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:vpp:japi:cfg">prefix:vpp-japi</type>
<name>vpp-japi</name>
</vpp-japi>
- <reader-registry>
- <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-registry</type>
- <name>read-registry</name>
- </reader-registry>
- <writer-registry>
- <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type>
- <name>write-registry</name>
- </writer-registry>
<serializer>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
<name>runtime-mapping-singleton</name>
</serializer>
+ <dom-data-broker>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-async-data-broker</type>
+ <name>honeycomb-dom-data-broker</name>
+ </dom-data-broker>
+ </module>
+
+ <!-- Config initialization -->
+ <!-- Empty registry which does not pass data to VPP -->
+ <module>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:utils">prefix:noop-writer-registry</type>
+ <name>noop-writer-registry</name>
+ </module>
+ <!-- Config data tree which does not pass data to translation layer (uses noop-write-registry) -->
+ <module>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:honeycomb-config-data-tree</type>
+ <name>cfg-init-config-data-tree</name>
+ <data-tree>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:data-tree</type>
+ <name>inmemory-config-data-tree</name>
+ </data-tree>
+ <serializer>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+ <name>runtime-mapping-singleton</name>
+ </serializer>
+ <writer-registry>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type>
+ <name>noop-writer-registry</name>
+ </writer-registry>
+ </module>
+ <!-- DOM data broker for config initialization -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:v3po:impl">prefix:honeycomb-dom-data-broker</type>
+ <name>cfg-init-dom-data-broker</name>
<config-data-tree>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-modifiable-data-tree</type>
- <name>config-data-tree</name>
+ <name>cfg-init-config-data-tree</name>
</config-data-tree>
<operational-data-tree>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-readable-data-tree</type>
<name>operational-data-tree</name>
</operational-data-tree>
</module>
-
+ <!-- Binding data broker for config initialization -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
+ <name>cfg-init-binding-data-broker</name>
+ <binding-forwarded-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+ <dom-async-broker>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <name>cfg-init-dom-data-broker</name>
+ </dom-async-broker>
+ <schema-service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+ <name>yang-schema-service</name>
+ </schema-service>
+ <binding-mapping-service>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+ <name>runtime-mapping-singleton</name>
+ </binding-mapping-service>
+ </binding-forwarded-data-broker>
+ </module>
+ <!-- Config initializer -->
<module>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:vpp:data:init">prefix:vpp-cfg-initializer-impl</type>
<name>vpp-cfg-initializer</name>
- <reader-registry>
- <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-registry</type>
- <name>read-registry</name>
- </reader-registry>
- <config-data-tree>
- <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-modifiable-data-tree</type>
- <name>config-data-tree</name>
- </config-data-tree>
- <serializer>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
- <name>runtime-mapping-singleton</name>
- </serializer>
- </module>
-
+ <binding-data-broker>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-async-data-broker</type>
+ <name>cfg-init-binding-data-broker</name>
+ </binding-data-broker>
+ </module>noop-writer-registry
+ <!-- END: Config initialization -->
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
@@ -192,6 +243,16 @@
<provider>/modules/module[type='delegating-writer-registry'][name='write-registry']</provider>
</instance>
</service>
+
+ <service>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:data-tree</type>
+ <instance>
+ <name>inmemory-config-data-tree</name>
+ <provider>/modules/module[type='inmemory-config-data-tree'][name='inmemory-config-data-tree']
+ </provider>
+ </instance>
+ </service>
+
<service>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-modifiable-data-tree</type>
<instance>
@@ -209,14 +270,6 @@
</instance>
</service>
<service>
- <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:vpp:data:init">prefix:vpp-cfg-initializer</type>
- <instance>
- <name>vpp-cfg-initializer</name>
- <provider>/modules/module[type='vpp-cfg-initializer-impl'][name='vpp-cfg-initializer']
- </provider>
- </instance>
- </service>
- <service>
<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
dom:dom-broker-osgi-registry
</type>
@@ -226,6 +279,46 @@
</instance>
</service>
+ <!-- Config initialization -->
+ <service>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type>
+ <instance>
+ <name>noop-writer-registry</name>
+ <provider>/modules/module[type='noop-writer-registry'][name='noop-writer-registry']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-modifiable-data-tree</type>
+ <instance>
+ <name>cfg-init-config-data-tree</name>
+ <provider>/modules/module[type='honeycomb-config-data-tree'][name='cfg-init-config-data-tree']
+ </provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <instance>
+ <name>cfg-init-dom-data-broker</name>
+ <provider>/modules/module[type='honeycomb-dom-data-broker'][name='cfg-init-dom-data-broker']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <instance>
+ <name>cfg-init-binding-data-broker</name>
+ <provider>/modules/module[type='binding-forwarded-data-broker'][name='cfg-init-binding-data-broker']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:vpp:data:init">prefix:vpp-cfg-initializer</type>
+ <instance>
+ <name>vpp-cfg-initializer</name>
+ <provider>/modules/module[type='vpp-cfg-initializer-impl'][name='vpp-cfg-initializer']
+ </provider>
+ </instance>
+ </service>
+ <!-- END: Config initialization -->
+
</services>
</data>
</configuration>
diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
index 36eeb8598..8ed83d53a 100644
--- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
+++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
@@ -20,10 +20,6 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.data.ReadableDataTree;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
-import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -71,31 +67,22 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker
private static final Logger LOG = LoggerFactory.getLogger(V3poProvider.class);
private final Broker domBroker;
private final BindingNormalizedNodeSerializer serializer;
+ private final DOMDataBroker domDataBroker;
private RpcRegistration<V3poService> v3poService;
private VppIetfInterfaceListener vppInterfaceListener;
private VppBridgeDomainListener vppBridgeDomainListener;
private vppApi api;
- private ReaderRegistry readerRegistry;
- private WriterRegistry writerRegistry;
private DataBroker db;
VppPollOperDataImpl vppPollOperData;
private VppDataBrokerInitializationProvider vppDataBrokerInitializationProvider;
- private final ModifiableDataTree configDataTree;
- private final ReadableDataTree operationalDataTree;
public V3poProvider(@Nonnull final Broker domBroker, final vppApi vppJapi,
- @Nonnull final ReaderRegistry readerRegistry,
- @Nonnull final WriterRegistry writerRegistry,
@Nonnull final BindingNormalizedNodeSerializer serializer,
- @Nonnull final ModifiableDataTree configDataTree,
- @Nonnull final ReadableDataTree operationalDataTree) {
+ @Nonnull final DOMDataBroker domDataBroker) {
api = vppJapi;
- this.readerRegistry = Preconditions.checkNotNull(readerRegistry, "readerRegistry should not be null");
- this.writerRegistry = Preconditions.checkNotNull(writerRegistry, "writerRegistry should not be null");
this.domBroker = Preconditions.checkNotNull(domBroker, "domBroker should not be null");
this.serializer = Preconditions.checkNotNull(serializer, "serializer should not be null");
- this.configDataTree = Preconditions.checkNotNull(configDataTree, "configDataTree should not be null");
- this.operationalDataTree = Preconditions.checkNotNull(operationalDataTree, "operationalDataTree should not be null");
+ this.domDataBroker = Preconditions.checkNotNull(domDataBroker, "domDataBroker should not be null");
}
private void initializeVppConfig() {
@@ -206,7 +193,7 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker
startOperationalUpdateTimer();
// TODO make configurable:
- vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry, serializer, configDataTree, operationalDataTree);
+ vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, serializer, domDataBroker);
// TODO pull the registration into Module
domBroker.registerProvider(vppDataBrokerInitializationProvider);
}
diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java
index bbb004b73..c1d22f9da 100644
--- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java
+++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java
@@ -20,11 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.data.ReadableDataTree;
-import io.fd.honeycomb.v3po.data.impl.DataBroker;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
-import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
import java.util.Collection;
import java.util.Collections;
import javax.annotation.Nonnull;
@@ -67,28 +62,18 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
private final TopologyId VPP_TOPOLOGY_ID = TopologyId.getDefaultInstance("vpp-topology");
private final NodeId VPP_TOPOLOGY_NODE_ID = NodeId.getDefaultInstance("vpp");
private final org.opendaylight.controller.md.sal.binding.api.DataBroker bindingBroker;
- private final ReaderRegistry readerRegistry;
private final InstanceIdentifier<Node> mountPointPath;
- private final WriterRegistry writerRegistry;
private final BindingNormalizedNodeSerializer serializer;
private ObjectRegistration<DOMMountPoint> mountPointRegistration;
- private DOMDataBroker broker;
- private final ModifiableDataTree configDataTree;
- private final ReadableDataTree operationalDataTree;
+ private final DOMDataBroker domDataBroker;
public VppDataBrokerInitializationProvider(
@Nonnull final org.opendaylight.controller.md.sal.binding.api.DataBroker bindingBroker,
- @Nonnull final ReaderRegistry readerRegistry,
- @Nonnull final WriterRegistry writerRegistry,
@Nonnull final BindingNormalizedNodeSerializer serializer,
- @Nonnull final ModifiableDataTree configDataTree,
- @Nonnull final ReadableDataTree operationalDataTree) {
+ @Nonnull final DOMDataBroker domDataBroker) {
this.bindingBroker = checkNotNull(bindingBroker, "bindingBroker should not be null");
- this.readerRegistry = checkNotNull(readerRegistry, "readerRegistry should not be null");
- this.writerRegistry = checkNotNull(writerRegistry, "writerRegistry should not be null");
this.serializer = checkNotNull(serializer, "serializer should not be null");
- this.configDataTree = checkNotNull(configDataTree, "configDataTree should not be null");
- this.operationalDataTree = checkNotNull(operationalDataTree, "configDataTree should not be null");
+ this.domDataBroker = checkNotNull(domDataBroker, "domDataBroker should not be null");
this.mountPointPath = getMountPointPath();
}
@@ -115,8 +100,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
final DOMMountPointService.DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(path);
mountPointBuilder.addInitialSchemaContext(globalContext);
- broker = new DataBroker(operationalDataTree, configDataTree);
- mountPointBuilder.addService(DOMDataBroker.class, broker);
+ mountPointBuilder.addService(DOMDataBroker.class, domDataBroker);
mountPointRegistration = mountPointBuilder.register();
final DOMMountPoint mountPoint = mountPointRegistration.getInstance();
@@ -164,7 +148,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
}
public Optional<DOMDataBroker> getBroker() {
- return Optional.fromNullable(broker);
+ return Optional.fromNullable(domDataBroker);
}
@Override
@@ -173,10 +157,6 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
mountPointRegistration.close();
}
- if (broker != null) {
- broker = null;
- }
-
// remove MD-SAL placeholder data for VPP mount point:
final WriteTransaction rwTx = bindingBroker.newWriteOnlyTransaction();
// does not fail if data is not present:
diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/DataBrokerModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/DataBrokerModule.java
index 76f014456..24e34c0a9 100644
--- a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/DataBrokerModule.java
+++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/DataBrokerModule.java
@@ -41,7 +41,7 @@ public class DataBrokerModule extends
@Override
public java.lang.AutoCloseable createInstance() {
- LOG.info("DataBrokerModule.createInstance()");
+ LOG.debug("DataBrokerModule.createInstance()");
return new CloseableDataBroker(
new DataBroker(getOperationalDataTreeDependency(), getConfigDataTreeDependency()));
}
@@ -56,7 +56,7 @@ public class DataBrokerModule extends
@Override
public void close() throws Exception {
- LOG.info("CloseableDataBroker.close()");
+ LOG.debug("CloseableDataBroker.close()");
// NOP
}
diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java
index 959780496..697213b3c 100644
--- a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java
+++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java
@@ -57,9 +57,8 @@ public class V3poModule extends
final Broker domBroker = getDomBrokerDependency();
domBroker.registerProvider(new InitializationProvider());
- final V3poProvider provider = new V3poProvider(domBroker, getVppJapiDependency(), getReaderRegistryDependency(),
- getWriterRegistryDependency(), getSerializerDependency(),
- getConfigDataTreeDependency(), getOperationalDataTreeDependency());
+ final V3poProvider provider = new V3poProvider(domBroker, getVppJapiDependency(), getSerializerDependency(),
+ getDomDataBrokerDependency());
getBrokerDependency().registerProvider(provider);
return provider;
}
diff --git a/v3po/impl/src/main/yang/v3po-impl.yang b/v3po/impl/src/main/yang/v3po-impl.yang
index c0240cde3..d6fd25199 100644
--- a/v3po/impl/src/main/yang/v3po-impl.yang
+++ b/v3po/impl/src/main/yang/v3po-impl.yang
@@ -54,24 +54,6 @@ module v3po-impl {
}
}
- container reader-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tapi:honeycomb-reader-registry;
- }
- }
- }
-
- container writer-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tapi:honeycomb-writer-registry;
- }
- }
- }
-
container serializer {
uses config:service-ref {
refine type {
@@ -81,20 +63,11 @@ module v3po-impl {
}
}
- container config-data-tree {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity dapi:honeycomb-modifiable-data-tree;
- }
- }
- }
-
- container operational-data-tree {
+ container dom-data-broker {
uses config:service-ref {
refine type {
mandatory true;
- config:required-identity dapi:honeycomb-readable-data-tree;
+ config:required-identity dom:dom-async-data-broker;
}
}
}
diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
index cd362345b..ee7619cee 100644
--- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
+++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
@@ -26,11 +26,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.util.concurrent.CheckedFuture;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.data.ReadableDataTree;
import io.fd.honeycomb.v3po.impl.VppDataBrokerInitializationProvider;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
-import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -38,9 +34,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.osgi.framework.Configurable;
public class VppDataBrokerInitializationProviderTest {
@@ -49,15 +45,9 @@ public class VppDataBrokerInitializationProviderTest {
@Mock
private WriteTransaction writeTx;
@Mock
- private ReaderRegistry readerRegistry;
- @Mock
- private WriterRegistry writerRegistry;
- @Mock
private BindingNormalizedNodeSerializer serializer;
@Mock
- private ModifiableDataTree configDataTree;
- @Mock
- private ReadableDataTree operationalDataTree;
+ private DOMDataBroker domDataBroker;
private VppDataBrokerInitializationProvider provider;
@@ -65,8 +55,7 @@ public class VppDataBrokerInitializationProviderTest {
public void setUp() throws Exception {
initMocks(this);
doReturn(writeTx).when(bindingBroker).newWriteOnlyTransaction();
- provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry, serializer,
- configDataTree, operationalDataTree);
+ provider = new VppDataBrokerInitializationProvider(bindingBroker, serializer, domDataBroker);
}
@Test
diff --git a/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java b/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java
index 060b436cd..845e679d6 100644
--- a/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java
+++ b/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java
@@ -21,16 +21,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.data.ReadableDataTree;
import io.fd.honeycomb.v3po.impl.V3poProvider;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
-import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
import javax.management.ObjectName;
import org.junit.Test;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
@@ -55,16 +52,10 @@ public class V3poModuleTest {
final org.opendaylight.controller.sal.core.api.Broker domBroker = mock(org.opendaylight.controller.sal.core.api.Broker.class);
when(dependencyResolver.resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class)))
.thenReturn(domBroker);
- when(dependencyResolver.resolveInstance(eq(ReaderRegistry.class), any(ObjectName.class), any(JmxAttribute.class)))
- .thenReturn(mock(ReaderRegistry.class));
- when(dependencyResolver.resolveInstance(eq(WriterRegistry.class), any(ObjectName.class), any(JmxAttribute.class)))
- .thenReturn(mock(WriterRegistry.class));
when(dependencyResolver.resolveInstance(eq(BindingNormalizedNodeSerializer.class), any(ObjectName.class), any(JmxAttribute.class)))
.thenReturn(mock(BindingNormalizedNodeSerializer.class));
- when(dependencyResolver.resolveInstance(eq(ModifiableDataTree.class), any(ObjectName.class), any(JmxAttribute.class)))
- .thenReturn(mock(ModifiableDataTree.class));
- when(dependencyResolver.resolveInstance(eq(ReadableDataTree.class), any(ObjectName.class), any(JmxAttribute.class)))
- .thenReturn(mock(ReadableDataTree.class));
+ when(dependencyResolver.resolveInstance(eq(DOMDataBroker.class), any(ObjectName.class), any(JmxAttribute.class)))
+ .thenReturn(mock(DOMDataBroker.class));
// create instance of module with injected mocks
V3poModule module = new V3poModule(mock(ModuleIdentifier.class), dependencyResolver);
diff --git a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/CloseableWriterRegistry.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/CloseableWriterRegistry.java
new file mode 100644
index 000000000..cd53a4f8b
--- /dev/null
+++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/CloseableWriterRegistry.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.v3po.translate.util.write;
+
+import io.fd.honeycomb.v3po.translate.TranslationException;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
+import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
+import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * WriterRegistry wrapper providing AutoCloseable interface.
+ */
+public final class CloseableWriterRegistry implements WriterRegistry, AutoCloseable {
+ private final WriterRegistry writerRegistry;
+
+ public CloseableWriterRegistry( final WriterRegistry writerRegistry) {
+ this.writerRegistry = writerRegistry;
+ }
+
+ @Override
+ public void update(
+ @Nonnull final Map<InstanceIdentifier<?>, DataObject> nodesBefore,
+ @Nonnull final Map<InstanceIdentifier<?>, DataObject> nodesAfter,
+ @Nonnull final WriteContext ctx) throws TranslationException {
+ writerRegistry.update(nodesBefore, nodesAfter, ctx);
+ }
+
+ @Override
+ public void update(
+ @Nonnull final InstanceIdentifier<? extends DataObject> id,
+ @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter,
+ @Nonnull final WriteContext ctx) throws WriteFailedException {
+ writerRegistry.update(id, dataBefore, dataAfter, ctx);
+ }
+
+ @Nonnull
+ @Override
+ public InstanceIdentifier<DataObject> getManagedDataObjectType() {
+ return writerRegistry.getManagedDataObjectType();
+ }
+
+ @Override
+ public void close() throws Exception {
+ // NOOP
+ }
+} \ No newline at end of file
diff --git a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterRegistry.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterRegistry.java
new file mode 100644
index 000000000..866854212
--- /dev/null
+++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/NoopWriterRegistry.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.v3po.translate.util.write;
+
+import io.fd.honeycomb.v3po.translate.TranslationException;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
+import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
+import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Empty registry that does not perform any changes. Can be used in data layer, if we want to disable passing data to
+ * translation layer.
+ */
+public class NoopWriterRegistry implements WriterRegistry {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NoopWriterRegistry.class);
+
+ @Override
+ public void update(@Nonnull final Map<InstanceIdentifier<?>, DataObject> dataBefore,
+ @Nonnull final Map<InstanceIdentifier<?>, DataObject> dataAfter, @Nonnull final WriteContext ctx)
+ throws TranslationException {
+ LOG.trace("NoopWriterRegistry.update dataBefore{}, dataAfter={], ctx={}", dataBefore, dataAfter, ctx);
+ // NOOP
+ }
+
+ @Override
+ public void update(@Nonnull final InstanceIdentifier<? extends DataObject> id,
+ @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter,
+ @Nonnull final WriteContext ctx) throws WriteFailedException {
+ LOG.trace("NoopWriterRegistry.update id={}, dataBefore{}, dataAfter={], ctx={}", id, dataBefore, dataAfter,
+ ctx);
+ // NOOP
+ }
+
+ @Nonnull
+ @Override
+ public InstanceIdentifier<DataObject> getManagedDataObjectType() {
+ throw new UnsupportedOperationException("Root registry has no type");
+ }
+}
diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingWriterRegistryModule.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingWriterRegistryModule.java
index 72ec87691..0266ca900 100644
--- a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingWriterRegistryModule.java
+++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingWriterRegistryModule.java
@@ -2,18 +2,11 @@ package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.
import com.google.common.base.Function;
import com.google.common.collect.Lists;
-import io.fd.honeycomb.v3po.translate.TranslationException;
+import io.fd.honeycomb.v3po.translate.util.write.CloseableWriterRegistry;
import io.fd.honeycomb.v3po.translate.util.write.DelegatingWriterRegistry;
-import io.fd.honeycomb.v3po.translate.write.WriteContext;
-import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import io.fd.honeycomb.v3po.translate.write.Writer;
-import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
import java.util.List;
-import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class DelegatingWriterRegistryModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractDelegatingWriterRegistryModule {
public DelegatingWriterRegistryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
@@ -43,41 +36,4 @@ public class DelegatingWriterRegistryModule extends org.opendaylight.yang.gen.v1
return new CloseableWriterRegistry(new DelegatingWriterRegistry(rootReadersDependency));
}
- // TODO move to translate-utils
- private static final class CloseableWriterRegistry implements WriterRegistry, AutoCloseable {
- private final DelegatingWriterRegistry delegatingWriterRegistry;
-
- CloseableWriterRegistry(
- final DelegatingWriterRegistry delegatingWriterRegistry) {
- this.delegatingWriterRegistry = delegatingWriterRegistry;
- }
-
- @Override
- public void update(
- @Nonnull final Map<InstanceIdentifier<?>, DataObject> nodesBefore,
- @Nonnull final Map<InstanceIdentifier<?>, DataObject> nodesAfter,
- @Nonnull final WriteContext ctx) throws TranslationException {
- delegatingWriterRegistry.update(nodesBefore, nodesAfter, ctx);
- }
-
- @Override
- public void update(
- @Nonnull final InstanceIdentifier<? extends DataObject> id,
- @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter,
- @Nonnull final WriteContext ctx) throws WriteFailedException {
- delegatingWriterRegistry.update(id, dataBefore, dataAfter, ctx);
- }
-
- @Nonnull
- @Override
- public InstanceIdentifier<DataObject> getManagedDataObjectType() {
- return delegatingWriterRegistry.getManagedDataObjectType();
- }
-
- @Override
- public void close() throws Exception {
- // NOOP
- }
- }
-
}
diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java
new file mode 100644
index 000000000..16c8af359
--- /dev/null
+++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java
@@ -0,0 +1,25 @@
+package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406;
+
+import io.fd.honeycomb.v3po.translate.util.write.*;
+import io.fd.honeycomb.v3po.translate.util.write.NoopWriterRegistry;
+
+public class NoopWriterRegistryModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractNoopWriterRegistryModule {
+ public NoopWriterRegistryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public NoopWriterRegistryModule(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.translate.utils.rev160406.NoopWriterRegistryModule 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() {
+ return new CloseableWriterRegistry(new NoopWriterRegistry());
+ }
+
+}
diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModuleFactory.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModuleFactory.java
new file mode 100644
index 000000000..57b6859f3
--- /dev/null
+++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModuleFactory.java
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: translate-utils yang module local name: noop-writer-registry
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Apr 12 08:41:08 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.translate.utils.rev160406;
+public class NoopWriterRegistryModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractNoopWriterRegistryModuleFactory {
+
+}
diff --git a/v3po/translate-utils/src/main/yang/translate-utils.yang b/v3po/translate-utils/src/main/yang/translate-utils.yang
index 093e1725b..238528d56 100644
--- a/v3po/translate-utils/src/main/yang/translate-utils.yang
+++ b/v3po/translate-utils/src/main/yang/translate-utils.yang
@@ -58,4 +58,15 @@ module translate-utils {
}
}
+ identity noop-writer-registry {
+ base config:module-type;
+ config:provided-service tapi:honeycomb-writer-registry;
+ config:java-name-prefix NoopWriterRegistry;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case noop-writer-registry {
+ when "/config:modules/config:module/config:type = 'noop-writer-registry'";
+ }
+ }
} \ No newline at end of file
diff --git a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/AbstractDataTreeConverter.java b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/AbstractDataTreeConverter.java
index 3048dc18b..bf5a77d4b 100644
--- a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/AbstractDataTreeConverter.java
+++ b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/AbstractDataTreeConverter.java
@@ -20,20 +20,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.translate.Context;
-import io.fd.honeycomb.v3po.translate.read.ReadContext;
-import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
-import java.util.Map;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,20 +42,14 @@ public abstract class AbstractDataTreeConverter<O extends DataObject, C extends
implements DataTreeInitializer {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDataTreeConverter.class);
- private final ReaderRegistry readerRegistry;
- private final ModifiableDataTree configDataTree;
- private final BindingNormalizedNodeSerializer serializer;
private final InstanceIdentifier<O> idOper;
private final InstanceIdentifier<C> idConfig;
+ private final DataBroker bindingDataBroker;
- public AbstractDataTreeConverter(@Nonnull final ReaderRegistry readerRegistry,
- @Nonnull final ModifiableDataTree configDataTree,
- @Nonnull final BindingNormalizedNodeSerializer serializer,
- @Nonnull final InstanceIdentifier<O> idOper,
- @Nonnull final InstanceIdentifier<C> idConfig) {
- this.readerRegistry = checkNotNull(readerRegistry, "readerRegistry should not be null");
- this.configDataTree = checkNotNull(configDataTree, "configDataTree should not be null");
- this.serializer = checkNotNull(serializer, "serializer should not be null");
+ public AbstractDataTreeConverter(final DataBroker bindingDataBroker,
+ final InstanceIdentifier<O> idOper,
+ final InstanceIdentifier<C> idConfig) {
+ this.bindingDataBroker = checkNotNull(bindingDataBroker, "bindingDataBroker should not be null");
this.idOper = checkNotNull(idOper, "idOper should not be null");
this.idConfig = checkNotNull(idConfig, "idConfig should not be null");
}
@@ -69,59 +57,42 @@ public abstract class AbstractDataTreeConverter<O extends DataObject, C extends
@Override
public final void initialize() throws InitializeException {
LOG.debug("AbstractDataTreeConverter.initialize()");
-
- final Optional<? extends DataObject> data;
- try (ReadContext ctx = new ReadContextImpl()) {
- data = readerRegistry.read(idOper, ctx);
- } catch (ReadFailedException e) {
- LOG.warn("Failed to read operational state", e);
- return;
- }
- LOG.debug("Config initialization data={}", data);
+ final Optional<O> data = readData();
if (data.isPresent()) {
- // conversion
- final O operationalData = idOper.getTargetType().cast(data.get());
- final C configData = convert(operationalData);
+ LOG.debug("Config initialization data={}", data);
- final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedData =
- serializer.toNormalizedNode(idConfig, configData);
-
- final DataTreeModification modification = configDataTree.takeSnapshot().newModification();
- final YangInstanceIdentifier biPath = normalizedData.getKey();
- final NormalizedNode<?, ?> biData = normalizedData.getValue();
- LOG.debug("Config initialization biPath={}, biData={}", biPath, biData);
- modification.write(biPath, biData);
- modification.ready();
+ final O operationalData = data.get();
+ final C configData = convert(operationalData);
- LOG.debug("Config writing modification ...");
try {
- configDataTree.initialize(modification);
- LOG.debug("Config writing modification written successfully.");
- } catch (DataValidationFailedException e) {
- throw new InitializeException("Failed to read operational state", e);
+ LOG.debug("Initializing config with data={}", configData);
+ writeData(configData);
+ LOG.debug("Config initialization successful");
+ } catch (TransactionCommitFailedException e) {
+ throw new InitializeException("Failed to perform config initialization", e);
}
} else {
LOG.warn("Data is not present");
}
}
- protected abstract C convert(final O operationalData);
-
- // TODO move to utility module
- private static final class ReadContextImpl implements ReadContext {
- public final Context ctx = new Context();
-
- @Nonnull
- @Override
- public Context getContext() {
- return ctx;
+ private Optional<O> readData() {
+ try (ReadOnlyTransaction readTx = bindingDataBroker.newReadOnlyTransaction()) {
+ final CheckedFuture<Optional<O>, org.opendaylight.controller.md.sal.common.api.data.ReadFailedException>
+ readFuture = readTx.read(LogicalDatastoreType.OPERATIONAL, idOper);
+ return readFuture.checkedGet();
+ } catch (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException e) {
+ LOG.warn("Failed to read operational state", e);
}
+ return Optional.absent();
+ }
- @Override
- public void close() {
- // Make sure to clear the storage in case some customizer stored it to prevent memory leaks
- ctx.close();
- }
+ private void writeData(final C configData) throws TransactionCommitFailedException {
+ final WriteTransaction writeTx = bindingDataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, idConfig, configData);
+ writeTx.submit().checkedGet();
}
+
+ protected abstract C convert(final O operationalData);
}
diff --git a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/VppInitializer.java b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/VppInitializer.java
index c0316c0b8..3fad2a8d3 100644
--- a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/VppInitializer.java
+++ b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/VppInitializer.java
@@ -16,18 +16,16 @@
package io.fd.honeycomb.v3po.vpp.data.init;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomains;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,10 +33,8 @@ import org.slf4j.LoggerFactory;
public class VppInitializer extends AbstractDataTreeConverter<VppState, Vpp> {
private static final Logger LOG = LoggerFactory.getLogger(VppInitializer.class);
- public VppInitializer(@Nonnull final ReaderRegistry readerRegistry,
- @Nonnull final ModifiableDataTree configDataTree,
- @Nonnull final BindingNormalizedNodeSerializer serializer) {
- super(readerRegistry, configDataTree, serializer, InstanceIdentifier.create(VppState.class), InstanceIdentifier.create(Vpp.class) );
+ public VppInitializer(@Nonnull final DataBroker bindingDataBroker) {
+ super(bindingDataBroker, InstanceIdentifier.create(VppState.class), InstanceIdentifier.create(Vpp.class));
}
@Override
@@ -61,7 +57,6 @@ public class VppInitializer extends AbstractDataTreeConverter<VppState, Vpp> {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain>
listOfBDs = new ArrayList<>();
- // TODO use reflexion
for (BridgeDomain bd : bridgeDomainList) {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder
bdBuilder =
diff --git a/v3po/vpp-cfg-init/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/vpp/data/init/rev160407/VppConfigurationInitializerModule.java b/v3po/vpp-cfg-init/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/vpp/data/init/rev160407/VppConfigurationInitializerModule.java
index 8b6f589c4..eddc74d27 100644
--- a/v3po/vpp-cfg-init/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/vpp/data/init/rev160407/VppConfigurationInitializerModule.java
+++ b/v3po/vpp-cfg-init/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/vpp/data/init/rev160407/VppConfigurationInitializerModule.java
@@ -1,13 +1,11 @@
package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.vpp.data.init.rev160407;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
-import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
import io.fd.honeycomb.v3po.vpp.data.init.DataTreeInitializer;
import io.fd.honeycomb.v3po.vpp.data.init.InitializerRegistry;
import io.fd.honeycomb.v3po.vpp.data.init.InitializerRegistryImpl;
import io.fd.honeycomb.v3po.vpp.data.init.VppInitializer;
import java.util.Collections;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,14 +33,12 @@ public class VppConfigurationInitializerModule extends
@Override
public java.lang.AutoCloseable createInstance() {
- LOG.info("VppConfigurationInitializerModule.createInstance()");
- final ReaderRegistry readerRegistry = getReaderRegistryDependency();
- final ModifiableDataTree configDataTree = getConfigDataTreeDependency();
- final BindingNormalizedNodeSerializer serializer = getSerializerDependency();
+ LOG.debug("VppConfigurationInitializerModule.createInstance()");
+ final DataBroker bindingDataBroker = getBindingDataBrokerDependency();
// TODO make configurable
final VppInitializer vppInitializer =
- new VppInitializer(readerRegistry, configDataTree, serializer);
+ new VppInitializer(bindingDataBroker);
final InitializerRegistry initializer =
new InitializerRegistryImpl(Collections.<DataTreeInitializer>singletonList(vppInitializer));
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 15a842e0e..e4ce95aea 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
@@ -31,33 +31,14 @@ module vpp-cfg-init {
case vpp-cfg-initializer-impl {
when "/config:modules/config:module/config:type = 'vpp-cfg-initializer-impl'";
- container reader-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity tapi:honeycomb-reader-registry;
- }
- }
- }
-
- // TODO swich to binding broker
- container config-data-tree {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity dapi:honeycomb-modifiable-data-tree;
- }
- }
- }
-
- container serializer {
+ container binding-data-broker {
uses config:service-ref {
refine type {
mandatory true;
- config:required-identity md-sal-binding:binding-normalized-node-serializer;
+ config:required-identity md-sal-binding:binding-async-data-broker;
}
}
- }
+ }
}
}
diff --git a/v3po/vpp-cfg-init/src/test/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImplTest.java b/v3po/vpp-cfg-init/src/test/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImplTest.java
index d77ac3fe5..d562fb60c 100644
--- a/v3po/vpp-cfg-init/src/test/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImplTest.java
+++ b/v3po/vpp-cfg-init/src/test/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImplTest.java
@@ -19,7 +19,6 @@ package io.fd.honeycomb.v3po.vpp.data.init;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
-import java.util.ArrayList;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
@@ -34,18 +33,12 @@ public class InitializerRegistryImplTest {
@Mock(name="dti3")
private DataTreeInitializer dti3;
- private ArrayList<DataTreeInitializer> initializers;
-
private InitializerRegistryImpl initializerRegistry;
@Before
public void setUp() throws Exception {
initMocks(this);
- initializers = new ArrayList<>();
- initializers.add(dti1);
- initializers.add(dti2);
- initializers.add(dti3);
- initializerRegistry = new InitializerRegistryImpl(initializers);
+ initializerRegistry = new InitializerRegistryImpl(Arrays.asList(dti1, dti2, dti3));
}
@Test(expected = IllegalArgumentException.class)