From 4bae81490857f1ea292a89bead675669fae6de4e Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 26 Jun 2017 11:05:33 -0400 Subject: [PATCH 1/3] ARTEMIS-1253 Adding testcase --- ...nTest.java => NetworkReplicationTest.java} | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) rename tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/{NetworkIsolationReplicationTest.java => NetworkReplicationTest.java} (87%) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkIsolationReplicationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkReplicationTest.java similarity index 87% rename from tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkIsolationReplicationTest.java rename to tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkReplicationTest.java index e179c2187c..98b169a07b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkIsolationReplicationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkReplicationTest.java @@ -26,14 +26,18 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; +import org.apache.activemq.artemis.tests.util.Wait; import org.jboss.logging.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class NetworkIsolationReplicationTest extends FailoverTestBase { +public class NetworkReplicationTest extends FailoverTestBase { - private static final Logger logger = Logger.getLogger(NetworkIsolationReplicationTest.class); + private static final Logger logger = Logger.getLogger(NetworkReplicationTest.class); + + // This address is guaranteed to fail... reserved for documentation https://tools.ietf.org/html/rfc5737 + private static final String badAddress = "203.0.113.1"; @Before @Override @@ -59,6 +63,22 @@ public class NetworkIsolationReplicationTest extends FailoverTestBase { return addClientSession(sf1.createSession(xa, autoCommitSends, autoCommitAcks)); } + @Test + public void testReactivate() throws Exception { + liveServer.getServer().getConfiguration().setNetworkCheckPeriod(100).setNetworkCheckTimeout(200); + liveServer.start(); + + Assert.assertTrue(Wait.waitFor(liveServer::isActive)); + + liveServer.getServer().getNetworkHealthCheck().addAddress(InetAddress.getByName(badAddress)); + + Assert.assertTrue(Wait.waitFor(() -> !liveServer.isStarted())); + + liveServer.getServer().getNetworkHealthCheck().clearAddresses(); + + Assert.assertTrue(Wait.waitFor(liveServer::isStarted)); + } + @Test public void testDoNotActivateOnIsolation() throws Exception { AssertionLoggerHandler.startCapture(); @@ -81,7 +101,7 @@ public class NetworkIsolationReplicationTest extends FailoverTestBase { backupServer.getServer().getNetworkHealthCheck().clearAddresses(); } - backupServer.getServer().getNetworkHealthCheck().addAddress(InetAddress.getByName("203.0.113.1")); + backupServer.getServer().getNetworkHealthCheck().addAddress(InetAddress.getByName(badAddress)); backupServer.getServer().start(); ClientSessionFactory sf = addSessionFactory(locator.createSessionFactory()); @@ -121,7 +141,7 @@ public class NetworkIsolationReplicationTest extends FailoverTestBase { backupServer.stop(); liveServer.stop(); - liveServer.getServer().getConfiguration().setNetworkCheckList("203.0.113.1"). + liveServer.getServer().getConfiguration().setNetworkCheckList(badAddress). setNetworkCheckPeriod(100).setNetworkCheckTimeout(100); try { From 36110da9c834d606c0c5fb731b4e79504d32d7b2 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 26 Jun 2017 12:52:18 -0400 Subject: [PATCH 2/3] ARTEMIS-1253 Refactoring renaming stop(boolean) to fail(boolean) This method name would clash with ServiceComponent As the real meaning here on this method is just to failover So I've renamed the method to avoid the clash with my next commit (I've done this on a separate commit as you may need to redo this commit from scratch again in other branches instead of lots of clashes on cherry-pick) --- .../management/impl/ActiveMQServerControlImpl.java | 4 ++-- .../activemq/artemis/core/server/ActiveMQServer.java | 2 +- .../artemis/core/server/impl/ActiveMQServerImpl.java | 2 +- .../server/impl/SharedNothingLiveActivation.java | 2 +- .../artemis/tests/util/ActiveMQTestBase.java | 2 +- .../artemis/tests/extras/byteman/BMFailoverTest.java | 2 +- .../byteman/LargeMessageOverReplicationTest.java | 2 +- .../RaceOnSyncLargeMessageOverReplication2Test.java | 2 +- .../RaceOnSyncLargeMessageOverReplicationTest.java | 2 +- .../tests/extras/byteman/StartStopDeadlockTest.java | 2 +- .../client/InterruptedLargeMessageTest.java | 12 ++++++------ .../cluster/bridge/BridgeReconnectTest.java | 6 +++--- .../tests/integration/cluster/bridge/BridgeTest.java | 2 +- .../cluster/failover/GroupingFailoverTestBase.java | 4 ++-- .../cluster/util/SameProcessActiveMQServer.java | 2 +- .../divert/ReplicationWithDivertTest.java | 2 +- .../integration/jms/server/management/JMSUtil.java | 2 +- .../tests/integration/mqtt/imported/MQTTTest.java | 2 +- .../paging/PagingWithFailoverAndCountersTest.java | 2 +- .../integration/server/SimpleStartStopTest.java | 2 +- 20 files changed, 29 insertions(+), 29 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index faa25cca37..069ebf0023 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -2216,7 +2216,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active clearIO(); - server.stop(true); + server.fail(true); } @Override @@ -2251,7 +2251,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active liveOnlyPolicy.getScaleDownPolicy().getConnectors().add(0, connector); } - server.stop(true); + server.fail(true); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java index 42ba7a22fe..5d4aaeb8d8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java @@ -381,7 +381,7 @@ public interface ActiveMQServer extends ServiceComponent { */ boolean isAddressBound(String address) throws Exception; - void stop(boolean failoverOnServerShutdown) throws Exception; + void fail(boolean failoverOnServerShutdown) throws Exception; Queue updateQueue(String name, RoutingType routingType, diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index c0e0c9e733..6ab95ee931 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -832,7 +832,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { } @Override - public final void stop(boolean failoverOnServerShutdown) throws Exception { + public final void fail(boolean failoverOnServerShutdown) throws Exception { stop(failoverOnServerShutdown, false, false, false); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java index 7e8eb5dcb4..ce67e21daa 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java @@ -180,7 +180,7 @@ public class SharedNothingLiveActivation extends LiveActivation { clusterConnection.addClusterTopologyListener(listener1); if (listener1.waitForBackup()) { //if we have to many backups kept or are not configured to restart just stop, otherwise restart as a backup - activeMQServer.stop(true); + activeMQServer.fail(true); ActiveMQServerLogger.LOGGER.restartingReplicatedBackupAfterFailback(); // activeMQServer.moveServerData(replicatedPolicy.getReplicaPolicy().getMaxSavedReplicatedJournalsSize()); activeMQServer.setHAPolicy(replicatedPolicy.getReplicaPolicy()); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java index 17f2d88396..1b35393eab 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java @@ -2358,7 +2358,7 @@ public abstract class ActiveMQTestBase extends Assert { clusterManager.flushExecutor(); clusterManager.clear(); Assert.assertTrue("server should be running!", server.isStarted()); - server.stop(true); + server.fail(true); if (sessions.length > 0) { // Wait to be informed of failure diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java index e658a5372e..9ccd1f8113 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/BMFailoverTest.java @@ -71,7 +71,7 @@ public class BMFailoverTest extends FailoverTestBase { public static void stopAndThrow() throws ActiveMQUnBlockedException { if (!stopped) { try { - serverToStop.getServer().stop(true); + serverToStop.getServer().fail(true); } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java index d228c22dae..ddedeaa833 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageOverReplicationTest.java @@ -233,7 +233,7 @@ public class LargeMessageOverReplicationTest extends ActiveMQTestBase { try { if (messageChunkCount == 10) { - liveServer.stop(true); + liveServer.fail(true); System.err.println("activating"); if (!backupServer.waitForActivation(1, TimeUnit.MINUTES)) { diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java index 0437ae069d..3888a3efea 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplication2Test.java @@ -221,7 +221,7 @@ public class RaceOnSyncLargeMessageOverReplication2Test extends ActiveMQTestBase waitForRemoteBackup(connection.getSessionFactory(), 30); - liveServer.stop(true); + liveServer.fail(true); Assert.assertTrue(failedOver.await(10, TimeUnit.SECONDS)); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java index 99818d4b61..162c4d1898 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/RaceOnSyncLargeMessageOverReplicationTest.java @@ -200,7 +200,7 @@ public class RaceOnSyncLargeMessageOverReplicationTest extends ActiveMQTestBase Assert.assertFalse(t.isAlive()); - liveServer.stop(true); + liveServer.fail(true); Assert.assertTrue(failedOver.await(10, TimeUnit.SECONDS)); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java index 29c885a416..03f3e19140 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/StartStopDeadlockTest.java @@ -92,7 +92,7 @@ public class StartStopDeadlockTest extends ActiveMQTestBase { align.countDown(); startLatch.await(); System.out.println("Crashing...."); - serverLive.stop(true); + serverLive.fail(true); } catch (Exception e) { errors.incrementAndGet(); e.printStackTrace(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java index 44015e1992..f926af195c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java @@ -129,7 +129,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { // ((ServerSessionImpl) srvSession).clearLargeMessage(); // } - server.stop(false); + server.fail(false); ActiveMQTestBase.forceGC(); @@ -307,7 +307,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { session.rollback(); } - server.stop(false); + server.fail(false); server.start(); server.stop(); @@ -385,7 +385,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { sf.close(); } - server.stop(false); + server.fail(false); server.start(); validateNoFilesOnLargeDir(); @@ -443,7 +443,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { session.close(); sf.close(); - server.stop(false); + server.fail(false); server.start(); for (int start = 0; start < 2; start++) { @@ -635,7 +635,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { } ((ActiveMQServerImpl) server).replaceQueueFactory(original); - server.stop(false); + server.fail(false); server.start(); server.stop(); @@ -698,7 +698,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { } ((ActiveMQServerImpl) server).replaceQueueFactory(original); - server.stop(false); + server.fail(false); server.start(); server.stop(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java index 4a6fcaa626..88c0e81589 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java @@ -155,7 +155,7 @@ public class BridgeReconnectTest extends BridgeTestBase { startServers(); waitForServerStart(server0); - server0.stop(true); + server0.fail(true); waitForServerStart(server2); @@ -206,7 +206,7 @@ public class BridgeReconnectTest extends BridgeTestBase { BridgeReconnectTest.log.info("** failing connection"); // Now we will simulate a failure of the bridge connection between server0 and server1 - server0.stop(true); + server0.fail(true); waitForServerStart(server2); @@ -285,7 +285,7 @@ public class BridgeReconnectTest extends BridgeTestBase { startServers(); // Now we will simulate a failure of the bridge connection between server0 and server1 - server0.stop(true); + server0.fail(true); locator = addServerLocator(ActiveMQClient.createServerLocatorWithHA(server2tc)).setReconnectAttempts(100); ClientSessionFactory csf0 = addSessionFactory(locator.createSessionFactory(server2tc)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java index 2084796c40..e6a028fa98 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java @@ -1455,7 +1455,7 @@ public class BridgeTest extends ActiveMQTestBase { try { System.out.println("Stopping server"); latch.countDown(); - serverToStop.stop(false); + serverToStop.fail(false); } catch (Exception e) { e.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/GroupingFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/GroupingFailoverTestBase.java index 41f0e8f95f..de8c02c3e5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/GroupingFailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/GroupingFailoverTestBase.java @@ -93,7 +93,7 @@ public abstract class GroupingFailoverTestBase extends ClusterTestBase { closeSessionFactory(0); - servers[0].stop(true); + servers[0].fail(true); waitForServerRestart(2); @@ -194,7 +194,7 @@ public abstract class GroupingFailoverTestBase extends ClusterTestBase { closeSessionFactory(0); - servers[0].stop(true); + servers[0].fail(true); waitForServerRestart(2); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java index 35e17aa625..06305b48f5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/util/SameProcessActiveMQServer.java @@ -92,7 +92,7 @@ public class SameProcessActiveMQServer implements TestableServer { clusterManager.flushExecutor(); clusterManager.clear(); Assert.assertTrue("server should be running!", server.isStarted()); - server.stop(failover); + server.fail(failover); if (waitFailure) { // Wait to be informed of failure diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java index ede56f1280..dc179f92c7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/ReplicationWithDivertTest.java @@ -220,7 +220,7 @@ public class ReplicationWithDivertTest extends ActiveMQTestBase { } Assert.assertFalse(t.isAlive()); - liveServer.stop(true); + liveServer.fail(true); Assert.assertTrue(failedOver.await(10, TimeUnit.SECONDS)); { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java index e8af04912b..fc0b3704bc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSUtil.java @@ -257,7 +257,7 @@ public class JMSUtil { ClusterManager clusterManager = server.getClusterManager(); clusterManager.clear(); - server.stop(true); + server.fail(true); // Wait to be informed of failure boolean ok = latch.await(10000, TimeUnit.MILLISECONDS); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java index d8db226609..2e67dd694a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java @@ -1886,7 +1886,7 @@ public class MQTTTest extends MQTTTestSupport { connection1.connect(); connection1.publish(address, payload.getBytes(), QoS.AT_LEAST_ONCE, true); - getServer().stop(false); + getServer().fail(false); getServer().start(); waitForServerToStart(getServer()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java index 06bf59a7b5..0bc286e88e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java @@ -73,7 +73,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { if (inProcessBackup != null) { try { - inProcessBackup.getServer().stop(false); + inProcessBackup.getServer().fail(false); } catch (Throwable ignored) { ignored.printStackTrace(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java index c372a2ddf3..27d6f8a038 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SimpleStartStopTest.java @@ -47,7 +47,7 @@ public class SimpleStartStopTest extends ActiveMQTestBase { for (int i = 0; i < 50; i++) { server = createServer(true, false); server.start(); - server.stop(false); + server.fail(false); } // There shouldn't be any error from starting / stopping the server From f407d86f0fd8d8472600364caf88e1711c0e4e0b Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 26 Jun 2017 13:13:43 -0400 Subject: [PATCH 3/3] ARTEMIS-1253 Fixing NetworkHealthCheck being shutdown after failures --- .../activemq/artemis/cli/commands/Run.java | 4 ++-- .../artemis/integration/FileBroker.java | 12 ++++------ .../artemis/core/server/ServiceComponent.java | 2 +- .../core/server/impl/ActiveMQServerImpl.java | 22 ++++++++----------- .../core/server/impl/EmbeddedServerTest.java | 12 ++++++---- .../artemis/component/WebServerComponent.java | 4 ---- 6 files changed, 24 insertions(+), 32 deletions(-) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java index e48a1f40d1..229bd5b3ad 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java @@ -122,7 +122,7 @@ public class Run extends LockAbstract { if (file.exists()) { try { try { - server.exit(); + server.stop(true); } catch (Exception e) { e.printStackTrace(); } @@ -143,7 +143,7 @@ public class Run extends LockAbstract { @Override public void run() { try { - server.exit(); + server.stop(true); } catch (Exception e) { e.printStackTrace(); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java index af2286fc63..744a0e6c3b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java @@ -124,23 +124,19 @@ public class FileBroker implements Broker { @Override public void stop() throws Exception { - stop(false); - } - - @Override - public void exit() throws Exception { stop(true); } - private void stop(boolean isShutdown) throws Exception { + @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 && isShutdown) { - ((ServiceComponent) mqComponents[i]).exit(); + if (mqComponents[i] instanceof ServiceComponent) { + ((ServiceComponent) mqComponents[i]).stop(isShutdown); } else { mqComponents[i].stop(); } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ServiceComponent.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ServiceComponent.java index 6c347dd327..8ef15775fe 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ServiceComponent.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ServiceComponent.java @@ -22,5 +22,5 @@ package org.apache.activemq.artemis.core.server; public interface ServiceComponent extends ActiveMQComponent { //called by shutdown hooks before exit the VM - void exit() throws Exception; + void stop(boolean shutdown) throws Exception; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 6ab95ee931..ba7bed05cb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -340,7 +340,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { @Override public void stop() throws Exception { - internalStop(false); + ActiveMQServerImpl.this.stop(false); } @Override @@ -679,20 +679,16 @@ public class ActiveMQServerImpl implements ActiveMQServer { } @Override - public void exit() throws Exception { - internalStop(true); + public void stop() throws Exception { + stop(true); } @Override - public final void stop() throws Exception { - internalStop(false); - } - - private void internalStop(boolean isExit) throws Exception { + public void stop(boolean isShutdown) throws Exception { try { - stop(false, isExit); + stop(false, isShutdown); } finally { - networkHealthCheck.stop(); + if (isShutdown) networkHealthCheck.stop(); } } @@ -866,7 +862,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { * * @param criticalIOError whether we have encountered an IO error with the journal etc */ - void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boolean restarting, boolean isExit) { + void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boolean restarting, boolean isShutdown) { synchronized (this) { if (state == SERVER_STATE.STOPPED || state == SERVER_STATE.STOPPING) { @@ -1055,8 +1051,8 @@ public class ActiveMQServerImpl implements ActiveMQServer { for (ActiveMQComponent externalComponent : externalComponents) { try { - if (isExit && externalComponent instanceof ServiceComponent) { - ((ServiceComponent)externalComponent).exit(); + if (externalComponent instanceof ServiceComponent) { + ((ServiceComponent)externalComponent).stop(isShutdown); } else { externalComponent.stop(); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java index e47440dcbe..31b2626ce6 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/EmbeddedServerTest.java @@ -81,7 +81,7 @@ public class EmbeddedServerTest { server.addExternalComponent(normalComponent); server.addExternalComponent(serviceComponent); - server.stop(); + server.stop(false); assertTrue(normalComponent.stopCalled); assertTrue(serviceComponent.stopCalled); @@ -91,7 +91,7 @@ public class EmbeddedServerTest { serviceComponent.resetFlags(); server.start(); - server.exit(); + server.stop(); assertTrue(normalComponent.stopCalled); assertFalse(serviceComponent.stopCalled); @@ -129,8 +129,12 @@ public class EmbeddedServerTest { volatile boolean exitCalled; @Override - public void exit() throws Exception { - exitCalled = true; + public void stop(boolean isShutdown) throws Exception { + if (isShutdown) { + exitCalled = true; + } else { + stop(); + } } @Override diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java index 6dce708dc8..5ac42df4ae 100644 --- a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java +++ b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java @@ -191,10 +191,6 @@ public class WebServerComponent implements ExternalComponent { } @Override - public void exit() throws Exception { - stop(true); - } - public void stop(boolean isShutdown) throws Exception { if (isShutdown) { internalStop();