use of org.apache.activemq.artemis.utils.critical.CriticalComponent in project activemq-artemis by apache.
the class CriticalSimpleTest method testCriticalOff.
@Test
public void testCriticalOff() throws Exception {
Configuration configuration = createDefaultConfig(false);
configuration.setCriticalAnalyzerCheckPeriod(10).setCriticalAnalyzer(false);
ActiveMQServer server = createServer(false, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES);
server.start();
try {
server.getCriticalAnalyzer().add(new CriticalComponent() {
@Override
public boolean isExpired(long timeout) {
return true;
}
});
Wait.waitFor(() -> !server.isStarted(), 500, 10);
Assert.assertTrue(server.isStarted());
} finally {
server.stop();
}
}
use of org.apache.activemq.artemis.utils.critical.CriticalComponent in project activemq-artemis by apache.
the class CriticalSimpleTest method testSimpleShutdown.
@Test
public void testSimpleShutdown() throws Exception {
Configuration configuration = createDefaultConfig(false);
configuration.setCriticalAnalyzerCheckPeriod(10).setCriticalAnalyzerPolicy(CriticalAnalyzerPolicy.SHUTDOWN);
ActiveMQServer server = createServer(false, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES);
server.start();
try {
CountDownLatch latch = new CountDownLatch(1);
server.getConfiguration().registerBrokerPlugin(new ActiveMQServerPlugin() {
@Override
public void criticalFailure(CriticalComponent components) throws ActiveMQException {
latch.countDown();
}
});
server.getCriticalAnalyzer().add(new CriticalComponent() {
@Override
public boolean isExpired(long timeout) {
return true;
}
});
Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
Wait.waitFor(() -> !server.isStarted());
Assert.assertFalse(server.isStarted());
} finally {
server.stop();
}
}
Aggregations