use of voldemort.utils.ConfigurationException in project voldemort by voldemort.
the class VoldemortConfig method loadFromVoldemortHome.
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.");
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.");
Props properties = null;
try {
properties = new Props(new File(propertiesFile));
properties.put(VOLDEMORT_HOME, voldemortHome);
properties.put(METADATA_DIRECTORY, voldemortConfigDir);
} catch (IOException e) {
throw new ConfigurationException(e);
}
return new VoldemortConfig(properties);
}
use of voldemort.utils.ConfigurationException in project voldemort by voldemort.
the class VoldemortConfig method loadFromEnvironmentVariable.
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);
}
use of voldemort.utils.ConfigurationException in project voldemort by voldemort.
the class StorageService method openSystemStore.
public void openSystemStore(StoreDefinition storeDef) {
logger.info("Opening system store '" + storeDef.getName() + "' (" + storeDef.getType() + ").");
StorageConfiguration config = storageConfigs.get(storeDef.getType());
if (config == null)
throw new ConfigurationException("Attempt to open system store " + storeDef.getName() + " but " + storeDef.getType() + " storage engine has not been enabled.");
final StorageEngine<ByteArray, byte[], byte[]> engine = config.getStore(storeDef, null);
// openStore() should have atomic semantics
try {
registerSystemEngine(engine);
if (voldemortConfig.isServerRoutingEnabled())
registerNodeStores(storeDef, metadata.getCluster(), voldemortConfig.getNodeId());
if (storeDef.hasRetentionPeriod())
scheduleCleanupJob(storeDef, engine);
} catch (Exception e) {
unregisterSystemEngine(engine);
throw new VoldemortException(e);
}
}
use of voldemort.utils.ConfigurationException in project voldemort by voldemort.
the class StorageService method initStorageConfig.
private void initStorageConfig(String configClassName) {
// add the configurations of the storage engines needed by user stores
try {
Class<?> configClass = ReflectUtils.loadClass(configClassName);
StorageConfiguration configuration = (StorageConfiguration) ReflectUtils.callConstructor(configClass, new Class<?>[] { VoldemortConfig.class }, new Object[] { voldemortConfig });
logger.info("Initializing " + configuration.getType() + " storage engine.");
storageConfigs.put(configuration.getType(), configuration);
if (voldemortConfig.isJmxEnabled())
JmxUtils.registerMbean(configuration.getType() + "StorageConfiguration", configuration);
} catch (IllegalStateException e) {
logger.error("Error loading storage configuration '" + configClassName + "'.", e);
}
if (storageConfigs.size() == 0)
throw new ConfigurationException("No storage engine has been enabled!");
// now, add the configurations of the storage engines needed by system
// stores, if not yet exist
initSystemStorageConfig();
}
Aggregations