use of voldemort.store.PersistenceFailureException in project voldemort by voldemort.
the class BdbStorageEngine method putAndUnlock.
@Override
public void putAndUnlock(ByteArray key, KeyLockHandle<byte[]> handle) {
long startTimeNs = -1;
if (logger.isTraceEnabled())
startTimeNs = System.nanoTime();
StoreUtils.assertValidKey(key);
DatabaseEntry keyEntry = new DatabaseEntry(key.get());
DatabaseEntry valueEntry = new DatabaseEntry();
boolean succeeded = false;
Transaction transaction = null;
try {
transaction = (Transaction) handle.getKeyLock();
valueEntry.setData(StoreBinaryFormat.toByteArray(handle.getValues()));
OperationStatus status = getBdbDatabase().put(transaction, keyEntry, valueEntry);
if (status != OperationStatus.SUCCESS)
throw new PersistenceFailureException("putAndUnlock operation failed with status: " + status);
succeeded = true;
} catch (DatabaseException e) {
this.bdbEnvironmentStats.reportException(e);
logger.error("Error in putAndUnlock for store " + this.getName(), e);
throw new PersistenceFailureException(e);
} finally {
if (succeeded)
attemptCommit(transaction);
else
attemptAbort(transaction);
if (logger.isTraceEnabled()) {
logger.trace("Completed PUTANDUNLOCK (" + getName() + ") to key " + key + " (keyRef: " + System.identityHashCode(key) + " in " + (System.nanoTime() - startTimeNs) + " ns at " + System.currentTimeMillis());
}
handle.close();
}
}
Aggregations