From 3edb738db9c756d42ee5c0b6fa172b6f2caa808a Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 11 Apr 2016 21:23:57 +0200 Subject: HONEYCOMB-34: Config tree initialization using binding data broker Change-Id: I070aca2cc35dd10ea5bde19c8cbf4cad1c50f468 Signed-off-by: Marek Gradzki --- v3po/impl/src/main/config/default-config.xml | 161 ++++++++++++++++----- .../io/fd/honeycomb/v3po/impl/V3poProvider.java | 21 +-- .../impl/VppDataBrokerInitializationProvider.java | 30 +--- .../yang/v3po/impl/rev141210/DataBrokerModule.java | 4 +- .../ns/yang/v3po/impl/rev141210/V3poModule.java | 5 +- v3po/impl/src/main/yang/v3po-impl.yang | 31 +--- .../VppDataBrokerInitializationProviderTest.java | 17 +-- .../yang/v3po/impl/rev141210/V3poModuleTest.java | 15 +- 8 files changed, 148 insertions(+), 136 deletions(-) (limited to 'v3po/impl') 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 @@ write-registry + - prefix:honeycomb-config-data-tree - config-data-tree + prefix:inmemory-config-data-tree + inmemory-config-data-tree dom:schema-service yang-schema-service + + + + + + prefix:honeycomb-config-data-tree + config-data-tree + + prefix:data-tree + inmemory-config-data-tree + prefix:binding-dom-mapping-service runtime-mapping-singleton @@ -54,6 +66,7 @@ + prefix:honeycomb-operational-data-tree operational-data-tree @@ -71,6 +84,7 @@ + prefix:honeycomb-dom-data-broker honeycomb-dom-data-broker @@ -84,6 +98,7 @@ + prefix:binding-forwarded-data-broker honeycomb-binding-data-broker @@ -119,45 +134,81 @@ prefix:vpp-japi vpp-japi - - prefix:honeycomb-reader-registry - read-registry - - - prefix:honeycomb-writer-registry - write-registry - prefix:binding-dom-mapping-service runtime-mapping-singleton + + prefix:dom-async-data-broker + honeycomb-dom-data-broker + + + + + + + prefix:noop-writer-registry + noop-writer-registry + + + + prefix:honeycomb-config-data-tree + cfg-init-config-data-tree + + prefix:data-tree + inmemory-config-data-tree + + + prefix:binding-dom-mapping-service + runtime-mapping-singleton + + + prefix:honeycomb-writer-registry + noop-writer-registry + + + + + prefix:honeycomb-dom-data-broker + cfg-init-dom-data-broker prefix:honeycomb-modifiable-data-tree - config-data-tree + cfg-init-config-data-tree prefix:honeycomb-readable-data-tree operational-data-tree - + + + prefix:binding-forwarded-data-broker + cfg-init-binding-data-broker + + + dom:dom-async-data-broker + cfg-init-dom-data-broker + + + dom:schema-service + yang-schema-service + + + binding:binding-dom-mapping-service + runtime-mapping-singleton + + + + prefix:vpp-cfg-initializer-impl vpp-cfg-initializer - - prefix:honeycomb-reader-registry - read-registry - - - prefix:honeycomb-modifiable-data-tree - config-data-tree - - - binding:binding-dom-mapping-service - runtime-mapping-singleton - - - + + prefix:binding-async-data-broker + cfg-init-binding-data-broker + + noop-writer-registry + @@ -192,6 +243,16 @@ /modules/module[type='delegating-writer-registry'][name='write-registry'] + + + prefix:data-tree + + inmemory-config-data-tree + /modules/module[type='inmemory-config-data-tree'][name='inmemory-config-data-tree'] + + + + prefix:honeycomb-modifiable-data-tree @@ -208,14 +269,6 @@ - - prefix:vpp-cfg-initializer - - vpp-cfg-initializer - /modules/module[type='vpp-cfg-initializer-impl'][name='vpp-cfg-initializer'] - - - dom:dom-broker-osgi-registry @@ -226,6 +279,46 @@ + + + prefix:honeycomb-writer-registry + + noop-writer-registry + /modules/module[type='noop-writer-registry'][name='noop-writer-registry'] + + + + prefix:honeycomb-modifiable-data-tree + + cfg-init-config-data-tree + /modules/module[type='honeycomb-config-data-tree'][name='cfg-init-config-data-tree'] + + + + + dom:dom-async-data-broker + + cfg-init-dom-data-broker + /modules/module[type='honeycomb-dom-data-broker'][name='cfg-init-dom-data-broker'] + + + + binding:binding-async-data-broker + + cfg-init-binding-data-broker + /modules/module[type='binding-forwarded-data-broker'][name='cfg-init-binding-data-broker'] + + + + prefix:vpp-cfg-initializer + + vpp-cfg-initializer + /modules/module[type='vpp-cfg-initializer-impl'][name='vpp-cfg-initializer'] + + + + + 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; 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 mountPointPath; - private final WriterRegistry writerRegistry; private final BindingNormalizedNodeSerializer serializer; private ObjectRegistration 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 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); -- cgit 1.2.3-korg