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();
}
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);
}
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();
}
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();
}
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);
}
Aggregations