diff options
author | 2016-04-11 00:18:11 +0200 | |
---|---|---|
committer | 2016-04-12 11:02:55 +0200 | |
commit | d99066504f76a181c90832b939956f43b409c075 (patch) | |
tree | 2f863ec633c9869cf8803db44073730a3eed0323 /v3po/impl/src/main/java | |
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/main/java')
3 files changed, 16 insertions, 20 deletions
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; } |