Search in sources :

Example 1 with RollbackException

use of com.persistit.exception.RollbackException in project titan by thinkaurelius.

the class PersistitTransaction method commit.

@Override
public void commit() throws StorageException {
    synchronized (this) {
        if (null == sessionId) {
            // Already closed
            log.warn("Can't commit {}: already closed, trace to redundant commit follows", this, new IllegalStateException("redundant commit"));
            return;
        }
        super.commit();
        assign();
        Transaction tx = db.getTransaction();
        int retries = 3;
        try {
            if (tx.isActive() && !tx.isRollbackPending()) {
                int i = 0;
                while (true) {
                    try {
                        tx.commit(Transaction.CommitPolicy.HARD);
                        tx.end();
                        break;
                    } catch (RollbackException ex) {
                        if (i++ >= retries) {
                            throw ex;
                        }
                    }
                }
                close();
            }
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        }
    }
}
Also used : AbstractStoreTransaction(com.thinkaurelius.titan.diskstorage.common.AbstractStoreTransaction) Transaction(com.persistit.Transaction) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException) RollbackException(com.persistit.exception.RollbackException)

Aggregations

Transaction (com.persistit.Transaction)1 PersistitException (com.persistit.exception.PersistitException)1 RollbackException (com.persistit.exception.RollbackException)1 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)1 AbstractStoreTransaction (com.thinkaurelius.titan.diskstorage.common.AbstractStoreTransaction)1