use of org.janusgraph.diskstorage.locking.consistentkey.ExpiredLockException in project janusgraph by JanusGraph.
the class ConsistentKeyLockerTest method testCheckOwnExpiredLockThrowsException.
/**
* A transaction that writes a lock, waits past expiration, and attempts
* to check locks should receive an {@code ExpiredLockException} during
* the check stage.
*
* @throws org.janusgraph.diskstorage.BackendException shouldn't happen
* @throws InterruptedException
*/
@Test
public void testCheckOwnExpiredLockThrowsException() throws BackendException, InterruptedException {
// Fake a pre-existing lock that's long since expired
final ConsistentKeyLockStatus expired = makeStatusNow();
expect(lockState.getLocksForTx(defaultTx)).andReturn(ImmutableMap.of(defaultLockID, expired));
// pretend a huge multiple of the expiration time has passed
currentTimeNS = currentTimeNS.plus(100, ChronoUnit.DAYS);
// Checker should compare the fake lock's timestamp to the current time
expectSleepAfterWritingLock(expired);
// Checker must slice the store; we return the single expired lock column
recordLockGetSliceAndReturnSingleEntry(StaticArrayEntry.of(codec.toLockCol(expired.getWriteTimestamp(), defaultLockRid, times), defaultLockVal));
ctrl.replay();
ExpiredLockException ele = null;
try {
locker.checkLocks(defaultTx);
} catch (ExpiredLockException e) {
ele = e;
}
assertNotNull(ele);
}
Aggregations