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