summaryrefslogtreecommitdiffstats
path: root/infra/minimal-distribution/src/main/java/io
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-10-26 12:18:11 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-10-28 12:32:11 +0200
commit04c868333214c0e5bfce3926c43a4302615f2ac5 (patch)
tree4c3f4b8fd3c833e807abdc25aa7f74e05cfa0b38 /infra/minimal-distribution/src/main/java/io
parentb0615e61b93ef8530193bd45c270ed313dcc23a7 (diff)
Honeycomb-73 Extensible initializers framework
Change-Id: Ib23453d4040d59a512686315995a5cf9e532cefc Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/minimal-distribution/src/main/java/io')
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java2
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java6
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.java7
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryBuilderProvider.java40
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryProvider.java19
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.java2
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java55
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapterProvider.java (renamed from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.java)26
8 files changed, 119 insertions, 38 deletions
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
index 3c62382c2..4769b570d 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
@@ -119,8 +119,6 @@ public final class Main {
injector.getInstance(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class);
}
- LOG.info("Honeycomb started successfully!");
-
try {
LOG.info("Initializing configuration");
injector.getInstance(Key.get(InitializerRegistry.class,
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
index bac1b3ce0..488f0b390 100644
--- 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
@@ -24,9 +24,11 @@ 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.ReaderRegistryBuilderProvider;
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.read.registry.ReaderRegistry;
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;
@@ -43,8 +45,10 @@ public class ConfigAndOperationalPipelineModule extends PrivateModule {
// 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);
+ bind(ModifiableReaderRegistryBuilder.class).toProvider(ReaderRegistryBuilderProvider.class).in(Singleton.class);
expose(ModifiableReaderRegistryBuilder.class);
+ bind(ReaderRegistry.class).toProvider(ReaderRegistryProvider.class).in(Singleton.class);
+ expose(ReaderRegistry.class);
// Non persisting data tree for config
bind(DataTree.class).annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST))
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
index 13e82e85f..caac736b5 100644
--- 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
@@ -22,8 +22,7 @@ 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 io.fd.honeycomb.translate.read.registry.ReaderRegistry;
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;
@@ -35,7 +34,7 @@ public final class ReadableDTDelegProvider extends ProviderTrait<ReadableDataMan
@Inject
private SchemaService schemaService;
@Inject
- private ModifiableReaderRegistryBuilder registry;
+ private ReaderRegistry registry;
@Inject
@Named(ContextPipelineModule.HONEYCOMB_CONTEXT)
private DataBroker contextBroker;
@@ -43,6 +42,6 @@ public final class ReadableDTDelegProvider extends ProviderTrait<ReadableDataMan
@Override
protected ReadableDataTreeDelegator create() {
return new ReadableDataTreeDelegator(serializer, schemaService.getGlobalContext(),
- ((ReaderRegistryBuilder) registry).build(), contextBroker);
+ registry, contextBroker);
}
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryBuilderProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryBuilderProvider.java
new file mode 100644
index 000000000..05177d54d
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReaderRegistryBuilderProvider.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 ReaderRegistryBuilderProvider extends ProviderTrait<ModifiableReaderRegistryBuilder> {
+
+ @Inject(optional = true)
+ private Set<ReaderFactory> readerFactories = new HashSet<>();
+
+ @Override
+ protected CompositeReaderRegistryBuilder create() {
+ final CompositeReaderRegistryBuilder builder = new CompositeReaderRegistryBuilder();
+ readerFactories.stream()
+ .forEach(it -> it.init(builder));
+ return 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
index ef09e0e97..8370da8bb 100644
--- 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
@@ -18,23 +18,18 @@ 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;
+import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
+import io.fd.honeycomb.translate.read.registry.ReaderRegistryBuilder;
-public final class ReaderRegistryProvider extends ProviderTrait<ModifiableReaderRegistryBuilder> {
+public final class ReaderRegistryProvider extends ProviderTrait<ReaderRegistry> {
- @Inject(optional = true)
- private Set<ReaderFactory> readerFactories = new HashSet<>();
+ @Inject
+ private ModifiableReaderRegistryBuilder readerRegistryBuilder;
@Override
- protected CompositeReaderRegistryBuilder create() {
- final CompositeReaderRegistryBuilder builder = new CompositeReaderRegistryBuilder();
- readerFactories.stream()
- .forEach(it -> it.init(builder));
- return builder;
+ protected ReaderRegistry create() {
+ return ((ReaderRegistryBuilder) readerRegistryBuilder).build();
}
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.java
index f5240093e..e0c38f38b 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.java
@@ -42,7 +42,7 @@ public final class InitializerPipelineModule extends PrivateModule {
// Create initializer registry so that plugins can provide their initializers
bind(InitializerRegistry.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER))
- .toProvider(InitializerRegistryProvider.class).in(Singleton.class);
+ .toProvider(InitializerRegistryAdapterProvider.class).in(Singleton.class);
expose(InitializerRegistry.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER));
}
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java
index 8add9fdf0..85fb7772c 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java
@@ -16,12 +16,14 @@
package io.fd.honeycomb.infra.distro.initializer;
-import com.google.common.collect.Lists;
import io.fd.honeycomb.data.init.DataTreeInitializer;
import io.fd.honeycomb.data.init.InitializerRegistry;
-import io.fd.honeycomb.data.init.InitializerRegistryImpl;
-import java.util.List;
-import java.util.Set;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.registry.InitRegistry;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,27 +33,33 @@ final class InitializerRegistryAdapter implements InitializerRegistry {
private final DataTreeInitializer configInitializer;
private final DataTreeInitializer contextInitializer;
- private final List<DataTreeInitializer> pluginInitializers;
+ private final InitRegistry initRegistry;
+ private final DataBroker dataBroker;
+ private final MappingContext realtimeMappingContext;
- InitializerRegistryAdapter(final DataTreeInitializer configInitializer, final DataTreeInitializer contextInitializer,
- final Set<DataTreeInitializer> pluginInitializers) {
+ InitializerRegistryAdapter(final DataTreeInitializer configInitializer,
+ final DataTreeInitializer contextInitializer,
+ final InitRegistry initRegistry,
+ final DataBroker noopConfigDataBroker,
+ final MappingContext realtimeMappingContext) {
this.configInitializer = configInitializer;
this.contextInitializer = contextInitializer;
- this.pluginInitializers = Lists.newArrayList(pluginInitializers);
+ this.initRegistry = initRegistry;
+ this.dataBroker = noopConfigDataBroker;
+ this.realtimeMappingContext = realtimeMappingContext;
}
@Override
public void initialize() throws DataTreeInitializer.InitializeException {
LOG.info("Config initialization started");
- final InitializerRegistry initializer = new InitializerRegistryImpl(pluginInitializers);
try {
// Initialize contexts first so that other initializers can find any relevant mapping before initializing
// configuration to what is already in VPP
contextInitializer.initialize();
LOG.info("Persisted context restored successfully");
// Initialize all registered initializers
- initializer.initialize();
+ initRegistry.initAll(dataBroker, new InitReadContext(realtimeMappingContext));
LOG.info("Configuration initialized successfully");
// Initialize stored configuration on top
configInitializer.initialize();
@@ -63,4 +71,31 @@ final class InitializerRegistryAdapter implements InitializerRegistry {
LOG.info("Honeycomb initialized");
}
+ private static final class InitReadContext implements ReadContext {
+
+ private final ModificationCache modificationCache;
+ private final MappingContext realtimeMappingContext;
+
+ InitReadContext(final MappingContext realtimeMappingContext) {
+ modificationCache = new ModificationCache();
+ this.realtimeMappingContext = realtimeMappingContext;
+ }
+
+ @Nonnull
+ @Override
+ public ModificationCache getModificationCache() {
+ return modificationCache;
+ }
+
+ @Nonnull
+ @Override
+ public MappingContext getMappingContext() {
+ return realtimeMappingContext;
+ }
+
+ @Override
+ public void close() {
+ modificationCache.close();
+ }
+ }
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapterProvider.java
index a0ca925c1..f66284b19 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapterProvider.java
@@ -16,29 +16,39 @@
package io.fd.honeycomb.infra.distro.initializer;
+import static io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule.HONEYCOMB_CONTEXT;
+import static io.fd.honeycomb.infra.distro.initializer.InitializerPipelineModule.HONEYCOMB_INITIALIZER;
+
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.fd.honeycomb.data.init.DataTreeInitializer;
import io.fd.honeycomb.data.init.InitializerRegistry;
import io.fd.honeycomb.infra.distro.ProviderTrait;
import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule;
-import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule;
-import java.util.HashSet;
-import java.util.Set;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-public final class InitializerRegistryProvider extends ProviderTrait<InitializerRegistry> {
+public final class InitializerRegistryAdapterProvider extends ProviderTrait<InitializerRegistry> {
@Inject
- @Named(ContextPipelineModule.HONEYCOMB_CONTEXT)
+ @Named(HONEYCOMB_CONTEXT)
private DataTreeInitializer contextInitializer;
@Inject
@Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG)
private DataTreeInitializer configInitializer;
- @Inject(optional = true)
- private Set<DataTreeInitializer> pluginInitializers = new HashSet<>();
+ @Inject
+ private ReaderRegistry initRegistry;
+ @Inject
+ @Named(HONEYCOMB_INITIALIZER)
+ private DataBroker noopConfigDataBroker;
+ @Inject
+ @Named(HONEYCOMB_CONTEXT)
+ private MappingContext realtimeMappingContext;
@Override
protected InitializerRegistryAdapter create() {
- return new InitializerRegistryAdapter(configInitializer, contextInitializer, pluginInitializers);
+ return new InitializerRegistryAdapter(configInitializer, contextInitializer, initRegistry,
+ noopConfigDataBroker, realtimeMappingContext);
}
}