Search in sources :

Example 6 with StorageConfiguration

use of voldemort.store.StorageConfiguration in project voldemort by voldemort.

the class StorageService method updateStore.

public void updateStore(StoreDefinition storeDef) {
    logger.info("Updating store '" + storeDef.getName() + "' (" + storeDef.getType() + ").");
    StorageConfiguration config = storageConfigs.get(storeDef.getType());
    if (config == null)
        throw new ConfigurationException("Attempt to open store " + storeDef.getName() + " but " + storeDef.getType() + " storage engine has not been enabled.");
    config.update(storeDef);
}
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)

Example 7 with StorageConfiguration

use of voldemort.store.StorageConfiguration in project voldemort by voldemort.

the class StorageService method openStore.

public StorageEngine<ByteArray, byte[], byte[]> openStore(StoreDefinition storeDef) {
    logger.info("Opening store '" + storeDef.getName() + "' (" + storeDef.getType() + ").");
    StorageConfiguration config = storageConfigs.get(storeDef.getType());
    if (config == null)
        throw new ConfigurationException("Attempt to open store " + storeDef.getName() + " but " + storeDef.getType() + " storage engine has not been enabled.");
    boolean isReadOnly = storeDef.getType().compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) == 0;
    final RoutingStrategy routingStrategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, metadata.getCluster());
    final StorageEngine<ByteArray, byte[], byte[]> engine = config.getStore(storeDef, routingStrategy);
    // Update the routing strategy + add listener to metadata
    if (storeDef.getType().compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) == 0) {
        metadata.addMetadataStoreListener(storeDef.getName(), new MetadataStoreListener() {

            public void updateRoutingStrategy(RoutingStrategy updatedRoutingStrategy) {
                ((ReadOnlyStorageEngine) engine).setRoutingStrategy(updatedRoutingStrategy);
            }

            public void updateStoreDefinition(StoreDefinition storeDef) {
                return;
            }
        });
    }
    // openStore() should have atomic semantics
    try {
        registerEngine(engine, isReadOnly, storeDef.getType(), storeDef);
        if (voldemortConfig.isServerRoutingEnabled())
            registerNodeStores(storeDef, metadata.getCluster(), voldemortConfig.getNodeId());
        if (storeDef.hasRetentionPeriod())
            scheduleCleanupJob(storeDef, engine);
    } catch (Exception e) {
        removeEngine(engine, isReadOnly, storeDef.getType(), false);
        throw new VoldemortException(e);
    }
    return engine;
}
Also used : ConfigurationException(voldemort.utils.ConfigurationException) RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) StoreDefinition(voldemort.store.StoreDefinition) RoutingStrategy(voldemort.routing.RoutingStrategy) 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) MetadataStoreListener(voldemort.store.metadata.MetadataStoreListener) VoldemortException(voldemort.VoldemortException) ConfigurationException(voldemort.utils.ConfigurationException) NoSuchCapabilityException(voldemort.store.NoSuchCapabilityException) DisabledStoreException(voldemort.store.DisabledStoreException) VoldemortException(voldemort.VoldemortException)

Example 8 with StorageConfiguration

use of voldemort.store.StorageConfiguration 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 StorageConfiguration

use of voldemort.store.StorageConfiguration 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

StorageConfiguration (voldemort.store.StorageConfiguration)9 ViewStorageConfiguration (voldemort.store.views.ViewStorageConfiguration)8 FileBackedCachingStorageConfiguration (voldemort.store.configuration.FileBackedCachingStorageConfiguration)7 InMemoryStorageConfiguration (voldemort.store.memory.InMemoryStorageConfiguration)7 ReadOnlyStorageConfiguration (voldemort.store.readonly.ReadOnlyStorageConfiguration)7 ConfigurationException (voldemort.utils.ConfigurationException)7 ByteArray (voldemort.utils.ByteArray)6 VoldemortException (voldemort.VoldemortException)4 DisabledStoreException (voldemort.store.DisabledStoreException)4 NoSuchCapabilityException (voldemort.store.NoSuchCapabilityException)4 VoldemortConfig (voldemort.server.VoldemortConfig)3 StoreDefinition (voldemort.store.StoreDefinition)3 File (java.io.File)2 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)2 IdentitySerializer (voldemort.serialization.IdentitySerializer)2 StringSerializer (voldemort.serialization.StringSerializer)2 BdbStorageConfiguration (voldemort.store.bdb.BdbStorageConfiguration)2 ViewStorageEngine (voldemort.store.views.ViewStorageEngine)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1