Search in sources :

Example 1 with ExpiredLockException

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);
}
Also used : ExpiredLockException(org.janusgraph.diskstorage.locking.consistentkey.ExpiredLockException) ConsistentKeyLockStatus(org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLockStatus) Test(org.junit.jupiter.api.Test)

Aggregations

ConsistentKeyLockStatus (org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLockStatus)1 ExpiredLockException (org.janusgraph.diskstorage.locking.consistentkey.ExpiredLockException)1 Test (org.junit.jupiter.api.Test)1