Search in sources :

Example 1 with JournalRollbackRecordTX

use of org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX in project activemq-artemis by apache.

the class FileWrapperJournal method appendRollbackRecord.

@Override
public void appendRollbackRecord(long txID, boolean sync, IOCompletion callback) throws Exception {
    JournalInternalRecord rollbackRecord = new JournalRollbackRecordTX(txID);
    writeRecord(rollbackRecord, true, txID, true, callback);
}
Also used : JournalRollbackRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 2 with JournalRollbackRecordTX

use of org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX in project activemq-artemis by apache.

the class JournalImpl method appendRollbackRecord.

@Override
public void appendRollbackRecord(final long txID, final boolean sync, final IOCompletion callback) throws Exception {
    checkJournalIsLoaded();
    lineUpContext(callback);
    if (logger.isTraceEnabled()) {
        logger.trace("scheduling appendRollbackRecord::txID=" + txID);
    }
    final SimpleFuture<JournalTransaction> result = newSyncAndCallbackResult(sync, callback);
    appendExecutor.execute(new Runnable() {

        @Override
        public void run() {
            journalLock.readLock().lock();
            final JournalTransaction tx = transactions.remove(txID);
            try {
                if (logger.isTraceEnabled()) {
                    logger.trace("appendRollbackRecord::txID=" + txID);
                }
                if (tx == null) {
                    throw new IllegalStateException("Cannot find tx with id " + txID);
                }
                JournalInternalRecord rollbackRecord = new JournalRollbackRecordTX(txID);
                JournalFile usedFile = appendRecord(rollbackRecord, false, sync, tx, callback);
                tx.rollback(usedFile);
            } catch (Throwable e) {
                result.fail(e);
                logger.error("appendRollbackRecord:" + e, e);
                setErrorCondition(callback, tx, e);
            } finally {
                journalLock.readLock().unlock();
                result.set(tx);
            }
        }
    });
    JournalTransaction tx = result.get();
    if (tx != null) {
        tx.checkErrorCondition();
    }
}
Also used : JournalRollbackRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 3 with JournalRollbackRecordTX

use of org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX in project activemq-artemis by apache.

the class JournalCompactor method onReadRollbackRecord.

@Override
public void onReadRollbackRecord(final long transactionID) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("onReadRollbackRecord " + transactionID);
    }
    if (pendingTransactions.get(transactionID) != null) {
        // Sanity check, this should never happen
        throw new IllegalStateException("Inconsistency during compacting: RollbackRecord ID = " + transactionID + " for an already rolled back transaction during compacting");
    } else {
        JournalTransaction newTransaction = newTransactions.remove(transactionID);
        if (newTransaction != null) {
            JournalInternalRecord rollbackRecord = new JournalRollbackRecordTX(transactionID);
            checkSize(rollbackRecord.getEncodeSize());
            writeEncoder(rollbackRecord);
            newTransaction.rollback(currentFile);
        }
    }
}
Also used : JournalRollbackRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Aggregations

JournalInternalRecord (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)3 JournalRollbackRecordTX (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX)3