use of org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory in project activemq-artemis by apache.
the class PagingStoreImplTest method testConcurrentDepage.
@Test
public void testConcurrentDepage() throws Exception {
SequentialFileFactory factory = new FakeSequentialFileFactory(1, false);
testConcurrentPaging(factory, 10);
}
use of org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory in project activemq-artemis by apache.
the class JournalAsyncTest method setupJournal.
// Private -------------------------------------------------------
private void setupJournal(final int journalSize, final int alignment, final int numberOfMinimalFiles) throws Exception {
if (factory == null) {
factory = new FakeSequentialFileFactory(alignment, true);
}
if (journalImpl != null) {
journalImpl.stop();
}
journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, numberOfMinimalFiles, 0, 0, factory, "tt", "tt", 1000);
journalImpl.start();
records.clear();
transactions.clear();
journalImpl.load(records, transactions, null);
}
use of org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory in project activemq-artemis by apache.
the class AlignedJournalImplTest method testAlignmentOverReload.
@Test
public void testAlignmentOverReload() throws Exception {
factory = new FakeSequentialFileFactory(512, false);
journalImpl = new JournalImpl(512 + 512 * 3, 20, 20, 0, 0, factory, "amq", "amq", 1000);
journalImpl.start();
journalImpl.load(AlignedJournalImplTest.dummyLoader);
journalImpl.appendAddRecord(1L, (byte) 0, new SimpleEncoding(100, (byte) 'a'), false);
journalImpl.appendAddRecord(2L, (byte) 0, new SimpleEncoding(100, (byte) 'b'), false);
journalImpl.appendAddRecord(3L, (byte) 0, new SimpleEncoding(100, (byte) 'b'), false);
journalImpl.appendAddRecord(4L, (byte) 0, new SimpleEncoding(100, (byte) 'b'), false);
journalImpl.stop();
journalImpl = new JournalImpl(512 + 1024 + 512, 20, 20, 0, 0, factory, "amq", "amq", 1000);
addActiveMQComponent(journalImpl);
journalImpl.start();
journalImpl.load(AlignedJournalImplTest.dummyLoader);
// It looks silly, but this forceMoveNextFile is in place to replicate one
// specific bug caught during development
journalImpl.forceMoveNextFile();
journalImpl.appendDeleteRecord(1L, false);
journalImpl.appendDeleteRecord(2L, false);
journalImpl.appendDeleteRecord(3L, false);
journalImpl.appendDeleteRecord(4L, false);
journalImpl.stop();
journalImpl = new JournalImpl(512 + 1024 + 512, 20, 20, 0, 0, factory, "amq", "amq", 1000);
addActiveMQComponent(journalImpl);
journalImpl.start();
ArrayList<RecordInfo> info = new ArrayList<>();
ArrayList<PreparedTransactionInfo> trans = new ArrayList<>();
journalImpl.load(info, trans, null);
Assert.assertEquals(0, info.size());
Assert.assertEquals(0, trans.size());
}
use of org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory in project activemq-artemis by apache.
the class AlignedJournalImplTest method testBasicAlignment.
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
// This test just validates basic alignment on the FakeSequentialFile itself
@Test
public void testBasicAlignment() throws Exception {
FakeSequentialFileFactory factory = new FakeSequentialFileFactory(200, true);
SequentialFile file = factory.createSequentialFile("test1");
file.open();
try {
ByteBuffer buffer = ByteBuffer.allocateDirect(200);
for (int i = 0; i < 200; i++) {
buffer.put(i, (byte) 1);
}
file.writeDirect(buffer, true);
buffer = ByteBuffer.allocate(400);
for (int i = 0; i < 400; i++) {
buffer.put(i, (byte) 2);
}
file.writeDirect(buffer, true);
buffer = ByteBuffer.allocate(600);
file.position(0);
file.read(buffer);
for (int i = 0; i < 200; i++) {
Assert.assertEquals((byte) 1, buffer.get(i));
}
for (int i = 201; i < 600; i++) {
Assert.assertEquals("Position " + i, (byte) 2, buffer.get(i));
}
} catch (Exception ignored) {
}
}
use of org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory in project activemq-artemis by apache.
the class AlignedJournalImplTest method setupAndLoadJournal.
private void setupAndLoadJournal(final int journalSize, final int alignment, final int numberOfMinimalFiles) throws Exception {
if (factory == null) {
factory = new FakeSequentialFileFactory(alignment, true);
}
if (journalImpl != null) {
journalImpl.stop();
}
journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, numberOfMinimalFiles, 0, 0, factory, "tt", "tt", 1000);
addActiveMQComponent(journalImpl);
journalImpl.start();
records.clear();
transactions.clear();
incompleteTransactions.clear();
journalImpl.load(records, transactions, new TransactionFailureCallback() {
@Override
public void failedTransaction(final long transactionID, final List<RecordInfo> records, final List<RecordInfo> recordsToDelete) {
System.out.println("records.length = " + records.size());
incompleteTransactions.add(transactionID);
}
});
}
Aggregations