use of com.palantir.atlasdb.transaction.impl.RawTransaction in project atlasdb by palantir.
the class AtlasDbServiceImpl method startTransaction.
@Override
public TransactionToken startTransaction() {
String id = UUID.randomUUID().toString();
TransactionToken token = new TransactionToken(id);
RawTransaction tx = txManager.setupRunTaskWithConditionThrowOnConflict(PreCommitConditions.NO_OP);
transactions.put(token, tx);
return token;
}
use of com.palantir.atlasdb.transaction.impl.RawTransaction in project atlasdb by palantir.
the class AtlasDbServiceImpl method runReadOnly.
private <T> T runReadOnly(TransactionToken token, RuntimeTransactionTask<T> task) {
if (token.shouldAutoCommit()) {
return txManager.runTaskWithRetry(task);
} else {
RawTransaction tx = transactions.getIfPresent(token);
Preconditions.checkNotNull(tx, "The given transaction does not exist.");
return task.execute(tx);
}
}
use of com.palantir.atlasdb.transaction.impl.RawTransaction in project atlasdb by palantir.
the class AtlasDbServiceImpl method runWithRetry.
private <T> T runWithRetry(TransactionToken token, RuntimeTransactionTask<T> task) {
if (token.shouldAutoCommit()) {
return txManager.runTaskWithRetry(task);
} else {
RawTransaction tx = transactions.getIfPresent(token);
Preconditions.checkNotNull(tx, "The given transaction does not exist.");
return task.execute(tx);
}
}
use of com.palantir.atlasdb.transaction.impl.RawTransaction in project atlasdb by palantir.
the class AtlasDbServiceImpl method abort.
@Override
public void abort(TransactionToken token) {
RawTransaction tx = transactions.getIfPresent(token);
if (tx != null) {
txManager.finishRunTaskWithLockThrowOnConflict(tx, (TxTask) transaction -> {
transaction.abort();
return null;
});
transactions.invalidate(token);
}
}
use of com.palantir.atlasdb.transaction.impl.RawTransaction in project atlasdb by palantir.
the class AtlasDbServiceImpl method commit.
@Override
public void commit(TransactionToken token) {
RawTransaction tx = transactions.getIfPresent(token);
if (tx != null) {
txManager.finishRunTaskWithLockThrowOnConflict(tx, (TxTask) transaction -> null);
transactions.invalidate(token);
}
}
Aggregations