use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class TestSupport method stopBrokerWithStoreFailure.
public void stopBrokerWithStoreFailure(BrokerService broker, PersistenceAdapterChoice choice) throws Exception {
switch(choice) {
case KahaDB:
KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
// have the broker stop with an IOException on next checkpoint so it has a pending local transaction to recover
kahaDBPersistenceAdapter.getStore().getJournal().close();
break;
default:
// just stop normally by default
broker.stop();
}
broker.waitUntilStopped();
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class KahaDBQueueTest method configureBroker.
@Override
protected void configureBroker(BrokerService answer, String uri) throws Exception {
File dataFileDir = new File("target/test-amq-data/perfTest/kahadb");
File archiveDir = new File(dataFileDir, "archive");
KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
kaha.setDirectory(dataFileDir);
kaha.setDirectoryArchive(archiveDir);
kaha.setArchiveDataLogs(false);
// The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified
// what happens if the index is updated but a journal update is lost.
// Index is going to be in consistent, but can it be repaired?
kaha.setEnableJournalDiskSyncs(true);
// Using a bigger journal file size makes he take fewer spikes as it is not switching files as often.
// kaha.setJournalMaxFileLength(1024*1024*100);
// small batch means more frequent and smaller writes
// kaha.setIndexWriteBatchSize(100);
// do the index write in a separate thread
kaha.setEnableIndexWriteAsync(true);
kaha.setIndexCacheSize(10000);
answer.setPersistenceAdapter(kaha);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class NumberOfDestinationsTest method configureBroker.
protected void configureBroker(BrokerService answer) throws Exception {
File dataFileDir = new File("target/test-amq-data/perfTest/kahadb");
KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
kaha.setDirectory(dataFileDir);
// answer.setUseJmx(false);
// The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified
// what happens if the index is updated but a journal update is lost.
// Index is going to be in consistent, but can it be repaired?
// kaha.setEnableJournalDiskSyncs(false);
// Using a bigger journal file size makes he take fewer spikes as it is not switching files as often.
// kaha.setJournalMaxFileLength(1024*100);
// small batch means more frequent and smaller writes
// kaha.setIndexWriteBatchSize(100);
// do the index write in a separate thread
// kaha.setEnableIndexWriteAsync(true);
answer.setPersistenceAdapter(kaha);
answer.setAdvisorySupport(false);
answer.setEnableStatistics(false);
answer.addConnector(bindAddress);
answer.setDeleteAllMessagesOnStartup(true);
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class RunBroker method main.
public static void main(String[] arg) {
try {
KahaDBPersistenceAdapter kahaDB = new KahaDBPersistenceAdapter();
File dataFileDir = new File("target/test-amq-data/perfTest/kahadb");
IOHelper.deleteChildren(dataFileDir);
kahaDB.setDirectory(dataFileDir);
// The setEnableJournalDiskSyncs(false) setting is a little
// dangerous right now, as I have not verified
// what happens if the index is updated but a journal update is
// lost.
// Index is going to be in consistent, but can it be repaired?
// kaha.setEnableJournalDiskSyncs(false);
// Using a bigger journal file size makes he take fewer spikes as it
// is not switching files as often.
// kaha.setJournalMaxFileLength(1024*1024*100);
// small batch means more frequent and smaller writes
kahaDB.setIndexWriteBatchSize(1000);
kahaDB.setIndexCacheSize(10000);
// do the index write in a separate thread
// kahaDB.setEnableIndexWriteAsync(true);
BrokerService broker = new BrokerService();
broker.setUseJmx(false);
// broker.setPersistenceAdapter(adaptor);
broker.setPersistenceAdapter(kahaDB);
// broker.setPersistent(false);
broker.setDeleteAllMessagesOnStartup(true);
broker.addConnector("tcp://0.0.0.0:61616");
broker.start();
System.err.println("Running");
Thread.sleep(Long.MAX_VALUE);
} catch (Throwable e) {
e.printStackTrace();
}
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class TwoBrokerQueueClientsReconnectTest method testDuplicateSendWithNoAuditEnqueueCountStat.
public void testDuplicateSendWithNoAuditEnqueueCountStat() throws Exception {
broker1 = "BrokerA";
broker2 = "BrokerB";
NetworkConnector networkConnector = bridgeBrokers(broker1, broker2);
final AtomicBoolean first = new AtomicBoolean();
final CountDownLatch gotMessageLatch = new CountDownLatch(1);
BrokerService brokerService = brokers.get(broker2).broker;
brokerService.setPersistent(true);
brokerService.setDeleteAllMessagesOnStartup(true);
// disable concurrent dispatch otherwise store duplicate suppression will be skipped b/c cursor audit is already
// disabled so verification of stats will fail - ie: duplicate will be dispatched
((KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter()).setConcurrentStoreAndDispatchQueues(false);
brokerService.setPlugins(new BrokerPlugin[] { new BrokerPluginSupport() {
@Override
public void send(final ProducerBrokerExchange producerExchange, org.apache.activemq.command.Message messageSend) throws Exception {
super.send(producerExchange, messageSend);
if (first.compareAndSet(false, true)) {
producerExchange.getConnectionContext().setDontSendReponse(true);
new Thread() {
@Override
public void run() {
try {
LOG.info("Waiting for recepit");
assertTrue("message received on time", gotMessageLatch.await(60, TimeUnit.SECONDS));
LOG.info("Stopping connection post send and receive and multiple producers");
producerExchange.getConnectionContext().getConnection().stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
}
} });
// Create queue
ActiveMQDestination dest = createDestination("TEST.FOO", false);
// statically include our destination
networkConnector.addStaticallyIncludedDestination(dest);
// Run brokers
startAllBrokers();
waitForBridgeFormation();
sendMessages("BrokerA", dest, 1);
// wait for broker2 to get the initial forward
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return brokers.get(broker2).broker.getAdminView().getTotalMessageCount() == 1;
}
});
// message still pending on broker1
assertEquals("messages message still there", 1, brokers.get(broker1).broker.getAdminView().getTotalMessageCount());
// allow the bridge to be shutdown and restarted
gotMessageLatch.countDown();
// verify message is forwarded after restart
assertTrue("no messages enqueued on origin", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 0 == brokers.get(broker1).broker.getAdminView().getTotalMessageCount();
}
}));
assertEquals("one messages pending", 1, brokers.get(broker2).broker.getAdminView().getTotalMessageCount());
assertEquals("one messages enqueued", 1, brokers.get(broker2).broker.getDestination(dest).getDestinationStatistics().getEnqueues().getCount());
}
Aggregations