use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractSemaphoreAdvancedTest method testRetriedReleaseIsSuccessfulAfterAcquiredByAnotherEndpoint.
@Test
public void testRetriedReleaseIsSuccessfulAfterAcquiredByAnotherEndpoint() throws InterruptedException {
semaphore.init(1);
semaphore.acquire();
RaftGroupId groupId = getGroupId();
long sessionId = getSessionManager().getSession(groupId);
UUID invUid = newUnsecureUUID();
invokeRaftOp(groupId, new ReleasePermitsOp(objectName, sessionId, getThreadId(), invUid, 1)).joinInternal();
spawn(() -> {
try {
semaphore.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
invokeRaftOp(groupId, new ReleasePermitsOp(objectName, sessionId, getThreadId(), invUid, 1)).joinInternal();
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockBasicTest method testFailedTryLock_doesNotAcquireSession.
@Test
public void testFailedTryLock_doesNotAcquireSession() {
lockByOtherThread(lock);
AbstractProxySessionManager sessionManager = getSessionManager(proxyInstance);
RaftGroupId groupId = (RaftGroupId) lock.getGroupId();
long sessionId = sessionManager.getSession(groupId);
assertNotEquals(NO_SESSION_ID, sessionId);
assertEquals(1, sessionManager.getSessionAcquireCount(groupId, sessionId));
long fence = lock.tryLockAndGetFence();
assertInvalidFence(fence);
assertEquals(1, sessionManager.getSessionAcquireCount(groupId, sessionId));
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockBasicTest method testGetFenceFails_whenNewSessionCreated.
@Test
public void testGetFenceFails_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.getFence();
} catch (LockOwnershipLostException ignored) {
}
assertFalse(lock.isLockedByCurrentThread());
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockBasicTest method testUnlockFails_whenSessionClosed.
@Test
public void testUnlockFails_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.unlock();
} catch (LockOwnershipLostException ignored) {
}
assertFalse(lock.isLockedByCurrentThread());
assertFalse(lock.isLocked());
assertNoLockedSessionId();
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractFencedLockBasicTest method testReentrantLockFails_whenSessionClosed.
@Test
public void testReentrantLockFails_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.lock();
} catch (LockOwnershipLostException ignored) {
}
}
Aggregations