use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.
the class UnlockMessageTask method processMessage.
@Override
protected void processMessage() {
RaftOp op = new UnlockOp(parameters.name, parameters.sessionId, parameters.threadId, parameters.invocationUid);
invoke(parameters.groupId, op);
}
use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.
the class SessionAwareSemaphoreProxy method tryAcquire.
@Override
public boolean tryAcquire(int permits, long timeout, TimeUnit unit) {
checkPositive("permits", permits);
long timeoutMs = max(0, unit.toMillis(timeout));
long threadId = getThreadId();
UUID invocationUid = newUnsecureUUID();
long start;
for (; ; ) {
start = Clock.currentTimeMillis();
long sessionId = acquireSession(permits);
RaftOp op = new AcquirePermitsOp(objectName, sessionId, threadId, invocationUid, permits, timeoutMs);
try {
InternalCompletableFuture<Boolean> f = invocationManager.invoke(groupId, op);
boolean acquired = f.joinInternal();
if (!acquired) {
releaseSession(sessionId, permits);
}
return acquired;
} catch (SessionExpiredException e) {
invalidateSession(sessionId);
timeoutMs -= (Clock.currentTimeMillis() - start);
if (timeoutMs <= 0) {
return false;
}
} catch (WaitKeyCancelledException e) {
releaseSession(sessionId, permits);
return false;
} catch (RuntimeException e) {
releaseSession(sessionId, permits);
throw e;
}
}
}
use of com.hazelcast.cp.internal.RaftOp 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.RaftOp in project hazelcast by hazelcast.
the class AcquirePermitsMessageTask method processMessage.
@Override
protected void processMessage() {
RaftOp op = new AcquirePermitsOp(parameters.name, parameters.sessionId, parameters.threadId, parameters.invocationUid, parameters.permits, parameters.timeoutMs);
invoke(parameters.groupId, op);
}
use of com.hazelcast.cp.internal.RaftOp in project hazelcast by hazelcast.
the class TryLockMessageTask method processMessage.
@Override
protected void processMessage() {
RaftOp op = new TryLockOp(parameters.name, parameters.sessionId, parameters.threadId, parameters.invocationUid, parameters.timeoutMs);
invoke(parameters.groupId, op);
}
Aggregations