use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockBasicTest method testReentrantTryLockFails_whenSessionClosed.
@Test
public void testReentrantTryLockFails_whenSessionClosed() throws ExecutionException, InterruptedException {
long fence = lock.lockAndGetFence();
assertValidFence(fence);
AbstractProxySessionManager sessionManager = getSessionManager(proxyInstance);
RaftGroupId groupId = (RaftGroupId) lock.getGroupId();
long sessionId = sessionManager.getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
closeSession(instances[0], groupId, sessionId);
assertTrueEventually(() -> assertNotEquals(sessionId, sessionManager.getSession(groupId)));
try {
lock.tryLock();
} catch (LockOwnershipLostException ignored) {
}
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockBasicTest method testUnlockFails_whenNewSessionCreated.
@Test
public void testUnlockFails_whenNewSessionCreated() throws ExecutionException, InterruptedException {
long fence = lock.lockAndGetFence();
assertValidFence(fence);
AbstractProxySessionManager sessionManager = getSessionManager(proxyInstance);
RaftGroupId groupId = (RaftGroupId) lock.getGroupId();
long sessionId = sessionManager.getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
closeSession(instances[0], groupId, sessionId);
assertTrueEventually(() -> assertNotEquals(sessionId, sessionManager.getSession(groupId)));
lockByOtherThread(lock);
try {
lock.unlock();
} catch (LockOwnershipLostException ignored) {
}
assertFalse(lock.isLockedByCurrentThread());
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockAdvancedTest method testInactiveSessionsAreEventuallyClosed.
@Test
public void testInactiveSessionsAreEventuallyClosed() throws ExecutionException, InterruptedException {
lock.lock();
RaftGroupId groupId = (RaftGroupId) lock.getGroupId();
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService sessionService = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertFalse(sessionService.getAllSessions(groupId).get().isEmpty());
}
});
RaftSessionService sessionService = getNodeEngineImpl(primaryInstance).getService(RaftSessionService.SERVICE_NAME);
long sessionId = sessionService.getAllSessions(groupId).get().iterator().next().id();
getRaftInvocationManager(proxyInstance).invoke(groupId, new UnlockOp(objectName, sessionId, getThreadId(), newUnsecureUUID())).joinInternal();
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService service = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertTrue(service.getAllSessions(groupId).get().isEmpty());
}
ProxySessionManagerService service = getNodeEngineImpl(proxyInstance).getService(ProxySessionManagerService.SERVICE_NAME);
assertEquals(NO_SESSION_ID, service.getSession(groupId));
});
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockFailureTest method testLockAcquireRetry.
@Test(timeout = 300_000)
public void testLockAcquireRetry() {
lock.lock();
lock.unlock();
// there is a session id now
RaftGroupId groupId = lock.getGroupId();
long sessionId = getSessionManager().getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
RaftInvocationManager invocationManager = getRaftInvocationManager();
UUID invUid = newUnsecureUUID();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, getThreadId(), invUid)).joinInternal();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, getThreadId(), invUid)).joinInternal();
assertEquals(1, lock.getLockCount());
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockFailureTest method testLockReentrantAcquireRetry.
@Test(timeout = 300_000)
public void testLockReentrantAcquireRetry() {
lock.lock();
lock.unlock();
// there is a session id now
RaftGroupId groupId = lock.getGroupId();
long sessionId = getSessionManager().getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
RaftInvocationManager invocationManager = getRaftInvocationManager();
UUID invUid1 = newUnsecureUUID();
UUID invUid2 = newUnsecureUUID();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, getThreadId(), invUid1)).joinInternal();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, getThreadId(), invUid2)).joinInternal();
invocationManager.invoke(groupId, new LockOp(objectName, sessionId, getThreadId(), invUid2)).joinInternal();
assertEquals(2, lock.getLockCount());
}
Aggregations