Search in sources :

Example 1 with ColumnPrefixDistributedRowLock

use of com.netflix.astyanax.recipes.locks.ColumnPrefixDistributedRowLock 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)

Aggregations

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