Search in sources :

Example 21 with RaftOp

use of com.hazelcast.cp.internal.RaftOp 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);
}
Also used : ChangePermitsOp(com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp) RaftOp(com.hazelcast.cp.internal.RaftOp)

Example 22 with RaftOp

use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.

the class ReleasePermitsMessageTask method processMessage.

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

Example 23 with RaftOp

use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.

the class DrainPermitsMessageTask method processMessage.

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

Example 24 with RaftOp

use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.

the class SessionlessSemaphoreProxy method acquire.

@Override
public void acquire(int permits) {
    checkPositive(permits, "Permits must be positive!");
    long clusterWideThreadId = getOrCreateUniqueThreadId();
    RaftOp op = new AcquirePermitsOp(objectName, NO_SESSION_ID, clusterWideThreadId, newUnsecureUUID(), permits, -1L);
    try {
        invocationManager.invoke(groupId, op).joinInternal();
    } catch (WaitKeyCancelledException e) {
        throw new IllegalStateException("Semaphore[" + objectName + "] not acquired because the acquire call " + "on the CP group is cancelled, possibly because of another indeterminate call from the same thread.");
    }
}
Also used : WaitKeyCancelledException(com.hazelcast.cp.internal.datastructures.exception.WaitKeyCancelledException) AcquirePermitsOp(com.hazelcast.cp.internal.datastructures.semaphore.operation.AcquirePermitsOp) RaftOp(com.hazelcast.cp.internal.RaftOp)

Example 25 with RaftOp

use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.

the class SessionlessSemaphoreProxy method release.

@Override
public void release(int permits) {
    checkPositive(permits, "Permits must be positive!");
    long clusterWideThreadId = getOrCreateUniqueThreadId();
    RaftOp op = new ReleasePermitsOp(objectName, NO_SESSION_ID, clusterWideThreadId, newUnsecureUUID(), permits);
    invocationManager.invoke(groupId, op).joinInternal();
}
Also used : ReleasePermitsOp(com.hazelcast.cp.internal.datastructures.semaphore.operation.ReleasePermitsOp) RaftOp(com.hazelcast.cp.internal.RaftOp)

Aggregations

RaftOp (com.hazelcast.cp.internal.RaftOp)28 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)7 UUID (java.util.UUID)7 AcquirePermitsOp (com.hazelcast.cp.internal.datastructures.semaphore.operation.AcquirePermitsOp)6 SessionExpiredException (com.hazelcast.cp.internal.session.SessionExpiredException)5 CPGroupId (com.hazelcast.cp.CPGroupId)4 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)4 WaitKeyCancelledException (com.hazelcast.cp.internal.datastructures.exception.WaitKeyCancelledException)4 ChangePermitsOp (com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp)4 ReleasePermitsOp (com.hazelcast.cp.internal.datastructures.semaphore.operation.ReleasePermitsOp)4 DrainPermitsOp (com.hazelcast.cp.internal.datastructures.semaphore.operation.DrainPermitsOp)3 Test (org.junit.Test)3 RaftService (com.hazelcast.cp.internal.RaftService)2 ApplyOp (com.hazelcast.cp.internal.datastructures.atomicref.operation.ApplyOp)2 TryLockOp (com.hazelcast.cp.internal.datastructures.lock.operation.TryLockOp)2 ExpireWaitKeysOp (com.hazelcast.cp.internal.datastructures.spi.blocking.operation.ExpireWaitKeysOp)2 AbstractProxySessionManager (com.hazelcast.cp.internal.session.AbstractProxySessionManager)2 BiTuple (com.hazelcast.internal.util.BiTuple)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 PartitionSpecificRunnable (com.hazelcast.spi.impl.PartitionSpecificRunnable)2