From 31f01fcfadf8707aefe6bf3a09daf570ce248fc5 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Fri, 19 Aug 2016 12:20:33 +0200 Subject: HONEYCOMB-18 Fixing comments from reviews Change-Id: Ic0565d601d13b5f50ec3c714a43600e32a7e456b Signed-off-by: Maros Marsalek --- .../data/ConfigAndOperationalPipelineModule.groovy | 32 ++++++++++++-------- .../distro/data/HoneycombDOMBrokerProvider.groovy | 1 - .../HoneycombNotificationManagerProvider.groovy | 4 +-- .../data/InmemoryDOMDataBrokerProvider.groovy | 4 +-- .../distro/data/ModifiableDTDelegProvider.groovy | 5 ++-- .../distro/data/PersistingDataTreeProvider.groovy | 5 ++-- .../data/context/ContextPipelineModule.groovy | 35 +++++++++++----------- .../context/RealtimeMappingContextProvider.groovy | 2 +- .../data/oper/ReadableDTDelegProvider.groovy | 3 +- 9 files changed, 49 insertions(+), 42 deletions(-) (limited to 'infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data') diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy index ede905d06..eb17cf36a 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy @@ -38,6 +38,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree @Slf4j class ConfigAndOperationalPipelineModule extends PrivateModule { + public static final String HONEYCOMB_CONFIG_NONPERSIST = "honeycomb-config-nopersist" + public static final String HONEYCOMB_CONFIG = "honeycomb-config" + protected void configure() { // Expose registries for plugin reader/writer factories bind(ModifiableWriterRegistryBuilder).toProvider(WriterRegistryProvider).in(Singleton) @@ -45,43 +48,48 @@ class ConfigAndOperationalPipelineModule extends PrivateModule { bind(ModifiableReaderRegistryBuilder).toProvider(ReaderRegistryProvider).in(Singleton) expose(ModifiableReaderRegistryBuilder) - // Non persisting data tree + // Non persisting data tree for config bind(DataTree) - .annotatedWith(Names.named("honeycomb-config-nopersist")) + .annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) .toProvider(DataTreeProvider.ConfigDataTreeProvider) .in(Singleton) - expose(DataTree).annotatedWith(Names.named("honeycomb-config-nopersist")) - // Persisting data tree wrapper + expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) + // Persisting data tree wrapper for config bind(DataTree) - .annotatedWith(Names.named("honeycomb-config")) + .annotatedWith(Names.named(HONEYCOMB_CONFIG)) .toProvider(PersistingDataTreeProvider.ConfigPersistingDataTreeProvider) .in(Singleton) - expose(DataTree).annotatedWith(Names.named("honeycomb-config")) + expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONFIG)) + // Config Data Tree manager working on top of config data tree + writer registry bind(ModifiableDataManager).toProvider(ModifiableDTDelegProvider).in(Singleton) + // Operational Data Tree manager working on top of reader registry bind(ReadableDataManager).toProvider(ReadableDTDelegProvider).in(Singleton) expose(ReadableDataManager) + // DOMDataBroker wrapper on top of data tree managers def domBrokerProvider = new HoneycombDOMDataBrokerProvider() -// bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(domBrokerProvider).in(Singleton) - // Bind also without annotation for easy private injection bind(DOMDataBroker).toProvider(domBrokerProvider).in(Singleton) - bind(DataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(BindingDataBrokerProvider).in(Singleton) - expose(DataBroker).annotatedWith(Names.named("honeycomb-config")) + // BA version of data broker + bind(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONFIG)).toProvider(BindingDataBrokerProvider).in(Singleton) + expose(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONFIG)) + // Create initializer to init persisted config data bind(DataTreeInitializer) - .annotatedWith(Names.named("honeycomb-config")) + .annotatedWith(Names.named(HONEYCOMB_CONFIG)) .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider) .in(Singleton) - expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-config")) + expose(DataTreeInitializer).annotatedWith(Names.named(HONEYCOMB_CONFIG)) configureNotifications() } protected void configureNotifications() { + // Create notification service bind(DOMNotificationRouter).toProvider(DOMNotificationServiceProvider).in(Singleton) expose(DOMNotificationRouter) + // Wrap notification service, data broker and schema service in a Broker MD-SAL API bind(Broker).toProvider(HoneycombDOMBrokerProvider).in(Singleton) expose(Broker) } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy index 5dc98cded..dc620b445 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy @@ -31,7 +31,6 @@ import org.opendaylight.controller.sal.core.api.model.SchemaService class HoneycombDOMBrokerProvider extends ProviderTrait { @Inject -// @Named("honeycomb-config") DOMDataBroker domDataBroker @Inject SchemaService schemaService diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy index 473112341..b81a8d784 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy @@ -28,9 +28,7 @@ import io.fd.honeycomb.notification.impl.NotificationProducerTracker import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter -/** - * Mirror of org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.notification.impl.rev160601.HoneycombNotificationManagerModule - */ + @Slf4j @ToString class HoneycombNotificationManagerProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy index 6462baa71..a04f1a81c 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy @@ -28,9 +28,7 @@ import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroke import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService import org.opendaylight.yangtools.util.concurrent.SpecialExecutors -/** - * Mirror of org.opendaylight.controller.config.yang.md.sal.dom.impl.DomInmemoryDataBrokerModule - */ + @Slf4j @ToString class InmemoryDOMDataBrokerProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy index f7ec4cc12..cd4d9c624 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy @@ -23,6 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.ModifiableDataManager import io.fd.honeycomb.data.impl.ModifiableDataTreeDelegator import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec @@ -35,12 +36,12 @@ class ModifiableDTDelegProvider extends ProviderTrait { @Inject BindingToNormalizedNodeCodec serializer @Inject - @Named("honeycomb-config") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) DataTree dataTree @Inject ModifiableWriterRegistryBuilder registry @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy index 753963309..6c41ad69f 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy @@ -23,6 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.impl.PersistingDataTreeAdapter import io.fd.honeycomb.infra.distro.ProviderTrait import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import org.opendaylight.controller.sal.core.api.model.SchemaService import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType @@ -49,7 +50,7 @@ abstract class PersistingDataTreeProvider extends ProviderTrait { static class ConfigPersistingDataTreeProvider extends PersistingDataTreeProvider { @Inject - @Named("honeycomb-config-nopersist") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG_NONPERSIST) DataTree delegate String getPath() { config.peristConfigPath } @@ -60,7 +61,7 @@ abstract class PersistingDataTreeProvider extends ProviderTrait { static class ContextPersistingDataTreeProvider extends PersistingDataTreeProvider { @Inject - @Named("honeycomb-context-nopersist") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT_NOPERSIST) DataTree delegate String getPath() { config.peristContextPath } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy index 25244cb2f..a4cf73162 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy @@ -32,44 +32,45 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree class ContextPipelineModule extends PrivateModule { - protected void configure() { - // Bind also without annotation for easy private injection + public static final String HONEYCOMB_CONTEXT_NOPERSIST = "honeycomb-context-nopersist" + public static final String HONEYCOMB_CONTEXT = "honeycomb-context" - // Non persisting data tree + protected void configure() { + // Non persisting data tree for context def noPersistDataTreeProvider = new DataTreeProvider.ContextDataTreeProvider() bind(DataTree) - .annotatedWith(Names.named("honeycomb-context-nopersist")) + .annotatedWith(Names.named(HONEYCOMB_CONTEXT_NOPERSIST)) .toProvider(noPersistDataTreeProvider) .in(Singleton) - expose(DataTree).annotatedWith(Names.named("honeycomb-context-nopersist")) - // Persisting data tree wrapper + expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONTEXT_NOPERSIST)) + // Persisting data tree wrapper for context def dataTreeProvider = new PersistingDataTreeProvider.ContextPersistingDataTreeProvider() bind(DataTree).toProvider(dataTreeProvider).in(Singleton) -// bind(DataTree).annotatedWith(Names.named("honeycomb-context")).toProvider(dataTreeProvider).in(Singleton) -// expose(DataTree).annotatedWith(Names.named("honeycomb-context")) + // Data Tree manager (without any delegation) on top of context data tree bind(ModifiableDataManager).toProvider(ModifiableDTMgrProvider).in(Singleton) + // DOMDataBroker interface on top of data tree manager def domBrokerProvider = new HoneycombContextDOMDataBrokerProvider() -// bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(domBrokerProvider).in(Singleton) - // Bind also without annotation for easy private injection bind(DOMDataBroker).toProvider(domBrokerProvider).in(Singleton) -// expose(DOMDataBroker).annotatedWith(Names.named("honeycomb-context")) - bind(DataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(BindingDataBrokerProvider).in(Singleton) - expose(DataBroker).annotatedWith(Names.named("honeycomb-context")) + // BA version of data broker for context + bind(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONTEXT)).toProvider(BindingDataBrokerProvider).in(Singleton) + expose(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) + // Create initializer to init persisted config data bind(DataTreeInitializer) - .annotatedWith(Names.named("honeycomb-context")) + .annotatedWith(Names.named(HONEYCOMB_CONTEXT)) .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider) .in(Singleton) - expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-context")) + expose(DataTreeInitializer).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) + // Mapping context is just a small adapter on top of BA data broker to simplify CRUD of context data bind(MappingContext) - .annotatedWith(Names.named("honeycomb-context")) + .annotatedWith(Names.named(HONEYCOMB_CONTEXT)) .toProvider(RealtimeMappingContextProvider) .in(Singleton.class) - expose(MappingContext).annotatedWith(Names.named("honeycomb-context")) + expose(MappingContext).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) } } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy index 3c7eebb3d..c6afd92fc 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy @@ -30,7 +30,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker class RealtimeMappingContextProvider extends ProviderTrait { @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextDataBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy index 384278793..11eaf49a4 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy @@ -23,6 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.ReadableDataManager import io.fd.honeycomb.data.impl.ReadableDataTreeDelegator import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec @@ -39,7 +40,7 @@ class ReadableDTDelegProvider extends ProviderTrait { @Inject ModifiableReaderRegistryBuilder registry @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextBroker def create() { -- cgit 1.2.3-korg