summaryrefslogtreecommitdiffstats
path: root/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data
diff options
context:
space:
mode:
Diffstat (limited to 'infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data')
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.groovy39
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy71
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.groovy34
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.groovy40
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy59
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy44
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy43
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy72
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy65
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy48
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy45
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy39
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy58
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.groovy36
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.groovy36
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy48
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy39
17 files changed, 816 insertions, 0 deletions
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
new file mode 100644
index 0000000..e73f149
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/BindingDataBrokerProvider.groovy
@@ -0,0 +1,39 @@
+/*
+ * 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<DataBroker> {
+
+ @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/ConfigAndOperationalPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy
new file mode 100644
index 0000000..01ec8c1
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy
@@ -0,0 +1,71 @@
+/*
+ * 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.yangtools.yang.data.api.schema.tree.DataTree
+
+@Slf4j
+class ConfigAndOperationalPipelineModule extends PrivateModule {
+
+ protected void configure() {
+ // Expose registries
+ bind(ModifiableWriterRegistryBuilder).toProvider(WriterRegistryProvider).in(Singleton)
+ expose(ModifiableWriterRegistryBuilder)
+ bind(ModifiableReaderRegistryBuilder).toProvider(ReaderRegistryProvider).in(Singleton)
+ expose(ModifiableReaderRegistryBuilder)
+
+ def dataTreeProvider = new DataTreeProvider.ConfigDataTreeProvider()
+ bind(DataTree).annotatedWith(Names.named("honeycomb-config")).toProvider(dataTreeProvider).in(Singleton)
+ expose(DataTree).annotatedWith(Names.named("honeycomb-config"))
+
+ bind(ModifiableDataManager).toProvider(ModifiableDTDelegProvider).in(Singleton)
+ bind(ReadableDataManager)
+ .annotatedWith(Names.named("honeycomb-operational"))
+ .toProvider(ReadableDTDelegProvider).in(Singleton)
+ // Expose reader for initializer
+ expose(ReadableDataManager).annotatedWith(Names.named("honeycomb-operational"))
+
+ def domBrokerProvider = new HoneycombDOMDataBrokerProvider()
+ bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(domBrokerProvider).in(Singleton)
+ // Bind also without annotation for easy private injection
+ bind(DOMDataBroker).toProvider(domBrokerProvider).in(Singleton)
+ expose(DOMDataBroker).annotatedWith(Names.named("honeycomb-config"))
+ bind(DataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(BindingDataBrokerProvider).in(Singleton)
+ expose(DataBroker).annotatedWith(Names.named("honeycomb-config"))
+
+ bind(DataTreeInitializer)
+ .annotatedWith(Names.named("honeycomb-config"))
+ .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider)
+ .in(Singleton)
+ expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-config"))
+ }
+}
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
new file mode 100644
index 0000000..f8a1859
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DOMNotificationServiceProvider.groovy
@@ -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
+
+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<DOMNotificationRouter> {
+
+ @Inject
+ HoneycombConfiguration cfg
+
+ def create() { 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
new file mode 100644
index 0000000..6d075cc
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataStoreProvider.groovy
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.infra.distro.data
+
+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<InMemoryDOMDataStore> {
+
+ @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/DataTreeProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy
new file mode 100644
index 0000000..6915a3c
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/DataTreeProvider.groovy
@@ -0,0 +1,59 @@
+/*
+ * 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.impl.PersistingDataTreeAdapter
+import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration
+import io.fd.honeycomb.infra.distro.ProviderTrait
+import org.opendaylight.controller.sal.core.api.model.SchemaService
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory
+
+import java.nio.file.Paths
+
+@Slf4j
+@ToString
+abstract class DataTreeProvider extends ProviderTrait<DataTree> {
+
+ @Inject
+ SchemaService schemaService
+ @Inject
+ HoneycombConfiguration config
+
+ def create() {
+ def delegate = InMemoryDataTreeFactory.getInstance().create(getType())
+ delegate.setSchemaContext(schemaService.getGlobalContext())
+ new PersistingDataTreeAdapter(delegate, schemaService, Paths.get(getPath()))
+ }
+
+ abstract String getPath()
+ abstract TreeType getType()
+
+ static class ConfigDataTreeProvider extends DataTreeProvider {
+ String getPath() { config.peristConfigPath }
+ TreeType getType() { TreeType.CONFIGURATION }
+ }
+
+ static class ContextDataTreeProvider extends DataTreeProvider {
+ String getPath() { config.peristContextPath }
+ TreeType getType() { TreeType.OPERATIONAL }
+ }
+}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy
new file mode 100644
index 0000000..2b275f7
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy
@@ -0,0 +1,44 @@
+/*
+ * 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.impl.NorthboundFacadeHoneycombDOMBroker
+import io.fd.honeycomb.infra.distro.ProviderTrait
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService
+import org.opendaylight.controller.sal.core.api.Broker
+import org.opendaylight.controller.sal.core.api.model.SchemaService
+
+@Slf4j
+@ToString
+class HoneycombDOMBrokerProvider extends ProviderTrait<Broker> {
+
+ @Inject
+ @Named("honeycomb-config")
+ DOMDataBroker domDataBroker
+ @Inject
+ SchemaService schemaService
+ @Inject
+ @Named("honeycomb")
+ DOMNotificationService domNotificationService
+
+ def create() { new NorthboundFacadeHoneycombDOMBroker(domDataBroker, schemaService, domNotificationService) }
+}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy
new file mode 100644
index 0000000..e91054b
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMDataBrokerProvider.groovy
@@ -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 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.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<DOMDataBroker> {
+
+ @Inject
+ ModifiableDataManager modDataManager
+
+ @Inject
+ @Named("honeycomb-operational")
+ 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/HoneycombNotificationManagerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy
new file mode 100644
index 0000000..f150691
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy
@@ -0,0 +1,72 @@
+/*
+ * 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 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
+
+/**
+ * Mirror of org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.notification.impl.rev160601.HoneycombNotificationManagerModule
+ */
+@Slf4j
+@ToString
+class HoneycombNotificationManagerProvider extends ProviderTrait<NotificationCollector> {
+
+ @Inject
+ @Named("honeycomb")
+ DOMNotificationRouter notificationRouter
+ @Inject(optional = true)
+ Set<ManagedNotificationProducer> 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/InmemoryDOMDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy
new file mode 100644
index 0000000..6462baa
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy
@@ -0,0 +1,65 @@
+/*
+ * 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
+/**
+ * Mirror of org.opendaylight.controller.config.yang.md.sal.dom.impl.DomInmemoryDataBrokerModule
+ */
+@Slf4j
+@ToString
+class InmemoryDOMDataBrokerProvider extends ProviderTrait<DOMDataBroker> {
+
+ 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/ModifiableDTDelegProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy
new file mode 100644
index 0000000..f7ec4cc
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy
@@ -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
+
+import com.google.inject.Inject
+import com.google.inject.name.Named
+import groovy.transform.ToString
+import groovy.util.logging.Slf4j
+import io.fd.honeycomb.data.ModifiableDataManager
+import io.fd.honeycomb.data.impl.ModifiableDataTreeDelegator
+import io.fd.honeycomb.infra.distro.ProviderTrait
+import io.fd.honeycomb.translate.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<ModifiableDataManager> {
+
+ @Inject
+ BindingToNormalizedNodeCodec serializer
+ @Inject
+ @Named("honeycomb-config")
+ DataTree dataTree
+ @Inject
+ ModifiableWriterRegistryBuilder registry
+ @Inject
+ @Named("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/NotificationModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy
new file mode 100644
index 0000000..4836a0f
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/NotificationModule.groovy
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.infra.distro.data
+
+import com.google.inject.AbstractModule
+import com.google.inject.Singleton
+import com.google.inject.name.Names
+import groovy.util.logging.Slf4j
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService
+import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter
+import org.opendaylight.controller.sal.core.api.Broker
+
+@Slf4j
+class NotificationModule extends AbstractModule {
+
+ protected void configure() {
+ def provider = new DOMNotificationServiceProvider()
+ bind(DOMNotificationService)
+ .annotatedWith(Names.named("honeycomb"))
+ .toProvider(provider)
+ .in(Singleton)
+ bind(DOMNotificationRouter)
+ .annotatedWith(Names.named("honeycomb"))
+ .toProvider(provider)
+ .in(Singleton)
+ bind(Broker)
+ .annotatedWith(Names.named("honeycomb"))
+ .toProvider(HoneycombDOMBrokerProvider)
+ .in(Singleton)
+ }
+}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy
new file mode 100644
index 0000000..3c94812
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/config/WriterRegistryProvider.groovy
@@ -0,0 +1,39 @@
+/*
+ * 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<ModifiableWriterRegistryBuilder> {
+
+ @Inject(optional = true)
+ Set<WriterFactory> 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/context/ContextPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy
new file mode 100644
index 0000000..0112413
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy
@@ -0,0 +1,58 @@
+/*
+ * 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.initializer.PersistedFileInitializerProvider
+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 {
+
+ protected void configure() {
+ // Bind also without annotation for easy private injection
+ def dataTreeProvider = new DataTreeProvider.ContextDataTreeProvider()
+ bind(DataTree).toProvider(dataTreeProvider).in(Singleton)
+ bind(DataTree).annotatedWith(Names.named("honeycomb-context")).toProvider(dataTreeProvider).in(Singleton)
+ expose(DataTree).annotatedWith(Names.named("honeycomb-context"))
+
+ bind(ModifiableDataManager).toProvider(ModifiableDTMgrProvider).in(Singleton)
+
+ def domBrokerProvider = new HoneycombContextDOMDataBrokerProvider()
+ bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(domBrokerProvider).in(Singleton)
+ // Bind also without annotation for easy private injection
+ bind(DOMDataBroker).toProvider(domBrokerProvider).in(Singleton)
+ expose(DOMDataBroker).annotatedWith(Names.named("honeycomb-context"))
+
+ bind(DataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(BindingDataBrokerProvider).in(Singleton)
+ expose(DataBroker).annotatedWith(Names.named("honeycomb-context"))
+
+ bind(DataTreeInitializer)
+ .annotatedWith(Names.named("honeycomb-context"))
+ .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider)
+ .in(Singleton)
+ expose(DataTreeInitializer).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
new file mode 100644
index 0000000..eecd87e
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/HoneycombContextDOMDataBrokerProvider.groovy
@@ -0,0 +1,36 @@
+/*
+ * 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<DOMDataBroker> {
+
+ @Inject
+ ModifiableDataManager modDataManager
+
+ def create() { 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
new file mode 100644
index 0000000..01d854b
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ModifiableDTMgrProvider.groovy
@@ -0,0 +1,36 @@
+/*
+ * 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<ModifiableDataManager> {
+
+ @Inject
+ DataTree dataTree
+
+ @Override
+ def create() { new ModifiableDataTreeManager(dataTree) }
+}
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
new file mode 100644
index 0000000..3842787
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy
@@ -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 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.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<ReadableDataManager> {
+
+ @Inject
+ BindingToNormalizedNodeCodec serializer
+ @Inject
+ SchemaService schemaService
+ @Inject
+ ModifiableReaderRegistryBuilder registry
+ @Inject
+ @Named("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/ReaderRegistryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy
new file mode 100644
index 0000000..36f74d9
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.groovy
@@ -0,0 +1,39 @@
+/*
+ * 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<ModifiableReaderRegistryBuilder> {
+
+ @Inject(optional = true)
+ Set<ReaderFactory> readerFactories = []
+
+ def create() {
+ def builder = new CompositeReaderRegistryBuilder()
+ readerFactories.forEach { it.init(builder) }
+ builder
+ }
+}