diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-04-10 23:45:43 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-04-12 11:00:37 +0200 |
commit | 8764f31fa74942d963dc85dd53227e980ceadf44 (patch) | |
tree | cf4a05617adbe8ef445e6220d40f4b65b6fa6eec /v3po/impl | |
parent | c806dc87185ee3a994685561ea024cad45210036 (diff) |
HONEYCOMB-34: Configurable ConfigDataTree dependency
Change-Id: I17a93835541e66835398391e2a127b25767b774a
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/impl')
7 files changed, 72 insertions, 45 deletions
diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml index 13ab70211..3d0e4f7fc 100644 --- a/v3po/impl/src/main/config/default-config.xml +++ b/v3po/impl/src/main/config/default-config.xml @@ -20,6 +20,7 @@ <capability>urn:honeycomb:params:xml:ns:yang:translate:utils?module=translate-utils&revision=2016-04-06</capability> <capability>urn:honeycomb:params:xml:ns:yang:vpp:japi:cfg?module=vpp-japi-cfg&revision=2016-04-06</capability> <capability>urn:honeycomb:params:xml:ns:yang:vpp:data:init?module=vpp-cfg-init&revision=2016-04-07</capability> + <capability>urn:honeycomb:params:xml:ns:yang:data:impl?module=data-impl&revision=2016-04-11</capability> <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability> </required-capabilities> <configuration> @@ -85,6 +86,24 @@ </module> <module> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:honeycomb-config-data-tree</type> + <name>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> + <binding-normalized-node-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> + </binding-normalized-node-serializer> + <writer-registry> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type> + <name>write-registry</name> + </writer-registry> + </module> + + <module> <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:v3po:impl">prefix:v3po</type> <name>v3po-default</name> <broker> @@ -107,17 +126,14 @@ <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type> <name>write-registry</name> </writer-registry> - - - <!--<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-normalized-node-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> </binding-normalized-node-serializer> + <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> </module> <module> @@ -165,6 +181,14 @@ </instance> </service> <service> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-modifiable-data-tree</type> + <instance> + <name>config-data-tree</name> + <provider>/modules/module[type='honeycomb-config-data-tree'][name='config-data-tree'] + </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> @@ -182,15 +206,6 @@ </instance> </service> - - <!--<service>--> - <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>--> - <!--<instance>--> - <!--<name>runtime-generated-mappingy</name>--> - <!--<provider>/modules/module[type='runtime-generated-mapping'][name='runtime-generated-mapping']</provider>--> - <!--</instance>--> - <!--</service>--> - </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 d07c0ffca..bd5141282 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,6 +20,7 @@ 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.translate.read.ReaderRegistry; import io.fd.honeycomb.v3po.translate.write.WriterRegistry; import java.util.Collections; @@ -78,16 +79,19 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker private DataBroker db; VppPollOperDataImpl vppPollOperData; private VppDataBrokerInitializationProvider vppDataBrokerInitializationProvider; + private final ModifiableDataTree configDataTree; public V3poProvider(@Nonnull final Broker domBroker, final vppApi vppJapi, @Nonnull final ReaderRegistry readerRegistry, @Nonnull final WriterRegistry writerRegistry, - @Nonnull final BindingNormalizedNodeSerializer serializer) { + @Nonnull final BindingNormalizedNodeSerializer serializer, + @Nonnull final ModifiableDataTree configDataTree) { 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"); } private void initializeVppConfig() { @@ -198,7 +202,7 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker startOperationalUpdateTimer(); // TODO make configurable: - vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry, serializer); + vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry, serializer, configDataTree); // 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 b0ee447ba..e0e8c999e 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 @@ -25,7 +25,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import io.fd.honeycomb.v3po.data.ModifiableDataTree; import io.fd.honeycomb.v3po.data.ReadableDataTree; -import io.fd.honeycomb.v3po.data.impl.ConfigDataTree; import io.fd.honeycomb.v3po.data.impl.DataBroker; import io.fd.honeycomb.v3po.data.impl.OperationalDataTree; import io.fd.honeycomb.v3po.translate.Context; @@ -73,11 +72,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; 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.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.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,16 +95,19 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto private final BindingNormalizedNodeSerializer serializer; private ObjectRegistration<DOMMountPoint> mountPointRegistration; private DOMDataBroker broker; + private ModifiableDataTree configDataTree; public VppDataBrokerInitializationProvider( @Nonnull final org.opendaylight.controller.md.sal.binding.api.DataBroker bindingBroker, - final ReaderRegistry readerRegistry, - final WriterRegistry writerRegistry, - final BindingNormalizedNodeSerializer serializer) { + @Nonnull final ReaderRegistry readerRegistry, + @Nonnull final WriterRegistry writerRegistry, + @Nonnull final BindingNormalizedNodeSerializer serializer, + @Nonnull final ModifiableDataTree configDataTree) { 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.mountPointPath = getMountPointPath(); } @@ -136,7 +135,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto final DOMMountPointService.DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(path); mountPointBuilder.addInitialSchemaContext(globalContext); - broker = initVppDataBroker(globalContext, serializer); + broker = initVppDataBroker(globalContext, serializer, configDataTree); mountPointBuilder.addService(DOMDataBroker.class, broker); mountPointRegistration = mountPointBuilder.register(); @@ -169,16 +168,17 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto } private DOMDataBroker initVppDataBroker(final SchemaContext globalContext, - final BindingNormalizedNodeSerializer serializer) { + final BindingNormalizedNodeSerializer serializer, + final ModifiableDataTree configDataTree) { final ReadableDataTree operationalDataTree = new OperationalDataTree(serializer, globalContext, readerRegistry); // TODO make configurable - final DataTree dataTree = - InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); // TODO make configurable - dataTree.setSchemaContext(globalContext); +// final DataTree dataTree = +// InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); // TODO make configurable +// dataTree.setSchemaContext(globalContext); - final ModifiableDataTree configDataTree = - new ConfigDataTree(serializer, dataTree, writerRegistry); // TODO make configurable +// final ModifiableDataTree configDataTree = +// new ConfigDataTree(serializer, dataTree, writerRegistry); // TODO make configurable // init operational data tree before data broker is initialized 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 406525c19..0078f16fc 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 @@ -17,8 +17,6 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210; import io.fd.honeycomb.v3po.impl.V3poProvider; -import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; -import io.fd.honeycomb.v3po.translate.write.WriterRegistry; import java.util.Collection; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; @@ -30,7 +28,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; -import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; @@ -57,17 +54,12 @@ public class V3poModule extends @Override public java.lang.AutoCloseable createInstance() { - final ReaderRegistry readerRegistry = getReaderRegistryDependency(); - final WriterRegistry writerRegistry = getWriterRegistryDependency(); - final Broker domBroker = getDomBrokerDependency(); domBroker.registerProvider(new InitializationProvider()); - final BindingNormalizedNodeSerializer serializer = - getBindingNormalizedNodeSerializerDependency(); - - final V3poProvider provider = - new V3poProvider(domBroker, getVppJapiDependency(), readerRegistry, writerRegistry, serializer); + final V3poProvider provider = new V3poProvider(domBroker, getVppJapiDependency(), getReaderRegistryDependency(), + getWriterRegistryDependency(), getBindingNormalizedNodeSerializerDependency(), + getConfigDataTreeDependency()); 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 589148f28..2c2e95028 100644 --- a/v3po/impl/src/main/yang/v3po-impl.yang +++ b/v3po/impl/src/main/yang/v3po-impl.yang @@ -8,6 +8,7 @@ module v3po-impl { import opendaylight-md-sal-dom {prefix dom;} import vpp-japi-cfg { prefix vjc; revision-date 2016-04-06; } import translate-api { prefix tapi; revision-date 2016-04-06; } + import data-api { prefix dapi; revision-date 2016-04-11; } description "Service definition for v3po project"; @@ -80,6 +81,15 @@ module v3po-impl { } } + container config-data-tree { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity dapi:honeycomb-modifiable-data-tree; + } + } + } + } } 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 eb2349fb2..166104d67 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,6 +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.impl.VppDataBrokerInitializationProvider; import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; import io.fd.honeycomb.v3po.translate.write.WriterRegistry; @@ -38,6 +39,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.osgi.framework.Configurable; public class VppDataBrokerInitializationProviderTest { @@ -51,7 +53,8 @@ public class VppDataBrokerInitializationProviderTest { private WriterRegistry writerRegistry; @Mock private BindingNormalizedNodeSerializer serializer; - + @Mock + private ModifiableDataTree configDataTree; private VppDataBrokerInitializationProvider provider; @@ -59,7 +62,7 @@ public class VppDataBrokerInitializationProviderTest { public void setUp() throws Exception { initMocks(this); doReturn(writeTx).when(bindingBroker).newWriteOnlyTransaction(); - provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry, serializer); + provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry, serializer, configDataTree); } @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 6eef488cc..fb8c7047b 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,6 +21,7 @@ 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.impl.V3poProvider; import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; import io.fd.honeycomb.v3po.translate.write.WriterRegistry; @@ -59,6 +60,8 @@ public class V3poModuleTest { .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)); // create instance of module with injected mocks V3poModule module = new V3poModule(mock(ModuleIdentifier.class), dependencyResolver); |