@Override public void run() { boolean healthy = check(); if (healthy) { for (ActiveMQComponent component : componentList) { if (!component.isStarted() && ownShutdown) { try { ActiveMQUtilLogger.LOGGER.startingService(component.toString()); component.start(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString()); } } ownShutdown = false; } } else { for (ActiveMQComponent component : componentList) { if (component.isStarted()) { ownShutdown = true; try { ActiveMQUtilLogger.LOGGER.stoppingService(component.toString()); component.stop(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString()); } } } } }
protected static final void stopComponent(ActiveMQComponent component) { if (component == null) return; try { component.stop(); } catch (Exception e) { // no-op } }
@Test public void testAlreadyShutdown() throws Exception { assumeTrue(purePingWorks(IPV6_LOCAL)); ReusableLatch latch = new ReusableLatch(0); NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100) { @Override public void run() { super.run(); latch.countDown(); System.out.println("Check"); } }); check.addComponent(component); InetAddress address = InetAddress.getByName("127.0.0.1"); check.addAddress(address); component.stop(); latch.setCount(1); Assert.assertTrue(latch.await(1, TimeUnit.MINUTES)); Assert.assertFalse("NetworkHealthCheck should have no business on restarting the component, the network was never down, hence no check needed!", component.isStarted()); }
private void startComponents() throws Exception { for (final ActiveMQComponent component : getComponents()) { component.start(); } }
protected static final void waitForComponent(final ActiveMQComponent component, final long seconds) throws InterruptedException { long time = System.currentTimeMillis(); long toWait = seconds * 1000; while (!component.isStarted()) { Thread.sleep(50); if (System.currentTimeMillis() > (time + toWait)) { fail("component did not start within timeout of " + seconds); } } }
static void stopComponent(ActiveMQComponent component) { try { if (component != null) { component.stop(); } } catch (Throwable t) { ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, component.getClass().getName()); } }
@Override public void start() throws Exception { if (!dataSourceDependency) { List<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components); for (ActiveMQComponent component : componentsByStartOrder) { component.start(); } register(context, properties); } }
@Test public void testCheckUsingHTTP() throws Exception { startHTTPServer(); NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 1000)); Assert.assertTrue(check.check(new URL("http://localhost:8787"))); stopHTTPServer(); Assert.assertFalse(check.check(new URL("http://localhost:8787"))); check.addComponent(component); URL url = new URL("http://localhost:8787"); Assert.assertFalse(check.check(url)); startHTTPServer(); Assert.assertTrue(check.check(url)); check.addURL(url); Assert.assertFalse(latch.await(500, TimeUnit.MILLISECONDS)); Assert.assertTrue(component.isStarted()); // stopping the web server should stop the component stopHTTPServer(); Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); Assert.assertFalse(component.isStarted()); latch.setCount(1); startHTTPServer(); Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); Assert.assertTrue(component.isStarted()); }
@Override public void run() { boolean healthy = check(); if (healthy) { for (ActiveMQComponent component : componentList) { if (!component.isStarted() && ownShutdown) { try { ActiveMQUtilLogger.LOGGER.startingService(component.toString()); component.start(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString()); } } ownShutdown = false; } } else { for (ActiveMQComponent component : componentList) { if (component.isStarted()) { ownShutdown = true; try { ActiveMQUtilLogger.LOGGER.stoppingService(component.toString()); component.stop(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString()); } } } } }
@Override public void stop() throws Exception { ActiveMQComponent[] mqComponents = new ActiveMQComponent[components.size()]; components.values().toArray(mqComponents); for (int i = mqComponents.length - 1; i >= 0; i--) { mqComponents[i].stop(); } unregister(); }
@Override public synchronized void start() throws Exception { if (started) { return; } //todo if we start to pullout more configs from the main config then we should pull out the configuration objects from factories if available FileConfiguration configuration = new FileConfiguration(); LegacyJMSConfiguration legacyJMSConfiguration = new LegacyJMSConfiguration(configuration); FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl); fileDeploymentManager.addDeployable(configuration).addDeployable(legacyJMSConfiguration); fileDeploymentManager.readConfiguration(); createDirectories(configuration); components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer()); ArrayList<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components); ActiveMQBootstrapLogger.LOGGER.serverStarting(); for (ActiveMQComponent component : componentsByStartOrder) { component.start(); } started = true; }
Assert.assertTrue(backupServer.getServer().getExternalComponents().get(0).isStarted()); ((ServiceComponent) (backupServer.getServer().getExternalComponents().get(0))).stop(true); } finally {
@Override public void run() { boolean healthy = check(); if (healthy) { for (ActiveMQComponent component : componentList) { if (!component.isStarted() && ownShutdown) { try { ActiveMQUtilLogger.LOGGER.startingService(component.toString()); component.start(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString()); } } ownShutdown = false; } } else { for (ActiveMQComponent component : componentList) { if (component.isStarted()) { ownShutdown = true; try { ActiveMQUtilLogger.LOGGER.stoppingService(component.toString()); component.stop(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString()); } } } } }
private void stopComponents() throws Exception { for (final ActiveMQComponent component : reverse(getComponents())) { component.stop(); } } }
ActiveMQBootstrapLogger.LOGGER.serverStarting(); for (ActiveMQComponent component : componentsByStartOrder) { component.start();
@Override public void run() { boolean healthy = check(); if (healthy) { for (ActiveMQComponent component : componentList) { if (!component.isStarted() && ownShutdown) { try { ActiveMQUtilLogger.LOGGER.startingService(component.toString()); component.start(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString()); } } ownShutdown = false; } } else { for (ActiveMQComponent component : componentList) { if (component.isStarted()) { ownShutdown = true; try { ActiveMQUtilLogger.LOGGER.stoppingService(component.toString()); component.stop(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString()); } } } } }
@Override public void stop(boolean isShutdown) throws Exception { if (!started) { return; } ActiveMQComponent[] mqComponents = new ActiveMQComponent[components.size()]; components.values().toArray(mqComponents); for (int i = mqComponents.length - 1; i >= 0; i--) { if (mqComponents[i] instanceof ServiceComponent) { ((ServiceComponent) mqComponents[i]).stop(isShutdown); } else { mqComponents[i].stop(); } } started = false; }
@Override public void run() { boolean healthy = check(); if (healthy) { for (ActiveMQComponent component : componentList) { if (!component.isStarted() && ownShutdown) { try { ActiveMQUtilLogger.LOGGER.startingService(component.toString()); component.start(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString()); } } ownShutdown = false; } } else { for (ActiveMQComponent component : componentList) { if (component.isStarted()) { ownShutdown = true; try { ActiveMQUtilLogger.LOGGER.stoppingService(component.toString()); component.stop(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString()); } } } } }
@Override public void stop(boolean isShutdown) throws Exception { if (!started) { return; } ActiveMQComponent[] mqComponents = new ActiveMQComponent[components.size()]; components.values().toArray(mqComponents); for (int i = mqComponents.length - 1; i >= 0; i--) { if (mqComponents[i] instanceof ServiceComponent) { ((ServiceComponent) mqComponents[i]).stop(isShutdown); } else { mqComponents[i].stop(); } } started = false; }
@Override public void run() { boolean healthy = check(); if (healthy) { for (ActiveMQComponent component : componentList) { if (!component.isStarted() && ownShutdown) { try { ActiveMQUtilLogger.LOGGER.startingService(component.toString()); component.start(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString()); } } ownShutdown = false; } } else { for (ActiveMQComponent component : componentList) { if (component.isStarted()) { ownShutdown = true; try { ActiveMQUtilLogger.LOGGER.stoppingService(component.toString()); component.stop(); } catch (Exception e) { ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString()); } } } } }