use of com.sleepycat.je.DatabaseException in project voldemort by voldemort.
the class BdbStorageConfiguration method checkPointAllEnvironments.
/**
* Forceful checkpointing
*/
@JmxOperation(description = "Forcefully checkpoint all the environments")
public void checkPointAllEnvironments() {
synchronized (lock) {
try {
for (Environment environment : environments.values()) {
CheckpointConfig checkPointConfig = new CheckpointConfig();
checkPointConfig.setForce(true);
environment.checkpoint(checkPointConfig);
}
} catch (DatabaseException e) {
throw new VoldemortException(e);
}
}
}
use of com.sleepycat.je.DatabaseException in project voldemort by voldemort.
the class BdbStorageConfiguration method getStore.
public StorageEngine<ByteArray, byte[], byte[]> getStore(StoreDefinition storeDef, RoutingStrategy strategy) {
synchronized (lock) {
try {
String storeName = storeDef.getName();
Environment environment = getEnvironment(storeDef);
Database db = environment.openDatabase(null, storeName, databaseConfig);
BdbRuntimeConfig runtimeConfig = new BdbRuntimeConfig(voldemortConfig);
BdbStorageEngine engine = null;
if (voldemortConfig.getBdbPrefixKeysWithPartitionId()) {
engine = new PartitionPrefixedBdbStorageEngine(storeName, environment, db, runtimeConfig, strategy);
} else {
engine = new BdbStorageEngine(storeName, environment, db, runtimeConfig);
}
if (voldemortConfig.isJmxEnabled()) {
// register the environment stats mbean
JmxUtils.registerMbean(storeName, engine.getBdbEnvironmentStats());
// aggregated stats
if (useOneEnvPerStore) {
aggBdbStats.trackEnvironment(engine.getBdbEnvironmentStats());
}
}
return engine;
} catch (DatabaseException d) {
throw new StorageInitializationException(d);
}
}
}
use of com.sleepycat.je.DatabaseException in project voldemort by voldemort.
the class BdbStorageEngine method getStats.
public DatabaseStats getStats(boolean setFast) {
try {
StatsConfig config = new StatsConfig();
config.setFast(setFast);
return this.getBdbDatabase().getStats(config);
} catch (DatabaseException e) {
this.bdbEnvironmentStats.reportException(e);
logger.error(e);
throw new VoldemortException(e);
}
}
use of com.sleepycat.je.DatabaseException in project voldemort by voldemort.
the class BdbStorageEngine method truncate.
@Override
public void truncate() {
if (isTruncating.compareAndSet(false, true)) {
Transaction transaction = null;
boolean succeeded = false;
try {
transaction = this.environment.beginTransaction(null, null);
// close current bdbDatabase first
bdbDatabase.close();
// truncate the database
environment.truncateDatabase(transaction, this.getName(), false);
succeeded = true;
} catch (DatabaseException e) {
this.bdbEnvironmentStats.reportException(e);
logger.error(e);
throw new VoldemortException("Failed to truncate Bdb store " + getName(), e);
} finally {
commitOrAbort(succeeded, transaction);
// reopen the bdb database for future queries.
if (reopenBdbDatabase()) {
isTruncating.compareAndSet(true, false);
} else {
throw new VoldemortException("Failed to reopen Bdb Database after truncation, All request will fail on store " + getName());
}
}
} else {
throw new VoldemortException("Store " + getName() + " is already truncating, cannot start another one.");
}
}
use of com.sleepycat.je.DatabaseException in project voldemort by voldemort.
the class BdbStorageEngine method getAndLock.
@Override
public KeyLockHandle<byte[]> getAndLock(ByteArray key) {
long startTimeNs = -1;
if (logger.isTraceEnabled())
startTimeNs = System.nanoTime();
StoreUtils.assertValidKey(key);
DatabaseEntry keyEntry = new DatabaseEntry(key.get());
DatabaseEntry valueEntry = new DatabaseEntry();
Transaction transaction = null;
List<Versioned<byte[]>> vals = null;
KeyLockHandle<byte[]> handle;
try {
transaction = environment.beginTransaction(null, null);
// do a get for the existing values
OperationStatus status = getBdbDatabase().get(transaction, keyEntry, valueEntry, LockMode.RMW);
if (OperationStatus.SUCCESS == status) {
vals = StoreBinaryFormat.fromByteArray(valueEntry.getData());
} else {
vals = new ArrayList<Versioned<byte[]>>(0);
}
handle = new KeyLockHandle<byte[]>(vals, transaction);
} catch (DatabaseException e) {
this.bdbEnvironmentStats.reportException(e);
// Unless we return out properly from this method, we need to ensure
// the transaction handle is closed on exception..
attemptAbort(transaction);
logger.error("Error in getAndLock for store " + this.getName(), e);
throw new PersistenceFailureException(e);
} finally {
if (logger.isTraceEnabled()) {
logger.trace("Completed getAndLock (" + getName() + ") to key " + key + " (keyRef: " + System.identityHashCode(key) + " in " + (System.nanoTime() - startTimeNs) + " ns at " + System.currentTimeMillis());
}
}
return handle;
}
Aggregations