use of com.hazelcast.cp.internal.datastructures.lock.operation.LockOp in project hazelcast by hazelcast.
the class AbstractFencedLockFailureTest method testRetriedLockDoesNotCancelPendingLockRequest.
@Test(timeout = 300_000)
public void testRetriedLockDoesNotCancelPendingLockRequest() {
lockByOtherThread();
// there is a session id now
RaftGroupId groupId = lock.getGroupId();
long sessionId = getSessionManager().getSession(groupId);
RaftInvocationManager invocationManager = getRaftInvocationManager();
UUID invUid = newUnsecureUUID();
invocationManager.invoke(groupId, new TryLockOp(objectName, sessionId, getThreadId(), invUid, MINUTES.toMillis(5)));
assertTrueEventually(() -> {
LockService service = getNodeEngineImpl(primaryInstance).getService(LockService.SERVICE_NAME);
LockRegistry registry = service.getRegistryOrNull(groupId);
assertNotNull(registry);
assertEquals(1, registry.getWaitTimeouts().size());
});
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, getThreadId(), invUid));
assertTrueAllTheTime(() -> {
LockService service = getNodeEngineImpl(primaryInstance).getService(LockService.SERVICE_NAME);
LockRegistry registry = service.getRegistryOrNull(groupId);
assertEquals(1, registry.getWaitTimeouts().size());
}, 10);
}
use of com.hazelcast.cp.internal.datastructures.lock.operation.LockOp in project hazelcast by hazelcast.
the class AbstractFencedLockFailureTest method testGetLockCountCallInitializesLockedSessionId.
@Test(timeout = 300_000)
public void testGetLockCountCallInitializesLockedSessionId() {
lock.lock();
lock.unlock();
// there is a session id now
long threadId = getThreadId();
RaftGroupId groupId = lock.getGroupId();
long sessionId = getSessionManager().getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
RaftInvocationManager invocationManager = getRaftInvocationManager();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, threadId, newUnsecureUUID())).joinInternal();
int getLockCount = lock.getLockCount();
assertEquals(1, getLockCount);
Long lockedSessionId = lock.getLockedSessionId(threadId);
assertNotNull(lockedSessionId);
assertEquals(sessionId, (long) lockedSessionId);
}
use of com.hazelcast.cp.internal.datastructures.lock.operation.LockOp in project hazelcast by hazelcast.
the class AbstractFencedLockFailureTest method testUnlockCallInitializesLockedSessionId.
@Test(timeout = 300_000)
public void testUnlockCallInitializesLockedSessionId() {
lock.lock();
lock.unlock();
// there is a session id now
long threadId = getThreadId();
RaftGroupId groupId = lock.getGroupId();
long sessionId = getSessionManager().getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
RaftInvocationManager invocationManager = getRaftInvocationManager();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, threadId, newUnsecureUUID())).joinInternal();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, threadId, newUnsecureUUID())).joinInternal();
lock.unlock();
Long lockedSessionId = lock.getLockedSessionId(threadId);
assertNotNull(lockedSessionId);
assertEquals(sessionId, (long) lockedSessionId);
}
use of com.hazelcast.cp.internal.datastructures.lock.operation.LockOp in project hazelcast by hazelcast.
the class AbstractFencedLockFailureTest method testIsLockedCallInitializesLockedSessionId.
@Test(timeout = 300_000)
public void testIsLockedCallInitializesLockedSessionId() {
lock.lock();
lock.unlock();
// there is a session id now
long threadId = getThreadId();
RaftGroupId groupId = lock.getGroupId();
long sessionId = getSessionManager().getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
RaftInvocationManager invocationManager = getRaftInvocationManager();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, threadId, newUnsecureUUID())).joinInternal();
boolean locked = lock.isLocked();
assertTrue(locked);
Long lockedSessionId = lock.getLockedSessionId(threadId);
assertNotNull(lockedSessionId);
assertEquals(sessionId, (long) lockedSessionId);
}
Aggregations