Search in sources :

Example 1 with TransactionException

use of com.cinchapi.concourse.TransactionException in project concourse by cinchapi.

the class ConcourseAccount method debit.

@Override
public boolean debit(String charge, double amount) {
    Preconditions.checkArgument(amount > 0);
    Concourse concourse = Constants.CONCOURSE_CONNECTIONS.request();
    try {
        concourse.stage();
        if (withdrawImpl(concourse, amount)) {
            // By using the #add method, we can store multiple charges in
            // the record at the same time
            concourse.add("charges", charge, id);
            return concourse.commit();
        } else {
            concourse.abort();
            return false;
        }
    } catch (TransactionException e) {
        concourse.abort();
        return false;
    } finally {
        Constants.CONCOURSE_CONNECTIONS.release(concourse);
    }
}
Also used : TransactionException(com.cinchapi.concourse.TransactionException) Concourse(com.cinchapi.concourse.Concourse)

Aggregations

Concourse (com.cinchapi.concourse.Concourse)1 TransactionException (com.cinchapi.concourse.TransactionException)1