Search in sources :

Example 1 with AcquireResult

use of com.hazelcast.cp.internal.datastructures.lock.AcquireResult in project hazelcast by hazelcast.

the class TryLockOp method run.

@Override
public Object run(CPGroupId groupId, long commitIndex) {
    LockService service = getService();
    LockInvocationKey key = new LockInvocationKey(commitIndex, invocationUid, callerAddress, callId, getLockEndpoint());
    AcquireResult result = service.acquire(groupId, name, key, timeoutMs);
    if (result.status() == WAIT_KEY_ADDED) {
        return PostponedResponse.INSTANCE;
    }
    // SUCCESSFUL or FAILED
    return result.fence();
}
Also used : LockInvocationKey(com.hazelcast.cp.internal.datastructures.lock.LockInvocationKey) LockService(com.hazelcast.cp.internal.datastructures.lock.LockService) AcquireResult(com.hazelcast.cp.internal.datastructures.lock.AcquireResult)

Example 2 with AcquireResult

use of com.hazelcast.cp.internal.datastructures.lock.AcquireResult in project hazelcast by hazelcast.

the class LockOp method run.

@Override
public Object run(CPGroupId groupId, long commitIndex) {
    LockService service = getService();
    LockInvocationKey key = new LockInvocationKey(commitIndex, invocationUid, callerAddress, callId, getLockEndpoint());
    AcquireResult result = service.acquire(groupId, name, key, -1L);
    if (result.status() == WAIT_KEY_ADDED) {
        return PostponedResponse.INSTANCE;
    }
    // SUCCESSFUL or FAILED
    return result.fence();
}
Also used : LockInvocationKey(com.hazelcast.cp.internal.datastructures.lock.LockInvocationKey) LockService(com.hazelcast.cp.internal.datastructures.lock.LockService) AcquireResult(com.hazelcast.cp.internal.datastructures.lock.AcquireResult)

Aggregations

AcquireResult (com.hazelcast.cp.internal.datastructures.lock.AcquireResult)2 LockInvocationKey (com.hazelcast.cp.internal.datastructures.lock.LockInvocationKey)2 LockService (com.hazelcast.cp.internal.datastructures.lock.LockService)2