Search in sources :

Example 1 with JournalAddRecordTX

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

the class JournalImpl method appendUpdateRecordTransactional.

@Override
public void appendUpdateRecordTransactional(final long txID, final long id, final byte recordType, final Persister persister, final Object record) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("scheduling appendUpdateRecordTransactional::txID=" + txID + ",id=" + id + ", userRecordType=" + recordType + ", record = " + record);
    }
    checkJournalIsLoaded();
    appendExecutor.execute(new Runnable() {

        @Override
        public void run() {
            journalLock.readLock().lock();
            final JournalTransaction tx = getTransactionInfo(txID);
            try {
                tx.checkErrorCondition();
                JournalInternalRecord updateRecordTX = new JournalAddRecordTX(false, txID, id, recordType, persister, record);
                JournalFile usedFile = appendRecord(updateRecordTX, false, false, tx, null);
                if (logger.isTraceEnabled()) {
                    logger.trace("appendUpdateRecordTransactional::txID=" + txID + ",id=" + id + ", userRecordType=" + recordType + ", record = " + record + ", usedFile = " + usedFile);
                }
                tx.addPositive(usedFile, id, updateRecordTX.getEncodeSize());
            } catch (Exception e) {
                logger.error("appendUpdateRecordTransactional:" + e.getMessage(), e);
                setErrorCondition(null, tx, e);
            } finally {
                journalLock.readLock().unlock();
            }
        }
    });
}
Also used : JournalAddRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 2 with JournalAddRecordTX

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

the class JournalImpl method appendAddRecordTransactional.

@Override
public void appendAddRecordTransactional(final long txID, final long id, final byte recordType, final Persister persister, final Object record) throws Exception {
    checkJournalIsLoaded();
    if (logger.isTraceEnabled()) {
        logger.trace("scheduling appendAddRecordTransactional:txID=" + txID + ",id=" + id + ", userRecordType=" + recordType + ", record = " + record);
    }
    appendExecutor.execute(new Runnable() {

        @Override
        public void run() {
            journalLock.readLock().lock();
            final JournalTransaction tx = getTransactionInfo(txID);
            try {
                if (tx != null) {
                    tx.checkErrorCondition();
                }
                JournalInternalRecord addRecord = new JournalAddRecordTX(true, txID, id, recordType, persister, record);
                JournalFile usedFile = appendRecord(addRecord, false, false, tx, null);
                if (logger.isTraceEnabled()) {
                    logger.trace("appendAddRecordTransactional:txID=" + txID + ",id=" + id + ", userRecordType=" + recordType + ", record = " + record + ", usedFile = " + usedFile);
                }
                tx.addPositive(usedFile, id, addRecord.getEncodeSize());
            } catch (Exception e) {
                logger.error("appendAddRecordTransactional:" + e, e);
                setErrorCondition(null, tx, e);
            } finally {
                journalLock.readLock().unlock();
            }
        }
    });
}
Also used : JournalAddRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 3 with JournalAddRecordTX

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

the class FileWrapperJournal method appendAddRecordTransactional.

@Override
public void appendAddRecordTransactional(long txID, long id, byte recordType, Persister persister, Object record) throws Exception {
    JournalInternalRecord addRecord = new JournalAddRecordTX(true, txID, id, recordType, persister, record);
    writeRecord(addRecord, false, txID, false, null);
}
Also used : JournalAddRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 4 with JournalAddRecordTX

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

the class JournalCompactor method onReadAddRecordTX.

@Override
public void onReadAddRecordTX(final long transactionID, final RecordInfo info) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("Read Add Recprd TX " + transactionID + " info " + info);
    }
    if (pendingTransactions.get(transactionID) != null || lookupRecord(info.id)) {
        JournalTransaction newTransaction = getNewJournalTransaction(transactionID);
        JournalInternalRecord record = new JournalAddRecordTX(true, transactionID, info.id, info.getUserRecordType(), EncoderPersister.getInstance(), new ByteArrayEncoding(info.data));
        record.setCompactCount((short) (info.compactCount + 1));
        checkSize(record.getEncodeSize(), info.compactCount);
        newTransaction.addPositive(currentFile, info.id, record.getEncodeSize());
        writeEncoder(record);
    }
}
Also used : ByteArrayEncoding(org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding) JournalAddRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Example 5 with JournalAddRecordTX

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

the class FileWrapperJournal method appendUpdateRecordTransactional.

@Override
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, Persister persister, Object record) throws Exception {
    JournalInternalRecord updateRecordTX = new JournalAddRecordTX(false, txID, id, recordType, persister, record);
    writeRecord(updateRecordTX, false, txID, false, null);
}
Also used : JournalAddRecordTX(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX) JournalInternalRecord(org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)

Aggregations

JournalAddRecordTX (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX)6 JournalInternalRecord (org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord)6 IOException (java.io.IOException)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 ByteArrayEncoding (org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding)2