You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2015/10/07 00:15:45 UTC
svn commit: r1707157 -
/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/controller/AbstractTestRunner.java
Author: kwall
Date: Tue Oct 6 22:15:45 2015
New Revision: 1707157
URL: http://svn.apache.org/viewvc?rev=1707157&view=rev
Log:
QPID-6732: [Java Perf Tests] Prevent race to remove queues between shutdown-hook and controller thread causing spurious exceptions during handling of a ^C
Modified:
qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/controller/AbstractTestRunner.java
Modified: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/controller/AbstractTestRunner.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/controller/AbstractTestRunner.java?rev=1707157&r1=1707156&r2=1707157&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/controller/AbstractTestRunner.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/controller/AbstractTestRunner.java Tue Oct 6 22:15:45 2015
@@ -27,9 +27,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
+import com.google.common.util.concurrent.SettableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,23 +64,28 @@ public abstract class AbstractTestRunner
private final long _testResultTimeout;
private CountDownLatch _testResultsLatch;
protected ControllerJmsDelegate _jmsDelegate;
- private final Thread _removeQueuesShutdownHook = new Thread()
+ private volatile SettableFuture<Object> _testCleanupComplete;
+ private final Thread _removeQueuesShutdownHook = new Thread("shutdown-hook")
{
@Override
public void run()
{
LOGGER.info("Shutdown intercepted: deleting test queues");
+ SettableFuture cleanupComplete = _testCleanupComplete;
try
{
- deleteQueues();
+ cleanupComplete.get(30, TimeUnit.SECONDS);
+ LOGGER.info("Test queues deleted");
}
- catch (Exception t)
+ catch (InterruptedException| TimeoutException | ExecutionException e)
{
- LOGGER.error("Failed to delete test queues during shutdown", t);
+ LOGGER.warn("Failed to delete test queues during shutdown."
+ + "Manual clean-up of queues may be required.", e);
}
}
};
private volatile CountDownLatch _commandResponseLatch = null;
+
protected AbstractTestRunner(ParticipatingClients participatingClients,
long commandResponseTimeout,
TestInstance testInstance,
@@ -221,7 +229,7 @@ public abstract class AbstractTestRunner
setOriginalTestDetailsOn(result);
testResult.addParticipantResult(result);
- LOGGER.debug("Received result " + result);
+ LOGGER.debug("Received result {}", result);
_testResultsLatch.countDown();
checkForResponseError(result);
@@ -308,8 +316,10 @@ public abstract class AbstractTestRunner
try
{
+ _testCleanupComplete = SettableFuture.create();
createQueues();
queuesCreated = true;
+
Runtime.getRuntime().addShutdownHook(_removeQueuesShutdownHook);
sendTestSetupCommands();
@@ -327,9 +337,16 @@ public abstract class AbstractTestRunner
finally
{
- if (queuesCreated)
+ try
+ {
+ if (queuesCreated)
+ {
+ deleteQueues();
+ }
+ }
+ finally
{
- deleteQueues();
+ _testCleanupComplete.set(null);
}
Runtime.getRuntime().removeShutdownHook(_removeQueuesShutdownHook);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org