use of com.hazelcast.internal.locksupport.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;
}
});
NodeEngine nodeEngine = getNodeEngineImpl(instance1);
Data keyData = nodeEngine.toData(keyOwnedByInstance2);
LockSupportService lockService = nodeEngine.getService(LockSupportService.SERVICE_NAME);
for (LockResource lockResource : lockService.getAllLocks()) {
if (keyData.equals(lockResource.getKey())) {
assertEquals(0, lockResource.getLockCount());
}
}
}
use of com.hazelcast.internal.locksupport.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