Search in sources :

Example 1 with INTERNAL_LOCK_GRANT_CLIENT

use of com.palantir.lock.LockClient.INTERNAL_LOCK_GRANT_CLIENT in project atlasdb by palantir.

the class LockServiceImpl method unlockInternal.

private <T extends ExpiringToken> boolean unlockInternal(T token, ConcurrentMap<T, HeldLocks<T>> heldLocksMap) {
    @Nullable HeldLocks<T> heldLocks = heldLocksMap.remove(token);
    if (heldLocks == null) {
        return false;
    }
    long heldDuration = System.currentTimeMillis() - token.getCreationDateMs();
    if (requestLogger.isDebugEnabled()) {
        requestLogger.debug("Releasing locks {} after holding for {} ms", UnsafeArg.of("heldLocks", heldLocks), SafeArg.of("heldDuration", heldDuration));
    }
    @Nullable LockClient client = heldLocks.realToken.getClient();
    if (client == null) {
        client = INTERNAL_LOCK_GRANT_CLIENT;
    } else {
        lockClientMultimap.remove(client, token);
    }
    for (Entry<? extends ClientAwareReadWriteLock, LockMode> entry : heldLocks.locks.entries()) {
        entry.getKey().get(client, entry.getValue()).unlock();
    }
    if (heldLocks.realToken.getVersionId() != null) {
        versionIdMap.remove(client, heldLocks.realToken.getVersionId());
    }
    return true;
}
Also used : BLOCK_UNTIL_TIMEOUT(com.palantir.lock.BlockingMode.BLOCK_UNTIL_TIMEOUT) INTERNAL_LOCK_GRANT_CLIENT(com.palantir.lock.LockClient.INTERNAL_LOCK_GRANT_CLIENT) LockClient(com.palantir.lock.LockClient) LockMode(com.palantir.lock.LockMode) Nullable(javax.annotation.Nullable)

Aggregations

BLOCK_UNTIL_TIMEOUT (com.palantir.lock.BlockingMode.BLOCK_UNTIL_TIMEOUT)1 LockClient (com.palantir.lock.LockClient)1 INTERNAL_LOCK_GRANT_CLIENT (com.palantir.lock.LockClient.INTERNAL_LOCK_GRANT_CLIENT)1 LockMode (com.palantir.lock.LockMode)1 Nullable (javax.annotation.Nullable)1