This closes #2234
This commit is contained in:
commit
9c905a2b58
|
@ -60,6 +60,8 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
// To be used on tests. As we use the loopback as a valid address on tests.
|
||||
private boolean ignoreLoopback = false;
|
||||
|
||||
private boolean ownShutdown = false;
|
||||
|
||||
/**
|
||||
* The timeout to be used on isReachable
|
||||
*/
|
||||
|
@ -274,7 +276,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
|
||||
if (healthy) {
|
||||
for (ActiveMQComponent component : componentList) {
|
||||
if (!component.isStarted()) {
|
||||
if (!component.isStarted() && ownShutdown) {
|
||||
try {
|
||||
ActiveMQUtilLogger.LOGGER.startingService(component.toString());
|
||||
component.start();
|
||||
|
@ -282,6 +284,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString());
|
||||
}
|
||||
}
|
||||
ownShutdown = false;
|
||||
}
|
||||
} else {
|
||||
for (ActiveMQComponent component : componentList) {
|
||||
|
@ -289,6 +292,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
try {
|
||||
ActiveMQUtilLogger.LOGGER.stoppingService(component.toString());
|
||||
component.stop();
|
||||
ownShutdown = true;
|
||||
} catch (Exception e) {
|
||||
ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString());
|
||||
}
|
||||
|
|
|
@ -142,6 +142,31 @@ public class NetworkHealthTest {
|
|||
Assert.assertTrue(check.check(address));
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseSpaces() throws Exception {
|
||||
NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100));
|
||||
|
|
Loading…
Reference in New Issue