use of com.scalar.db.exception.transaction.CrudException in project scalardb by scalar-labs.
the class DistributedTransactionIntegrationTestBase method populateRecords.
private void populateRecords() throws TransactionException {
DistributedTransaction transaction = manager.start();
IntStream.range(0, NUM_ACCOUNTS).forEach(i -> IntStream.range(0, NUM_TYPES).forEach(j -> {
Key partitionKey = new Key(ACCOUNT_ID, i);
Key clusteringKey = new Key(ACCOUNT_TYPE, j);
Put put = new Put(partitionKey, clusteringKey).forNamespace(namespace).forTable(TABLE).withIntValue(BALANCE, INITIAL_BALANCE).withIntValue(SOME_COLUMN, i * j);
try {
transaction.put(put);
} catch (CrudException e) {
throw new RuntimeException(e);
}
}));
transaction.commit();
}
use of com.scalar.db.exception.transaction.CrudException in project scalardb by scalar-labs.
the class JdbcTransaction method put.
@Override
public void put(Put put) throws CrudException {
put = copyAndSetTargetToIfNot(put);
// Ignore the condition in the put
if (put.getCondition().isPresent()) {
LOGGER.warn("ignoring the condition of the mutation: {}", put);
put.withCondition(null);
}
try {
jdbcService.put(put, connection);
} catch (SQLException e) {
throw createCrudException(e, "put operation failed");
} catch (ExecutionException e) {
throw new CrudException("put operation failed", e);
}
}
use of com.scalar.db.exception.transaction.CrudException in project scalardb by scalar-labs.
the class GrpcTwoPhaseCommitTransactionOnBidirectionalStream method scan.
public List<Result> scan(Scan scan) throws CrudException {
throwIfTransactionFinished();
ResponseOrError responseOrError = sendRequest(TwoPhaseCommitTransactionRequest.newBuilder().setScanRequest(ScanRequest.newBuilder().setScan(ProtoUtils.toScan(scan))).build());
throwIfErrorForCrud(responseOrError);
TableMetadata tableMetadata = getTableMetadata(scan);
return responseOrError.getResponse().getScanResponse().getResultList().stream().map(r -> ProtoUtils.toResult(r, tableMetadata)).collect(Collectors.toList());
}
use of com.scalar.db.exception.transaction.CrudException in project scalardb by scalar-labs.
the class JdbcTransactionIntegrationTest method populateRecords.
private void populateRecords() throws TransactionException {
JdbcTransaction transaction = manager.start();
IntStream.range(0, NUM_ACCOUNTS).forEach(i -> IntStream.range(0, NUM_TYPES).forEach(j -> {
Key partitionKey = new Key(ACCOUNT_ID, i);
Key clusteringKey = new Key(ACCOUNT_TYPE, j);
Put put = new Put(partitionKey, clusteringKey).forNamespace(NAMESPACE).forTable(TABLE).withValue(BALANCE, INITIAL_BALANCE);
try {
transaction.put(put);
} catch (CrudException e) {
throw new RuntimeException(e);
}
}));
transaction.commit();
}
Aggregations