Bug 5329: Add factory akka.conf
authorTom Pantelis <tpanteli@brocade.com>
Fri, 12 Feb 2016 14:08:15 +0000 (09:08 -0500)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 23 Feb 2016 20:47:46 +0000 (20:47 +0000)
Added a factory akka.conf file that is shipped to
configuration/factory/akka.conf. This file contains all the necessary
akka settings. Modified the FileAkkaConfigurationReader to load the
existing configuration/initial/akka.conf file with the factory file as
the fallback. In this manner akka will overlay/merge the initial file
with the factory file. I pared down the initial file to only contain the
settings that users would normally set or configure to setup a cluster,
ie hostname, port, seed-nodes, roles.

In the features.xml, the factory file is configured to always overwrite
so changes are picked up on upgrade. We still preserve the initial file.

Change-Id: I8e80161e21d0ad0e26f1efa1023c670b3a5ef6bc
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
java/org/opendaylight/controller/cluster/common/actor/FileAkkaConfigurationReader.java

index 384ba81526329748b98e82e3287c7ade905c5ecb..1e3adf9d391051ef2173de187004c3c6edaa6e40 100644 (file)
@@ -14,12 +14,19 @@ import com.typesafe.config.ConfigFactory;
 import java.io.File;
 
 public class FileAkkaConfigurationReader implements AkkaConfigurationReader {
-    private static final String DEFAULT_AKKA_CONF_PATH = "./configuration/initial/akka.conf";
+    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 configFile = new File(DEFAULT_AKKA_CONF_PATH);
-        Preconditions.checkState(configFile.exists(), "%s is missing", configFile);
-        return ConfigFactory.parseFile(configFile);
+    @Override
+    public Config read() {
+        File customConfigFile = new File(CUSTOM_AKKA_CONF_PATH);
+        Preconditions.checkState(customConfigFile.exists(), "%s is missing", customConfigFile);
 
+        File factoryConfigFile = new File(FACTORY_AKKA_CONF_PATH);
+        if(factoryConfigFile.exists()) {
+            return ConfigFactory.parseFile(customConfigFile).withFallback(ConfigFactory.parseFile(factoryConfigFile));
+        }
+
+        return ConfigFactory.parseFile(customConfigFile);
     }
 }