diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-04-12 10:13:31 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-04-12 10:13:31 +0200 |
commit | 5ba8a8f44117579c9fa6dfdc038c8e41d2213d52 (patch) | |
tree | b57707ccda530b06914d95f3457be591e17384c2 /v3po/impl | |
parent | 4c59ba41ef8c5bfbf5d407c06700857389db973e (diff) |
HONEYCOMB-9: Add configuration and wiring for readers and writers
Remove config module
Wrap vpp-japi in a config module
Change-Id: Iee1e0c653309bd3c1019323ce689dacf3ed995cd
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/impl')
7 files changed, 90 insertions, 31 deletions
diff --git a/v3po/impl/pom.xml b/v3po/impl/pom.xml index be824ca79..ffa16aed2 100644 --- a/v3po/impl/pom.xml +++ b/v3po/impl/pom.xml @@ -46,11 +46,6 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>config</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> <artifactId>data-impl</artifactId> <version>${project.version}</version> </dependency> diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml index 261cd3d6f..f4b75efc7 100644 --- a/v3po/impl/src/main/config/default-config.xml +++ b/v3po/impl/src/main/config/default-config.xml @@ -15,15 +15,26 @@ limitations under the License. --> <snapshot> - <!--TODO update required caps--> <required-capabilities> <capability>urn:opendaylight:params:xml:ns:yang:v3po:impl?module=v3po-impl&revision=2014-12-10</capability> + <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:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability> </required-capabilities> <configuration> <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> + + <module> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:utils">prefix:delegating-reader-registry</type> + <name>read-registry</name> + </module> + <module> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:utils">prefix:delegating-writer-registry</type> + <name>write-registry</name> + </module> + <module> <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:v3po:impl">prefix:v3po</type> <name>v3po-default</name> @@ -35,18 +46,43 @@ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type> <name>dom-broker</name> </dom-broker> + <vpp-japi> + <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> </module> </modules> <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> <service> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-registry</type> + <instance> + <name>read-registry</name> + <provider>/modules/module[type='delegating-reader-registry'][name='read-registry']</provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type> + <instance> + <name>write-registry</name> + <provider>/modules/module[type='delegating-writer-registry'][name='write-registry']</provider> + </instance> + </service> + <service> <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom"> dom:dom-broker-osgi-registry </type> <instance> <name>vpp-dom-broker</name> - <provider>/modules/module[type='v3po'][name='v3po-default'] - </provider> + <provider>/modules/module[type='v3po'][name='v3po-default']</provider> </instance> </service> </services> 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 a97909190..973d34585 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,9 +20,8 @@ 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.config.ReaderRegistry; -import io.fd.honeycomb.v3po.config.WriterRegistry; -import java.io.IOException; +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; @@ -72,11 +71,18 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker private VppIetfInterfaceListener vppInterfaceListener; private VppBridgeDomainListener vppBridgeDomainListener; private vppApi api; + private ReaderRegistry readerRegistry; + private WriterRegistry writerRegistry; private DataBroker db; VppPollOperDataImpl vppPollOperData; private VppDataBrokerInitializationProvider vppDataBrokerInitializationProvider; - public V3poProvider(@Nonnull final Broker domBroker) { + public V3poProvider(@Nonnull final Broker domBroker, final vppApi vppJapiDependency, + final ReaderRegistry readerRegistry, + final WriterRegistry writerRegistry) { + api = vppJapiDependency; + this.readerRegistry = readerRegistry; + this.writerRegistry = writerRegistry; this.domBroker = Preconditions.checkNotNull(domBroker, "domBroker should not be null"); } @@ -98,6 +104,7 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker transaction = db.newWriteOnlyTransaction(); // FIXME this is minimal and we need to sync the entire configuration + // FIXME remove from here and make this specific for interface customizers syncInterfaces(transaction, api); future = transaction.submit(); @@ -177,15 +184,6 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker public void onSessionInitiated(final ProviderContext session) { LOG.info("VPP-INFO: V3poProvider Session Initiated"); - try { - api = new vppApi("v3poODL"); - } catch (IOException e) { - LOG.error("VPP-ERROR: VPP api client connection failed", e); - return; - } - - LOG.info("VPP-INFO: VPP api client connection established"); - db = session.getSALService(DataBroker.class); initializeVppConfig(); initVppOperational(); @@ -195,9 +193,6 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker vppPollOperData); startOperationalUpdateTimer(); - final ReaderRegistry readerRegistry = ReaderRegistry.getInstance(api); - final WriterRegistry writerRegistry = WriterRegistry.getInstance(api); - // TODO make configurable: vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry); // TODO pull the registration into Module @@ -210,9 +205,6 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker if (v3poService != null) { v3poService.close(); } - if (api != null) { - api.close(); - } if (vppDataBrokerInitializationProvider != null) { vppDataBrokerInitializationProvider.close(); } 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 0939fe239..58195ba3f 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 @@ -23,13 +23,13 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import io.fd.honeycomb.v3po.config.WriterRegistry; 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.OperationalDataTree; 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 javassist.ClassPool; @@ -136,7 +136,8 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto createMountPointPlaceholder(); - initialVppConfigSynchronization(broker); + // TODO initial sync has to go out of here +// initialVppConfigSynchronization(broker); } @Override @@ -272,6 +273,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto final WriteTransaction rwTx = bindingBroker.newWriteOnlyTransaction(); // does not fail if data is not present: rwTx.delete(LogicalDatastoreType.CONFIGURATION, mountPointPath); + rwTx.delete(LogicalDatastoreType.OPERATIONAL, mountPointPath); try { rwTx.submit().checkedGet(); } catch (TransactionCommitFailedException e) { 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 390545563..3b77418ad 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,6 +17,8 @@ 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; @@ -54,9 +56,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 V3poProvider provider = new V3poProvider(domBroker); + final V3poProvider provider = new V3poProvider(domBroker, getVppJapiDependency(), readerRegistry, writerRegistry); 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 12f9d6f13..32696125b 100644 --- a/v3po/impl/src/main/yang/v3po-impl.yang +++ b/v3po/impl/src/main/yang/v3po-impl.yang @@ -6,6 +6,8 @@ module v3po-impl { import config { prefix config; revision-date 2013-04-05; } import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;} 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; } description "Service definition for v3po project"; @@ -41,6 +43,33 @@ module v3po-impl { } } } + + container vpp-japi { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity vjc:vpp-japi; + } + } + } + + 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; + } + } + } } } 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 770ca7068..d8628f2bf 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,9 +26,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.config.WriterRegistry; 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; |