diff options
author | Keith Wall <kwall@apache.org> | 2012-04-30 05:06:23 +0000 |
---|---|---|
committer | Keith Wall <kwall@apache.org> | 2012-04-30 05:06:23 +0000 |
commit | 0792d245a58c68fbd5313ef698609443e9ad9ec3 (patch) | |
tree | 1f0444d3ce7f7d81e5dd28e483a89b729d631b44 | |
parent | 9eb4edcd1a30aa8c7d6005a5e3d13189f3d4265d (diff) | |
download | qpid-python-0792d245a58c68fbd5313ef698609443e9ad9ec3.tar.gz |
QPID-3936: Performance Test Tool: Try to remove test queues in the event of unexpected shutdown (Control-C etc)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1332057 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java b/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java index 3183a66edb..30595269b3 100644 --- a/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java +++ b/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java @@ -62,6 +62,22 @@ public class TestRunner /** Length of time to await test results or {@value #WAIT_FOREVER} */ private final long _testResultTimeout; + private Thread _removeQueuesShutdownHook = new Thread() + { + @Override + public void run() + { + LOGGER.info("Shutdown intercepted: deleting test queues"); + try + { + deleteQueues(); + } + catch (Throwable t) + { + LOGGER.error("Failed to delete test queues during shutdown", t); + } + } + }; public TestRunner(ParticipatingClients participatingClients, TestInstance testInstance, ControllerJmsDelegate jmsDelegate, long commandResponseTimeout, long testResultTimeout) { @@ -98,10 +114,13 @@ public class TestRunner private void runParts() { boolean queuesCreated = false; + try { createQueues(); queuesCreated = true; + Runtime.getRuntime().addShutdownHook(_removeQueuesShutdownHook); + sendTestSetupCommands(); awaitCommandResponses(); sendCommandToParticipatingClients(new StartTestCommand()); @@ -114,10 +133,14 @@ public class TestRunner } finally { + if (queuesCreated) { deleteQueues(); } + + Runtime.getRuntime().removeShutdownHook(_removeQueuesShutdownHook); + } } |