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();
}
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) {
}
}
}
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);
}
});
}
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
}
}
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);
}
Aggregations