Search in sources :

Example 1 with CommitConflictException

use of com.scalar.db.exception.transaction.CommitConflictException in project scalardb by scalar-labs.

the class TwoPhaseConsensusCommit method prepare.

@Override
public void prepare() throws PreparationException {
    checkStatus("The transaction is not active", Status.ACTIVE);
    beforePrepareHook.run();
    try {
        commit.prepare(crud.getSnapshot(), false);
        status = Status.PREPARED;
    } catch (CommitConflictException e) {
        status = Status.PREPARE_FAILED;
        throw new PreparationConflictException("prepare failed", e);
    } catch (CommitException e) {
        status = Status.PREPARE_FAILED;
        throw new PreparationException("prepare failed", e);
    } catch (UnknownTransactionStatusException e) {
    // Should not be reached here because CommitHandler.prepare() with abortIfError=false won't
    // throw UnknownTransactionStatusException
    }
}
Also used : CommitConflictException(com.scalar.db.exception.transaction.CommitConflictException) CommitException(com.scalar.db.exception.transaction.CommitException) PreparationException(com.scalar.db.exception.transaction.PreparationException) UnknownTransactionStatusException(com.scalar.db.exception.transaction.UnknownTransactionStatusException) PreparationConflictException(com.scalar.db.exception.transaction.PreparationConflictException)

Example 2 with CommitConflictException

use of com.scalar.db.exception.transaction.CommitConflictException 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
    }
}
Also used : CommitConflictException(com.scalar.db.exception.transaction.CommitConflictException) CommitException(com.scalar.db.exception.transaction.CommitException) ValidationException(com.scalar.db.exception.transaction.ValidationException) UnknownTransactionStatusException(com.scalar.db.exception.transaction.UnknownTransactionStatusException) ValidationConflictException(com.scalar.db.exception.transaction.ValidationConflictException)

Aggregations

CommitConflictException (com.scalar.db.exception.transaction.CommitConflictException)2 CommitException (com.scalar.db.exception.transaction.CommitException)2 UnknownTransactionStatusException (com.scalar.db.exception.transaction.UnknownTransactionStatusException)2 PreparationConflictException (com.scalar.db.exception.transaction.PreparationConflictException)1 PreparationException (com.scalar.db.exception.transaction.PreparationException)1 ValidationConflictException (com.scalar.db.exception.transaction.ValidationConflictException)1 ValidationException (com.scalar.db.exception.transaction.ValidationException)1