@Override public boolean isStarted() { return server.isStarted(); }
@Override public boolean isStarted() { return server.isStarted(); }
private void checkStarted() { if (!server.isStarted()) { throw new IllegalStateException("Broker is not started. It can not be managed yet"); } }
@Override public boolean isStarted() { return server.isStarted(); }
public static void waitForServer(ActiveMQServer server) throws InterruptedException { long timetowait = System.currentTimeMillis() + 5000; while (!server.isStarted()) { Thread.sleep(100); if (server.isStarted()) { break; } else if (System.currentTimeMillis() > timetowait) { throw new IllegalStateException("server didn't start"); } } }
@Override public boolean isStarted() { clearIO(); try { return server.isStarted(); } finally { blockOnIO(); } }
public static boolean isActiveMQServerActive(ServiceRegistry serviceRegistry, ServiceName activeMQServerServiceName) { ServiceController<?> service = serviceRegistry.getService(activeMQServerServiceName); if (service != null) { ActiveMQServer server = ActiveMQServer.class.cast(service.getValue()); if (server.isStarted() && server.isActive()) { return true; } } return false; }
public static boolean isActiveMQServerActive(ServiceRegistry serviceRegistry, ServiceName activeMQServerServiceName) { ServiceController<?> service = serviceRegistry.getService(activeMQServerServiceName); if (service != null) { ActiveMQServer server = ActiveMQServer.class.cast(service.getValue()); if (server.isStarted() && server.isActive()) { return true; } } return false; }
public void stopBroker() throws Exception { if (server.isStarted()) { server.stop(); server = null; } }
protected void waitForServerToStop(ActiveMQServer server) throws InterruptedException { if (server == null) return; final long wait = 5000; long timetowait = System.currentTimeMillis() + wait; while (server.isStarted() && System.currentTimeMillis() < timetowait) { Thread.sleep(50); } if (server.isStarted()) { log.info(threadDump("Server didn't start")); fail("Server didn't start: " + server); } }
public void deliverUpToDateMsg() { live.getRemotingService().removeIncomingInterceptor(this); if (backup.isStarted()) handler.deliver(); }
@Test public void testForceFailover() throws Exception { ActiveMQServerControl serverControl = createManagementControl(); try { serverControl.forceFailover(); } catch (Exception e) { if (!usingCore()) { fail(e.getMessage()); } } Wait.waitFor(() -> !server.isStarted()); assertFalse(server.isStarted()); }
protected void waitForServerToStart(ActiveMQServer server, boolean activation) throws InterruptedException { if (server == null) return; final long wait = 5000; long timetowait = System.currentTimeMillis() + wait; while (!server.isStarted() && System.currentTimeMillis() < timetowait) { Thread.sleep(50); } if (!server.isStarted()) { log.info(threadDump("Server didn't start")); fail("server didn't start: " + server); } if (activation) { if (!server.getHAPolicy().isBackup()) { if (!server.waitForActivation(wait, TimeUnit.MILLISECONDS)) fail("Server didn't initialize: " + server); } } }
public void perform(String startedString) throws Exception { Configuration config = new ConfigurationImpl().setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY)); ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, false); server.start(); while (!server.isStarted()) { System.out.println("Still starting"); Thread.sleep(100); } System.out.println(WORD_START); log.info("### server: " + startedString); } }
protected void stopClusterConnections(final int... nodes) throws Exception { for (int node : nodes) { if (servers[node].isStarted()) { for (ClusterConnection cc : servers[node].getClusterManager().getClusterConnections()) { cc.stop(); cc.flushExecutor(); } } } }
public static void crashAndWaitForFailure(ActiveMQServer server, ClientSession... sessions) throws Exception { CountDownLatch latch = new CountDownLatch(sessions.length); for (ClientSession session : sessions) { CountDownSessionFailureListener listener = new CountDownSessionFailureListener(latch, session); session.addFailureListener(listener); } ClusterManager clusterManager = server.getClusterManager(); clusterManager.flushExecutor(); clusterManager.clear(); Assert.assertTrue("server should be running!", server.isStarted()); server.fail(true); if (sessions.length > 0) { // Wait to be informed of failure boolean ok = latch.await(10000, TimeUnit.MILLISECONDS); Assert.assertTrue("Failed to stop the server! Latch count is " + latch.getCount() + " out of " + sessions.length, ok); } }
@Test public void liveCrashOnBackupSyncLargeMessageTest() throws Exception { Process process = SpawnedVMSupport.spawnVM(LiveCrashOnBackupSyncTest.class.getCanonicalName(), backupDir.getAbsolutePath(), liveDir.getAbsolutePath()); try { Assert.assertEquals(OK, process.waitFor()); Configuration liveConfiguration = createLiveConfiguration(); ActiveMQServer liveServer = ActiveMQServers.newActiveMQServer(liveConfiguration); liveServer.start(); Wait.waitFor(() -> liveServer.isStarted()); File liveLMDir = liveServer.getConfiguration().getLargeMessagesLocation(); Set<Long> liveLM = getAllMessageFileIds(liveLMDir); Assert.assertEquals("we really ought to delete these after delivery", 0, liveLM.size()); liveServer.stop(); } finally { process.destroy(); Assert.assertTrue(process.waitFor(5, TimeUnit.SECONDS)); Assert.assertFalse(process.isAlive()); } }
@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(); } }
@Override protected void createClientSessionFactory() throws Exception { if (liveServer.getServer().isStarted()) { sf = (ClientSessionFactoryInternal) createSessionFactory(locator); sf = (ClientSessionFactoryInternal) locator.createSessionFactory(liveServer.getServer().getNodeID().toString()); } else { sf = (ClientSessionFactoryInternal) createSessionFactory(locator); } }
@Test public void testShutdownServer() throws Throwable { ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true, false); session.createQueue(QUEUE, QUEUE, null, true); ClientConsumer consumer = session.createConsumer(QUEUE); ClientProducer producer = session.createProducer(QUEUE); ClientMessage message = session.createMessage(Message.TEXT_TYPE, true, 0, System.currentTimeMillis(), (byte) 4); message.getBodyBuffer().writeString("hi"); message.putStringProperty("hello", "elo"); producer.send(message); ActiveMQServerImpl impl = (ActiveMQServerImpl) server; JournalStorageManager journal = (JournalStorageManager) impl.getStorageManager(); JDBCJournalImpl journalimpl = (JDBCJournalImpl) journal.getMessageJournal(); journalimpl.handleException(null, new Exception("failure")); Wait.waitFor(() -> !server.isStarted()); Assert.assertFalse(server.isStarted()); }