use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.
the class JournalImplTestBase method checkRecordsEquivalent.
protected void checkRecordsEquivalent(final List<RecordInfo> expected, final List<RecordInfo> actual) {
if (expected.size() != actual.size()) {
printJournalLists(expected, actual);
}
Assert.assertEquals("Lists not same length", expected.size(), actual.size());
Iterator<RecordInfo> iterExpected = expected.iterator();
Iterator<RecordInfo> iterActual = actual.iterator();
while (iterExpected.hasNext()) {
RecordInfo rexpected = iterExpected.next();
RecordInfo ractual = iterActual.next();
if (rexpected.id != ractual.id || rexpected.isUpdate != ractual.isUpdate) {
printJournalLists(expected, actual);
}
Assert.assertEquals("ids not same", rexpected.id, ractual.id);
Assert.assertEquals("type not same", rexpected.isUpdate, ractual.isUpdate);
ActiveMQTestBase.assertEqualsByteArrays(rexpected.data, ractual.data);
}
}
use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.
the class JournalImplTestBase method updateTx.
protected void updateTx(final long txID, final long... arguments) throws Exception {
TransactionHolder tx = getTransaction(txID);
for (long element : arguments) {
byte[] updateRecord = generateRecord(recordLength - (JournalImpl.SIZE_ADD_RECORD_TX + 1));
beforeJournalOperation();
journal.appendUpdateRecordTransactional(txID, element, (byte) 0, updateRecord);
tx.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 deleteTx.
protected void deleteTx(final long txID, final long... arguments) throws Exception {
TransactionHolder tx = getTransaction(txID);
for (long element : arguments) {
beforeJournalOperation();
journal.appendDeleteRecordTransactional(txID, element);
tx.deletes.add(new RecordInfo(element, (byte) 0, null, true, (short) 0));
}
journal.debugWait();
}
use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.
the class BatchIDGeneratorUnitTest method testSequence.
@Test
public void testSequence() throws Exception {
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(new File(getTestDir()), 1);
Journal journal = new JournalImpl(10 * 1024, 2, 2, 0, 0, factory, "activemq-bindings", "bindings", 1);
journal.start();
journal.load(new ArrayList<RecordInfo>(), new ArrayList<PreparedTransactionInfo>(), null);
BatchingIDGenerator batch = new BatchingIDGenerator(0, 1000, getJournalStorageManager(journal));
long id1 = batch.generateID();
long id2 = batch.generateID();
Assert.assertTrue(id2 > id1);
journal.stop();
batch = new BatchingIDGenerator(0, 1000, getJournalStorageManager(journal));
loadIDs(journal, batch);
long id3 = batch.generateID();
Assert.assertEquals(1001, id3);
long id4 = batch.generateID();
Assert.assertTrue(id4 > id3 && id4 < 2000);
batch.persistCurrentID();
journal.stop();
batch = new BatchingIDGenerator(0, 1000, getJournalStorageManager(journal));
loadIDs(journal, batch);
long id5 = batch.generateID();
Assert.assertTrue(id5 > id4 && id5 < 2000);
long lastId = id5;
boolean close = true;
for (int i = 0; i < 100000; i++) {
if (i % 1000 == 0) {
// interchanging closes and simulated crashes
if (close) {
batch.persistCurrentID();
}
close = !close;
journal.stop();
batch = new BatchingIDGenerator(0, 1000, getJournalStorageManager(journal));
loadIDs(journal, batch);
}
long id = batch.generateID();
Assert.assertTrue(id > lastId);
lastId = id;
}
batch.persistCurrentID();
journal.stop();
batch = new BatchingIDGenerator(0, 1000, getJournalStorageManager(journal));
loadIDs(journal, batch);
lastId = batch.getCurrentID();
journal.stop();
batch = new BatchingIDGenerator(0, 1000, getJournalStorageManager(journal));
loadIDs(journal, batch);
Assert.assertEquals("No Ids were generated, so the currentID was supposed to stay the same", lastId, batch.getCurrentID());
journal.stop();
}
use of org.apache.activemq.artemis.core.journal.RecordInfo in project activemq-artemis by apache.
the class CrashOnCompactTest method checkJournalSize.
private void checkJournalSize() throws Exception {
JournalImpl journal = createJournal(getTestDirfile(), false);
ArrayList<RecordInfo> info = new ArrayList<>();
ArrayList<PreparedTransactionInfo> txInfo = new ArrayList<>();
journal.load(info, txInfo, new TransactionFailureCallback() {
@Override
public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
}
});
Assert.assertEquals(900, info.size());
}
Aggregations