use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class FailoverStaticNetworkTest method doTestRepeatedSendReceiveWithMasterSlaveAlternate.
public void doTestRepeatedSendReceiveWithMasterSlaveAlternate(HashMap<String, String> networkConnectorProps) throws Exception {
brokerB = createBroker("tcp", "62617", new String[] { "61610", "61611" }, networkConnectorProps);
brokerB.start();
final AtomicBoolean done = new AtomicBoolean(false);
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
while (!done.get()) {
brokerA = createBroker("tcp", "61610", null);
brokerA.setBrokerName("Pair");
brokerA.setBrokerObjectName(new ObjectName(brokerA.getManagementContext().getJmxDomainName() + ":" + "BrokerName=" + JMXSupport.encodeObjectNamePart("A") + "," + "Type=Broker"));
((KahaDBPersistenceAdapter) brokerA.getPersistenceAdapter()).getLocker().setLockAcquireSleepInterval(1000);
brokerA.start();
brokerA.waitUntilStopped();
// restart after peer taken over
brokerA1.waitUntilStarted();
}
} catch (Exception ignored) {
LOG.info("A create/start, unexpected: " + ignored, ignored);
}
}
});
// start with brokerA as master
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return brokerA != null && brokerA.waitUntilStarted();
}
});
executorService.execute(new Runnable() {
@Override
public void run() {
try {
while (!done.get()) {
brokerA1 = createBroker("tcp", "61611", null);
brokerA1.setBrokerName("Pair");
// so they can coexist in local jmx we set the object name b/c the brokername identifies the shared store
brokerA1.setBrokerObjectName(new ObjectName(brokerA.getManagementContext().getJmxDomainName() + ":" + "BrokerName=" + JMXSupport.encodeObjectNamePart("A1") + "," + "Type=Broker"));
((KahaDBPersistenceAdapter) brokerA1.getPersistenceAdapter()).getLocker().setLockAcquireSleepInterval(1000);
brokerA1.start();
brokerA1.waitUntilStopped();
// restart after peer taken over
brokerA.waitUntilStarted();
}
} catch (Exception ignored) {
LOG.info("A1 create/start, unexpected: " + ignored, ignored);
}
}
});
for (int i = 0; i < 4; i++) {
BrokerService currentMaster = (i % 2 == 0 ? brokerA : brokerA1);
LOG.info("iteration: " + i + ", using: " + currentMaster.getBrokerObjectName().getKeyProperty("BrokerName"));
currentMaster.waitUntilStarted();
doTestNetworkSendReceive(brokerB, currentMaster);
LOG.info("Stopping " + currentMaster.getBrokerObjectName().getKeyProperty("BrokerName"));
currentMaster.stop();
currentMaster.waitUntilStopped();
}
done.set(true);
LOG.info("all done");
executorService.shutdownNow();
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class NetworkBrokerDetachTest method configureBroker.
// variants for each store....
protected void configureBroker(BrokerService broker) throws Exception {
KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
persistenceAdapter.setDirectory(new File("target/activemq-data/kahadb/" + broker.getBrokerName() + "NetworBrokerDetatchTest"));
broker.setPersistenceAdapter(persistenceAdapter);
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class CheckDuplicateMessagesOnDuplexTest method persistenceAdapterFactory_KahaDB.
private PersistenceAdapter persistenceAdapterFactory_KahaDB(String path) {
KahaDBPersistenceAdapter kahaDBPersistenceAdapter = new KahaDBPersistenceAdapter();
kahaDBPersistenceAdapter.setDirectory(new File(path));
kahaDBPersistenceAdapter.setIgnoreMissingJournalfiles(true);
kahaDBPersistenceAdapter.setCheckForCorruptJournalFiles(true);
kahaDBPersistenceAdapter.setChecksumJournalFiles(true);
return kahaDBPersistenceAdapter;
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class TestSupport method setPersistenceAdapter.
public static PersistenceAdapter setPersistenceAdapter(BrokerService broker, PersistenceAdapterChoice choice) throws IOException {
PersistenceAdapter adapter = null;
switch(choice) {
case JDBC:
JDBCPersistenceAdapter jdbcPersistenceAdapter = new JDBCPersistenceAdapter();
// rollback (at shutdown) on derby can take a long time with file io etc
jdbcPersistenceAdapter.setUseLock(false);
adapter = jdbcPersistenceAdapter;
break;
case KahaDB:
adapter = new KahaDBPersistenceAdapter();
break;
case LevelDB:
adapter = new LevelDBPersistenceAdapter();
break;
case MEM:
adapter = new MemoryPersistenceAdapter();
break;
}
broker.setPersistenceAdapter(adapter);
adapter.setDirectory(new File(broker.getBrokerDataDirectory(), choice.name()));
return adapter;
}
use of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter in project activemq-artemis by apache.
the class XARecoveryBrokerTest method testPreparedJmxView.
public void testPreparedJmxView() throws Exception {
ActiveMQDestination destination = createDestination();
// Setup the producer and send the message.
StubConnection connection = createConnection();
ConnectionInfo connectionInfo = createConnectionInfo();
SessionInfo sessionInfo = createSessionInfo(connectionInfo);
ProducerInfo producerInfo = createProducerInfo(sessionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
connection.send(producerInfo);
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.send(consumerInfo);
// Prepare 4 message sends.
for (int i = 0; i < 4; i++) {
// Begin the transaction.
XATransactionId txid = createXATransaction(sessionInfo);
connection.send(createBeginTransaction(connectionInfo, txid));
Message message = createMessage(producerInfo, destination);
message.setPersistent(true);
message.setTransactionId(txid);
connection.send(message);
// Prepare
connection.send(createPrepareTransaction(connectionInfo, txid));
}
Response response = connection.request(new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER));
assertNotNull(response);
DataArrayResponse dar = (DataArrayResponse) response;
assertEquals(4, dar.getData().length);
// view prepared in kahadb view
if (broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) {
PersistenceAdapterViewMBean kahadbView = getProxyToPersistenceAdapter(broker.getPersistenceAdapter().toString());
String txFromView = kahadbView.getTransactions();
LOG.info("Tx view fromm PA:" + txFromView);
assertTrue("xid with our dud format in transaction string " + txFromView, txFromView.contains("XID:[55,"));
}
// restart the broker.
restartBroker();
connection = createConnection();
connectionInfo = createConnectionInfo();
connection.send(connectionInfo);
response = connection.request(new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER));
assertNotNull(response);
dar = (DataArrayResponse) response;
assertEquals(4, dar.getData().length);
// validate destination depth via jmx
DestinationViewMBean destinationView = getProxyToDestination(destinationList(destination)[0]);
assertEquals("enqueue count does not see prepared", 0, destinationView.getQueueSize());
TransactionId first = (TransactionId) dar.getData()[0];
int commitCount = 0;
// via jmx, force outcome
for (int i = 0; i < 4; i++) {
RecoveredXATransactionViewMBean mbean = getProxyToPreparedTransactionViewMBean((TransactionId) dar.getData()[i]);
if (i % 2 == 0) {
mbean.heuristicCommit();
commitCount++;
} else {
mbean.heuristicRollback();
}
}
// verify all completed
response = connection.request(new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER));
assertNotNull(response);
dar = (DataArrayResponse) response;
assertEquals(0, dar.getData().length);
// verify messages available
assertEquals("enqueue count reflects outcome", commitCount, destinationView.getQueueSize());
// verify mbeans gone
try {
RecoveredXATransactionViewMBean gone = getProxyToPreparedTransactionViewMBean(first);
gone.heuristicRollback();
fail("Excepted not found");
} catch (InstanceNotFoundException expectedNotfound) {
}
}
Aggregations