Search in sources :

Example 26 with PersistenceFailureException

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();
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) AsyncOperationStatus(voldemort.server.protocol.admin.AsyncOperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) PersistenceFailureException(voldemort.store.PersistenceFailureException) DatabaseException(com.sleepycat.je.DatabaseException)

Aggregations

PersistenceFailureException (voldemort.store.PersistenceFailureException)26 Versioned (voldemort.versioning.Versioned)13 ByteArray (voldemort.utils.ByteArray)9 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 SQLException (java.sql.SQLException)6 DatabaseEntry (com.sleepycat.je.DatabaseEntry)5 DatabaseException (com.sleepycat.je.DatabaseException)5 OperationStatus (com.sleepycat.je.OperationStatus)5 ResultSet (java.sql.ResultSet)5 Test (org.junit.Test)5 AsyncOperationStatus (voldemort.server.protocol.admin.AsyncOperationStatus)5 Transaction (com.sleepycat.je.Transaction)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 RocksDBException (org.rocksdb.RocksDBException)4 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)4 VectorClock (voldemort.versioning.VectorClock)4 Occurred (voldemort.versioning.Occurred)3 LockTimeoutException (com.sleepycat.je.LockTimeoutException)2