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);
}
}
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);
}
}
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));
}
}
Aggregations