Search in sources :

Example 6 with TransactionFailureCallback

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

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

the class JournalCleanupCompactStressTest method reloadJournal.

/**
 * @throws Exception
 */
private void reloadJournal() throws Exception {
    assertEquals(0, errors.get());
    ArrayList<RecordInfo> committedRecords = new ArrayList<>();
    ArrayList<PreparedTransactionInfo> preparedTransactions = new ArrayList<>();
    journal.load(committedRecords, preparedTransactions, new TransactionFailureCallback() {

        @Override
        public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
        }
    });
    long appends = 0, updates = 0;
    for (RecordInfo record : committedRecords) {
        if (record.isUpdate) {
            updates++;
        } else {
            appends++;
        }
    }
    assertEquals(numberOfRecords.get() - numberOfDeletes.get(), appends);
}
Also used : PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) ArrayList(java.util.ArrayList) TransactionFailureCallback(org.apache.activemq.artemis.core.journal.TransactionFailureCallback)

Example 8 with TransactionFailureCallback

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

the class MessageJournalTest method testStoreAMQP.

@Test
public void testStoreAMQP() throws Throwable {
    ActiveMQServer server = createServer(true);
    server.start();
    ProtonProtocolManagerFactory factory = (ProtonProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("AMQP");
    Message protonJMessage = Message.Factory.create();
    AMQPMessage message = new AMQPMessage(protonJMessage);
    message.setMessageID(333);
    Assert.assertNotNull(factory);
    server.getStorageManager().storeMessage(message);
    server.getStorageManager().stop();
    JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
    List<RecordInfo> committedRecords = new LinkedList<>();
    List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
    TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {

        @Override
        public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
        }
    };
    try {
        journalStorageManager.getMessageJournal().start();
        journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
        Assert.assertEquals(1, committedRecords.size());
    } finally {
        journalStorageManager.getMessageJournal().stop();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Message(org.apache.qpid.proton.message.Message) ProtonProtocolManagerFactory(org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) List(java.util.List) LinkedList(java.util.LinkedList) TransactionFailureCallback(org.apache.activemq.artemis.core.journal.TransactionFailureCallback) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) LinkedList(java.util.LinkedList) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Example 9 with TransactionFailureCallback

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

the class MessageJournalTest method testStoreCore.

@Test
public void testStoreCore() throws Throwable {
    ActiveMQServer server = createServer(true);
    server.start();
    CoreMessage message = new CoreMessage().initBuffer(10 * 1024).setDurable(true);
    message.setMessageID(333);
    CoreProtocolManagerFactory factory = (CoreProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("CORE");
    Assert.assertNotNull(factory);
    message.getBodyBuffer().writeByte((byte) 'Z');
    server.getStorageManager().storeMessage(message);
    server.getStorageManager().stop();
    JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
    List<RecordInfo> committedRecords = new LinkedList<>();
    List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
    TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {

        @Override
        public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
        }
    };
    try {
        journalStorageManager.getMessageJournal().start();
        journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
        Assert.assertEquals(1, committedRecords.size());
    } finally {
        journalStorageManager.getMessageJournal().stop();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) CoreProtocolManagerFactory(org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory) List(java.util.List) LinkedList(java.util.LinkedList) TransactionFailureCallback(org.apache.activemq.artemis.core.journal.TransactionFailureCallback) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) LinkedList(java.util.LinkedList) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) Test(org.junit.Test)

Aggregations

RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)9 TransactionFailureCallback (org.apache.activemq.artemis.core.journal.TransactionFailureCallback)9 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)8 LinkedList (java.util.LinkedList)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 JournalImpl (org.apache.activemq.artemis.core.journal.impl.JournalImpl)2 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)2 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 InputBuffer (com.arjuna.ats.arjuna.state.InputBuffer)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)1 Journal (org.apache.activemq.artemis.core.journal.Journal)1 JournalLoadInformation (org.apache.activemq.artemis.core.journal.JournalLoadInformation)1