use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class DurablePersistentFalseRestartTest method configureBroker.
@Override
protected void configureBroker(BrokerService broker) throws Exception {
super.configureBroker(broker);
broker.setPersistent(false);
broker.setPersistenceAdapter(new KahaDBPersistenceAdapter());
broker.addConnector("tcp://0.0.0.0:0");
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class kahaDbJdbcLeaseQueueMasterSlaveTest method createSlave.
@Override
protected void createSlave() throws Exception {
// use a separate thread as the slave will block waiting for
// the exclusive db lock
Thread t = new Thread() {
@Override
public void run() {
try {
BrokerService broker = new BrokerService();
broker.setBrokerName("slave");
TransportConnector connector = new TransportConnector();
connector.setUri(new URI(SLAVE_URL));
broker.addConnector(connector);
broker.setUseJmx(false);
broker.setPersistent(true);
KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
leaseDatabaseLocker.setDataSource(getExistingDataSource());
leaseDatabaseLocker.setStatements(new Statements());
kahaDBPersistenceAdapter.setLocker(leaseDatabaseLocker);
configureLocker(kahaDBPersistenceAdapter);
configureBroker(broker);
broker.start();
slave.set(broker);
slaveStarted.countDown();
} catch (IllegalStateException expectedOnShutdown) {
} catch (Exception e) {
fail("failed to start slave broker, reason:" + e);
}
}
};
t.start();
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class mKahaDbQueueMasterSlaveTest method createSlave.
@Override
protected void createSlave() throws Exception {
// use a separate thread as the slave will block waiting for
// the exclusive db lock
Thread t = new Thread() {
@Override
public void run() {
try {
BrokerService broker = new BrokerService();
broker.setBrokerName("slave");
TransportConnector connector = new TransportConnector();
connector.setUri(new URI(SLAVE_URL));
broker.addConnector(connector);
// no need for broker.setMasterConnectorURI(masterConnectorURI)
// as the db lock provides the slave/master initialisation
broker.setUseJmx(false);
broker.setPersistent(true);
MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter();
List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>();
FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter();
defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter());
defaultEntry.setPerDestination(true);
adapters.add(defaultEntry);
mKahaDB.setFilteredPersistenceAdapters(adapters);
broker.setPersistenceAdapter(mKahaDB);
broker.start();
slave.set(broker);
slaveStarted.countDown();
} catch (IllegalStateException expectedOnShutdown) {
} catch (Exception e) {
fail("failed to start slave broker, reason:" + e);
}
}
};
t.start();
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class DurableSubDelayedUnsubscribeTest method testProcess.
@Test
public void testProcess() throws Exception {
server.start();
clientManager.start();
houseKeeper.start();
// Sleep to
Thread.sleep(RUNTIME);
// inform message producer to stop
server.stopped = true;
// add one Subscriber to the topic that will not be unsubscribed.
// should not have any pending messages in the kahadb store
Client lastClient = new Client(32000, ClientType.A);
lastClient.process(1000);
// stop client manager from creating any more clients
clientManager.stopped = true;
final BrokerService brokerService = this.broker;
// Wait for all client subscription to be unsubscribed or swept away.
// Ensure we sleep longer than the housekeeper's sweep delay otherwise we can
// miss the fact that all durables that were abandoned do finally get cleaned up.
// Wait for all clients to stop
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return clientManager.getClientCount() == 0;
}
}, Client.lifetime + TimeUnit.SECONDS.toMillis(10));
assertTrue("should have only one inactiveSubscriber subscribed but was: " + brokerService.getAdminView().getInactiveDurableTopicSubscribers().length, Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return brokerService.getAdminView().getInactiveDurableTopicSubscribers().length == 1;
}
}, houseKeeper.SWEEP_DELAY * 2));
assertTrue("should be no subscribers subscribed but was: " + brokerService.getAdminView().getDurableTopicSubscribers().length, Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return brokerService.getAdminView().getDurableTopicSubscribers().length == 0;
}
}, TimeUnit.MINUTES.toMillis(3)));
processLock.writeLock().lock();
// check outcome.
ObjectName[] subscribers = broker.getAdminView().getDurableTopicSubscribers();
ObjectName[] inactiveSubscribers = broker.getAdminView().getInactiveDurableTopicSubscribers();
final KahaDBPersistenceAdapter persistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
printDebugClientInfo(subscribers, inactiveSubscribers, persistenceAdapter);
assertEquals("should have only one inactiveSubscriber subscribed", 1, broker.getAdminView().getInactiveDurableTopicSubscribers().length);
assertEquals("should be no subscribers subscribed", 0, broker.getAdminView().getDurableTopicSubscribers().length);
final KahaDBPersistenceAdapter pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
assertTrue("should be less than 3 journal file left but was: " + persistenceAdapter.getStore().getJournal().getFileMap().size(), Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return pa.getStore().getJournal().getFileMap().size() <= 3;
}
}, TimeUnit.MINUTES.toMillis(3)));
// Be good and cleanup our mess a bit.
this.houseKeeper.shutdown();
assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
LOG.info("DONE.");
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class DurableSubProcessConcurrentCommitActivateNoDuplicateTest method startBroker.
private void startBroker(boolean deleteAllMessages) throws Exception {
if (broker != null)
return;
broker = BrokerFactory.createBroker("broker:(vm://" + getName() + ")");
broker.setBrokerName(getName());
broker.setAdvisorySupport(false);
broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
switch(PERSISTENT_ADAPTER) {
case MEMORY:
broker.setPersistent(false);
break;
case LEVELDB:
File amqData = new File("activemq-data/" + getName() + "-leveldb");
if (deleteAllMessages)
delete(amqData);
broker.setPersistent(true);
LevelDBStore amq = new LevelDBStore();
amq.setDirectory(amqData);
broker.setPersistenceAdapter(amq);
break;
case KAHADB:
File kahadbData = new File("activemq-data/" + getName() + "-kahadb");
if (deleteAllMessages)
delete(kahadbData);
broker.setPersistent(true);
KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter();
kahadb.setDirectory(kahadbData);
kahadb.setJournalMaxFileLength(5 * 1024 * 1024);
broker.setPersistenceAdapter(kahadb);
break;
}
broker.addConnector("tcp://localhost:61656");
broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024);
broker.getSystemUsage().getTempUsage().setLimit(256 * 1024 * 1024);
broker.getSystemUsage().getStoreUsage().setLimit(1024 * 1024 * 1024);
PolicyMap policyMap = new PolicyMap();
PolicyEntry defaultEntry = new PolicyEntry();
defaultEntry.setMaxAuditDepth(20000);
policyMap.setDefaultEntry(defaultEntry);
broker.setDestinationPolicy(policyMap);
broker.start();
}
Aggregations