Search in sources :

Example 1 with ProxySessionManagerService

use of com.hazelcast.cp.internal.session.ProxySessionManagerService in project hazelcast by hazelcast.

the class CPMemberAddRemoveTest method test_sessionClosedOnCPSubsystemReset.

@Test
public void test_sessionClosedOnCPSubsystemReset() throws Exception {
    HazelcastInstance[] instances = newInstances(3, 3, 1);
    instances[0].getCPSubsystem().getAtomicLong("long1").set(1);
    instances[0].getCPSubsystem().getAtomicLong("long1@custom").set(2);
    FencedLock lock = instances[3].getCPSubsystem().getLock("lock");
    lock.lock();
    instances[0].getCPSubsystem().getCPSubsystemManagementService().reset().toCompletableFuture().get();
    assertTrueEventually(() -> {
        ProxySessionManagerService service = getNodeEngineImpl(instances[3]).getService(ProxySessionManagerService.SERVICE_NAME);
        assertEquals(NO_SESSION_ID, service.getSession((RaftGroupId) lock.getGroupId()));
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) FencedLock(com.hazelcast.cp.lock.FencedLock) ProxySessionManagerService(com.hazelcast.cp.internal.session.ProxySessionManagerService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 2 with ProxySessionManagerService

use of com.hazelcast.cp.internal.session.ProxySessionManagerService 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));
    });
}
Also used : RaftSessionService(com.hazelcast.cp.internal.session.RaftSessionService) UnlockOp(com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp) HazelcastInstance(com.hazelcast.core.HazelcastInstance) RaftGroupId(com.hazelcast.cp.internal.RaftGroupId) ProxySessionManagerService(com.hazelcast.cp.internal.session.ProxySessionManagerService) Test(org.junit.Test)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 ProxySessionManagerService (com.hazelcast.cp.internal.session.ProxySessionManagerService)2 Test (org.junit.Test)2 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)1 UnlockOp (com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp)1 RaftSessionService (com.hazelcast.cp.internal.session.RaftSessionService)1 FencedLock (com.hazelcast.cp.lock.FencedLock)1 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1