use of com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp in project hazelcast by hazelcast.
the class SessionlessSemaphoreProxy method increasePermits.
@Override
public void increasePermits(int increase) {
checkNotNegative(increase, "Increase must be non-negative!");
if (increase == 0) {
return;
}
long clusterWideThreadId = getOrCreateUniqueThreadId();
RaftOp op = new ChangePermitsOp(objectName, NO_SESSION_ID, clusterWideThreadId, newUnsecureUUID(), increase);
invocationManager.invoke(groupId, op).joinInternal();
}
use of com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp in project hazelcast by hazelcast.
the class SessionlessSemaphoreProxy method reducePermits.
@Override
public void reducePermits(int reduction) {
checkNotNegative(reduction, "Reduction must be non-negative!");
if (reduction == 0) {
return;
}
long clusterWideThreadId = getOrCreateUniqueThreadId();
RaftOp op = new ChangePermitsOp(objectName, NO_SESSION_ID, clusterWideThreadId, newUnsecureUUID(), -reduction);
invocationManager.invoke(groupId, op).joinInternal();
}
use of com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp in project hazelcast by hazelcast.
the class SessionAwareSemaphoreProxy method doChangePermits.
private void doChangePermits(int delta) {
long sessionId = acquireSession();
long threadId = getThreadId();
UUID invocationUid = newUnsecureUUID();
try {
RaftOp op = new ChangePermitsOp(objectName, sessionId, threadId, invocationUid, delta);
invocationManager.invoke(groupId, op).joinInternal();
} catch (SessionExpiredException e) {
invalidateSession(sessionId);
throw newIllegalStateException(e);
} finally {
releaseSession(sessionId);
}
}
use of com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp in project hazelcast by hazelcast.
the class ChangePermitsMessageTask method processMessage.
@Override
protected void processMessage() {
RaftOp op = new ChangePermitsOp(parameters.name, parameters.sessionId, parameters.threadId, parameters.invocationUid, parameters.permits);
invoke(parameters.groupId, op);
}
use of com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp in project hazelcast by hazelcast.
the class AbstractSemaphoreAdvancedTest method testRetriedIncreasePermitsAppliedOnlyOnce.
@Test
public void testRetriedIncreasePermitsAppliedOnlyOnce() throws InterruptedException {
semaphore.init(1);
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(2, semaphore.availablePermits());
}
Aggregations