Search in sources :

Example 6 with TransactionToken

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

the class TransactionRemotingTest method testAbort.

@Test
public void testAbort() {
    TransactionToken txId = service.startTransaction();
    service.put(txId, new TableCellVal("sweep.priority", getSweepPriorityTableContents("foo")));
    service.abort(txId);
    service.commit(txId);
    txId = TransactionToken.autoCommit();
    RangeToken range = service.getRange(txId, 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 : TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

Example 7 with TransactionToken

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

the class TransactionRemotingTest method testRaw.

@Test
public void testRaw() throws JsonProcessingException {
    String tableName = "ns.my_table";
    service.createTable(tableName);
    TransactionToken txId = service.startTransaction();
    TableCellVal putArg = new TableCellVal(tableName, getSweepPriorityTableContents("foo"));
    String str = mapper.writeValueAsString(putArg);
    System.out.println(str);
    service.put(txId, putArg);
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal) Test(org.junit.Test)

Example 8 with TransactionToken

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

the class TransactionRemotingTest method testRaw2.

@Test
public void testRaw2() throws JsonProcessingException {
    String tableName = "ns.my_table";
    service.createTable(tableName);
    TransactionToken txId = service.startTransaction();
    Cell rawCell = Cell.create(new byte[] { 0, 1, 2 }, new byte[] { 3, 4, 5 });
    TableCellVal putArg = new TableCellVal(tableName, ImmutableMap.of(rawCell, new byte[] { 40, 0 }));
    service.put(txId, putArg);
    TableCell tableCell = new TableCell(tableName, ImmutableList.of(rawCell));
    service.getCells(txId, tableCell);
}
Also used : TableCell(com.palantir.atlasdb.api.TableCell) TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal) Cell(com.palantir.atlasdb.keyvalue.api.Cell) TableCell(com.palantir.atlasdb.api.TableCell) Test(org.junit.Test)

Example 9 with TransactionToken

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

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

the class TransactionRemotingTest method testGetRangeNone.

@Test
public void testGetRangeNone() {
    setupFooStatus1("sweep.priority");
    TransactionToken token = TransactionToken.autoCommit();
    RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[1], new byte[2], ImmutableList.<byte[]>of(), 10));
    Assert.assertTrue(Iterables.isEmpty(range.getResults().getResults()));
    Assert.assertNull(range.getNextRange());
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

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