@Override public void get(long firstBlock, long numBlocks, OutputStream destination) { if (parent.isUncommitted()) { loadNBlocksToOutputStream(parent, id, firstBlock, numBlocks, destination); } else { txnMgr.runTaskReadOnly(txn -> { loadNBlocksToOutputStream(txn, id, firstBlock, numBlocks, destination); return null; }); } }
@Override public boolean isUncommitted() { return delegate().isUncommitted(); }
protected final <T, E extends Exception> T runTaskThrowOnConflict(TransactionTask<T, E> task, Transaction txn) throws E, TransactionFailedException { checkOpen(); try { T ret = task.execute(txn); if (txn.isUncommitted()) { txn.commit(); } return ret; } finally { // Make sure that anyone trying to retain a reference to this transaction // will not be able to use it. if (txn.isUncommitted()) { txn.abort(); } } }
@Override public void get(long firstBlock, long numBlocks, OutputStream destination) { if (parent.isUncommitted()) { loadNBlocksToOutputStream(parent, id, firstBlock, numBlocks, destination); } else { txnMgr.runTaskReadOnly(txn -> { loadNBlocksToOutputStream(txn, id, firstBlock, numBlocks, destination); return null; }); } }
@Override public boolean isUncommitted() { return delegate().isUncommitted(); }
protected final <T, E extends Exception> T runTaskThrowOnConflict(TransactionTask<T, E> task, Transaction txn) throws E, TransactionFailedException { checkOpen(); try { T ret = task.execute(txn); if (txn.isUncommitted()) { txn.commit(); } return ret; } finally { // Make sure that anyone trying to retain a reference to this transaction // will not be able to use it. if (txn.isUncommitted()) { txn.abort(); } } }