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