Search in sources :

Example 21 with JournalInternalRecord

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

the class FileWrapperJournal method appendPrepareRecord.

@Override
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync, IOCompletion callback) throws Exception {
    JournalInternalRecord prepareRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.PREPARE, txID, transactionData);
    writeRecord(prepareRecord, true, txID, false, callback);
}
Also used : JournalCompleteRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalCompleteRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 22 with JournalInternalRecord

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

the class FileWrapperJournal method appendDeleteRecord.

@Override
public void appendDeleteRecord(long id, boolean sync, IOCompletion callback) throws Exception {
    JournalInternalRecord deleteRecord = new JournalDeleteRecord(id);
    writeRecord(deleteRecord, false, -1, false, callback);
}
Also used : JournalDeleteRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 23 with JournalInternalRecord

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

the class JournalCompactor method onReadPrepareRecord.

@Override
public void onReadPrepareRecord(final long transactionID, final byte[] extraData, final int numberOfRecords) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("onReadPrepareRecord " + transactionID);
    }
    if (pendingTransactions.get(transactionID) != null) {
        JournalTransaction newTransaction = getNewJournalTransaction(transactionID);
        JournalInternalRecord prepareRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.PREPARE, transactionID, new ByteArrayEncoding(extraData));
        checkSize(prepareRecord.getEncodeSize());
        writeEncoder(prepareRecord, newTransaction.getCounter(currentFile));
        newTransaction.prepare(currentFile);
    }
}
Also used : ByteArrayEncoding(org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding) JournalCompleteRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalCompleteRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 24 with JournalInternalRecord

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

the class JournalCompactor method onReadAddRecord.

// JournalReaderCallback implementation -------------------------------------------
@Override
public void onReadAddRecord(final RecordInfo info) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("Read Record " + info);
    }
    if (lookupRecord(info.id)) {
        JournalInternalRecord addRecord = new JournalAddRecord(true, info.id, info.getUserRecordType(), EncoderPersister.getInstance(), new ByteArrayEncoding(info.data));
        addRecord.setCompactCount((short) (info.compactCount + 1));
        checkSize(addRecord.getEncodeSize(), info.compactCount);
        writeEncoder(addRecord);
        newRecords.put(info.id, new JournalRecord(currentFile, addRecord.getEncodeSize()));
    }
}
Also used : JournalAddRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord) ByteArrayEncoding(org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 25 with JournalInternalRecord

use of org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord 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)27 ByteArrayEncoding (org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding)7 JournalAddRecord (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord)7 IOException (java.io.IOException)6 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)6 JournalAddRecordTX (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX)6 JournalCompleteRecordTX (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalCompleteRecordTX)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 JournalDeleteRecordTX (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecordTX)3 JournalRollbackRecordTX (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalRollbackRecordTX)3 JournalDeleteRecord (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalDeleteRecord)2 ByteBuffer (java.nio.ByteBuffer)1 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)1 SequentialFile (org.apache.activemq.artemis.core.io.SequentialFile)1