Search in sources :

Example 41 with TableReference

use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.

the class SnapshotTransaction method throwIfConflictOnCommit.

/**
 * Make sure we have all the rows we are checking already locked before calling this.
 */
protected void throwIfConflictOnCommit(LockToken commitLocksToken, TransactionService transactionService) throws TransactionConflictException {
    for (Entry<TableReference, ConcurrentNavigableMap<Cell, byte[]>> write : writesByTable.entrySet()) {
        ConflictHandler conflictHandler = getConflictHandlerForTable(write.getKey());
        throwIfWriteAlreadyCommitted(write.getKey(), write.getValue(), conflictHandler, commitLocksToken, transactionService);
    }
}
Also used : ConflictHandler(com.palantir.atlasdb.transaction.api.ConflictHandler) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap)

Example 42 with TableReference

use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.

the class SerializableTransaction method verifyRows.

private void verifyRows(Transaction ro) {
    for (Map.Entry<TableReference, Set<RowRead>> tableAndRowsEntry : rowsRead.entrySet()) {
        TableReference table = tableAndRowsEntry.getKey();
        Set<RowRead> rows = tableAndRowsEntry.getValue();
        ConcurrentNavigableMap<Cell, byte[]> readsForTable = getReadsForTable(table);
        Multimap<ColumnSelection, byte[]> rowsReadByColumns = Multimaps.newSortedSetMultimap(Maps.newHashMap(), () -> Sets.newTreeSet(UnsignedBytes.lexicographicalComparator()));
        for (RowRead r : rows) {
            rowsReadByColumns.putAll(r.cols, r.rows);
        }
        for (ColumnSelection cols : rowsReadByColumns.keySet()) {
            verifyColumns(ro, table, readsForTable, rowsReadByColumns, cols);
        }
    }
}
Also used : ColumnSelection(com.palantir.atlasdb.keyvalue.api.ColumnSelection) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

Example 43 with TableReference

use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.

the class SpecificTableSweeper method runOnceAndSaveResults.

void runOnceAndSaveResults(TableToSweep tableToSweep, SweepBatchConfig batchConfig) {
    TableReference tableRef = tableToSweep.getTableRef();
    byte[] startRow = tableToSweep.getStartRow();
    SweepResults results = runOneIteration(tableRef, startRow, batchConfig);
    processSweepResults(tableToSweep, results);
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults)

Example 44 with TableReference

use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.

the class KeyValueServiceScrubberStoreTest method testMultipleEntryStore.

@Test
public void testMultipleEntryStore() {
    Cell cell1 = Cell.create(new byte[] { 1, 2, 3 }, new byte[] { 4, 5, 6 });
    Cell cell2 = Cell.create(new byte[] { 7, 8, 9 }, new byte[] { 4, 5, 6 });
    Cell cell3 = Cell.create(new byte[] { 1, 2, 3 }, new byte[] { 7, 8, 9 });
    TableReference ref1 = TableReference.fromString("foo.bar");
    TableReference ref2 = TableReference.fromString("foo.baz");
    long timestamp1 = 10;
    long timestamp2 = 20;
    scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell1, ref1, cell2, ref1), timestamp1, 1000);
    scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell1, ref1, cell3, ref2), timestamp2, 1000);
    Assert.assertEquals(ImmutableList.of(ImmutableSortedMap.of(timestamp1, ImmutableMultimap.of(ref1, cell2), timestamp2, ImmutableMultimap.of(ref2, cell3, ref1, cell1))), getScrubQueue());
    scrubStore.markCellsAsScrubbed(ImmutableMap.of(ref2, ImmutableMultimap.of(cell3, timestamp2), ref1, ImmutableMultimap.of(cell1, timestamp1, cell1, timestamp2)), 1000);
    Assert.assertEquals(ImmutableList.of(ImmutableSortedMap.of(timestamp1, ImmutableMultimap.of(ref1, cell2))), getScrubQueue());
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Test(org.junit.Test)

Example 45 with TableReference

use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.

the class KeyValueServiceScrubberStoreTest method testSingleEntryStore.

@Test
public void testSingleEntryStore() {
    Cell cell = Cell.create(new byte[] { 1, 2, 3 }, new byte[] { 4, 5, 6 });
    TableReference ref = TableReference.fromString("foo.bar");
    long timestamp = 10;
    scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell, ref), timestamp, 1000);
    Assert.assertEquals(ImmutableList.of(ImmutableSortedMap.of(timestamp, ImmutableMultimap.of(ref, cell))), getScrubQueue());
    scrubStore.markCellsAsScrubbed(ImmutableMap.of(ref, ImmutableMultimap.of(cell, timestamp)), 1000);
    Assert.assertEquals(ImmutableList.of(), getScrubQueue());
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Test(org.junit.Test)

Aggregations

TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)112 Cell (com.palantir.atlasdb.keyvalue.api.Cell)41 Test (org.junit.Test)41 Map (java.util.Map)17 ImmutableMap (com.google.common.collect.ImmutableMap)13 Multimap (com.google.common.collect.Multimap)13 Entry (java.util.Map.Entry)13 Set (java.util.Set)13 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)12 Value (com.palantir.atlasdb.keyvalue.api.Value)12 Collection (java.util.Collection)12 List (java.util.List)12 ImmutableSet (com.google.common.collect.ImmutableSet)11 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)11 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)11 SortedMap (java.util.SortedMap)11 Lists (com.google.common.collect.Lists)10 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)10 Sets (com.google.common.collect.Sets)9 InsufficientConsistencyException (com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException)9