From 8e3413360a84045c17cacc269452237eea540a45 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 12 Jul 2020 09:55:19 +0200 Subject: [PATCH] Turn FileAkkaConfigurationReader into a component This is a clearly standalone implementation of a common service, turn it into a properly-injected component. Change-Id: I521c3433093ab3aa911aa870c10b3d4e2bff8418 Signed-off-by: Robert Varga --- .../md-sal/sal-clustering-commons/pom.xml | 20 ++++++++++++++ .../actor/FileAkkaConfigurationReader.java | 27 ++++++++++++++++--- .../blueprint/clustered-datastore.xml | 3 ++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-clustering-commons/pom.xml b/opendaylight/md-sal/sal-clustering-commons/pom.xml index 26bfff67c6..c3f03074ca 100644 --- a/opendaylight/md-sal/sal-clustering-commons/pom.xml +++ b/opendaylight/md-sal/sal-clustering-commons/pom.xml @@ -57,6 +57,12 @@ com.typesafe.akka akka-osgi_2.13 + + + org.osgi + org.osgi.compendium + + com.typesafe.akka @@ -98,6 +104,20 @@ io.dropwizard.metrics metrics-jmx + + javax.inject + javax.inject + provided + true + + + org.kohsuke.metainf-services + metainf-services + + + org.osgi + osgi.cmpn + diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/FileAkkaConfigurationReader.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/FileAkkaConfigurationReader.java index 883dbd7210..7951f5d3cc 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/FileAkkaConfigurationReader.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/FileAkkaConfigurationReader.java @@ -5,22 +5,33 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.common.actor; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkState; + import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import java.io.File; +import javax.inject.Singleton; +import org.kohsuke.MetaInfServices; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +@Component(immediate = true) +@MetaInfServices +@Singleton public class FileAkkaConfigurationReader implements AkkaConfigurationReader { + private static final Logger LOG = LoggerFactory.getLogger(FileAkkaConfigurationReader.class); private static final String CUSTOM_AKKA_CONF_PATH = "./configuration/initial/akka.conf"; private static final String FACTORY_AKKA_CONF_PATH = "./configuration/factory/akka.conf"; @Override public Config read() { File customConfigFile = new File(CUSTOM_AKKA_CONF_PATH); - Preconditions.checkState(customConfigFile.exists(), "%s is missing", customConfigFile); + checkState(customConfigFile.exists(), "%s is missing", customConfigFile); File factoryConfigFile = new File(FACTORY_AKKA_CONF_PATH); if (factoryConfigFile.exists()) { @@ -29,4 +40,14 @@ public class FileAkkaConfigurationReader implements AkkaConfigurationReader { return ConfigFactory.parseFile(customConfigFile); } + + @Activate + void activate() { + LOG.info("File-based Akka configuration reader enabled"); + } + + @Deactivate + void deactivate() { + LOG.info("File-based Akka configuration reader disabled"); + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml index 182a1b4085..d6fadcbb37 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml @@ -25,7 +25,8 @@ - + + -- 2.36.6