use of com.hazelcast.cp.internal.session.RaftSessionService in project hazelcast by hazelcast.
the class AbstractFencedLockAdvancedTest method testActiveSessionIsNotClosedWhenPendingWaitKey.
@Test
public void testActiveSessionIsNotClosedWhenPendingWaitKey() {
FencedLock other = null;
for (HazelcastInstance instance : instances) {
if (instance != proxyInstance) {
other = instance.getCPSubsystem().getLock(lock.getName());
break;
}
}
assertNotNull(other);
// lock from another instance
other.lock();
spawn(() -> {
lock.tryLock(30, TimeUnit.MINUTES);
});
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService sessionService = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertEquals(2, sessionService.getAllSessions(lock.getGroupId()).get().size());
}
});
assertTrueAllTheTime(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService sessionService = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertEquals(2, sessionService.getAllSessions(lock.getGroupId()).get().size());
}
}, 20);
}
use of com.hazelcast.cp.internal.session.RaftSessionService 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.session.RaftSessionService in project hazelcast by hazelcast.
the class AbstractSemaphoreAdvancedTest method testInactiveSessionsAreEventuallyClosed.
@Test
public void testInactiveSessionsAreEventuallyClosed() throws ExecutionException, InterruptedException {
semaphore.init(1);
semaphore.acquire();
RaftGroupId groupId = getGroupId();
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService sessionService = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertFalse(sessionService.getAllSessions(groupId).get().isEmpty());
}
});
AbstractProxySessionManager sessionManager = getSessionManager();
long sessionId = sessionManager.getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
// Not using semaphore.release(), because we want to keep sending session HBs.
RaftOp op = new ReleasePermitsOp(objectName, sessionId, getThreadId(), newUnsecureUUID(), 1);
invokeRaftOp(groupId, op).get();
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService service1 = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertTrue(service1.getAllSessions(groupId).get().isEmpty());
}
assertEquals(NO_SESSION_ID, sessionManager.getSession(groupId));
});
}
use of com.hazelcast.cp.internal.session.RaftSessionService in project hazelcast by hazelcast.
the class AbstractSemaphoreAdvancedTest method testActiveSessionWithPendingPermitIsNotClosed.
@Test
public void testActiveSessionWithPendingPermitIsNotClosed() {
spawn(() -> {
try {
semaphore.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService sessionService = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertFalse(sessionService.getAllSessions(getGroupId()).get().isEmpty());
}
});
assertTrueAllTheTime(() -> {
for (HazelcastInstance instance : instances) {
RaftSessionService sessionService = getNodeEngineImpl(instance).getService(RaftSessionService.SERVICE_NAME);
assertFalse(sessionService.getAllSessions(getGroupId()).get().isEmpty());
}
}, 20);
}
Aggregations