diff options
Diffstat (limited to 'v3po')
11 files changed, 177 insertions, 27 deletions
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 88e87956b..115eb065f 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 @@ -33,8 +33,8 @@ public class ConfigDataTreeModule extends public java.lang.AutoCloseable createInstance() { final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); dataTree.setSchemaContext(getSchemaServiceDependency().getGlobalContext()); - return new CloseableConfigDataTree(new ConfigDataTree(getBindingNormalizedNodeSerializerDependency(), dataTree, - getWriterRegistryDependency())); + return new CloseableConfigDataTree( + new ConfigDataTree(getSerializerDependency(), dataTree, getWriterRegistryDependency())); } private static final class CloseableConfigDataTree implements ModifiableDataTree, AutoCloseable { 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 new file mode 100644 index 000000000..48053c366 --- /dev/null +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java @@ -0,0 +1,57 @@ +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.CheckedFuture; +import io.fd.honeycomb.v3po.data.ReadableDataTree; +import io.fd.honeycomb.v3po.data.impl.OperationalDataTree; +import javax.annotation.Nonnull; +import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class OperationalDataTreeModule extends + org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractOperationalDataTreeModule { + public OperationalDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public OperationalDataTreeModule(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.OperationalDataTreeModule 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 CloseableOperationalDataTree( + new OperationalDataTree(getSerializerDependency(), getSchemaServiceDependency().getGlobalContext(), + getReaderRegistryDependency())); + } + + private static final class CloseableOperationalDataTree implements ReadableDataTree, AutoCloseable { + + private final OperationalDataTree delegate; + + CloseableOperationalDataTree(final OperationalDataTree delegate) { + this.delegate = delegate; + } + + @Override + public void close() throws Exception { + // NOP + } + + @Override + public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read( + @Nonnull final YangInstanceIdentifier path) { + return delegate.read(path); + } + } +} diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModuleFactory.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModuleFactory.java new file mode 100644 index 000000000..221eabe5c --- /dev/null +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: data-impl yang module local name: honeycomb-operational-data-tree +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Sun Apr 10 23:52:21 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 OperationalDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractOperationalDataTreeModuleFactory { + +} diff --git a/v3po/data-impl/src/main/yang/data-impl.yang b/v3po/data-impl/src/main/yang/data-impl.yang index 841cdb3df..a1dfee301 100644 --- a/v3po/data-impl/src/main/yang/data-impl.yang +++ b/v3po/data-impl/src/main/yang/data-impl.yang @@ -37,7 +37,7 @@ module data-impl { } } - container binding-normalized-node-serializer { + container serializer { uses config:service-ref { refine type { mandatory true; @@ -58,4 +58,44 @@ module data-impl { } } + identity honeycomb-operational-data-tree { + base config:module-type; + config:provided-service dapi:honeycomb-readable-data-tree; + config:java-name-prefix OperationalDataTree; + } + + augment "/config:modules/config:module/config:configuration" { + case honeycomb-operational-data-tree { + when "/config:modules/config:module/config:type = 'honeycomb-operational-data-tree'"; + + container schema-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity dom:schema-service; + } + } + } + + container serializer { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-normalized-node-serializer; + } + } + } + + container reader-registry { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity tapi:honeycomb-reader-registry; + } + } + } + + } + } + }
\ 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 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); |