use of org.apache.activemq.artemis.core.journal.IOCompletion in project activemq-artemis by apache.
the class JournalImpl method runDirectJournalBlast.
@Override
public void runDirectJournalBlast() throws Exception {
final int numIts = 100000000;
ActiveMQJournalLogger.LOGGER.runningJournalBlast(numIts);
final CountDownLatch latch = new CountDownLatch(numIts * 2);
class MyAIOCallback implements IOCompletion {
@Override
public void done() {
latch.countDown();
}
@Override
public void onError(final int errorCode, final String errorMessage) {
}
@Override
public void storeLineUp() {
}
}
final MyAIOCallback task = new MyAIOCallback();
final int recordSize = 1024;
final byte[] bytes = new byte[recordSize];
class MyRecord implements EncodingSupport {
@Override
public void decode(final ActiveMQBuffer buffer) {
}
@Override
public void encode(final ActiveMQBuffer buffer) {
buffer.writeBytes(bytes);
}
@Override
public int getEncodeSize() {
return recordSize;
}
}
MyRecord record = new MyRecord();
for (int i = 0; i < numIts; i++) {
appendAddRecord(i, (byte) 1, record, true, task);
appendDeleteRecord(i, true, task);
}
latch.await();
}
use of org.apache.activemq.artemis.core.journal.IOCompletion in project activemq-artemis by apache.
the class JDBCJournalTest method testCallbacks.
@Test
public void testCallbacks() throws Exception {
final int noRecords = 10;
final CountDownLatch done = new CountDownLatch(noRecords);
IOCompletion completion = new IOCompletion() {
@Override
public void storeLineUp() {
}
@Override
public void done() {
done.countDown();
}
@Override
public void onError(int errorCode, String errorMessage) {
}
};
for (int i = 0; i < noRecords; i++) {
journal.appendAddRecord(1, (byte) 1, new FakeEncodingSupportImpl(new byte[0]), true, completion);
}
journal.sync();
done.await(5, TimeUnit.SECONDS);
assertEquals(done.getCount(), 0);
}
Aggregations