Search in sources :

Example 6 with ConfigurationException

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);
}
Also used : ConfigurationException(voldemort.utils.ConfigurationException) IOException(java.io.IOException) Props(voldemort.utils.Props) File(java.io.File)

Example 7 with ConfigurationException

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);
}
Also used : ConfigurationException(voldemort.utils.ConfigurationException)

Example 8 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(voldemort.utils.ConfigurationException) StorageConfiguration(voldemort.store.StorageConfiguration) FileBackedCachingStorageConfiguration(voldemort.store.configuration.FileBackedCachingStorageConfiguration) InMemoryStorageConfiguration(voldemort.store.memory.InMemoryStorageConfiguration) ViewStorageConfiguration(voldemort.store.views.ViewStorageConfiguration) ReadOnlyStorageConfiguration(voldemort.store.readonly.ReadOnlyStorageConfiguration) ByteArray(voldemort.utils.ByteArray) VoldemortException(voldemort.VoldemortException) ConfigurationException(voldemort.utils.ConfigurationException) NoSuchCapabilityException(voldemort.store.NoSuchCapabilityException) DisabledStoreException(voldemort.store.DisabledStoreException) VoldemortException(voldemort.VoldemortException)

Example 9 with ConfigurationException

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();
}
Also used : ConfigurationException(voldemort.utils.ConfigurationException) StorageConfiguration(voldemort.store.StorageConfiguration) FileBackedCachingStorageConfiguration(voldemort.store.configuration.FileBackedCachingStorageConfiguration) InMemoryStorageConfiguration(voldemort.store.memory.InMemoryStorageConfiguration) ViewStorageConfiguration(voldemort.store.views.ViewStorageConfiguration) ReadOnlyStorageConfiguration(voldemort.store.readonly.ReadOnlyStorageConfiguration) VoldemortConfig(voldemort.server.VoldemortConfig)

Aggregations

ConfigurationException (voldemort.utils.ConfigurationException)9 StorageConfiguration (voldemort.store.StorageConfiguration)6 FileBackedCachingStorageConfiguration (voldemort.store.configuration.FileBackedCachingStorageConfiguration)6 InMemoryStorageConfiguration (voldemort.store.memory.InMemoryStorageConfiguration)6 ReadOnlyStorageConfiguration (voldemort.store.readonly.ReadOnlyStorageConfiguration)6 ViewStorageConfiguration (voldemort.store.views.ViewStorageConfiguration)6 DisabledStoreException (voldemort.store.DisabledStoreException)3 NoSuchCapabilityException (voldemort.store.NoSuchCapabilityException)3 ByteArray (voldemort.utils.ByteArray)3 VoldemortException (voldemort.VoldemortException)2 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)2 StoreDefinition (voldemort.store.StoreDefinition)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 Node (voldemort.cluster.Node)1