Search in sources :

Example 41 with RecordInfo

use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.

the class JournalImplTestBase method update.

protected void update(final long... arguments) throws Exception {
    for (long element : arguments) {
        byte[] updateRecord = generateRecord(recordLength);
        beforeJournalOperation();
        journal.appendUpdateRecord(element, (byte) 0, updateRecord, sync);
        records.add(new RecordInfo(element, (byte) 0, updateRecord, true, (short) 0));
    }
    journal.debugWait();
}
Also used : RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo)

Example 42 with RecordInfo

use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.

the class JournalImplTestBase method loadAndCheck.

protected void loadAndCheck(final boolean printDebugJournal) throws Exception {
    List<RecordInfo> committedRecords = new ArrayList<>();
    List<PreparedTransactionInfo> preparedTransactions = new ArrayList<>();
    journal.load(committedRecords, preparedTransactions, null);
    checkRecordsEquivalent(records, committedRecords);
    if (printDebugJournal) {
        printJournalLists(records, committedRecords);
    }
    // check prepared transactions
    List<PreparedTransactionInfo> prepared = new ArrayList<>();
    for (Map.Entry<Long, TransactionHolder> entry : transactions.entrySet()) {
        if (entry.getValue().prepared) {
            PreparedTransactionInfo info = new PreparedTransactionInfo(entry.getKey(), null);
            info.getRecords().addAll(entry.getValue().records);
            info.getRecordsToDelete().addAll(entry.getValue().deletes);
            prepared.add(info);
        }
    }
    checkTransactionsEquivalent(prepared, preparedTransactions);
}
Also used : PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 43 with RecordInfo

use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.

the class JournalImplTestBase method addWithSize.

protected void addWithSize(final int size, final long... arguments) throws Exception {
    for (long element : arguments) {
        byte[] record = generateRecord(size);
        beforeJournalOperation();
        journal.appendAddRecord(element, (byte) 0, record, sync);
        records.add(new RecordInfo(element, (byte) 0, record, false, (short) 0));
    }
    journal.debugWait();
}
Also used : RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo)

Example 44 with RecordInfo

use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.

the class JournalImplTestBase method addTx.

protected void addTx(final long txID, final long... arguments) throws Exception {
    TransactionHolder tx = getTransaction(txID);
    for (long element : arguments) {
        // SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_INT + record.length +
        // SIZE_BYTE
        byte[] record = generateRecord(recordLength - (JournalImpl.SIZE_ADD_RECORD_TX + 1));
        beforeJournalOperation();
        journal.appendAddRecordTransactional(txID, element, (byte) 0, record);
        tx.records.add(new RecordInfo(element, (byte) 0, record, false, (short) 0));
    }
    journal.debugWait();
}
Also used : RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo)

Example 45 with RecordInfo

use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.

the class JournalImplTestBase method printJournalLists.

/**
 * @param expected
 * @param actual
 */
protected void printJournalLists(final List<RecordInfo> expected, final List<RecordInfo> actual) {
    HashSet<RecordInfo> expectedSet = new HashSet<>();
    expectedSet.addAll(expected);
    Assert.assertEquals("There are duplicated on the expected list", expectedSet.size(), expected.size());
    HashSet<RecordInfo> actualSet = new HashSet<>();
    actualSet.addAll(actual);
    expectedSet.removeAll(actualSet);
    for (RecordInfo info : expectedSet) {
        logger.warn("The following record is missing:: " + info);
    }
    Assert.assertEquals("There are duplicates on the actual list", actualSet.size(), actualSet.size());
    RecordInfo[] expectedArray = expected.toArray(new RecordInfo[expected.size()]);
    RecordInfo[] actualArray = actual.toArray(new RecordInfo[actual.size()]);
    Assert.assertArrayEquals(expectedArray, actualArray);
}
Also used : RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) HashSet(java.util.HashSet)

Aggregations

RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)65 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)33 ArrayList (java.util.ArrayList)22 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)20 Test (org.junit.Test)20 LinkedList (java.util.LinkedList)15 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)15 HashMap (java.util.HashMap)10 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)10 TransactionFailureCallback (org.apache.activemq.artemis.core.journal.TransactionFailureCallback)9 File (java.io.File)7 Journal (org.apache.activemq.artemis.core.journal.Journal)7 SimpleEncoding (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding)7 List (java.util.List)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)6 PageCountRecordInc (org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountRecordInc)6 IOException (java.io.IOException)5 HashSet (java.util.HashSet)5 LinkedHashMap (java.util.LinkedHashMap)5