use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo 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.PreparedTransactionInfo in project activemq-artemis by apache.
the class AddAndRemoveStressTest method testInsertAndLoad.
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testInsertAndLoad() throws Exception {
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
JournalImpl impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
impl.start();
impl.load(AddAndRemoveStressTest.dummyLoader);
for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
if (i % 10000 == 0) {
System.out.println("Append " + i);
}
impl.appendAddRecord(i, (byte) 0, new SimpleEncoding(1024, (byte) 'f'), false);
}
impl.stop();
factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
impl.start();
impl.load(AddAndRemoveStressTest.dummyLoader);
for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
if (i % 10000 == 0) {
System.out.println("Delete " + i);
}
impl.appendDeleteRecord(i, false);
}
impl.stop();
factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
impl.start();
ArrayList<RecordInfo> info = new ArrayList<>();
ArrayList<PreparedTransactionInfo> trans = new ArrayList<>();
impl.load(info, trans, null);
impl.forceMoveNextFile();
if (info.size() > 0) {
System.out.println("Info ID: " + info.get(0).id);
}
impl.stop();
Assert.assertEquals(0, info.size());
Assert.assertEquals(0, trans.size());
Assert.assertEquals(0, impl.getDataFilesCount());
}
use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo in project activemq-artemis by apache.
the class AddAndRemoveStressTest method testInsertUpdateAndLoad.
@Test
public void testInsertUpdateAndLoad() throws Exception {
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
JournalImpl impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
impl.start();
impl.load(AddAndRemoveStressTest.dummyLoader);
for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
if (i % 10000 == 0) {
System.out.println("Append " + i);
}
impl.appendAddRecord(i, (byte) 21, new SimpleEncoding(40, (byte) 'f'), false);
impl.appendUpdateRecord(i, (byte) 22, new SimpleEncoding(40, (byte) 'g'), false);
}
impl.stop();
factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
impl = new JournalImpl(10 * 1024 * 1024, 10, 10, 0, 0, factory, "amq", "amq", 1000);
impl.start();
impl.load(AddAndRemoveStressTest.dummyLoader);
for (long i = 1; i <= AddAndRemoveStressTest.NUMBER_OF_MESSAGES; i++) {
if (i % 10000 == 0) {
System.out.println("Delete " + i);
}
impl.appendDeleteRecord(i, false);
}
impl.stop();
factory = new AIOSequentialFileFactory(getTestDirfile(), 1000);
impl = new JournalImpl(10 * 1024 * 1024, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL, 0, 0, factory, "amq", "amq", 1000);
impl.start();
ArrayList<RecordInfo> info = new ArrayList<>();
ArrayList<PreparedTransactionInfo> trans = new ArrayList<>();
impl.load(info, trans, null);
if (info.size() > 0) {
System.out.println("Info ID: " + info.get(0).id);
}
impl.forceMoveNextFile();
impl.checkReclaimStatus();
impl.stop();
Assert.assertEquals(0, info.size());
Assert.assertEquals(0, trans.size());
Assert.assertEquals(0, impl.getDataFilesCount());
System.out.println("Size = " + impl.getDataFilesCount());
}
use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo in project activemq-artemis by apache.
the class JMSJournalStorageManagerImpl method load.
@Override
public void load() throws Exception {
mapFactories.clear();
List<RecordInfo> data = new ArrayList<>();
ArrayList<PreparedTransactionInfo> list = new ArrayList<>();
jmsJournal.load(data, list, null);
for (RecordInfo record : data) {
long id = record.id;
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(record.data);
byte rec = record.getUserRecordType();
if (rec == CF_RECORD) {
PersistedConnectionFactory cf = new PersistedConnectionFactory();
cf.decode(buffer);
cf.setId(id);
mapFactories.put(cf.getName(), cf);
} else if (rec == DESTINATION_RECORD) {
PersistedDestination destination = new PersistedDestination();
destination.decode(buffer);
destination.setId(id);
destinations.put(new Pair<>(destination.getType(), destination.getName()), destination);
} else if (rec == BINDING_RECORD) {
PersistedBindings bindings = new PersistedBindings();
bindings.decode(buffer);
bindings.setId(id);
Pair<PersistedType, String> key = new Pair<>(bindings.getType(), bindings.getName());
mapBindings.put(key, bindings);
} else {
throw new IllegalStateException("Invalid record type " + rec);
}
}
}
use of org.apache.activemq.artemis.core.journal.PreparedTransactionInfo in project activemq-artemis by apache.
the class ValidateTransactionHealthTest method appendData.
public static JournalImpl appendData(final String journalType, final String journalDir, final long numberOfElements, final int transactionSize, final int numberOfThreads) throws Exception {
final JournalImpl journal = ValidateTransactionHealthTest.createJournal(journalType, journalDir);
journal.start();
journal.load(new LoaderCallback() {
@Override
public void addPreparedTransaction(final PreparedTransactionInfo preparedTransaction) {
}
@Override
public void addRecord(final RecordInfo info) {
}
@Override
public void deleteRecord(final long id) {
}
@Override
public void updateRecord(final RecordInfo info) {
}
@Override
public void failedTransaction(final long transactionID, final List<RecordInfo> records, final List<RecordInfo> recordsToDelete) {
}
});
LocalThread[] threads = new LocalThread[numberOfThreads];
final AtomicLong sequenceTransaction = new AtomicLong();
for (int i = 0; i < numberOfThreads; i++) {
threads[i] = new LocalThread(journal, numberOfElements, transactionSize, sequenceTransaction);
threads[i].start();
}
Exception e = null;
for (LocalThread t : threads) {
t.join();
if (t.e != null) {
e = t.e;
}
}
if (e != null) {
throw e;
}
journal.flush();
return journal;
}
Aggregations