summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2012-04-30 05:06:23 +0000
committerKeith Wall <kwall@apache.org>2012-04-30 05:06:23 +0000
commit0792d245a58c68fbd5313ef698609443e9ad9ec3 (patch)
tree1f0444d3ce7f7d81e5dd28e483a89b729d631b44
parent9eb4edcd1a30aa8c7d6005a5e3d13189f3d4265d (diff)
downloadqpid-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.java23
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);
+
}
}