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 | 8434e6155118d7f68ff96b1e57476543e8c663ed (patch) | |
| tree | 38aebe3326f5cef58b1cf490e529bdb700fbee7f /java | |
| parent | 58de9d70b81d453e4d2d16e062a22e5fdfdeb46d (diff) | |
| download | qpid-python-8434e6155118d7f68ff96b1e57476543e8c663ed.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/qpid@1332057 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java index 3183a66edb..30595269b3 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/TestRunner.java +++ b/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); + } } |
