- @Deprecated
- public ListenableFuture<Void> submit(long timeout, TimeUnit timeUnit) {
- if (wasSubmittedOrCancelled.get()) {
- String msg = "Transaction was already submitted or canceled!";
- LOG.error(msg);
- return Futures.immediateFailedFuture(new IllegalStateException(msg));
- }
-
- LOG.debug("Transaction submitted. Lock: {}", deviceLock);
- wasSubmittedOrCancelled.set(true);
- ListenableFuture<Void> future =
- Futures.withTimeout(rwTx.submit(), timeout, timeUnit, scheduledExecutorService);
-
- Futures.addCallback(future, new FutureCallback<Void>() {
- @Override
- public void onSuccess(@Nullable Void result) {
- LOG.debug("Transaction with lock {} successfully submitted.", deviceLock);
- afterClose();
- }
-
- @Override
- public void onFailure(Throwable throwable) {
- LOG.error("Device transaction submit failed or submit took longer than {} {}! Unlocking device.",
- timeout, timeUnit, throwable);
- afterClose();
- }
- }, scheduledExecutorService);
- return future;
- }
-