use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo 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();
}
}
use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo 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();
}
}
use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo in project activemq-artemis by apache.
the class NIOJournalCompactTest method testCompactFirstFileReclaimed.
@Test
public void testCompactFirstFileReclaimed() throws Exception {
setup(2, 60 * 1024, false);
final byte recordType = (byte) 0;
journal = new JournalImpl(fileSize, minFiles, minFiles, 0, 0, fileFactory, filePrefix, fileExtension, maxAIO);
journal.start();
journal.loadInternalOnly();
journal.appendAddRecord(1, recordType, "test".getBytes(), true);
journal.forceMoveNextFile();
journal.appendUpdateRecord(1, recordType, "update".getBytes(), true);
journal.appendDeleteRecord(1, true);
journal.appendAddRecord(2, recordType, "finalRecord".getBytes(), true);
for (int i = 10; i < 100; i++) {
journal.appendAddRecord(i, recordType, ("tst" + i).getBytes(), true);
journal.forceMoveNextFile();
journal.appendUpdateRecord(i, recordType, ("uptst" + i).getBytes(), true);
journal.appendDeleteRecord(i, true);
}
journal.testCompact();
journal.stop();
List<RecordInfo> records1 = new ArrayList<>();
List<PreparedTransactionInfo> preparedRecords = new ArrayList<>();
journal.start();
journal.load(records1, preparedRecords, null);
assertEquals(1, records1.size());
}
use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo in project activemq-artemis by apache.
the class ActiveMQTestBase method loadMessageJournal.
/**
* Reads a journal system and returns a Map<Integer,AtomicInteger> of recordTypes and the number of records per type,
* independent of being deleted or not
*
* @param config
* @return
* @throws Exception
*/
protected Pair<List<RecordInfo>, List<PreparedTransactionInfo>> loadMessageJournal(Configuration config) throws Exception {
JournalImpl messagesJournal = null;
try {
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(new File(getJournalDir()), null, 1);
messagesJournal = new JournalImpl(config.getJournalFileSize(), config.getJournalMinFiles(), config.getJournalPoolFiles(), 0, 0, messagesFF, "activemq-data", "amq", 1);
final List<RecordInfo> committedRecords = new LinkedList<>();
final List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
messagesJournal.start();
messagesJournal.load(committedRecords, preparedTransactions, null, false);
return new Pair<>(committedRecords, preparedTransactions);
} finally {
try {
if (messagesJournal != null) {
messagesJournal.stop();
}
} catch (Throwable ignored) {
}
}
}
Aggregations