Search in sources :

Example 11 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testGetCellsNone.

@Test
public void testGetCellsNone() {
    setupFooStatus1("sweep.priority");
    TransactionToken txId = service.startTransaction();
    TableCellVal badCells = service.getCells(txId, new TableCell("sweep.priority", ImmutableList.of(Cell.create(new byte[1], SweepPriorityTable.SweepPriorityNamedColumn.CELLS_EXAMINED.getShortName()))));
    Assert.assertTrue(badCells.getResults().isEmpty());
}
Also used : TableCell(com.palantir.atlasdb.api.TableCell) TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal) Test(org.junit.Test)

Example 12 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testDelete.

@Test
public void testDelete() {
    setupFooStatus1("sweep.priority");
    Map<Cell, byte[]> contents = getSweepPriorityTableContents("foo");
    TransactionToken token = TransactionToken.autoCommit();
    service.delete(token, new TableCell("sweep.priority", contents.keySet()));
    RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[0], new byte[0], ImmutableList.<byte[]>of(), 10));
    Assert.assertTrue(Iterables.isEmpty(range.getResults().getResults()));
    Assert.assertNull(range.getNextRange());
}
Also used : TableCell(com.palantir.atlasdb.api.TableCell) TransactionToken(com.palantir.atlasdb.api.TransactionToken) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Cell(com.palantir.atlasdb.keyvalue.api.Cell) TableCell(com.palantir.atlasdb.api.TableCell) Test(org.junit.Test)

Example 13 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method setupFooStatus1.

private void setupFooStatus1(String table) {
    TransactionToken txId = service.startTransaction();
    service.put(txId, new TableCellVal(table, getSweepPriorityTableContents("foo")));
    service.commit(txId);
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal)

Example 14 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method setupMultipleValues.

private void setupMultipleValues() {
    TransactionToken txId = service.startTransaction();
    service.put(txId, new TableCellVal("sweep.priority", getSweepPriorityTableContents("foo")));
    service.put(txId, new TableCellVal("sweep.priority", getSweepPriorityTableContents("bar")));
    service.put(txId, new TableCellVal("sweep.priority", getSweepPriorityTableContents("baz")));
    service.commit(txId);
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal)

Example 15 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken 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)

Aggregations

TransactionToken (com.palantir.atlasdb.api.TransactionToken)16 Test (org.junit.Test)11 TableCellVal (com.palantir.atlasdb.api.TableCellVal)9 RangeToken (com.palantir.atlasdb.api.RangeToken)7 TableRange (com.palantir.atlasdb.api.TableRange)7 TableCell (com.palantir.atlasdb.api.TableCell)6 Cell (com.palantir.atlasdb.keyvalue.api.Cell)5 TableRowResult (com.palantir.atlasdb.api.TableRowResult)4 TableRowSelection (com.palantir.atlasdb.api.TableRowSelection)4 RawTransaction (com.palantir.atlasdb.transaction.impl.RawTransaction)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 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