use of com.palantir.atlasdb.transaction.api.ConflictHandler 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);
}
}
use of com.palantir.atlasdb.transaction.api.ConflictHandler in project atlasdb by palantir.
the class SnapshotTransaction method getLocksForWrites.
protected Set<LockDescriptor> getLocksForWrites() {
Set<LockDescriptor> result = Sets.newHashSet();
Iterable<TableReference> allTables = IterableUtils.append(writesByTable.keySet(), TransactionConstants.TRANSACTION_TABLE);
for (TableReference tableRef : allTables) {
if (tableRef.equals(TransactionConstants.TRANSACTION_TABLE)) {
result.add(AtlasRowLockDescriptor.of(TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(getStartTimestamp())));
continue;
}
ConflictHandler conflictHandler = getConflictHandlerForTable(tableRef);
if (conflictHandler == ConflictHandler.RETRY_ON_WRITE_WRITE_CELL) {
for (Cell cell : getLocalWrites(tableRef).keySet()) {
result.add(AtlasCellLockDescriptor.of(tableRef.getQualifiedName(), cell.getRowName(), cell.getColumnName()));
}
} else if (conflictHandler != ConflictHandler.IGNORE_ALL) {
Cell lastCell = null;
for (Cell cell : getLocalWrites(tableRef).keySet()) {
if (lastCell == null || !Arrays.equals(lastCell.getRowName(), cell.getRowName())) {
result.add(AtlasRowLockDescriptor.of(tableRef.getQualifiedName(), cell.getRowName()));
}
lastCell = cell;
}
}
}
return result;
}
Aggregations