Permalink
Browse files

Merge pull request #59 from akkumar/master

VOLDEMORT_CONFIG_DIR environment variable introduced
  • Loading branch information...
2 parents deeff41 + fe10ef0 commit a01e4deec732fcf31546853898cf73c6d1bd3632 @afeinberg afeinberg committed Dec 30, 2011
View
@@ -6,6 +6,7 @@ dist
*.iws
*#
.#*
+test-output
node.id
rebalancing.slave.list
server.state
View
@@ -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
@@ -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);
}
@@ -48,9 +48,11 @@ public void init(String[] args) throws Exception {
config = VoldemortConfig.loadFromEnvironmentVariable();
else if(args.length == 1)
config = VoldemortConfig.loadFromVoldemortHome(args[0]);
+ 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());
@@ -286,8 +286,11 @@ public static void main(String[] args) throws Exception {
config = VoldemortConfig.loadFromEnvironmentVariable();
else if(args.length == 1)
config = VoldemortConfig.loadFromVoldemortHome(args[0]);
+ 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());
@@ -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

0 comments on commit a01e4de

Please sign in to comment.