Skip to content

Loading…

VOLDEMORT_CONFIG_DIR environment variable introduced #59

Merged
merged 4 commits into from

2 participants

@akkumar

Currently, the properties for the voldemort server are loaded from -

VOLDEMORT_HOME/config/server.properties .

When it comes to testing different versions of the (voldemort) software and saving/storing configs independently, providing another environment variable - VOLDEMORT_CONFIG_DIR , to refer to the configuration directory , will help in upgradation / changing installation of voldemort .

The new environment variable is completely optional.

If not set, it will reduce to the default behavior as now , which is:

config_dir (metadata_directory) = voldemort_home + file.separator + 'config' .

Scripts changed accordingly to take in the new directory as output as well.
If not, it picks up the default as mentioned above ( as it exists before ( $voldemort_home/config ) ) .

@afeinberg afeinberg merged commit a01e4de into voldemort:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2011
  1. @akkumar

    new environment variable - VOLDEMORT_CONFIG_DIR refers to config dire…

    akkumar committed
    …ctory , while VOLDEMORT_HOME refers to home directory of installation as before to play with different configurations.
  2. @akkumar

    ignore test-output from testng

    akkumar committed
  3. @akkumar
  4. @akkumar

    preserve defaults as before

    akkumar committed
View
1 .gitignore
@@ -6,6 +6,7 @@ dist
*.iws
*#
.#*
+test-output
node.id
rebalancing.slave.list
server.state
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
4 src/java/voldemort/server/VoldemortJsvcDaemon.java
@@ -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());
View
5 src/java/voldemort/server/VoldemortServer.java
@@ -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());
View
4 test/integration/voldemort/rebalance/metadata/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
Something went wrong with that request. Please try again.