Search in sources :

Example 1 with Timepoint

use of com.thinkaurelius.titan.diskstorage.util.time.Timepoint in project incubator-atlas by apache.

the class HBaseKeyColumnValueStore method acquireLock.

@Override
public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws BackendException {
    KeyColumn lockID = new KeyColumn(key, column);
    logger.debug("Attempting to acquireLock on {} ", lockID);
    int trialCount = 0;
    boolean locked;
    while (trialCount < lockMaxRetries) {
        final Timepoint lockStartTime = Timestamps.MILLI.getTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
        locked = localLockMediator.lock(lockID, txh, lockStartTime.add(lockExpiryTimeMs));
        trialCount++;
        if (!locked) {
            handleLockFailure(txh, lockID, trialCount);
        } else {
            logger.debug("Acquired lock on {}, {}", lockID, txh);
            break;
        }
    }
    ((HBaseTransaction) txh).updateLocks(lockID, expectedValue);
}
Also used : KeyColumn(com.thinkaurelius.titan.diskstorage.util.KeyColumn) Timepoint(com.thinkaurelius.titan.diskstorage.util.time.Timepoint) Timepoint(com.thinkaurelius.titan.diskstorage.util.time.Timepoint)

Aggregations

KeyColumn (com.thinkaurelius.titan.diskstorage.util.KeyColumn)1 Timepoint (com.thinkaurelius.titan.diskstorage.util.time.Timepoint)1