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);
}
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;
}
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);
}
}
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();
}
Aggregations