Search in sources :

Example 1 with LockOperation

use of com.hazelcast.concurrent.lock.operations.LockOperation in project hazelcast by hazelcast.

the class LockProxySupport method lockInterruptly.

public void lockInterruptly(NodeEngine nodeEngine, Data key, long leaseTime) throws InterruptedException {
    leaseTime = getLeaseTime(leaseTime);
    LockOperation operation = new LockOperation(namespace, key, getThreadId(), leaseTime, -1);
    InternalCompletableFuture<Boolean> f = invoke(nodeEngine, operation, key);
    try {
        f.get();
    } catch (Throwable t) {
        throw rethrowAllowInterrupted(t);
    }
}
Also used : LockOperation(com.hazelcast.concurrent.lock.operations.LockOperation)

Example 2 with LockOperation

use of com.hazelcast.concurrent.lock.operations.LockOperation in project hazelcast by hazelcast.

the class LockProxySupport method lock.

public void lock(NodeEngine nodeEngine, Data key, long leaseTime) {
    leaseTime = getLeaseTime(leaseTime);
    LockOperation operation = new LockOperation(namespace, key, getThreadId(), leaseTime, -1);
    InternalCompletableFuture<Boolean> f = invoke(nodeEngine, operation, key);
    if (!f.join()) {
        throw new IllegalStateException();
    }
}
Also used : LockOperation(com.hazelcast.concurrent.lock.operations.LockOperation)

Example 3 with LockOperation

use of com.hazelcast.concurrent.lock.operations.LockOperation in project hazelcast by hazelcast.

the class LockProxySupport method tryLock.

public boolean tryLock(NodeEngine nodeEngine, Data key, long timeout, TimeUnit timeunit, long leaseTime, TimeUnit leaseTimeunit) throws InterruptedException {
    long timeoutInMillis = getTimeInMillis(timeout, timeunit);
    long leaseTimeInMillis = getTimeInMillis(leaseTime, leaseTimeunit);
    LockOperation operation = new LockOperation(namespace, key, getThreadId(), leaseTimeInMillis, timeoutInMillis);
    InternalCompletableFuture<Boolean> f = invoke(nodeEngine, operation, key);
    try {
        return f.get();
    } catch (Throwable t) {
        throw rethrowAllowInterrupted(t);
    }
}
Also used : LockOperation(com.hazelcast.concurrent.lock.operations.LockOperation)

Aggregations

LockOperation (com.hazelcast.concurrent.lock.operations.LockOperation)3