From cefd2555dbf421a62269c393d0d9d28964f38e2b Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Thu, 25 Aug 2016 10:46:02 +0200 Subject: Remove groovy to reduce footprint Change-Id: I798558e52329c26aa5481d702745c4d46e290615 Signed-off-by: Maros Marsalek --- .../distro/data/BindingDataBrokerProvider.groovy | 39 --------- .../distro/data/BindingDataBrokerProvider.java | 37 +++++++++ .../data/ConfigAndOperationalPipelineModule.groovy | 96 ---------------------- .../data/ConfigAndOperationalPipelineModule.java | 90 ++++++++++++++++++++ .../data/DOMNotificationServiceProvider.groovy | 34 -------- .../data/DOMNotificationServiceProvider.java | 33 ++++++++ .../infra/distro/data/DataStoreProvider.groovy | 40 --------- .../infra/distro/data/DataStoreProvider.java | 43 ++++++++++ .../infra/distro/data/DataTreeProvider.groovy | 57 ------------- .../infra/distro/data/DataTreeProvider.java | 56 +++++++++++++ .../distro/data/HoneycombDOMBrokerProvider.groovy | 41 --------- .../distro/data/HoneycombDOMBrokerProvider.java | 40 +++++++++ .../data/HoneycombDOMDataBrokerProvider.groovy | 41 --------- .../data/HoneycombDOMDataBrokerProvider.java | 38 +++++++++ .../HoneycombNotificationManagerProvider.groovy | 67 --------------- .../data/HoneycombNotificationManagerProvider.java | 68 +++++++++++++++ .../data/InmemoryDOMDataBrokerProvider.groovy | 63 -------------- .../distro/data/InmemoryDOMDataBrokerProvider.java | 61 ++++++++++++++ .../distro/data/ModifiableDTDelegProvider.groovy | 49 ----------- .../distro/data/ModifiableDTDelegProvider.java | 49 +++++++++++ .../distro/data/PersistingDataTreeProvider.groovy | 71 ---------------- .../distro/data/PersistingDataTreeProvider.java | 84 +++++++++++++++++++ .../data/config/WriterRegistryProvider.groovy | 39 --------- .../distro/data/config/WriterRegistryProvider.java | 40 +++++++++ .../data/context/ContextPipelineModule.groovy | 76 ----------------- .../distro/data/context/ContextPipelineModule.java | 74 +++++++++++++++++ .../HoneycombContextDOMDataBrokerProvider.groovy | 36 -------- .../HoneycombContextDOMDataBrokerProvider.java | 33 ++++++++ .../data/context/ModifiableDTMgrProvider.groovy | 36 -------- .../data/context/ModifiableDTMgrProvider.java | 34 ++++++++ .../context/RealtimeMappingContextProvider.groovy | 40 --------- .../context/RealtimeMappingContextProvider.java | 37 +++++++++ .../data/oper/ReadableDTDelegProvider.groovy | 49 ----------- .../distro/data/oper/ReadableDTDelegProvider.java | 48 +++++++++++ .../distro/data/oper/ReaderRegistryProvider.groovy | 39 --------- .../distro/data/oper/ReaderRegistryProvider.java | 40 +++++++++ 36 files changed, 905 insertions(+), 913 deletions(-) delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.java delete 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/PersistingDataTreeProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy create mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.java (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/BindingDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.groovy deleted file mode 100644 index e73f14932..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.groovy +++ /dev/null @@ -1,39 +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.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.ProviderTrait -import org.opendaylight.controller.md.sal.binding.api.DataBroker -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker - -@Slf4j -@ToString -class BindingDataBrokerProvider extends ProviderTrait { - - @Inject - DOMDataBroker domDataBroker - @Inject - BindingToNormalizedNodeCodec mappingService - - @Override - def create() { new BindingDOMDataBrokerAdapter(domDataBroker, mappingService) } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.java new file mode 100644 index 000000000..e17355143 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.java @@ -0,0 +1,37 @@ +/* + * 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 io.fd.honeycomb.infra.distro.ProviderTrait; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter; +import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; + +public final class BindingDataBrokerProvider extends ProviderTrait { + + @Inject + private DOMDataBroker domDataBroker; + @Inject + private BindingToNormalizedNodeCodec mappingService; + + @Override + protected BindingDOMDataBrokerAdapter create() { + return new BindingDOMDataBrokerAdapter(domDataBroker, mappingService); + } +} 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 deleted file mode 100644 index eb17cf36a..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy +++ /dev/null @@ -1,96 +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.PrivateModule -import com.google.inject.Singleton -import com.google.inject.name.Names -import groovy.util.logging.Slf4j -import io.fd.honeycomb.data.ModifiableDataManager -import io.fd.honeycomb.data.ReadableDataManager -import io.fd.honeycomb.data.init.DataTreeInitializer -import io.fd.honeycomb.infra.distro.data.config.WriterRegistryProvider -import io.fd.honeycomb.infra.distro.data.oper.ReadableDTDelegProvider -import io.fd.honeycomb.infra.distro.data.oper.ReaderRegistryProvider -import io.fd.honeycomb.infra.distro.initializer.PersistedFileInitializerProvider -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 { - - 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) - expose(ModifiableWriterRegistryBuilder) - bind(ModifiableReaderRegistryBuilder).toProvider(ReaderRegistryProvider).in(Singleton) - expose(ModifiableReaderRegistryBuilder) - - // Non persisting data tree for config - bind(DataTree) - .annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) - .toProvider(DataTreeProvider.ConfigDataTreeProvider) - .in(Singleton) - expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) - // Persisting data tree wrapper for config - bind(DataTree) - .annotatedWith(Names.named(HONEYCOMB_CONFIG)) - .toProvider(PersistingDataTreeProvider.ConfigPersistingDataTreeProvider) - .in(Singleton) - 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).toProvider(domBrokerProvider).in(Singleton) - - // 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)) - .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider) - .in(Singleton) - 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/ConfigAndOperationalPipelineModule.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java new file mode 100644 index 000000000..bac1b3ce0 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java @@ -0,0 +1,90 @@ +/* + * 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.PrivateModule; +import com.google.inject.Singleton; +import com.google.inject.name.Names; +import io.fd.honeycomb.data.ModifiableDataManager; +import io.fd.honeycomb.data.ReadableDataManager; +import io.fd.honeycomb.data.init.DataTreeInitializer; +import io.fd.honeycomb.infra.distro.data.config.WriterRegistryProvider; +import io.fd.honeycomb.infra.distro.data.oper.ReadableDTDelegProvider; +import io.fd.honeycomb.infra.distro.data.oper.ReaderRegistryProvider; +import io.fd.honeycomb.infra.distro.initializer.PersistedFileInitializerProvider; +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; + +public 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.class).toProvider(WriterRegistryProvider.class).in(Singleton.class); + expose(ModifiableWriterRegistryBuilder.class); + bind(ModifiableReaderRegistryBuilder.class).toProvider(ReaderRegistryProvider.class).in(Singleton.class); + expose(ModifiableReaderRegistryBuilder.class); + + // Non persisting data tree for config + bind(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) + .toProvider(DataTreeProvider.ConfigDataTreeProvider.class).in(Singleton.class); + expose(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)); + // Persisting data tree wrapper for config + bind(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)) + .toProvider(PersistingDataTreeProvider.ConfigPersistingDataTreeProvider.class).in(Singleton.class); + expose(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)); + + // Config Data Tree manager working on top of config data tree + writer registry + bind(ModifiableDataManager.class).toProvider(ModifiableDTDelegProvider.class).in(Singleton.class); + // Operational Data Tree manager working on top of reader registry + bind(ReadableDataManager.class).toProvider(ReadableDTDelegProvider.class).in(Singleton.class); + expose(ReadableDataManager.class); + + // DOMDataBroker wrapper on top of data tree managers + HoneycombDOMDataBrokerProvider domBrokerProvider = new HoneycombDOMDataBrokerProvider(); + bind(DOMDataBroker.class).toProvider(domBrokerProvider).in(Singleton.class); + + // BA version of data broker + bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)).toProvider(BindingDataBrokerProvider.class) + .in(Singleton.class); + expose(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)); + + // Create initializer to init persisted config data + bind(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)) + .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider.class) + .in(Singleton.class); + expose(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)); + + configureNotifications(); + } + + private void configureNotifications() { + // Create notification service + bind(DOMNotificationRouter.class).toProvider(DOMNotificationServiceProvider.class).in(Singleton.class); + expose(DOMNotificationRouter.class); + // Wrap notification service, data broker and schema service in a Broker MD-SAL API + bind(Broker.class).toProvider(HoneycombDOMBrokerProvider.class).in(Singleton.class); + expose(Broker.class); + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.groovy deleted file mode 100644 index f8a1859e2..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.groovy +++ /dev/null @@ -1,34 +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.Inject -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 org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter - -@Slf4j -@ToString -class DOMNotificationServiceProvider extends ProviderTrait { - - @Inject - HoneycombConfiguration cfg - - def create() { DOMNotificationRouter.create(cfg.notificationServiceQueueDepth) } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.java new file mode 100644 index 000000000..424393b8d --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.java @@ -0,0 +1,33 @@ +/* + * 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 io.fd.honeycomb.infra.distro.ProviderTrait; +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; +import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; + +public final class DOMNotificationServiceProvider extends ProviderTrait { + + @Inject + private HoneycombConfiguration cfg; + + @Override + protected DOMNotificationRouter create() { + return DOMNotificationRouter.create(cfg.notificationServiceQueueDepth); + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.groovy deleted file mode 100644 index 6d075ccc8..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.groovy +++ /dev/null @@ -1,40 +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.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.ProviderTrait -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory -import org.opendaylight.controller.sal.core.api.model.SchemaService - -@Slf4j -@ToString -class DataStoreProvider extends ProviderTrait { - - @Inject - SchemaService schemaService - - String name - LogicalDatastoreType type - - @Override - def create() { InMemoryDOMDataStoreFactory.create(name, type, schemaService, false, null) } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.java new file mode 100644 index 000000000..5b09f21f8 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.java @@ -0,0 +1,43 @@ +/* + * 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 io.fd.honeycomb.infra.distro.ProviderTrait; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory; +import org.opendaylight.controller.sal.core.api.model.SchemaService; + +public final class DataStoreProvider extends ProviderTrait { + + @Inject + private SchemaService schemaService; + private String name; + private LogicalDatastoreType type; + + public DataStoreProvider(final String name, + final LogicalDatastoreType type) { + this.name = name; + this.type = type; + } + + @Override + protected InMemoryDOMDataStore create() { + return InMemoryDOMDataStoreFactory.create(name, type, schemaService, false, null); + } +} 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 deleted file mode 100644 index bf1f562ec..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy +++ /dev/null @@ -1,57 +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.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -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 - -@Slf4j -@ToString -abstract class DataTreeProvider extends ProviderTrait { - - @Inject - SchemaService schemaService - @Inject - HoneycombConfiguration config - - def create() { - def delegate = InMemoryDataTreeFactory.getInstance().create(getType()) - delegate.setSchemaContext(schemaService.getGlobalContext()) - delegate - } - - abstract TreeType getType() - - @Slf4j - @ToString - static class ConfigDataTreeProvider extends DataTreeProvider { - TreeType getType() { TreeType.CONFIGURATION } - } - - @Slf4j - @ToString - static class ContextDataTreeProvider extends DataTreeProvider { - TreeType getType() { TreeType.OPERATIONAL } - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.java new file mode 100644 index 000000000..c5fcc050a --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.java @@ -0,0 +1,56 @@ +/* + * 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 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.TipProducingDataTree; +import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; +import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; + +public abstract class DataTreeProvider extends ProviderTrait { + + @Inject + private SchemaService schemaService; + @Inject + private HoneycombConfiguration config; + + public TipProducingDataTree create() { + TipProducingDataTree delegate = InMemoryDataTreeFactory.getInstance().create(getType()); + delegate.setSchemaContext(schemaService.getGlobalContext()); + return delegate; + } + + public abstract TreeType getType(); + + public static class ConfigDataTreeProvider extends DataTreeProvider { + public TreeType getType() { + return TreeType.CONFIGURATION; + } + + } + + public static class ContextDataTreeProvider extends DataTreeProvider { + public TreeType getType() { + return 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 deleted file mode 100644 index dc620b445..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy +++ /dev/null @@ -1,41 +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.Inject -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.broker.impl.DOMNotificationRouter -import org.opendaylight.controller.sal.core.api.Broker -import org.opendaylight.controller.sal.core.api.model.SchemaService - -@Slf4j -@ToString -class HoneycombDOMBrokerProvider extends ProviderTrait { - - @Inject - DOMDataBroker domDataBroker - @Inject - SchemaService schemaService - @Inject - DOMNotificationRouter domNotificationService - - def create() { new NorthboundFacadeHoneycombDOMBroker(domDataBroker, schemaService, domNotificationService) } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java new file mode 100644 index 000000000..eefa1c140 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java @@ -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; + +import com.google.inject.Inject; +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.broker.impl.DOMNotificationRouter; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.model.SchemaService; + +public final class HoneycombDOMBrokerProvider extends ProviderTrait { + + @Inject + private DOMDataBroker domDataBroker; + @Inject + private SchemaService schemaService; + @Inject + private DOMNotificationRouter domNotificationService; + + @Override + protected NorthboundFacadeHoneycombDOMBroker create() { + return 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 deleted file mode 100644 index a2fec2a60..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy +++ /dev/null @@ -1,41 +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.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.data.ModifiableDataManager -import io.fd.honeycomb.data.ReadableDataManager -import io.fd.honeycomb.data.impl.DataBroker -import io.fd.honeycomb.infra.distro.ProviderTrait -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker - -@Slf4j -@ToString -class HoneycombDOMDataBrokerProvider extends ProviderTrait { - - @Inject - ModifiableDataManager modDataManager - - @Inject - ReadableDataManager readDataManager - - def create() { - readDataManager ? DataBroker.create(modDataManager, readDataManager) : DataBroker.create(modDataManager) - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.java new file mode 100644 index 000000000..92bbc512d --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.java @@ -0,0 +1,38 @@ +/* + * 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 io.fd.honeycomb.data.ModifiableDataManager; +import io.fd.honeycomb.data.ReadableDataManager; +import io.fd.honeycomb.data.impl.DataBroker; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; + +public final class HoneycombDOMDataBrokerProvider extends ProviderTrait { + + @Inject + private ModifiableDataManager modDataManager; + @Inject(optional = true) + private ReadableDataManager readDataManager; + + protected DataBroker create() { + return readDataManager != null + ? DataBroker.create(modDataManager, readDataManager) + : DataBroker.create(modDataManager); + } +} 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 deleted file mode 100644 index b81a8d784..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy +++ /dev/null @@ -1,67 +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.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.ProviderTrait -import io.fd.honeycomb.notification.ManagedNotificationProducer -import io.fd.honeycomb.notification.NotificationCollector -import io.fd.honeycomb.notification.impl.HoneycombNotificationCollector -import io.fd.honeycomb.notification.impl.NotificationProducerRegistry -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 - -@Slf4j -@ToString -class HoneycombNotificationManagerProvider extends ProviderTrait { - - @Inject - DOMNotificationRouter notificationRouter - @Inject(optional = true) - Set notificationProducers = [] - @Inject - BindingToNormalizedNodeCodec codec - - @Override - def create() { - // Create the registry to keep track of what'OPERATIONAL registered - def notificationProducerRegistry = new NotificationProducerRegistry(notificationProducers as List); - - // Create BA version of notification service (implementation is free from ODL) - def bindingDOMNotificationPublishServiceAdapter = - new BindingDOMNotificationPublishServiceAdapter(codec, notificationRouter); - - // Create Collector on top of BA notification service and registry - def honeycombNotificationCollector = - new HoneycombNotificationCollector(bindingDOMNotificationPublishServiceAdapter, notificationProducerRegistry); - - // Create tracker, responsible for starting and stopping registered notification producers whenever necessary - def notificationProducerTracker = - new NotificationProducerTracker(notificationProducerRegistry, honeycombNotificationCollector, - notificationRouter); - - // TODO wire with restconf - // DOMNotificationService is already provided by DOMBroker injected into RESTCONF, however RESTCONF - // only supports data-change notification, nothing else. So currently its impossible. - - honeycombNotificationCollector - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java new file mode 100644 index 000000000..e25cb1569 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java @@ -0,0 +1,68 @@ +/* + * 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.common.collect.Lists; +import com.google.inject.Inject; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import io.fd.honeycomb.notification.ManagedNotificationProducer; +import io.fd.honeycomb.notification.NotificationCollector; +import io.fd.honeycomb.notification.impl.HoneycombNotificationCollector; +import io.fd.honeycomb.notification.impl.NotificationProducerRegistry; +import io.fd.honeycomb.notification.impl.NotificationProducerTracker; +import java.util.HashSet; +import java.util.Set; +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; + +public final class HoneycombNotificationManagerProvider extends ProviderTrait { + + @Inject + private DOMNotificationRouter notificationRouter; + @Inject(optional = true) + private Set notificationProducers = new HashSet<>(); + @Inject + private BindingToNormalizedNodeCodec codec; + + @Override + protected HoneycombNotificationCollector create() { + // Create the registry to keep track of what'OPERATIONAL registered + NotificationProducerRegistry notificationProducerRegistry = + new NotificationProducerRegistry(Lists.newArrayList(notificationProducers)); + + // Create BA version of notification service (implementation is free from ODL) + BindingDOMNotificationPublishServiceAdapter bindingDOMNotificationPublishServiceAdapter = + new BindingDOMNotificationPublishServiceAdapter(codec, notificationRouter); + + // Create Collector on top of BA notification service and registry + HoneycombNotificationCollector honeycombNotificationCollector = + new HoneycombNotificationCollector(bindingDOMNotificationPublishServiceAdapter, + notificationProducerRegistry); + + // Create tracker, responsible for starting and stopping registered notification producers whenever necessary + NotificationProducerTracker notificationProducerTracker = + new NotificationProducerTracker(notificationProducerRegistry, honeycombNotificationCollector, + notificationRouter); + + // TODO wire with restconf + // DOMNotificationService is already provided by DOMBroker injected into RESTCONF, however RESTCONF + // only supports data-change notification, nothing else. So currently its impossible. + + return honeycombNotificationCollector; + } +} 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 deleted file mode 100644 index a04f1a81c..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy +++ /dev/null @@ -1,63 +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.Inject -import com.google.inject.name.Named -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.ProviderTrait -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker -import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore -import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService -import org.opendaylight.yangtools.util.concurrent.SpecialExecutors - -@Slf4j -@ToString -class InmemoryDOMDataBrokerProvider extends ProviderTrait { - - public static final String CONFIG = "config" - public static final String OPERATIONAL = "operational" - - @Inject - @Named(InmemoryDOMDataBrokerProvider.CONFIG) - InMemoryDOMDataStore cfgDataStore - - @Inject - @Named(InmemoryDOMDataBrokerProvider.OPERATIONAL) - InMemoryDOMDataStore operDataStore - - @Override - def create() { - // This Databroker is dedicated for netconf metadata, not expected to be under heavy load - def listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 100, "commits") - def commitExecutor = SpecialExecutors.newBoundedSingleThreadExecutor(100, "WriteTxCommit") - // TODO try to provide more lightweight implementation of DataBroker, maybe a single executor would be enough - - def map = [:] - map.put(LogicalDatastoreType.CONFIGURATION, cfgDataStore) - map.put(LogicalDatastoreType.OPERATIONAL, operDataStore) - - new SerializedDOMDataBroker(map, - new DeadlockDetectingListeningExecutorService(commitExecutor, - TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, - listenableFutureExecutor)) - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.java new file mode 100644 index 000000000..7db2f7856 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.java @@ -0,0 +1,61 @@ +/* + * 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 io.fd.honeycomb.infra.distro.ProviderTrait; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; +import org.opendaylight.controller.sal.core.spi.data.DOMStore; +import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; +import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; + +public final class InmemoryDOMDataBrokerProvider extends ProviderTrait { + + public static final String CONFIG = "config"; + public static final String OPERATIONAL = "operational"; + + @Inject + @Named(InmemoryDOMDataBrokerProvider.CONFIG) + private InMemoryDOMDataStore cfgDataStore; + @Inject + @Named(InmemoryDOMDataBrokerProvider.OPERATIONAL) + private InMemoryDOMDataStore operDataStore; + + @Override + protected SerializedDOMDataBroker create() { + // This Databroker is dedicated for netconf metadata, not expected to be under heavy load + ExecutorService listenableFutureExecutor = + SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 100, "commits"); + ExecutorService commitExecutor = SpecialExecutors.newBoundedSingleThreadExecutor(100, "WriteTxCommit"); + // TODO try to provide more lightweight implementation of DataBroker, maybe a single executor would be enough + + Map map = new LinkedHashMap<>(); + map.put(LogicalDatastoreType.CONFIGURATION, cfgDataStore); + map.put(LogicalDatastoreType.OPERATIONAL, operDataStore); + + return new SerializedDOMDataBroker(map, new DeadlockDetectingListeningExecutorService(commitExecutor, + TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, listenableFutureExecutor)); + } +} 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 deleted file mode 100644 index cd4d9c624..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy +++ /dev/null @@ -1,49 +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.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.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 -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree - -@Slf4j -@ToString -class ModifiableDTDelegProvider extends ProviderTrait { - - @Inject - BindingToNormalizedNodeCodec serializer - @Inject - @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) - DataTree dataTree - @Inject - ModifiableWriterRegistryBuilder registry - @Inject - @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) - DataBroker contextBroker - - @Override - def create() { new ModifiableDataTreeDelegator(serializer, dataTree, registry.build(), contextBroker) } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.java new file mode 100644 index 000000000..edd4faadb --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.java @@ -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.data; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +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 io.fd.honeycomb.translate.write.registry.WriterRegistryBuilder; +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; + +public final class ModifiableDTDelegProvider extends ProviderTrait { + + @Inject + private BindingToNormalizedNodeCodec serializer; + @Inject + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) + private DataTree dataTree; + @Inject + private ModifiableWriterRegistryBuilder registry; + @Inject + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) + private DataBroker contextBroker; + + @Override + protected ModifiableDataTreeDelegator create() { + return new ModifiableDataTreeDelegator(serializer, dataTree, + ((WriterRegistryBuilder) registry).build(), contextBroker); + } +} 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 deleted file mode 100644 index 6c41ad69f..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy +++ /dev/null @@ -1,71 +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.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 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 - -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(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG_NONPERSIST) - DataTree delegate - - String getPath() { config.peristConfigPath } - TreeType getType() { TreeType.CONFIGURATION } - DataTree getDelegate() { return delegate } - } - - static class ContextPersistingDataTreeProvider extends PersistingDataTreeProvider { - - @Inject - @Named(ContextPipelineModule.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/PersistingDataTreeProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java new file mode 100644 index 000000000..fb4ebc69d --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java @@ -0,0 +1,84 @@ +/* + * 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 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 java.nio.file.Paths; +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; + +public abstract class PersistingDataTreeProvider extends ProviderTrait { + + @Inject + private SchemaService schemaService; + @Inject + protected HoneycombConfiguration config; + + public PersistingDataTreeAdapter create() { + return new PersistingDataTreeAdapter(getDelegate(), schemaService, Paths.get(getPath())); + } + + public abstract String getPath(); + + public abstract TreeType getType(); + + public abstract DataTree getDelegate(); + + public static final class ConfigPersistingDataTreeProvider extends PersistingDataTreeProvider { + + @Inject + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG_NONPERSIST) + private DataTree delegate; + + public String getPath() { + return config.peristConfigPath; + } + + public TreeType getType() { + return TreeType.CONFIGURATION; + } + + public DataTree getDelegate() { + return delegate; + } + } + + public static final class ContextPersistingDataTreeProvider extends PersistingDataTreeProvider { + + @Inject + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT_NOPERSIST) + private DataTree delegate; + + public String getPath() { + return config.peristContextPath; + } + + public TreeType getType() { + return TreeType.OPERATIONAL; + } + + public DataTree getDelegate() { + return delegate; + } + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy deleted file mode 100644 index 3c94812ef..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy +++ /dev/null @@ -1,39 +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.config - -import com.google.inject.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.ProviderTrait -import io.fd.honeycomb.translate.util.write.registry.FlatWriterRegistryBuilder -import io.fd.honeycomb.translate.write.WriterFactory -import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder - -@Slf4j -@ToString -class WriterRegistryProvider extends ProviderTrait { - - @Inject(optional = true) - Set writerFactories = [] - - def create() { - def builder = new FlatWriterRegistryBuilder() - writerFactories.forEach { it.init(builder) } - builder - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.java new file mode 100644 index 000000000..f3e8ce200 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.java @@ -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.config; + +import com.google.inject.Inject; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import io.fd.honeycomb.translate.util.write.registry.FlatWriterRegistryBuilder; +import io.fd.honeycomb.translate.write.WriterFactory; +import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; +import java.util.HashSet; +import java.util.Set; + +public final class WriterRegistryProvider extends ProviderTrait { + + @Inject(optional = true) + private Set writerFactories = new HashSet<>(); + + @Override + protected FlatWriterRegistryBuilder create() { + final FlatWriterRegistryBuilder builder = new FlatWriterRegistryBuilder(); + writerFactories + .stream() + .forEach(it -> it.init(builder)); + return builder; + } +} 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 deleted file mode 100644 index a4cf73162..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy +++ /dev/null @@ -1,76 +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.context - -import com.google.inject.PrivateModule -import com.google.inject.Singleton -import com.google.inject.name.Names -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 - -class ContextPipelineModule extends PrivateModule { - - public static final String HONEYCOMB_CONTEXT_NOPERSIST = "honeycomb-context-nopersist" - public static final String HONEYCOMB_CONTEXT = "honeycomb-context" - - protected void configure() { - // Non persisting data tree for context - 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 for context - def dataTreeProvider = new PersistingDataTreeProvider.ContextPersistingDataTreeProvider() - bind(DataTree).toProvider(dataTreeProvider).in(Singleton) - - // 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).toProvider(domBrokerProvider).in(Singleton) - - // 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)) - .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider) - .in(Singleton) - 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)) - .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/ContextPipelineModule.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java new file mode 100644 index 000000000..b0ded35bd --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java @@ -0,0 +1,74 @@ +/* + * 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.PrivateModule; +import com.google.inject.Singleton; +import com.google.inject.name.Names; +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; + +public class ContextPipelineModule extends PrivateModule { + + public static final String HONEYCOMB_CONTEXT_NOPERSIST = "honeycomb-context-nopersist"; + public static final String HONEYCOMB_CONTEXT = "honeycomb-context"; + + @Override + protected void configure() { + // Non persisting data tree for context + DataTreeProvider.ContextDataTreeProvider noPersistDataTreeProvider = + new DataTreeProvider.ContextDataTreeProvider(); + bind(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT_NOPERSIST)) + .toProvider(noPersistDataTreeProvider).in(Singleton.class); + expose(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT_NOPERSIST)); + // Persisting data tree wrapper for context + PersistingDataTreeProvider.ContextPersistingDataTreeProvider dataTreeProvider = + new PersistingDataTreeProvider.ContextPersistingDataTreeProvider(); + bind(DataTree.class).toProvider(dataTreeProvider).in(Singleton.class); + + // Data Tree manager (without any delegation) on top of context data tree + bind(ModifiableDataManager.class).toProvider(ModifiableDTMgrProvider.class).in(Singleton.class); + + // DOMDataBroker interface on top of data tree manager + HoneycombContextDOMDataBrokerProvider domBrokerProvider = new HoneycombContextDOMDataBrokerProvider(); + bind(DOMDataBroker.class).toProvider(domBrokerProvider).in(Singleton.class); + + // BA version of data broker for context + bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)).toProvider(BindingDataBrokerProvider.class) + .in(Singleton.class); + expose(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)); + + // Create initializer to init persisted config data + bind(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) + .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider.class) + .in(Singleton.class); + expose(DataTreeInitializer.class).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.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) + .toProvider(RealtimeMappingContextProvider.class).in(Singleton.class); + expose(MappingContext.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)); + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.groovy deleted file mode 100644 index eecd87e42..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.groovy +++ /dev/null @@ -1,36 +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.context - -import com.google.inject.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.data.ModifiableDataManager -import io.fd.honeycomb.data.impl.DataBroker -import io.fd.honeycomb.infra.distro.ProviderTrait -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker - -@Slf4j -@ToString -class HoneycombContextDOMDataBrokerProvider extends ProviderTrait { - - @Inject - ModifiableDataManager modDataManager - - def create() { DataBroker.create(modDataManager) } - -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.java new file mode 100644 index 000000000..8e178203d --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.java @@ -0,0 +1,33 @@ +/* + * 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 io.fd.honeycomb.data.ModifiableDataManager; +import io.fd.honeycomb.data.impl.DataBroker; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; + +public final class HoneycombContextDOMDataBrokerProvider extends ProviderTrait { + + @Inject + private ModifiableDataManager modDataManager; + + public DataBroker create() { + return DataBroker.create(modDataManager); + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.groovy deleted file mode 100644 index 01d854b28..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.groovy +++ /dev/null @@ -1,36 +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.context - -import com.google.inject.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.data.ModifiableDataManager -import io.fd.honeycomb.data.impl.ModifiableDataTreeManager -import io.fd.honeycomb.infra.distro.ProviderTrait -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree - -@Slf4j -@ToString -class ModifiableDTMgrProvider extends ProviderTrait { - - @Inject - DataTree dataTree - - @Override - def create() { new ModifiableDataTreeManager(dataTree) } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.java new file mode 100644 index 000000000..9da97a8e4 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.java @@ -0,0 +1,34 @@ +/* + * 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 io.fd.honeycomb.data.ModifiableDataManager; +import io.fd.honeycomb.data.impl.ModifiableDataTreeManager; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; + +public final class ModifiableDTMgrProvider extends ProviderTrait { + + @Inject + private DataTree dataTree; + + @Override + public ModifiableDataTreeManager create() { + return new ModifiableDataTreeManager(dataTree); + } +} 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 deleted file mode 100644 index c6afd92fc..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy +++ /dev/null @@ -1,40 +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.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(ContextPipelineModule.HONEYCOMB_CONTEXT) - DataBroker contextDataBroker - - @Override - def create() { - new RealtimeMappingContext(contextDataBroker) - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.java new file mode 100644 index 000000000..cc1a8b1b8 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.java @@ -0,0 +1,37 @@ +/* + * 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 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; + +public final class RealtimeMappingContextProvider extends ProviderTrait { + + @Inject + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) + private DataBroker contextDataBroker; + + @Override + public RealtimeMappingContext create() { + return new RealtimeMappingContext(contextDataBroker); + } + +} 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 deleted file mode 100644 index 11eaf49a4..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy +++ /dev/null @@ -1,49 +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.oper - -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.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 -import org.opendaylight.controller.sal.core.api.model.SchemaService - -@Slf4j -@ToString -class ReadableDTDelegProvider extends ProviderTrait { - - @Inject - BindingToNormalizedNodeCodec serializer - @Inject - SchemaService schemaService - @Inject - ModifiableReaderRegistryBuilder registry - @Inject - @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) - DataBroker contextBroker - - def create() { - new ReadableDataTreeDelegator(serializer, schemaService.getGlobalContext(), registry.build(), contextBroker) - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.java new file mode 100644 index 000000000..13e82e85f --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.java @@ -0,0 +1,48 @@ +/* + * 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.oper; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +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 io.fd.honeycomb.translate.read.registry.ReaderRegistryBuilder; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.controller.sal.core.api.model.SchemaService; + +public final class ReadableDTDelegProvider extends ProviderTrait { + + @Inject + private BindingToNormalizedNodeCodec serializer; + @Inject + private SchemaService schemaService; + @Inject + private ModifiableReaderRegistryBuilder registry; + @Inject + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) + private DataBroker contextBroker; + + @Override + protected ReadableDataTreeDelegator create() { + return new ReadableDataTreeDelegator(serializer, schemaService.getGlobalContext(), + ((ReaderRegistryBuilder) registry).build(), contextBroker); + } +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy deleted file mode 100644 index 36f74d948..000000000 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy +++ /dev/null @@ -1,39 +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.oper - -import com.google.inject.Inject -import groovy.transform.ToString -import groovy.util.logging.Slf4j -import io.fd.honeycomb.infra.distro.ProviderTrait -import io.fd.honeycomb.translate.read.ReaderFactory -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder -import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder - -@Slf4j -@ToString -class ReaderRegistryProvider extends ProviderTrait { - - @Inject(optional = true) - Set readerFactories = [] - - def create() { - def builder = new CompositeReaderRegistryBuilder() - readerFactories.forEach { it.init(builder) } - builder - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.java new file mode 100644 index 000000000..ef09e0e97 --- /dev/null +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.java @@ -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.oper; + +import com.google.inject.Inject; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import io.fd.honeycomb.translate.read.ReaderFactory; +import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; +import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder; +import java.util.HashSet; +import java.util.Set; + +public final class ReaderRegistryProvider extends ProviderTrait { + + @Inject(optional = true) + private Set readerFactories = new HashSet<>(); + + @Override + protected CompositeReaderRegistryBuilder create() { + final CompositeReaderRegistryBuilder builder = new CompositeReaderRegistryBuilder(); + readerFactories.stream() + .forEach(it -> it.init(builder)); + return builder; + } + +} -- cgit 1.2.3-korg