use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class PageStressTest method testStopDuringDepage.
@Test
public void testStopDuringDepage() throws Exception {
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false).setJournalSyncTransactional(false);
HashMap<String, AddressSettings> settings = new HashMap<>();
AddressSettings setting = new AddressSettings().setMaxSizeBytes(20 * 1024 * 1024);
settings.put("page-adr", setting);
server = addServer(createServer(true, config, 10 * 1024 * 1024, 20 * 1024 * 1024, settings));
server.start();
final int NUMBER_OF_MESSAGES = 60000;
ClientSessionFactory factory = createSessionFactory(locator);
ClientSession session = addClientSession(factory.createSession(null, null, false, false, true, false, 1024 * NUMBER_OF_MESSAGES));
SimpleString address = new SimpleString("page-adr");
session.createQueue(address, address, null, true);
ClientProducer prod = session.createProducer(address);
ClientMessage message = createBytesMessage(session, ActiveMQBytesMessage.TYPE, new byte[700], true);
for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
if (i % 10000 == 0) {
System.out.println("Sent " + i);
}
prod.send(message);
}
session.commit();
session.start();
ClientConsumer consumer = session.createConsumer(address);
int msgs = 0;
ClientMessage msg;
do {
msg = consumer.receive(10000);
if (msg != null) {
msg.acknowledge();
if (++msgs % 1000 == 0) {
System.out.println("Received " + msgs);
}
}
} while (msg != null);
session.commit();
session.close();
server.stop();
System.out.println("server stopped, nr msgs: " + msgs);
server = addServer(createServer(true, config, 10 * 1024 * 1024, 20 * 1024 * 1024, settings));
server.start();
factory = createSessionFactory(locator);
session = addClientSession(factory.createSession(false, false, false));
consumer = session.createConsumer(address);
session.start();
do {
msg = consumer.receive(10000);
if (msg != null) {
msg.acknowledge();
session.commit();
if (++msgs % 1000 == 0) {
System.out.println("Received " + msgs);
}
}
} while (msg != null);
System.out.println("msgs second time: " + msgs);
Assert.assertEquals(NUMBER_OF_MESSAGES, msgs);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class PageCursorStressTest method createServer.
/**
* @throws Exception
*/
private void createServer() throws Exception {
OperationContextImpl.clearContext();
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(true);
server = createServer(true, config, PAGE_SIZE, PAGE_MAX, new HashMap<String, AddressSettings>());
server.start();
queueList.clear();
try {
queue = server.createQueue(ADDRESS, RoutingType.ANYCAST, ADDRESS, null, true, false);
queue.pause();
} catch (Exception ignored) {
}
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method colocatedTestNullBackup.
@Test
public void colocatedTestNullBackup() throws Exception {
Configuration configuration = createConfiguration("colocated-hapolicy-config-null-backup.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof ColocatedActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof ColocatedPolicy);
ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
ReplicatedPolicy livePolicy = (ReplicatedPolicy) colocatedPolicy.getLivePolicy();
assertNotNull(livePolicy);
assertEquals(livePolicy.getGroupName(), "purple");
assertTrue(livePolicy.isCheckForLiveServer());
assertEquals(livePolicy.getClusterName(), "abcdefg");
ReplicaPolicy backupPolicy = (ReplicaPolicy) colocatedPolicy.getBackupPolicy();
assertNotNull(backupPolicy);
} finally {
server.stop();
}
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method ReplicaTest3.
@Test
public void ReplicaTest3() throws Exception {
Configuration configuration = createConfiguration("replica-hapolicy-config3.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof SharedNothingBackupActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof ReplicaPolicy);
ReplicaPolicy replicaPolicy = (ReplicaPolicy) haPolicy;
assertEquals(replicaPolicy.getGroupName(), "tiddles");
assertEquals(replicaPolicy.getMaxSavedReplicatedJournalsSize(), 22);
assertEquals(replicaPolicy.getClusterName(), "33rrrrr");
assertFalse(replicaPolicy.isRestartBackup());
ScaleDownPolicy scaleDownPolicy = replicaPolicy.getScaleDownPolicy();
assertNull(scaleDownPolicy);
} finally {
server.stop();
}
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method colocatedTest2nullbackup.
@Test
public void colocatedTest2nullbackup() throws Exception {
Configuration configuration = createConfiguration("colocated-hapolicy-config2-null-backup.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof ColocatedActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof ColocatedPolicy);
ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
SharedStoreMasterPolicy livePolicy = (SharedStoreMasterPolicy) colocatedPolicy.getLivePolicy();
assertNotNull(livePolicy);
assertFalse(livePolicy.isFailoverOnServerShutdown());
SharedStoreSlavePolicy backupPolicy = (SharedStoreSlavePolicy) colocatedPolicy.getBackupPolicy();
assertNotNull(backupPolicy);
} finally {
server.stop();
}
}
Aggregations