Search in sources :

Example 6 with SequentialFileFactory

use of org.apache.activemq.artemis.core.io.SequentialFileFactory 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 7 with SequentialFileFactory

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

the class PagingStoreImplTest method testRestartPage.

@Test
public void testRestartPage() throws Throwable {
    clearDataRecreateServerDirs();
    SequentialFileFactory factory = new NIOSequentialFileFactory(new File(getPageDir()), 1);
    PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
    final int MAX_SIZE = 1024 * 10;
    AddressSettings settings = new AddressSettings().setPageSizeBytes(MAX_SIZE).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
    final PagingStore storeImpl = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100, createMockManager(), createStorageManagerMock(), factory, storeFactory, new SimpleString("test"), settings, getExecutorFactory().getExecutor(), true);
    storeImpl.start();
    Assert.assertEquals(0, storeImpl.getNumberOfPages());
    // Marked the store to be paged
    storeImpl.startPaging();
    storeImpl.depage();
    Assert.assertNull(storeImpl.getCurrentPage());
    storeImpl.startPaging();
    Assert.assertNotNull(storeImpl.getCurrentPage());
    storeImpl.stop();
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) PagingStoreImpl(org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl) PagingStoreFactory(org.apache.activemq.artemis.core.paging.PagingStoreFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) File(java.io.File) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore) 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) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) Test(org.junit.Test)

Example 8 with SequentialFileFactory

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

the class JournalCleanupCompactStressTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    threadPool = Executors.newFixedThreadPool(20, tFactory);
    executorFactory = new OrderedExecutorFactory(threadPool);
    testExecutor = executorFactory.getExecutor();
    maxRecords = new Semaphore(MAX_WRITES);
    errors.set(0);
    File dir = new File(getTemporaryDir());
    dir.mkdirs();
    SequentialFileFactory factory;
    int maxAIO;
    if (LibaioContext.isLoaded()) {
        factory = new AIOSequentialFileFactory(dir, 10);
        maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio();
    } else {
        factory = new NIOSequentialFileFactory(dir, true, 1);
        maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio();
    }
    journal = new JournalImpl(50 * 1024, 20, 20, 50, ActiveMQDefaultConfiguration.getDefaultJournalCompactPercentage(), factory, "activemq-data", "amq", maxAIO) {

        @Override
        protected void onCompactLockingTheJournal() throws Exception {
        }

        @Override
        protected void onCompactStart() throws Exception {
            testExecutor.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        // System.out.println("OnCompactStart enter");
                        if (running) {
                            long id = idGen.generateID();
                            journal.appendAddRecord(id, (byte) 0, new byte[] { 1, 2, 3 }, false);
                            journal.forceMoveNextFile();
                            journal.appendDeleteRecord(id, id == 20);
                        }
                    // System.out.println("OnCompactStart leave");
                    } catch (Exception e) {
                        e.printStackTrace();
                        errors.incrementAndGet();
                    }
                }
            });
        }
    };
    journal.start();
    journal.loadInternalOnly();
}
Also used : OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) Semaphore(java.util.concurrent.Semaphore) File(java.io.File) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Before(org.junit.Before)

Example 9 with SequentialFileFactory

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

the class CleanBufferTest method testCleanOnNIO.

// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testCleanOnNIO() {
    SequentialFileFactory factory = new NIOSequentialFileFactory(new File("Whatever"), 1);
    testBuffer(factory);
}
Also used : File(java.io.File) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) Test(org.junit.Test)

Example 10 with SequentialFileFactory

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

the class ActiveMQTestBase method internalCountJournalLivingRecords.

/**
 * This method will load a journal and count the living records
 *
 * @param config
 * @param messageJournal if true -> MessageJournal, false -> BindingsJournal
 * @return
 * @throws Exception
 */
protected HashMap<Integer, AtomicInteger> internalCountJournalLivingRecords(Configuration config, boolean messageJournal) throws Exception {
    final HashMap<Integer, AtomicInteger> recordsType = new HashMap<>();
    SequentialFileFactory ff;
    JournalImpl journal;
    if (messageJournal) {
        ff = new NIOSequentialFileFactory(config.getJournalLocation(), null, 1);
        journal = new JournalImpl(config.getJournalFileSize(), config.getJournalMinFiles(), config.getJournalPoolFiles(), 0, 0, ff, "activemq-data", "amq", 1);
    } else {
        ff = new NIOSequentialFileFactory(config.getBindingsLocation(), null, 1);
        journal = new JournalImpl(1024 * 1024, 2, config.getJournalCompactMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactPercentage(), ff, "activemq-bindings", "bindings", 1);
    }
    journal.start();
    final List<RecordInfo> committedRecords = new LinkedList<>();
    final List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
    journal.load(committedRecords, preparedTransactions, null, false);
    for (RecordInfo info : committedRecords) {
        Integer ikey = new Integer(info.getUserRecordType());
        AtomicInteger value = recordsType.get(ikey);
        if (value == null) {
            value = new AtomicInteger();
            recordsType.put(ikey, value);
        }
        value.incrementAndGet();
    }
    journal.stop();
    return recordsType;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) LinkedList(java.util.LinkedList) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)

Aggregations

SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)30 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)25 Test (org.junit.Test)16 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)13 FakeSequentialFileFactory (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory)10 File (java.io.File)9 ArrayList (java.util.ArrayList)8 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 AIOSequentialFileFactory (org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory)8 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)7 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)7 SequentialFile (org.apache.activemq.artemis.core.io.SequentialFile)6 PagingStoreImpl (org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)5 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)5 PagingStoreFactory (org.apache.activemq.artemis.core.paging.PagingStoreFactory)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)4