Removing the redundant configuration reader in the distributed datastore. 39/25139/3
authorkalaiselvik <Kalaiselvi_K@Dell.com>
Tue, 11 Aug 2015 06:46:16 +0000 (12:16 +0530)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 17 Aug 2015 23:12:32 +0000 (23:12 +0000)
Having a common configuration reader in the clustering common for use
by both distributed datastore and remote rpc.

Change-Id: Id40295301d76dad40189fb45ffc2917260ba2925
Signed-off-by: kalaiselvik <Kalaiselvi_K@Dell.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/FileAkkaConfigurationReader.java [moved from opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/DefaultAkkaConfigurationReader.java with 60% similarity]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationReader.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileConfigurationReader.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ResourceConfigurationReader.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java

@@ -11,16 +11,15 @@ package org.opendaylight.controller.cluster.common.actor;
 import com.google.common.base.Preconditions;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
-
 import java.io.File;
 
-public class DefaultAkkaConfigurationReader implements AkkaConfigurationReader {
-    public static final String AKKA_CONF_PATH = "./configuration/initial/akka.conf";
+public class FileAkkaConfigurationReader implements AkkaConfigurationReader {
+    private static final String DEFAULT_AKKA_CONF_PATH = "./configuration/initial/akka.conf";
 
     @Override public Config read() {
-        File defaultConfigFile = new File(AKKA_CONF_PATH);
-        Preconditions.checkState(defaultConfigFile.exists(), "akka.conf is missing");
-        return ConfigFactory.parseFile(defaultConfigFile);
+        File configFile = new File(DEFAULT_AKKA_CONF_PATH);
+        Preconditions.checkState(configFile.exists(), "%s is missing", configFile);
+        return ConfigFactory.parseFile(configFile);
 
     }
 }
index 6ae9fb8..a7e21e8 100644 (file)
@@ -13,8 +13,8 @@ import com.google.common.collect.Sets;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang3.text.WordUtils;
-import org.opendaylight.controller.cluster.datastore.config.ConfigurationReader;
-import org.opendaylight.controller.cluster.datastore.config.FileConfigurationReader;
+import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
+import org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationReader;
 import org.opendaylight.controller.cluster.raft.ConfigParams;
 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
@@ -40,7 +40,7 @@ public class DatastoreContext {
     public static final Timeout DEFAULT_SHARD_INITIALIZATION_TIMEOUT = new Timeout(5, TimeUnit.MINUTES);
     public static final Timeout DEFAULT_SHARD_LEADER_ELECTION_TIMEOUT = new Timeout(30, TimeUnit.SECONDS);
     public static final boolean DEFAULT_PERSISTENT = true;
-    public static final FileConfigurationReader DEFAULT_CONFIGURATION_READER = new FileConfigurationReader();
+    public static final FileAkkaConfigurationReader DEFAULT_CONFIGURATION_READER = new FileAkkaConfigurationReader();
     public static final int DEFAULT_SHARD_SNAPSHOT_DATA_THRESHOLD_PERCENTAGE = 12;
     public static final int DEFAULT_SHARD_ELECTION_TIMEOUT_FACTOR = 2;
     public static final int DEFAULT_TX_CREATION_INITIAL_RATE_LIMIT = 100;
@@ -59,7 +59,7 @@ public class DatastoreContext {
     private Timeout shardInitializationTimeout = DEFAULT_SHARD_INITIALIZATION_TIMEOUT;
     private Timeout shardLeaderElectionTimeout = DEFAULT_SHARD_LEADER_ELECTION_TIMEOUT;
     private boolean persistent = DEFAULT_PERSISTENT;
-    private ConfigurationReader configurationReader = DEFAULT_CONFIGURATION_READER;
+    private AkkaConfigurationReader configurationReader = DEFAULT_CONFIGURATION_READER;
     private long transactionCreationInitialRateLimit = DEFAULT_TX_CREATION_INITIAL_RATE_LIMIT;
     private final DefaultConfigParamsImpl raftConfig = new DefaultConfigParamsImpl();
     private String dataStoreType = UNKNOWN_DATA_STORE_TYPE;
@@ -155,7 +155,7 @@ public class DatastoreContext {
         return persistent;
     }
 
-    public ConfigurationReader getConfigurationReader() {
+    public AkkaConfigurationReader getConfigurationReader() {
         return configurationReader;
     }
 
@@ -323,7 +323,7 @@ public class DatastoreContext {
             return shardLeaderElectionTimeout(timeout, TimeUnit.SECONDS);
         }
 
-        public Builder configurationReader(ConfigurationReader configurationReader){
+        public Builder configurationReader(AkkaConfigurationReader configurationReader){
             datastoreContext.configurationReader = configurationReader;
             return this;
         }
index ee8ac61..d156998 100644 (file)
@@ -15,7 +15,7 @@ import com.typesafe.config.ConfigFactory;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.cluster.datastore.config.ConfigurationReader;
+import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
 import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.osgi.framework.BundleContext;
@@ -57,7 +57,7 @@ public class DistributedDataStoreFactory {
     }
 
     private static synchronized final ActorSystem getActorSystem(final BundleContext bundleContext,
-                                                                 ConfigurationReader configurationReader) {
+                                                                 AkkaConfigurationReader configurationReader) {
         if (actorSystem == null) {
             // Create an OSGi bundle classloader for actor system
             BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(),
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationReader.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationReader.java
deleted file mode 100644 (file)
index 12afdbd..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.datastore.config;
-
-import com.typesafe.config.Config;
-
-public interface ConfigurationReader {
-    Config read();
-}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileConfigurationReader.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileConfigurationReader.java
deleted file mode 100644 (file)
index fb84734..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.datastore.config;
-
-import com.google.common.base.Preconditions;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-
-import java.io.File;
-
-public class FileConfigurationReader implements ConfigurationReader{
-
-    public static final String AKKA_CONF_PATH = "./configuration/initial/akka.conf";
-
-    @Override
-    public Config read() {
-        File defaultConfigFile = new File(AKKA_CONF_PATH);
-        Preconditions.checkState(defaultConfigFile.exists(), "akka.conf is missing");
-        return ConfigFactory.parseFile(defaultConfigFile);
-
-    }
-}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ResourceConfigurationReader.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ResourceConfigurationReader.java
deleted file mode 100644 (file)
index df17f97..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.datastore.config;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-
-public class ResourceConfigurationReader implements ConfigurationReader {
-    @Override
-    public Config read() {
-        return ConfigFactory.load();
-    }
-}
index 5d23141..8bf768d 100644 (file)
@@ -1,6 +1,6 @@
 package org.opendaylight.controller.config.yang.config.remote_rpc_connector;
 
-import org.opendaylight.controller.cluster.common.actor.DefaultAkkaConfigurationReader;
+import org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationReader;
 import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig;
 import org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory;
 import org.opendaylight.controller.sal.core.api.Broker;
@@ -33,7 +33,7 @@ public class RemoteRPCBrokerModule extends org.opendaylight.controller.config.ya
     RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder(getActorSystemName())
                               .metricCaptureEnabled(getEnableMetricCapture())
                               .mailboxCapacity(getBoundedMailboxCapacity())
-                              .withConfigReader(new DefaultAkkaConfigurationReader())
+                              .withConfigReader(new FileAkkaConfigurationReader())
                               .build();
 
     return RemoteRpcProviderFactory.createInstance(broker, bundleContext, config);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.