diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-08-11 15:37:28 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-08-19 12:49:56 +0200 |
commit | d022ca8d078e1731435bf3e69a9a1ff85e7e0c63 (patch) | |
tree | 18beba24af06d237521ea7f96e8b45fd102e5ed7 /infra/minimal-distribution/src/main/java | |
parent | 54a3992118f4455b99fee8f3a648145bcf2b8e65 (diff) |
HONEYCOMB-21 Vpp-integration minimal distribution
Change-Id: I1a44028ae38c3ab70aa3a7b173cd0c81c820378a
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/minimal-distribution/src/main/java')
25 files changed, 247 insertions, 130 deletions
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java index d715c592d..ff85cd2a7 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java @@ -38,7 +38,6 @@ import io.fd.honeycomb.infra.distro.netconf.NetconfTcpServerProvider; import io.fd.honeycomb.infra.distro.restconf.RestconfModule; import io.fd.honeycomb.infra.distro.schema.SchemaModule; import io.fd.honeycomb.infra.distro.schema.YangBindingProviderModule; -import io.fd.honeycomb.infra.distro.data.NotificationModule; import java.util.List; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; import org.opendaylight.netconf.sal.rest.api.RestConnector; @@ -54,7 +53,6 @@ public final class Main { // Infra new YangBindingProviderModule(), new SchemaModule(), - new NotificationModule(), new ConfigAndOperationalPipelineModule(), new ContextPipelineModule(), new InitializerPipelineModule(), @@ -69,7 +67,7 @@ public final class Main { init(BASE_MODULES); } - public static void init(final List<? extends Module> modules) { + public static Injector init(final List<? extends Module> modules) { LOG.info("Starting honeycomb"); Injector injector = Guice.createInjector(modules); @@ -88,11 +86,11 @@ public final class Main { LOG.info("Starting NETCONF"); injector.getInstance( - Key.get(NetconfOperationServiceFactory.class, Names.named(NetconfModule.NETCONF_MAPPER_HONEYCOMB))); + Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-honeycomb"))); injector.getInstance( - Key.get(NetconfOperationServiceFactory.class, Names.named(NetconfModule.NETCONF_MAPPER_NOTIFICATION))); + Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-notification"))); injector.getInstance( - Key.get(NetconfOperationServiceFactory.class, Names.named(NetconfModule.NETCONF_MAPPER_MONITORING))); + Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-monitoring"))); if (cfgAttributes.isNetconfTcpServerEnabled()) { injector.getInstance(NetconfTcpServerProvider.NetconfTcpServer.class); @@ -112,5 +110,7 @@ public final class Main { } LOG.info("Honeycomb started successfully!"); + + return injector; } } 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 01ec8c16a..ede905d06 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 @@ -31,34 +31,42 @@ import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker +import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter +import org.opendaylight.controller.sal.core.api.Broker import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree @Slf4j class ConfigAndOperationalPipelineModule extends PrivateModule { protected void configure() { - // Expose registries + // Expose registries for plugin reader/writer factories bind(ModifiableWriterRegistryBuilder).toProvider(WriterRegistryProvider).in(Singleton) expose(ModifiableWriterRegistryBuilder) bind(ModifiableReaderRegistryBuilder).toProvider(ReaderRegistryProvider).in(Singleton) expose(ModifiableReaderRegistryBuilder) - def dataTreeProvider = new DataTreeProvider.ConfigDataTreeProvider() - bind(DataTree).annotatedWith(Names.named("honeycomb-config")).toProvider(dataTreeProvider).in(Singleton) + // Non persisting data tree + bind(DataTree) + .annotatedWith(Names.named("honeycomb-config-nopersist")) + .toProvider(DataTreeProvider.ConfigDataTreeProvider) + .in(Singleton) + expose(DataTree).annotatedWith(Names.named("honeycomb-config-nopersist")) + // Persisting data tree wrapper + bind(DataTree) + .annotatedWith(Names.named("honeycomb-config")) + .toProvider(PersistingDataTreeProvider.ConfigPersistingDataTreeProvider) + .in(Singleton) expose(DataTree).annotatedWith(Names.named("honeycomb-config")) bind(ModifiableDataManager).toProvider(ModifiableDTDelegProvider).in(Singleton) - bind(ReadableDataManager) - .annotatedWith(Names.named("honeycomb-operational")) - .toProvider(ReadableDTDelegProvider).in(Singleton) - // Expose reader for initializer - expose(ReadableDataManager).annotatedWith(Names.named("honeycomb-operational")) + bind(ReadableDataManager).toProvider(ReadableDTDelegProvider).in(Singleton) + expose(ReadableDataManager) def domBrokerProvider = new HoneycombDOMDataBrokerProvider() - bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(domBrokerProvider).in(Singleton) +// 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) - expose(DOMDataBroker).annotatedWith(Names.named("honeycomb-config")) + bind(DataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(BindingDataBrokerProvider).in(Singleton) expose(DataBroker).annotatedWith(Names.named("honeycomb-config")) @@ -67,5 +75,14 @@ class ConfigAndOperationalPipelineModule extends PrivateModule { .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider) .in(Singleton) expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-config")) + + configureNotifications() + } + + protected void configureNotifications() { + bind(DOMNotificationRouter).toProvider(DOMNotificationServiceProvider).in(Singleton) + expose(DOMNotificationRouter) + bind(Broker).toProvider(HoneycombDOMBrokerProvider).in(Singleton) + expose(Broker) } } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy index 6915a3cec..bf1f562ec 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy @@ -19,16 +19,13 @@ package io.fd.honeycomb.infra.distro.data import com.google.inject.Inject import groovy.transform.ToString import groovy.util.logging.Slf4j -import io.fd.honeycomb.data.impl.PersistingDataTreeAdapter -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration 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 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory -import java.nio.file.Paths - @Slf4j @ToString abstract class DataTreeProvider extends ProviderTrait<DataTree> { @@ -41,19 +38,20 @@ abstract class DataTreeProvider extends ProviderTrait<DataTree> { def create() { def delegate = InMemoryDataTreeFactory.getInstance().create(getType()) delegate.setSchemaContext(schemaService.getGlobalContext()) - new PersistingDataTreeAdapter(delegate, schemaService, Paths.get(getPath())) + delegate } - abstract String getPath() abstract TreeType getType() + @Slf4j + @ToString static class ConfigDataTreeProvider extends DataTreeProvider { - String getPath() { config.peristConfigPath } TreeType getType() { TreeType.CONFIGURATION } } + @Slf4j + @ToString static class ContextDataTreeProvider extends DataTreeProvider { - String getPath() { config.peristContextPath } TreeType getType() { TreeType.OPERATIONAL } } } 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 2b275f7ff..5dc98cded 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 @@ -17,13 +17,12 @@ package io.fd.honeycomb.infra.distro.data import com.google.inject.Inject -import com.google.inject.name.Named import groovy.transform.ToString import groovy.util.logging.Slf4j import io.fd.honeycomb.impl.NorthboundFacadeHoneycombDOMBroker import io.fd.honeycomb.infra.distro.ProviderTrait import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService +import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter import org.opendaylight.controller.sal.core.api.Broker import org.opendaylight.controller.sal.core.api.model.SchemaService @@ -32,13 +31,12 @@ import org.opendaylight.controller.sal.core.api.model.SchemaService class HoneycombDOMBrokerProvider extends ProviderTrait<Broker> { @Inject - @Named("honeycomb-config") +// @Named("honeycomb-config") DOMDataBroker domDataBroker @Inject SchemaService schemaService @Inject - @Named("honeycomb") - DOMNotificationService domNotificationService + DOMNotificationRouter domNotificationService def create() { new NorthboundFacadeHoneycombDOMBroker(domDataBroker, schemaService, domNotificationService) } } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy index e91054b3b..a2fec2a60 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy @@ -17,7 +17,6 @@ package io.fd.honeycomb.infra.distro.data import com.google.inject.Inject -import com.google.inject.name.Named import groovy.transform.ToString import groovy.util.logging.Slf4j import io.fd.honeycomb.data.ModifiableDataManager @@ -34,7 +33,6 @@ class HoneycombDOMDataBrokerProvider extends ProviderTrait<DOMDataBroker> { ModifiableDataManager modDataManager @Inject - @Named("honeycomb-operational") ReadableDataManager readDataManager def create() { 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 f150691a8..473112341 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 @@ -17,7 +17,6 @@ package io.fd.honeycomb.infra.distro.data import com.google.inject.Inject -import com.google.inject.name.Named import groovy.transform.ToString import groovy.util.logging.Slf4j import io.fd.honeycomb.infra.distro.ProviderTrait @@ -29,7 +28,6 @@ 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 */ @@ -38,7 +36,6 @@ import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter class HoneycombNotificationManagerProvider extends ProviderTrait<NotificationCollector> { @Inject - @Named("honeycomb") DOMNotificationRouter notificationRouter @Inject(optional = true) Set<ManagedNotificationProducer> notificationProducers = [] diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy deleted file mode 100644 index 4836a0fbe..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.data - -import com.google.inject.AbstractModule -import com.google.inject.Singleton -import com.google.inject.name.Names -import groovy.util.logging.Slf4j -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter -import org.opendaylight.controller.sal.core.api.Broker - -@Slf4j -class NotificationModule extends AbstractModule { - - protected void configure() { - def provider = new DOMNotificationServiceProvider() - bind(DOMNotificationService) - .annotatedWith(Names.named("honeycomb")) - .toProvider(provider) - .in(Singleton) - bind(DOMNotificationRouter) - .annotatedWith(Names.named("honeycomb")) - .toProvider(provider) - .in(Singleton) - bind(Broker) - .annotatedWith(Names.named("honeycomb")) - .toProvider(HoneycombDOMBrokerProvider) - .in(Singleton) - } -} 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 new file mode 100644 index 000000000..753963309 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.data + +import com.google.inject.Inject +import com.google.inject.name.Named +import groovy.transform.ToString +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 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 + +import java.nio.file.Paths + +@Slf4j +@ToString +abstract class PersistingDataTreeProvider extends ProviderTrait<DataTree> { + + @Inject + SchemaService schemaService + @Inject + HoneycombConfiguration config + + def create() { + new PersistingDataTreeAdapter(delegate, schemaService, Paths.get(path)) + } + + abstract String getPath() + abstract TreeType getType() + abstract DataTree getDelegate() + + static class ConfigPersistingDataTreeProvider extends PersistingDataTreeProvider { + + @Inject + @Named("honeycomb-config-nopersist") + DataTree delegate + + String getPath() { config.peristConfigPath } + TreeType getType() { TreeType.CONFIGURATION } + DataTree getDelegate() { return delegate } + } + + static class ContextPersistingDataTreeProvider extends PersistingDataTreeProvider { + + @Inject + @Named("honeycomb-context-nopersist") + DataTree delegate + + String getPath() { config.peristContextPath } + TreeType getType() { TreeType.OPERATIONAL } + DataTree getDelegate() { return delegate } + } +} 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 01124131f..25244cb2f 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 @@ -23,7 +23,9 @@ import io.fd.honeycomb.data.ModifiableDataManager import io.fd.honeycomb.data.init.DataTreeInitializer import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider import io.fd.honeycomb.infra.distro.data.DataTreeProvider +import io.fd.honeycomb.infra.distro.data.PersistingDataTreeProvider import io.fd.honeycomb.infra.distro.initializer.PersistedFileInitializerProvider +import io.fd.honeycomb.translate.MappingContext import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree @@ -32,18 +34,27 @@ class ContextPipelineModule extends PrivateModule { protected void configure() { // Bind also without annotation for easy private injection - def dataTreeProvider = new DataTreeProvider.ContextDataTreeProvider() + + // Non persisting data tree + def noPersistDataTreeProvider = new DataTreeProvider.ContextDataTreeProvider() + bind(DataTree) + .annotatedWith(Names.named("honeycomb-context-nopersist")) + .toProvider(noPersistDataTreeProvider) + .in(Singleton) + expose(DataTree).annotatedWith(Names.named("honeycomb-context-nopersist")) + // Persisting data tree wrapper + 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")) +// bind(DataTree).annotatedWith(Names.named("honeycomb-context")).toProvider(dataTreeProvider).in(Singleton) +// expose(DataTree).annotatedWith(Names.named("honeycomb-context")) bind(ModifiableDataManager).toProvider(ModifiableDTMgrProvider).in(Singleton) def domBrokerProvider = new HoneycombContextDOMDataBrokerProvider() - bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(domBrokerProvider).in(Singleton) +// 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")) +// 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")) @@ -53,6 +64,12 @@ class ContextPipelineModule extends PrivateModule { .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider) .in(Singleton) expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-context")) + + bind(MappingContext) + .annotatedWith(Names.named("honeycomb-context")) + .toProvider(RealtimeMappingContextProvider) + .in(Singleton.class) + 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 new file mode 100644 index 000000000..3c7eebb3d --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.data.context + +import com.google.inject.Inject +import com.google.inject.name.Named +import groovy.transform.ToString +import groovy.util.logging.Slf4j +import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.translate.MappingContext +import io.fd.honeycomb.translate.util.RealtimeMappingContext +import org.opendaylight.controller.md.sal.binding.api.DataBroker + +@Slf4j +@ToString +class RealtimeMappingContextProvider extends ProviderTrait<MappingContext> { + + @Inject + @Named("honeycomb-context") + DataBroker contextDataBroker + + @Override + def create() { + new RealtimeMappingContext(contextDataBroker) + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy index 80b52f2b8..10757c1a5 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy @@ -24,9 +24,6 @@ import io.fd.honeycomb.data.ModifiableDataManager import io.fd.honeycomb.data.init.InitializerRegistry import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider import io.fd.honeycomb.infra.distro.data.HoneycombDOMDataBrokerProvider -import io.fd.honeycomb.infra.distro.data.ModifiableDTDelegProvider -import io.fd.honeycomb.translate.util.write.NoopWriterRegistry -import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker @@ -34,19 +31,11 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker class InitializerPipelineModule extends PrivateModule { protected void configure() { - // Initializer hierarchy uses fake writer registry to not send restored configuration from plugins back to plugins - def registry = new NoopWriterRegistry() - bind(ModifiableWriterRegistryBuilder) - .annotatedWith(Names.named("honeycomb-initializer")) - .toInstance([build: { registry }]) - - // Then just build data tree delegator and DataBrokers on top of it - bind(ModifiableDataManager).toProvider(ModifiableDTDelegProvider).in(Singleton) + bind(ModifiableDataManager).toProvider(ModifiableDTDelegInitProvider).in(Singleton) bind(DOMDataBroker).toProvider(HoneycombDOMDataBrokerProvider).in(Singleton) bind(DataBroker).annotatedWith(Names.named("honeycomb-initializer")).toProvider(BindingDataBrokerProvider).in(Singleton) expose(DataBroker).annotatedWith(Names.named("honeycomb-initializer")) - // NOW do initializer registry bind(InitializerRegistry) .annotatedWith(Names.named("honeycomb-initializer")) .toProvider(InitializerRegistryProvider) diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy new file mode 100644 index 000000000..2a1422dae --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.initializer + +import com.google.inject.Inject +import com.google.inject.name.Named +import groovy.transform.ToString +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.translate.util.write.NoopWriterRegistry +import org.opendaylight.controller.md.sal.binding.api.DataBroker +import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree + +/** + * Similar to ModifiableDTDelegProvider, but uses noop writer registry + */ +@Slf4j +@ToString +class ModifiableDTDelegInitProvider extends ProviderTrait<ModifiableDataManager> { + + @Inject + BindingToNormalizedNodeCodec serializer + @Inject + @Named("honeycomb-config-nopersist") + DataTree dataTree + @Inject + @Named("honeycomb-context") + DataBroker contextBroker + + @Override + def create() { new ModifiableDataTreeDelegator(serializer, dataTree, new NoopWriterRegistry(), contextBroker) } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy index c2448d234..9b7cfb4ae 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy @@ -20,8 +20,8 @@ import com.google.inject.Inject import groovy.transform.ToString import groovy.util.logging.Slf4j import io.fd.honeycomb.data.init.RestoringInitializer -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker import org.opendaylight.controller.sal.core.api.model.SchemaService diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy index a18d2c4f0..726dfb5af 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy @@ -17,11 +17,10 @@ package io.fd.honeycomb.infra.distro.netconf import com.google.inject.Inject -import com.google.inject.name.Named import groovy.transform.ToString import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.fd.honeycomb.notification.NotificationCollector import io.fd.honeycomb.notification.impl.NotificationProducerRegistry import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter @@ -39,7 +38,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath class HoneycombNotification2NetconfProvider extends ProviderTrait<HoneycombNotification2Netconf> { @Inject - @Named("honeycomb") DOMNotificationRouter notificationRouter @Inject SchemaService schemaService diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy index 8226c8d9e..8c5dcab01 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy @@ -33,7 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.honeycom class NetconfBindingBrokerProvider extends ProviderTrait<BindingAwareBroker> { @Inject - @Named(NetconfModule.NETCONF) + @Named("netconf") DataBroker dataBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy index d84af61a8..491eedcef 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy @@ -17,7 +17,6 @@ package io.fd.honeycomb.infra.distro.netconf import com.google.inject.Inject -import com.google.inject.name.Named import groovy.transform.ToString import groovy.util.logging.Slf4j import io.fd.honeycomb.infra.distro.ProviderTrait @@ -42,7 +41,6 @@ class NetconfMdsalMapperProvider extends ProviderTrait<NetconfOperationServiceFa ModuleInfoBackedContext moduleInfoBackedContext @Inject - @Named("honeycomb") Broker domBroker def create() { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy index effa50cfd..e1f8901c7 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy @@ -46,12 +46,6 @@ import static InmemoryDOMDataBrokerProvider.OPERATIONAL class NetconfModule extends PrivateModule { - public static final String NETCONF = "netconf" - public static final String NETCONF_MAPPER_AGGREGATOR = "netconf-mapper-aggregator" - public static final String NETCONF_MAPPER_NOTIFICATION = "netconf-mapper-notification" - public static final String NETCONF_MAPPER_MONITORING = "netconf-mapper-monitoring" - public static final String NETCONF_MAPPER_HONEYCOMB = "netconf-mapper-honeycomb" - @Override protected void configure() { bind(InMemoryDOMDataStore) @@ -65,19 +59,19 @@ class NetconfModule extends PrivateModule { bind(DOMDataBroker).toProvider(InmemoryDOMDataBrokerProvider).in(Singleton) bind(DataBroker) - .annotatedWith(Names.named(NETCONF)) + .annotatedWith(Names.named("netconf")) .toProvider(BindingDataBrokerProvider) .in(Singleton) - expose(DataBroker).annotatedWith(Names.named(NETCONF)) + expose(DataBroker).annotatedWith(Names.named("netconf")) bind(BindingAwareBroker) - .annotatedWith(Names.named(NETCONF)) + .annotatedWith(Names.named("netconf")) .toProvider(NetconfBindingBrokerProvider) .in(Singleton) // Mirror of org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfMapperAggregatorModule def factory = new AggregatedNetconfOperationServiceFactory() bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named(NETCONF_MAPPER_AGGREGATOR)) + .annotatedWith(Names.named("netconf-mapper-aggregator")) .toInstance(factory) bind(NetconfOperationServiceFactoryListener).toInstance(factory) @@ -89,25 +83,25 @@ class NetconfModule extends PrivateModule { // Netconf notification part bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named(NETCONF_MAPPER_NOTIFICATION)) + .annotatedWith(Names.named("netconf-mapper-notification")) .toProvider(NetconfNotificationMapperProvider) .in(Singleton) - expose(NetconfOperationServiceFactory).annotatedWith(Names.named(NETCONF_MAPPER_NOTIFICATION)) + expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-notification")) // Netconf core part - mapping between Honeycomb and Netconf bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named(NETCONF_MAPPER_HONEYCOMB)) + .annotatedWith(Names.named("netconf-mapper-honeycomb")) .toProvider(NetconfMdsalMapperProvider) .in(Singleton) - expose(NetconfOperationServiceFactory).annotatedWith(Names.named(NETCONF_MAPPER_HONEYCOMB)) + expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-honeycomb")) // Netconf monitoring part bind(NetconfMonitoringService).toProvider(NetconfMonitoringServiceProvider).in(Singleton) bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named(NETCONF_MAPPER_MONITORING)) + .annotatedWith(Names.named("netconf-mapper-monitoring")) .toProvider(NetconfMonitoringMapperProvider) .in(Singleton) - expose(NetconfOperationServiceFactory).annotatedWith(Names.named(NETCONF_MAPPER_MONITORING)) + expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-monitoring")) bind(NotificationCollector).toProvider(HoneycombNotificationManagerProvider).in(Singleton) bind(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf) diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy index 8f53c9d83..15daa6c81 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy @@ -35,7 +35,7 @@ import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListen class NetconfMonitoringMapperProvider extends ProviderTrait<NetconfOperationServiceFactory> { @Inject - @Named(NetconfModule.NETCONF) + @Named("netconf") BindingAwareBroker bindingAwareBroker @Inject NetconfOperationServiceFactoryListener aggregator diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy index 2945ae6d8..fee1944f4 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy @@ -30,7 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.honeycom class NetconfMonitoringReaderFactoryProvider extends ProviderTrait<ReaderFactory> { @Inject - @Named(NetconfModule.NETCONF) + @Named("netconf") DataBroker netconfDataBroker def create() { new NetconfMonitoringReaderModule.NetconfMonitoringReaderFactory(netconfDataBroker) } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy index 5762a0a7f..4592cf4bd 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy @@ -32,7 +32,7 @@ import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory class NetconfMonitoringServiceProvider extends ProviderTrait<NetconfMonitoringService> { @Inject - @Named(NetconfModule.NETCONF_MAPPER_AGGREGATOR) + @Named("netconf-mapper-aggregator") NetconfOperationServiceFactory aggregator @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy index 57f7038ab..02739290f 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy @@ -50,10 +50,10 @@ class NetconfNotificationMapperProvider extends ProviderTrait<NetconfOperationSe @Inject NetconfNotificationRegistry notificationRegistry @Inject - @Named(NetconfModule.NETCONF) + @Named("netconf") BindingAwareBroker bindingAwareBroker @Inject - @Named(NetconfModule.NETCONF) + @Named("netconf") DataBroker dataBroker @Inject NetconfOperationServiceFactoryListener aggregator diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy index 45b7a1c7e..2db186299 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy @@ -38,7 +38,7 @@ import javax.annotation.Nonnull class NetconfNotificationsReaderFactoryProvider extends ProviderTrait<ReaderFactory> { @Inject - @Named(NetconfModule.NETCONF) + @Named("netconf") DataBroker netconfDataBroker def create() { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy index 072a7f6ae..18019db57 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy @@ -43,7 +43,7 @@ class NetconfServerDispatcherProvider extends ProviderTrait<NetconfServerDispatc private static final long CONNECTION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20) @Inject - @Named(NetconfModule.NETCONF_MAPPER_AGGREGATOR) + @Named("netconf-mapper-aggregator") NetconfOperationServiceFactory aggregator @Inject NetconfMonitoringService monitoringService diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.groovy index f3b0852c1..ff96f4e86 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfProvider.groovy @@ -17,11 +17,10 @@ package io.fd.honeycomb.infra.distro.restconf import com.google.inject.Inject -import com.google.inject.name.Named import groovy.transform.ToString import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import org.eclipse.jetty.server.Server import org.eclipse.jetty.webapp.WebAppContext import org.opendaylight.controller.sal.core.api.Broker @@ -37,7 +36,6 @@ class RestconfProvider extends ProviderTrait<RestConnector> { HoneycombConfiguration cfg @Inject - @Named("honeycomb") Broker domBroker def create() { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy index ebf473a3b..3ea4bcaa6 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy @@ -18,6 +18,7 @@ package io.fd.honeycomb.infra.distro.schema import com.google.common.base.Charsets import com.google.inject.AbstractModule +import com.google.inject.Singleton import com.google.inject.multibindings.Multibinder import groovy.util.logging.Slf4j import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider @@ -41,7 +42,7 @@ class YangBindingProviderModule extends AbstractModule { .collect { this.getClass().forName(it) } .forEach { log.debug "ModuleProvider found for {}", it - addBinding().to(it) + addBinding().to(it).in(Singleton) } } } |