Search in sources :

Example 1 with RawTransaction

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;
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction)

Example 2 with RawTransaction

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);
    }
}
Also used : RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction)

Example 3 with RawTransaction

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);
    }
}
Also used : RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction)

Example 4 with RawTransaction

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);
    }
}
Also used : TableCellVal(com.palantir.atlasdb.api.TableCellVal) TableRowResult(com.palantir.atlasdb.api.TableRowResult) ColumnMetadataDescription(com.palantir.atlasdb.table.description.ColumnMetadataDescription) ConflictHandler(com.palantir.atlasdb.transaction.api.ConflictHandler) BatchingVisitable(com.palantir.common.base.BatchingVisitable) ColumnValueDescription(com.palantir.atlasdb.table.description.ColumnValueDescription) Inject(javax.inject.Inject) RangeToken(com.palantir.atlasdb.api.RangeToken) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) RuntimeTransactionTask(com.palantir.atlasdb.transaction.api.RuntimeTransactionTask) BatchingVisitables(com.palantir.common.base.BatchingVisitables) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TableRange(com.palantir.atlasdb.api.TableRange) TableMetadataPersistence(com.palantir.atlasdb.protos.generated.TableMetadataPersistence) TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) ImmutableSet(com.google.common.collect.ImmutableSet) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Collection(java.util.Collection) NameComponentDescription(com.palantir.atlasdb.table.description.NameComponentDescription) Set(java.util.Set) PreCommitConditions(com.palantir.atlasdb.transaction.impl.PreCommitConditions) UUID(java.util.UUID) RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction) Collectors(java.util.stream.Collectors) TableCell(com.palantir.atlasdb.api.TableCell) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) TimeUnit(java.util.concurrent.TimeUnit) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) List(java.util.List) TxTask(com.palantir.atlasdb.transaction.impl.TxTask) TransactionToken(com.palantir.atlasdb.api.TransactionToken) ValueType(com.palantir.atlasdb.table.description.ValueType) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) AtlasDbService(com.palantir.atlasdb.api.AtlasDbService) Preconditions(com.google.common.base.Preconditions) NameMetadataDescription(com.palantir.atlasdb.table.description.NameMetadataDescription) CacheBuilder(com.google.common.cache.CacheBuilder) Cache(com.google.common.cache.Cache) DynamicColumnDescription(com.palantir.atlasdb.table.description.DynamicColumnDescription) RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction)

Example 5 with RawTransaction

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);
    }
}
Also used : TableCellVal(com.palantir.atlasdb.api.TableCellVal) TableRowResult(com.palantir.atlasdb.api.TableRowResult) ColumnMetadataDescription(com.palantir.atlasdb.table.description.ColumnMetadataDescription) ConflictHandler(com.palantir.atlasdb.transaction.api.ConflictHandler) BatchingVisitable(com.palantir.common.base.BatchingVisitable) ColumnValueDescription(com.palantir.atlasdb.table.description.ColumnValueDescription) Inject(javax.inject.Inject) RangeToken(com.palantir.atlasdb.api.RangeToken) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) RuntimeTransactionTask(com.palantir.atlasdb.transaction.api.RuntimeTransactionTask) BatchingVisitables(com.palantir.common.base.BatchingVisitables) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TableRange(com.palantir.atlasdb.api.TableRange) TableMetadataPersistence(com.palantir.atlasdb.protos.generated.TableMetadataPersistence) TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) ImmutableSet(com.google.common.collect.ImmutableSet) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Collection(java.util.Collection) NameComponentDescription(com.palantir.atlasdb.table.description.NameComponentDescription) Set(java.util.Set) PreCommitConditions(com.palantir.atlasdb.transaction.impl.PreCommitConditions) UUID(java.util.UUID) RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction) Collectors(java.util.stream.Collectors) TableCell(com.palantir.atlasdb.api.TableCell) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) TimeUnit(java.util.concurrent.TimeUnit) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) List(java.util.List) TxTask(com.palantir.atlasdb.transaction.impl.TxTask) TransactionToken(com.palantir.atlasdb.api.TransactionToken) ValueType(com.palantir.atlasdb.table.description.ValueType) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) AtlasDbService(com.palantir.atlasdb.api.AtlasDbService) Preconditions(com.google.common.base.Preconditions) NameMetadataDescription(com.palantir.atlasdb.table.description.NameMetadataDescription) CacheBuilder(com.google.common.cache.CacheBuilder) Cache(com.google.common.cache.Cache) DynamicColumnDescription(com.palantir.atlasdb.table.description.DynamicColumnDescription) RawTransaction(com.palantir.atlasdb.transaction.impl.RawTransaction)

Aggregations

RawTransaction (com.palantir.atlasdb.transaction.impl.RawTransaction)5 TransactionToken (com.palantir.atlasdb.api.TransactionToken)3 Preconditions (com.google.common.base.Preconditions)2 Cache (com.google.common.cache.Cache)2 CacheBuilder (com.google.common.cache.CacheBuilder)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 AtlasDbService (com.palantir.atlasdb.api.AtlasDbService)2 RangeToken (com.palantir.atlasdb.api.RangeToken)2 TableCell (com.palantir.atlasdb.api.TableCell)2 TableCellVal (com.palantir.atlasdb.api.TableCellVal)2 TableRange (com.palantir.atlasdb.api.TableRange)2 TableRowResult (com.palantir.atlasdb.api.TableRowResult)2 TableRowSelection (com.palantir.atlasdb.api.TableRowSelection)2 Cell (com.palantir.atlasdb.keyvalue.api.Cell)2 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)2 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)2 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)2 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)2 TableMetadataPersistence (com.palantir.atlasdb.protos.generated.TableMetadataPersistence)2