Search in sources :

Example 11 with AIOSequentialFileFactory

use of org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory in project activemq-artemis by apache.

the class AddAndRemoveStressTest method testInsertAndLoad.

// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testInsertAndLoad() throws Exception {
    SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
    JournalImpl impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
    impl.start();
    impl.load(AddAndRemoveStressTest.dummyLoader);
    for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
        if (i % 10000 == 0) {
            System.out.println("Append " + i);
        }
        impl.appendAddRecord(i, (byte) 0, new SimpleEncoding(1024, (byte) 'f'), false);
    }
    impl.stop();
    factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
    impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
    impl.start();
    impl.load(AddAndRemoveStressTest.dummyLoader);
    for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
        if (i % 10000 == 0) {
            System.out.println("Delete " + i);
        }
        impl.appendDeleteRecord(i, false);
    }
    impl.stop();
    factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
    impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
    impl.start();
    ArrayList<RecordInfo> info = new ArrayList<>();
    ArrayList<PreparedTransactionInfo> trans = new ArrayList<>();
    impl.load(info, trans, null);
    impl.forceMoveNextFile();
    if (info.size() > 0) {
        System.out.println("Info ID: " + info.get(0).id);
    }
    impl.stop();
    Assert.assertEquals(0, info.size());
    Assert.assertEquals(0, trans.size());
    Assert.assertEquals(0, impl.getDataFilesCount());
}
Also used : PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) ArrayList(java.util.ArrayList) SimpleEncoding(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Test(org.junit.Test)

Example 12 with AIOSequentialFileFactory

use of org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory in project activemq-artemis by apache.

the class AddAndRemoveStressTest method testInsertUpdateAndLoad.

@Test
public void testInsertUpdateAndLoad() throws Exception {
    SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
    JournalImpl impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
    impl.start();
    impl.load(AddAndRemoveStressTest.dummyLoader);
    for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
        if (i % 10000 == 0) {
            System.out.println("Append " + i);
        }
        impl.appendAddRecord(i, (byte) 21, new SimpleEncoding(40, (byte) 'f'), false);
        impl.appendUpdateRecord(i, (byte) 22, new SimpleEncoding(40, (byte) 'g'), false);
    }
    impl.stop();
    factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
    impl = new JournalImpl(10 * 1024 * 1024, 10, 10, 0, 0, factory, "amq", "amq", 1000);
    impl.start();
    impl.load(AddAndRemoveStressTest.dummyLoader);
    for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
        if (i % 10000 == 0) {
            System.out.println("Delete " + i);
        }
        impl.appendDeleteRecord(i, false);
    }
    impl.stop();
    factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
    impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
    impl.start();
    ArrayList<RecordInfo> info = new ArrayList<>();
    ArrayList<PreparedTransactionInfo> trans = new ArrayList<>();
    impl.load(info, trans, null);
    if (info.size() > 0) {
        System.out.println("Info ID: " + info.get(0).id);
    }
    impl.forceMoveNextFile();
    impl.checkReclaimStatus();
    impl.stop();
    Assert.assertEquals(0, info.size());
    Assert.assertEquals(0, trans.size());
    Assert.assertEquals(0, impl.getDataFilesCount());
    System.out.println("Size = " + impl.getDataFilesCount());
}
Also used : PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) ArrayList(java.util.ArrayList) SimpleEncoding(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Test(org.junit.Test)

Example 13 with AIOSequentialFileFactory

use of org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory in project activemq-artemis by apache.

the class AIOJournalCompactTest method getFileFactory.

@Override
protected SequentialFileFactory getFileFactory() throws Exception {
    File file = new File(getTestDir());
    ActiveMQTestBase.deleteDirectory(file);
    file.mkdir();
    return new AIOSequentialFileFactory(getTestDirfile(), ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, 100000, 10, false);
}
Also used : AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) File(java.io.File)

Example 14 with AIOSequentialFileFactory

use of org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory in project activemq-artemis by apache.

the class AIOJournalImplTest method getFileFactory.

@Override
protected SequentialFileFactory getFileFactory() throws Exception {
    File file = new File(getTestDir());
    deleteDirectory(file);
    file.mkdir();
    // forcing the alignment to be 512, as this test was hard coded around this size.
    return new AIOSequentialFileFactory(getTestDirfile(), ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, 1000000, 10, false).setAlignment(512);
}
Also used : AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) File(java.io.File)

Example 15 with AIOSequentialFileFactory

use of org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory in project activemq-artemis by apache.

the class AIOUnbuferedJournalImplTest method getFileFactory.

@Override
protected SequentialFileFactory getFileFactory() throws Exception {
    File file = new File(getTestDir());
    deleteDirectory(file);
    file.mkdir();
    // forcing the alignment to be 512, as this test was hard coded around this size.
    return new AIOSequentialFileFactory(getTestDirfile(), ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, 0, 10, false).setAlignment(512);
}
Also used : AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) File(java.io.File)

Aggregations

AIOSequentialFileFactory (org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory)15 File (java.io.File)10 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)6 SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)5 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)5 ArrayList (java.util.ArrayList)4 MappedSequentialFileFactory (org.apache.activemq.artemis.core.io.mapped.MappedSequentialFileFactory)4 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)3 Test (org.junit.Test)3 Semaphore (java.util.concurrent.Semaphore)2 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)2 EncodingSupport (org.apache.activemq.artemis.core.journal.EncodingSupport)2 Journal (org.apache.activemq.artemis.core.journal.Journal)2 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)2 SimpleEncoding (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding)2 MpscArrayQueue (io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 ActiveMQExceptionType (org.apache.activemq.artemis.api.core.ActiveMQExceptionType)1 AIOSequentialFile (org.apache.activemq.artemis.core.io.aio.AIOSequentialFile)1