private boolean doAwait(long time, TimeUnit unit, long threadId) throws InterruptedException { try { long timeout = unit.toMillis(time); Data key = lockProxy.getKeyData(); AwaitOperation op = new AwaitOperation(namespace, key, threadId, timeout, conditionId); Future f = invoke(op); return Boolean.TRUE.equals(f.get()); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
private boolean doAwait(long time, TimeUnit unit, long threadId) throws InterruptedException { try { long timeout = unit.toMillis(time); Data key = lockProxy.getKeyData(); AwaitOperation op = new AwaitOperation(namespace, key, threadId, timeout, conditionId); Future f = invoke(op); return Boolean.TRUE.equals(f.get()); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
@Override public boolean tryAcquire(int permits, long timeout, TimeUnit unit) throws InterruptedException { checkNotNegative(permits, "permits can't be negative"); try { Operation operation = new AcquireOperation(name, permits, unit.toMillis(timeout)) .setPartitionId(partitionId); Future<Boolean> future = invokeOnPartition(operation); return future.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
@Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { checkNotNull(unit, "unit can't be null"); Operation op = new AwaitOperation(name, unit.toMillis(timeout)) .setPartitionId(partitionId); Future<Boolean> f = invokeOnPartition(op); try { return f.get(); } catch (ExecutionException e) { throw rethrowAllowInterrupted(e); } }
@Override public boolean tryAcquire(int permits, long timeout, TimeUnit unit) throws InterruptedException { checkNotNegative(permits, "permits can't be negative"); try { Operation operation = new AcquireOperation(name, permits, unit.toMillis(timeout)) .setPartitionId(partitionId); Future<Boolean> future = invokeOnPartition(operation); return future.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
@Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { checkNotNull(unit, "unit can't be null"); Operation op = new AwaitOperation(name, unit.toMillis(timeout)) .setPartitionId(partitionId); Future<Boolean> f = invokeOnPartition(op); try { return f.get(); } catch (ExecutionException e) { throw rethrowAllowInterrupted(e); } }
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage, int partitionId) throws InterruptedException { try { final Future future = new ClientInvocation(getClient(), clientMessage, getName(), partitionId).invoke(); return (T) future.get(); } catch (Exception e) { throw ExceptionUtil.rethrowAllowInterrupted(e); } }
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage, int partitionId) throws InterruptedException { try { final Future future = new ClientInvocation(getClient(), clientMessage, getName(), partitionId).invoke(); return (T) future.get(); } catch (Exception e) { throw ExceptionUtil.rethrowAllowInterrupted(e); } }
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage, long invocationTimeoutSeconds) throws InterruptedException { try { ClientInvocation clientInvocation = new ClientInvocation(getClient(), clientMessage, getName(), partitionId); clientInvocation.setInvocationTimeoutMillis(invocationTimeoutSeconds); final Future future = clientInvocation.invoke(); return (T) future.get(); } catch (Exception e) { throw ExceptionUtil.rethrowAllowInterrupted(e); } } }
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage, long invocationTimeoutSeconds) throws InterruptedException { try { ClientInvocation clientInvocation = new ClientInvocation(getClient(), clientMessage, getName(), partitionId); clientInvocation.setInvocationTimeoutMillis(invocationTimeoutSeconds); final Future future = clientInvocation.invoke(); return (T) future.get(); } catch (Exception e) { throw ExceptionUtil.rethrowAllowInterrupted(e); } } }
@Override public E readOne(long sequence) throws InterruptedException { checkSequence(sequence); Operation op = new ReadOneOperation(name, sequence) .setPartitionId(partitionId); InternalCompletableFuture<E> f = invokeOnPartition(op); try { return f.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
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); } }
@Override public void acquire(int permits) throws InterruptedException { checkNotNegative(permits, "permits can't be negative"); try { Operation operation = new AcquireOperation(name, permits, -1) .setPartitionId(partitionId); InternalCompletableFuture<Object> future = invokeOnPartition(operation); future.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
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); } }
@Override public E readOne(long sequence) throws InterruptedException { checkSequence(sequence); Operation op = new ReadOneOperation(name, sequence) .setPartitionId(partitionId); InternalCompletableFuture<E> f = invokeOnPartition(op); try { return f.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
@Override public void acquire(int permits) throws InterruptedException { checkNotNegative(permits, "permits can't be negative"); try { Operation operation = new AcquireOperation(name, permits, -1) .setPartitionId(partitionId); InternalCompletableFuture<Object> future = invokeOnPartition(operation); future.get(); } catch (Throwable t) { throw rethrowAllowInterrupted(t); } }
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); } }
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); } }