Search in sources :

Example 1 with UnlockOp

use of com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp in project hazelcast by hazelcast.

the class UnlockMessageTask method processMessage.

@Override
protected void processMessage() {
    RaftOp op = new UnlockOp(parameters.name, parameters.sessionId, parameters.threadId, parameters.invocationUid);
    invoke(parameters.groupId, op);
}
Also used : UnlockOp(com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp) RaftOp(com.hazelcast.cp.internal.RaftOp)

Example 2 with UnlockOp

use of com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp in project hazelcast by hazelcast.

the class AbstractFencedLockFailureTest method testRetriedUnlockIsSuccessfulAfterLockedByAnotherEndpoint.

@Test(timeout = 300_000)
public void testRetriedUnlockIsSuccessfulAfterLockedByAnotherEndpoint() {
    lock.lock();
    RaftGroupId groupId = lock.getGroupId();
    long sessionId = getSessionManager().getSession(groupId);
    RaftInvocationManager invocationManager = getRaftInvocationManager();
    UUID invUid = newUnsecureUUID();
    invocationManager.invoke(groupId, new UnlockOp(objectName, sessionId, getThreadId(), invUid)).joinInternal();
    lockByOtherThread();
    invocationManager.invoke(groupId, new UnlockOp(objectName, sessionId, getThreadId(), invUid)).joinInternal();
}
Also used : UnlockOp(com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp) RaftInvocationManager(com.hazelcast.cp.internal.RaftInvocationManager) RaftGroupId(com.hazelcast.cp.internal.RaftGroupId) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) UUID(java.util.UUID) Test(org.junit.Test)

Example 3 with UnlockOp

use of com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp 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

UnlockOp (com.hazelcast.cp.internal.datastructures.lock.operation.UnlockOp)3 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)2 Test (org.junit.Test)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 RaftInvocationManager (com.hazelcast.cp.internal.RaftInvocationManager)1 RaftOp (com.hazelcast.cp.internal.RaftOp)1 ProxySessionManagerService (com.hazelcast.cp.internal.session.ProxySessionManagerService)1 RaftSessionService (com.hazelcast.cp.internal.session.RaftSessionService)1 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)1 UUID (java.util.UUID)1