use of com.scalar.db.exception.transaction.ValidationException in project scalardb by scalar-labs.
the class GrpcTwoPhaseCommitTransactionOnBidirectionalStream method throwIfErrorForValidation.
private void throwIfErrorForValidation(ResponseOrError responseOrError) throws ValidationException {
if (responseOrError.isError()) {
finished.set(true);
Throwable error = responseOrError.getError();
if (error instanceof Error) {
throw (Error) error;
}
throw new ValidationException("failed to validate", error);
}
TwoPhaseCommitTransactionResponse response = responseOrError.getResponse();
if (response.hasError()) {
TwoPhaseCommitTransactionResponse.Error error = response.getError();
if (error.getErrorCode() == ErrorCode.CONFLICT) {
throw new ValidationConflictException(error.getMessage());
}
throw new ValidationException(error.getMessage());
}
}
use of com.scalar.db.exception.transaction.ValidationException in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommit method validate.
@Override
public void validate() throws ValidationException {
checkStatus("The transaction is not prepared", Status.PREPARED);
try {
commit.preCommitValidation(crud.getSnapshot(), false);
status = Status.VALIDATED;
} catch (CommitConflictException e) {
status = Status.VALIDATION_FAILED;
throw new ValidationConflictException("validation failed", e);
} catch (CommitException e) {
status = Status.VALIDATION_FAILED;
throw new ValidationException("validation failed", e);
} catch (UnknownTransactionStatusException e) {
// Should not be reached here because CommitHandler.prepare() with abortIfError=false won't
// throw UnknownTransactionStatusException
}
}
Aggregations