Search in sources :

Example 1 with FakeSequentialFileFactory

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);
}
Also used : FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) Test(org.junit.Test)

Example 2 with FakeSequentialFileFactory

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);
}
Also used : FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Example 3 with FakeSequentialFileFactory

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());
}
Also used : FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) ArrayList(java.util.ArrayList) SimpleEncoding(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Test(org.junit.Test)

Example 4 with FakeSequentialFileFactory

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) {
    }
}
Also used : FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 5 with FakeSequentialFileFactory

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);
        }
    });
}
Also used : FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) TransactionFailureCallback(org.apache.activemq.artemis.core.journal.TransactionFailureCallback) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Aggregations

FakeSequentialFileFactory (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory)11 Test (org.junit.Test)9 SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)6 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)6 ArrayList (java.util.ArrayList)4 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)4 PagingStoreImpl (org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl)4 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)4 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)3 Message (org.apache.activemq.artemis.api.core.Message)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)3 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)3 PagingStoreFactory (org.apache.activemq.artemis.core.paging.PagingStoreFactory)3 RoutingContextImpl (org.apache.activemq.artemis.core.server.impl.RoutingContextImpl)3 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)2 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)2 Page (org.apache.activemq.artemis.core.paging.impl.Page)2 NullStorageManager (org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager)2 ByteBuffer (java.nio.ByteBuffer)1