Search in sources :

Example 6 with ChangePermitsOp

use of com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp in project hazelcast by hazelcast.

the class AbstractSemaphoreAdvancedTest method testRetriedDecreasePermitsAppliedOnlyOnce.

@Test
public void testRetriedDecreasePermitsAppliedOnlyOnce() throws InterruptedException {
    semaphore.init(2);
    semaphore.acquire();
    semaphore.release();
    // we guarantee that there is a session id now...
    RaftGroupId groupId = getGroupId();
    long sessionId = getSessionManager().getSession(groupId);
    assertNotEquals(NO_SESSION_ID, sessionId);
    UUID invUid = newUnsecureUUID();
    invokeRaftOp(groupId, new ChangePermitsOp(objectName, sessionId, getThreadId(), invUid, -1)).joinInternal();
    invokeRaftOp(groupId, new ChangePermitsOp(objectName, sessionId, getThreadId(), invUid, -1)).joinInternal();
    assertEquals(1, semaphore.availablePermits());
}
Also used : ChangePermitsOp(com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp) RaftGroupId(com.hazelcast.cp.internal.RaftGroupId) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

ChangePermitsOp (com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp)6 RaftOp (com.hazelcast.cp.internal.RaftOp)4 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)3 UUID (java.util.UUID)3 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)2 Test (org.junit.Test)2 SessionExpiredException (com.hazelcast.cp.internal.session.SessionExpiredException)1