Search in sources :

Example 6 with RaftOp

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

the class AbstractSessionMessageTask method processMessage.

@Override
protected final void processMessage() {
    CPGroupId groupId = getGroupId();
    RaftOp raftOp = getRaftOp();
    invoke(groupId, raftOp);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) RaftOp(com.hazelcast.cp.internal.RaftOp)

Example 7 with RaftOp

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

Example 8 with RaftOp

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

the class SessionlessSemaphoreProxy method drainPermits.

@Override
public int drainPermits() {
    long clusterWideThreadId = getOrCreateUniqueThreadId();
    RaftOp op = new DrainPermitsOp(objectName, NO_SESSION_ID, clusterWideThreadId, newUnsecureUUID());
    return invocationManager.<Integer>invoke(groupId, op).joinInternal();
}
Also used : RaftOp(com.hazelcast.cp.internal.RaftOp) DrainPermitsOp(com.hazelcast.cp.internal.datastructures.semaphore.operation.DrainPermitsOp)

Example 9 with RaftOp

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

Example 10 with RaftOp

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

the class SessionlessSemaphoreProxy method tryAcquire.

@Override
public boolean tryAcquire(int permits, long timeout, TimeUnit unit) {
    checkPositive("permits", permits);
    long clusterWideThreadId = getOrCreateUniqueThreadId();
    long timeoutMs = max(0, unit.toMillis(timeout));
    RaftOp op = new AcquirePermitsOp(objectName, NO_SESSION_ID, clusterWideThreadId, newUnsecureUUID(), permits, timeoutMs);
    try {
        return invocationManager.<Boolean>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)

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