From d022ca8d078e1731435bf3e69a9a1ff85e7e0c63 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Thu, 11 Aug 2016 15:37:28 +0200 Subject: HONEYCOMB-21 Vpp-integration minimal distribution Change-Id: I1a44028ae38c3ab70aa3a7b173cd0c81c820378a Signed-off-by: Maros Marsalek --- .../data/ConfigAndOperationalPipelineModule.groovy | 37 ++++++++---- .../infra/distro/data/DataTreeProvider.groovy | 14 ++--- .../distro/data/HoneycombDOMBrokerProvider.groovy | 8 +-- .../data/HoneycombDOMDataBrokerProvider.groovy | 2 - .../HoneycombNotificationManagerProvider.groovy | 3 - .../infra/distro/data/NotificationModule.groovy | 45 -------------- .../distro/data/PersistingDataTreeProvider.groovy | 70 ++++++++++++++++++++++ .../data/context/ContextPipelineModule.groovy | 27 +++++++-- .../context/RealtimeMappingContextProvider.groovy | 40 +++++++++++++ 9 files changed, 168 insertions(+), 78 deletions(-) delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy (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 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 { @@ -41,19 +38,20 @@ abstract class DataTreeProvider extends ProviderTrait { 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 { @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 { 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 { @Inject - @Named("honeycomb") DOMNotificationRouter notificationRouter @Inject(optional = true) Set 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 { + + @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 { + + @Inject + @Named("honeycomb-context") + DataBroker contextDataBroker + + @Override + def create() { + new RealtimeMappingContext(contextDataBroker) + } +} -- cgit 1.2.3-korg