Search in sources :

Example 21 with JournalImpl

use of org.apache.activemq.artemis.core.journal.impl.JournalImpl in project activemq-artemis by apache.

the class JournalCrashTest method printJournal.

/**
 * @throws Exception
 */
private void printJournal() throws Exception {
    NIOSequentialFileFactory factory = new NIOSequentialFileFactory(new File(getJournalDir()), 100);
    JournalImpl journal = new JournalImpl(ActiveMQDefaultConfiguration.getDefaultJournalFileSize(), 2, 2, 0, 0, factory, "activemq-data", "amq", 100);
    ArrayList<RecordInfo> records = new ArrayList<>();
    ArrayList<PreparedTransactionInfo> transactions = new ArrayList<>();
    journal.start();
    journal.load(records, transactions, null);
    // System.out.println("===============================================");
    // System.out.println("Journal records at the end:");
    // 
    // for (RecordInfo record : records)
    // {
    // System.out.println(record.id + ", update = " + record.isUpdate);
    // }
    journal.stop();
}
Also used : PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) ArrayList(java.util.ArrayList) File(java.io.File) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Example 22 with JournalImpl

use of org.apache.activemq.artemis.core.journal.impl.JournalImpl in project activemq-artemis by apache.

the class HangConsumerTest method testDuplicateDestinationsOnTopic.

/**
 * This will simulate what would happen with topic creationg where a single record is supposed to be created on the journal
 *
 * @throws Exception
 */
@Test
public void testDuplicateDestinationsOnTopic() throws Exception {
    try {
        for (int i = 0; i < 5; i++) {
            if (server.locateQueue(SimpleString.toSimpleString("tt")) == null) {
                server.createQueue(SimpleString.toSimpleString("tt"), RoutingType.ANYCAST, SimpleString.toSimpleString("tt"), SimpleString.toSimpleString(Filter.GENERIC_IGNORED_FILTER), true, false);
            }
            server.stop();
            SequentialFileFactory messagesFF = new NIOSequentialFileFactory(server.getConfiguration().getBindingsLocation(), null, 1);
            JournalImpl messagesJournal = new JournalImpl(1024 * 1024, 2, 2, 0, 0, messagesFF, "activemq-bindings", "bindings", 1);
            messagesJournal.start();
            LinkedList<RecordInfo> infos = new LinkedList<>();
            messagesJournal.load(infos, null, null);
            int bindings = 0;
            for (RecordInfo info : infos) {
                System.out.println("info: " + info);
                if (info.getUserRecordType() == JournalRecordIds.QUEUE_BINDING_RECORD) {
                    bindings++;
                }
            }
            assertEquals(1, bindings);
            System.out.println("Bindings: " + bindings);
            messagesJournal.stop();
            if (i < 4)
                server.start();
        }
    } finally {
        try {
            server.stop();
        } catch (Throwable ignored) {
        }
    }
}
Also used : 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) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Test(org.junit.Test)

Example 23 with JournalImpl

use of org.apache.activemq.artemis.core.journal.impl.JournalImpl 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)

Example 24 with JournalImpl

use of org.apache.activemq.artemis.core.journal.impl.JournalImpl in project activemq-artemis by apache.

the class AlignedJournalImplTest method testInconsistentAlignment.

@Test
public void testInconsistentAlignment() throws Exception {
    factory = new FakeSequentialFileFactory(512, true);
    try {
        journalImpl = new JournalImpl(2000, 2, 2, 0, 0, factory, "tt", "tt", 1000);
        Assert.fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException ignored) {
    // expected
    }
}
Also used : FakeSequentialFileFactory(org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl) Test(org.junit.Test)

Example 25 with JournalImpl

use of org.apache.activemq.artemis.core.journal.impl.JournalImpl in project activemq-artemis by apache.

the class JournalImplTestBase method createJournal.

public void createJournal() throws Exception {
    journal = new JournalImpl(fileSize, minFiles, poolSize, 0, 0, fileFactory, filePrefix, fileExtension, maxAIO) {

        @Override
        public void onCompactDone() {
            latchDone.countDown();
            try {
                latchWait.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    };
    journal.setAutoReclaim(false);
    addActiveMQComponent(journal);
}
Also used : JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Aggregations

JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)41 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)20 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)19 SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)13 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)13 Test (org.junit.Test)12 File (java.io.File)10 ArrayList (java.util.ArrayList)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 JournalFile (org.apache.activemq.artemis.core.journal.impl.JournalFile)6 SimpleEncoding (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding)6 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)5 AIOSequentialFileFactory (org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory)5 Pair (org.apache.activemq.artemis.api.core.Pair)4 Journal (org.apache.activemq.artemis.core.journal.Journal)4 FakeSequentialFileFactory (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Configuration (org.apache.activemq.artemis.core.config.Configuration)3 MappedSequentialFileFactory (org.apache.activemq.artemis.core.io.mapped.MappedSequentialFileFactory)3