use of com.hazelcast.concurrent.lock.LockResource in project hazelcast by hazelcast.
the class MapTransactionTest method testGetForUpdate_releasesBackupLock.
@Test
public void testGetForUpdate_releasesBackupLock() {
Config config = getConfig();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
final String keyOwnedByInstance2 = generateKeyOwnedBy(instance2);
instance1.executeTransaction(new TransactionalTask<Object>() {
@Override
public Object execute(TransactionalTaskContext context) throws TransactionException {
TransactionalMap<Object, Object> map = context.getMap(randomString());
map.getForUpdate(keyOwnedByInstance2);
return null;
}
});
Node node = TestUtil.getNode(instance1);
Data keyData = node.nodeEngine.toData(keyOwnedByInstance2);
LockService lockService = node.nodeEngine.getService(LockService.SERVICE_NAME);
for (LockResource lockResource : lockService.getAllLocks()) {
if (keyData.equals(lockResource.getKey())) {
assertEquals(0, lockResource.getLockCount());
}
}
}
use of com.hazelcast.concurrent.lock.LockResource in project hazelcast by hazelcast.
the class LocalLockCleanupOperation method run.
@Override
public void run() throws Exception {
LockStoreImpl lockStore = getLockStore();
LockResource lock = lockStore.getLock(key);
if (uuid.equals(lock.getOwner())) {
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
logger.finest("Unlocking lock owned by uuid: " + uuid + ", thread-id: " + lock.getThreadId() + ", count: " + lock.getLockCount());
}
response = lockStore.forceUnlock(key);
}
}
Aggregations