use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.
the class UnlockIfLeaseExpiredOperation method run.
@Override
public void run() throws Exception {
LockStoreImpl lockStore = getLockStore();
int lockVersion = lockStore.getVersion(key);
ILogger logger = getLogger();
if (version == lockVersion) {
if (logger.isFinestEnabled()) {
logger.finest("Releasing a lock owned by " + lockStore.getOwnerInfo(key) + " after lease timeout!");
}
forceUnlock();
} else {
if (logger.isFinestEnabled()) {
logger.finest("Won't unlock since lock version is not matching expiration version: " + lockVersion + " vs " + version);
}
}
}
use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.
the class AwaitOperation method run.
@Override
public void run() throws Exception {
LockStoreImpl lockStore = getLockStore();
if (!lockStore.lock(key, getCallerUuid(), threadId, getReferenceCallId(), leaseTime)) {
throw new IllegalMonitorStateException("Current thread is not owner of the lock! -> " + lockStore.getOwnerInfo(key));
}
if (expired) {
response = false;
} else {
lockStore.removeSignalKey(getWaitKey());
lockStore.removeAwait(key, conditionId, getCallerUuid(), threadId);
response = true;
}
}
use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.
the class AwaitOperation method shouldWait.
@Override
public boolean shouldWait() {
LockStoreImpl lockStore = getLockStore();
boolean canAcquireLock = lockStore.canAcquireLock(key, getCallerUuid(), threadId);
if (!canAcquireLock) {
return true;
}
return !lockStore.hasSignalKey(getWaitKey());
}
use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.
the class AwaitOperation method onWaitExpire.
@Override
public void onWaitExpire() {
expired = true;
LockStoreImpl lockStore = getLockStore();
lockStore.removeSignalKey(getWaitKey());
lockStore.removeAwait(key, conditionId, getCallerUuid(), threadId);
boolean locked = lockStore.lock(key, getCallerUuid(), threadId, getReferenceCallId(), leaseTime);
if (locked) {
// expired & acquired lock, send FALSE
sendResponse(false);
} else {
// expired but could not acquire lock, no response atm
lockStore.registerExpiredAwaitOp(this);
}
}
use of com.hazelcast.concurrent.lock.LockStoreImpl in project hazelcast by hazelcast.
the class BeforeAwaitOperation method beforeRun.
@Override
public void beforeRun() throws Exception {
LockStoreImpl lockStore = getLockStore();
boolean isLockOwner = lockStore.isLockedBy(key, getCallerUuid(), threadId);
ensureOwner(lockStore, isLockOwner);
}
Aggregations