use of com.hazelcast.internal.locksupport.LockStoreImpl in project hazelcast by hazelcast.
the class LockReplicationOperation method run.
@Override
public void run() {
LockSupportServiceImpl lockService = getService();
LockStoreContainer container = lockService.getLockContainer(getPartitionId());
for (LockStoreImpl ls : locks) {
container.put(ls);
}
}
use of com.hazelcast.internal.locksupport.LockStoreImpl in project hazelcast by hazelcast.
the class LockReplicationOperation method writeInternal.
@Override
protected void writeInternal(final ObjectDataOutput out) throws IOException {
super.writeInternal(out);
int len = locks.size();
out.writeInt(len);
if (len > 0) {
for (LockStoreImpl ls : locks) {
out.writeObject(ls);
}
}
}
use of com.hazelcast.internal.locksupport.LockStoreImpl in project hazelcast by hazelcast.
the class UnlockIfLeaseExpiredOperation method run.
@Override
public void run() {
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.internal.locksupport.LockStoreImpl in project hazelcast by hazelcast.
the class UnlockOperation method forceUnlock.
protected final void forceUnlock() {
LockStoreImpl lockStore = getLockStore();
boolean unlocked = lockStore.forceUnlock(key);
this.response = unlocked;
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
if (unlocked) {
logger.finest("Released lock " + namespace.getObjectName());
} else {
logger.finest("Could not release lock " + namespace.getObjectName() + " as it is not locked");
}
}
}
use of com.hazelcast.internal.locksupport.LockStoreImpl in project hazelcast by hazelcast.
the class MapLockTest method lockStoreShouldBeRemoved_whenMapIsDestroyed.
/**
* See issue #4888
*/
@Test
public void lockStoreShouldBeRemoved_whenMapIsDestroyed() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<Integer, Integer> map = instance.getMap(randomName());
for (int i = 0; i < 1000; i++) {
map.lock(i);
}
map.destroy();
NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
LockSupportServiceImpl lockService = nodeEngine.getService(LockSupportService.SERVICE_NAME);
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int i = 0; i < partitionCount; i++) {
LockStoreContainer lockContainer = lockService.getLockContainer(i);
Collection<LockStoreImpl> lockStores = lockContainer.getLockStores().stream().filter(s -> !s.getNamespace().getObjectName().startsWith(JobRepository.INTERNAL_JET_OBJECTS_PREFIX)).collect(Collectors.toList());
assertEquals("LockStores should be empty", 0, lockStores.size());
}
}
Aggregations