diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-04-11 00:18:11 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-04-12 11:02:55 +0200 |
commit | d99066504f76a181c90832b939956f43b409c075 (patch) | |
tree | 2f863ec633c9869cf8803db44073730a3eed0323 /v3po/impl/src | |
parent | ac1fa871f050c36b798047fe7e93718d4681996a (diff) |
HONEYCOMB-34: Configurable OperationalDataTree dependency
Change-Id: I675a4ae11845990dfcacbe99eb0a1b799485de35
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/impl/src')
7 files changed, 64 insertions, 24 deletions
diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml index 3d0e4f7fc..e35c3a421 100644 --- a/v3po/impl/src/main/config/default-config.xml +++ b/v3po/impl/src/main/config/default-config.xml @@ -88,15 +88,14 @@ <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> + <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> + </serializer> <writer-registry> <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type> <name>write-registry</name> @@ -104,6 +103,23 @@ </module> <module> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:impl">prefix:honeycomb-operational-data-tree</type> + <name>operational-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> + <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> + <reader-registry> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-registry</type> + <name>read-registry</name> + </reader-registry> + </module> + + <module> <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:v3po:impl">prefix:v3po</type> <name>v3po-default</name> <broker> @@ -134,6 +150,10 @@ <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> + <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> <module> @@ -189,6 +209,14 @@ </instance> </service> <service> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:data:api">prefix:honeycomb-readable-data-tree</type> + <instance> + <name>operational-data-tree</name> + <provider>/modules/module[type='honeycomb-operational-data-tree'][name='operational-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> 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 bd5141282..36eeb8598 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 @@ -21,6 +21,7 @@ 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; @@ -80,18 +81,21 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker 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 ModifiableDataTree configDataTree, + @Nonnull final ReadableDataTree operationalDataTree) { 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"); } private void initializeVppConfig() { @@ -202,7 +206,7 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker startOperationalUpdateTimer(); // TODO make configurable: - vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry, serializer, configDataTree); + vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry, serializer, configDataTree, operationalDataTree); // 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 e0e8c999e..84301b711 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 @@ -26,7 +26,6 @@ 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.DataBroker; -import io.fd.honeycomb.v3po.data.impl.OperationalDataTree; import io.fd.honeycomb.v3po.translate.Context; import io.fd.honeycomb.v3po.translate.TranslationException; import io.fd.honeycomb.v3po.translate.read.ReadContext; @@ -95,19 +94,22 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto private final BindingNormalizedNodeSerializer serializer; private ObjectRegistration<DOMMountPoint> mountPointRegistration; private DOMDataBroker broker; - private ModifiableDataTree configDataTree; + private final ModifiableDataTree configDataTree; + private final ReadableDataTree operationalDataTree; 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 ModifiableDataTree configDataTree, + @Nonnull final ReadableDataTree operationalDataTree) { 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.mountPointPath = getMountPointPath(); } @@ -129,13 +131,12 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto final SchemaService schemaService = providerSession.getService(SchemaService.class); final SchemaContext globalContext = schemaService.getGlobalContext(); - // final BindingNormalizedNodeSerializer serializer = initSerializer(globalContext); final YangInstanceIdentifier path = serializer.toYangInstanceIdentifier(mountPointPath); final DOMMountPointService.DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(path); mountPointBuilder.addInitialSchemaContext(globalContext); - broker = initVppDataBroker(globalContext, serializer, configDataTree); + broker = initVppDataBroker(operationalDataTree, serializer, configDataTree); mountPointBuilder.addService(DOMDataBroker.class, broker); mountPointRegistration = mountPointBuilder.register(); @@ -167,19 +168,9 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto } } - private DOMDataBroker initVppDataBroker(final SchemaContext globalContext, + private DOMDataBroker initVppDataBroker(final ReadableDataTree operationalDataTree, 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 ModifiableDataTree configDataTree = -// new ConfigDataTree(serializer, dataTree, writerRegistry); // TODO make configurable - // init operational data tree before data broker is initialized try { @@ -191,6 +182,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto return new DataBroker(operationalDataTree, configDataTree); } + // FIXME move to initializer after wiring is finished private void initConfig(final BindingNormalizedNodeSerializer serializer, final ModifiableDataTree configDataTree) throws TranslationException, DataValidationFailedException { LOG.info("Config initialization"); @@ -230,7 +222,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain> listOfBDs = new ArrayList<>(); - // TODO use reflexions + // 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 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder(); bdBuilder.setLearn(bd.isLearn()); 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 0078f16fc..bae4a29d3 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 @@ -59,7 +59,7 @@ public class V3poModule extends final V3poProvider provider = new V3poProvider(domBroker, getVppJapiDependency(), getReaderRegistryDependency(), getWriterRegistryDependency(), getBindingNormalizedNodeSerializerDependency(), - getConfigDataTreeDependency()); + getConfigDataTreeDependency(), getOperationalDataTreeDependency()); 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 2c2e95028..b9868c450 100644 --- a/v3po/impl/src/main/yang/v3po-impl.yang +++ b/v3po/impl/src/main/yang/v3po-impl.yang @@ -90,6 +90,15 @@ module v3po-impl { } } + container operational-data-tree { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity dapi:honeycomb-readable-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 166104d67..cd362345b 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 @@ -27,6 +27,7 @@ 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; @@ -55,6 +56,8 @@ public class VppDataBrokerInitializationProviderTest { private BindingNormalizedNodeSerializer serializer; @Mock private ModifiableDataTree configDataTree; + @Mock + private ReadableDataTree operationalDataTree; private VppDataBrokerInitializationProvider provider; @@ -62,7 +65,8 @@ public class VppDataBrokerInitializationProviderTest { public void setUp() throws Exception { initMocks(this); doReturn(writeTx).when(bindingBroker).newWriteOnlyTransaction(); - provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry, serializer, configDataTree); + provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry, serializer, + configDataTree, operationalDataTree); } @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 fb8c7047b..060b436cd 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 @@ -22,6 +22,7 @@ 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; @@ -62,6 +63,8 @@ public class V3poModuleTest { .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)); // create instance of module with injected mocks V3poModule module = new V3poModule(mock(ModuleIdentifier.class), dependencyResolver); |