use of org.apache.kylin.job.lock.zookeeper.exception.ZkReleaseLockInterruptException in project kylin by apache.
the class ZookeeperDistributedLock method unlock.
@Override
public void unlock(String lockPath) {
logger.debug("{} trying to unlock {}", client, lockPath);
// peek owner first
String owner;
ZkPeekLockInterruptException peekLockInterruptException = null;
try {
owner = peekLock(lockPath);
} catch (ZkPeekLockInterruptException zie) {
// re-peek owner of lock when interrupted
owner = peekLock(lockPath);
peekLockInterruptException = zie;
} catch (ZkPeekLockException ze) {
// this exception should be thrown to diagnose even it may cause unlock failed
logger.error("{} failed to peekLock when unlock at {}", client, lockPath, ze);
throw ze;
}
// then unlock
ZkReleaseLockInterruptException unlockInterruptException = null;
try {
unlockInternal(owner, lockPath);
} catch (ZkReleaseLockInterruptException zlie) {
// re-unlock once when interrupted
unlockInternal(owner, lockPath);
unlockInterruptException = zlie;
} catch (Exception ex) {
throw new ZkReleaseLockException("Error while " + client + " trying to unlock " + lockPath, ex);
}
// need re-throw interrupt exception to avoid swallowing it
if (peekLockInterruptException != null) {
throw peekLockInterruptException;
}
if (unlockInterruptException != null) {
throw unlockInterruptException;
}
}
Aggregations