Пример #1
0
  public static VoldemortConfig loadFromEnvironmentVariable() {
    String voldemortHome = System.getenv(VoldemortConfig.VOLDEMORT_HOME_VAR_NAME);
    if (voldemortHome == null)
      throw new ConfigurationException(
          "No environment variable "
              + VoldemortConfig.VOLDEMORT_HOME_VAR_NAME
              + " has been defined, set it!");

    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);
  }
Пример #2
0
 private int getIntEnvVariable(String name) {
   String var = System.getenv(name);
   if (var == null)
     throw new ConfigurationException("The environment variable " + name + " is not defined.");
   try {
     return Integer.parseInt(var);
   } catch (NumberFormatException e) {
     throw new ConfigurationException(
         "Invalid format for environment variable " + name + ", expecting an integer.", e);
   }
 }