Search in sources :

Example 1 with PermanentLockingException

use of com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException in project titan by thinkaurelius.

the class AstyanaxRecipeLocker method deleteSingleLock.

@Override
protected void deleteSingleLock(KeyColumn lockID, AstyanaxLockStatus stat, StoreTransaction tx) throws PermanentLockingException {
    try {
        stat.getLock().release();
        log.debug("Unlocked {} in store {}", lockID, lockColumnFamily.getName());
    } catch (Exception e) {
        // TODO handle better?
        throw new PermanentLockingException(e);
    }
}
Also used : PermanentLockingException(com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException) PermanentLockingException(com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException) BusyLockException(com.netflix.astyanax.recipes.locks.BusyLockException) StaleLockException(com.netflix.astyanax.recipes.locks.StaleLockException) TemporaryLockingException(com.thinkaurelius.titan.diskstorage.locking.TemporaryLockingException)

Example 2 with PermanentLockingException

use of com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException in project titan by thinkaurelius.

the class AstyanaxRecipeLocker method writeSingleLock.

@Override
protected AstyanaxLockStatus writeSingleLock(KeyColumn lockID, StoreTransaction tx) throws TemporaryLockingException, PermanentLockingException {
    long approxTimeNS = times.getApproxNSSinceEpoch();
    ByteBuffer keyToLock = serializer.toLockKey(lockID.getKey(), lockID.getColumn()).asByteBuffer();
    ColumnPrefixDistributedRowLock<ByteBuffer> lock = new ColumnPrefixDistributedRowLock<ByteBuffer>(lockKeyspace, lockColumnFamily, keyToLock).expireLockAfter(lockExpireNS, TimeUnit.NANOSECONDS).withConsistencyLevel(ConsistencyLevel.CL_QUORUM);
    try {
        lock.acquire();
        log.debug("Locked {} in store {}", lockID, lockColumnFamily.getName());
        return new AstyanaxLockStatus(approxTimeNS, TimeUnit.NANOSECONDS, lock);
    } catch (StaleLockException e) {
        // TODO handle gracefully?
        throw new TemporaryLockingException(e);
    } catch (BusyLockException e) {
        // TODO handle gracefully?
        throw new TemporaryLockingException(e);
    } catch (Exception e) {
        throw new PermanentLockingException(e);
    }
}
Also used : PermanentLockingException(com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException) ColumnPrefixDistributedRowLock(com.netflix.astyanax.recipes.locks.ColumnPrefixDistributedRowLock) StaleLockException(com.netflix.astyanax.recipes.locks.StaleLockException) BusyLockException(com.netflix.astyanax.recipes.locks.BusyLockException) TemporaryLockingException(com.thinkaurelius.titan.diskstorage.locking.TemporaryLockingException) ByteBuffer(java.nio.ByteBuffer) PermanentLockingException(com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException) BusyLockException(com.netflix.astyanax.recipes.locks.BusyLockException) StaleLockException(com.netflix.astyanax.recipes.locks.StaleLockException) TemporaryLockingException(com.thinkaurelius.titan.diskstorage.locking.TemporaryLockingException)

Example 3 with PermanentLockingException

use of com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException in project titan by thinkaurelius.

the class ExpectedValueCheckingStore method acquireLock.

/**
 * {@inheritDoc}
 * <p/>
 * <p/>
 * <p/>
 * This implementation supports locking when {@code lockStore} is non-null.
 * <p/>
 * Consider the following scenario. This method is called twice with
 * identical key, column, and txh arguments, but with different
 * expectedValue arguments in each call. In testing, it seems titan's
 * graphdb requires that implementations discard the second expectedValue
 * and, when checking expectedValues vs actual values just prior to mutate,
 * only the initial expectedValue argument should be considered.
 */
@Override
public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws StorageException {
    if (locker != null) {
        ExpectedValueCheckingTransaction tx = (ExpectedValueCheckingTransaction) txh;
        if (tx.isMutationStarted())
            throw new PermanentLockingException("Attempted to obtain a lock after mutations had been persisted");
        KeyColumn lockID = new KeyColumn(key, column);
        log.debug("Attempting to acquireLock on {} ev={}", lockID, expectedValue);
        locker.writeLock(lockID, tx.getConsistentTransaction());
        tx.storeExpectedValue(this, lockID, expectedValue);
    } else {
        dataStore.acquireLock(key, column, expectedValue, getBaseTx(txh));
    }
}
Also used : PermanentLockingException(com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException) KeyColumn(com.thinkaurelius.titan.diskstorage.util.KeyColumn)

Aggregations

PermanentLockingException (com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException)3 BusyLockException (com.netflix.astyanax.recipes.locks.BusyLockException)2 StaleLockException (com.netflix.astyanax.recipes.locks.StaleLockException)2 TemporaryLockingException (com.thinkaurelius.titan.diskstorage.locking.TemporaryLockingException)2 ColumnPrefixDistributedRowLock (com.netflix.astyanax.recipes.locks.ColumnPrefixDistributedRowLock)1 KeyColumn (com.thinkaurelius.titan.diskstorage.util.KeyColumn)1 ByteBuffer (java.nio.ByteBuffer)1