Skip to content
Browse files

new environment variable - VOLDEMORT_CONFIG_DIR refers to config dire…

…ctory , while VOLDEMORT_HOME refers to home directory of installation as before to play with different configurations.
  • Loading branch information...
1 parent acd8a64 commit 903943ff3137ceb95566c2b5a5dfba0f52005aa4 @akkumar akkumar committed Dec 29, 2011
View
4 bin/voldemort-server.sh
@@ -16,9 +16,9 @@
# limitations under the License.
#
-if [ $# -gt 1 ];
+if [ $# -gt 2 ];
then
- echo 'USAGE: bin/voldemort-server.sh [voldemort_home]'
+ echo 'USAGE: bin/voldemort-server.sh [voldemort_home] [voldemort_config_dir]'
exit 1
fi
View
24 src/java/voldemort/server/VoldemortConfig.java
@@ -48,6 +48,7 @@
private static final long serialVersionUID = 1;
public static final String VOLDEMORT_HOME_VAR_NAME = "VOLDEMORT_HOME";
+ public static final String VOLDEMORT_CONFIG_DIR = "VOLDEMORT_CONFIG_DIR";
private static final String VOLDEMORT_NODE_ID_VAR_NAME = "VOLDEMORT_NODE_ID";
public static int VOLDEMORT_DEFAULT_ADMIN_PORT = 6660;
@@ -398,17 +399,33 @@ public static VoldemortConfig loadFromEnvironmentVariable() {
+ VoldemortConfig.VOLDEMORT_HOME_VAR_NAME
+ " has been defined, set it!");
- return loadFromVoldemortHome(voldemortHome);
+ String voldemortConfigDir = System.getenv(VoldemortConfig.VOLDEMORT_CONFIG_DIR);
+ if(voldemortConfigDir != null) {
+ if(!Utils.isReadableDir(voldemortConfigDir))
+ throw new ConfigurationException("Attempt to load configuration from VOLDEMORT_CONFIG_DIR, "
+ + voldemortConfigDir
+ + " failed. That is not a readable directory.");
+ }
+ return loadFromVoldemortHome(voldemortHome, voldemortConfigDir);
}
public static VoldemortConfig loadFromVoldemortHome(String voldemortHome) {
+ String voldemortConfigDir = voldemortHome + File.separator + "config";
+ return loadFromVoldemortHome(voldemortHome, voldemortConfigDir);
+
+ }
+
+ public static VoldemortConfig loadFromVoldemortHome(String voldemortHome,
+ String voldemortConfigDir) {
if(!Utils.isReadableDir(voldemortHome))
throw new ConfigurationException("Attempt to load configuration from VOLDEMORT_HOME, "
+ voldemortHome
+ " failed. That is not a readable directory.");
- String propertiesFile = voldemortHome + File.separator + "config" + File.separator
- + "server.properties";
+ if(voldemortConfigDir == null) {
+ voldemortConfigDir = voldemortHome + File.separator + "config";
+ }
+ String propertiesFile = voldemortConfigDir + File.separator + "server.properties";
if(!Utils.isReadableFile(propertiesFile))
throw new ConfigurationException(propertiesFile
+ " is not a readable configuration file.");
@@ -417,6 +434,7 @@ public static VoldemortConfig loadFromVoldemortHome(String voldemortHome) {
try {
properties = new Props(new File(propertiesFile));
properties.put("voldemort.home", voldemortHome);
+ properties.put("metadata.directory", voldemortConfigDir);
} catch(IOException e) {
throw new ConfigurationException(e);
}
View
6 src/java/voldemort/server/VoldemortJsvcDaemon.java
@@ -47,10 +47,12 @@ public void init(String[] args) throws Exception {
if(args.length == 0)
config = VoldemortConfig.loadFromEnvironmentVariable();
else if(args.length == 1)
- config = VoldemortConfig.loadFromVoldemortHome(args[0]);
+ config = VoldemortConfig.loadFromVoldemortHome(args[0], null);
+ else if(args.length == 2)
+ config = VoldemortConfig.loadFromVoldemortHome(args[0], args[1]);
else
croak("USAGE: java " + VoldemortJsvcDaemon.class.getName()
- + " [voldemort_home_dir]");
+ + " [voldemort_home_dir] [voldemort_config_dir]");
} catch(Exception e) {
logger.error(e);
croak("Error while loading configuration: " + e.getMessage());
View
7 src/java/voldemort/server/VoldemortServer.java
@@ -285,9 +285,12 @@ public static void main(String[] args) throws Exception {
if(args.length == 0)
config = VoldemortConfig.loadFromEnvironmentVariable();
else if(args.length == 1)
- config = VoldemortConfig.loadFromVoldemortHome(args[0]);
+ config = VoldemortConfig.loadFromVoldemortHome(args[0], null);
+ else if(args.length == 2)
+ config = VoldemortConfig.loadFromVoldemortHome(args[0], args[1]);
else
- croak("USAGE: java " + VoldemortServer.class.getName() + " [voldemort_home_dir]");
+ croak("USAGE: java " + VoldemortServer.class.getName()
+ + " [voldemort_home_dir] [voldemort_config_dir]");
} catch(Exception e) {
logger.error(e);
Utils.croak("Error while loading configuration: " + e.getMessage());
View
2 test/integration/voldemort/rebalance/metadata/voldemort-server.sh
@@ -18,7 +18,7 @@
if [ $# -gt 1 ];
then
- echo 'USAGE: bin/voldemort-server.sh [voldemort_home]'
+ echo 'USAGE: bin/voldemort-server.sh [voldemort_home] [voldemort_config_dir]'
exit 1
fi

0 comments on commit 903943f

Please sign in to comment.
Something went wrong with that request. Please try again.