You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ru...@apache.org on 2007/09/26 13:27:47 UTC
svn commit: r579602 -
/incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
Author: rupertlssmith
Date: Wed Sep 26 04:27:45 2007
New Revision: 579602
URL: http://svn.apache.org/viewvc?rev=579602&view=rev
Log:
Added timeout to perftests, to fail tests if message loss causes test to jam.
Modified:
incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
Modified: incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java?rev=579602&r1=579601&r2=579602&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java (original)
+++ incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java Wed Sep 26 04:27:45 2007
@@ -885,24 +885,8 @@
synchronized (_sendPauseMonitor)
{
if ((_maxPendingSize > 0) && (unreceivedSize < _maxPendingSize))
- // && (_sendPauseBarrier.getNumberWaiting() == 1))
{
- // log.debug("unreceived size estimate under limit = " + unreceivedSize);
-
- // Wait on the send pause barrier for the limit to be re-established.
- /*try
- {*/
- // _sendPauseBarrier.await();
_sendPauseMonitor.notify();
- /*}
- catch (InterruptedException e)
- {
- throw new RuntimeException(e);
- }
- catch (BrokenBarrierException e)
- {
- throw new RuntimeException(e);
- }*/
}
}
@@ -1159,12 +1143,23 @@
// If necessary, wait until the max pending message size comes within its limit.
synchronized (_sendPauseMonitor)
{
+ // Used to keep track of the number of times that send has to wait.
+ int numWaits = 0;
+
+ // The maximum number of waits before the test gives up and fails. This has been chosen to correspond with
+ // the test timeout.
+ int waitLimit = (int) (TIMEOUT_DEFAULT / 100);
+
while ((_maxPendingSize > 0))
{
// Get the size estimate of sent but not yet received messages.
int unreceived = _unreceived.get();
int unreceivedSize = (unreceived * ((_messageSize == 0) ? 1 : _messageSize));
+ // log.debug("unreceived = " + unreceived);
+ // log.debug("unreceivedSize = " + unreceivedSize);
+ // log.debug("_maxPendingSize = " + _maxPendingSize);
+
if (unreceivedSize > _maxPendingSize)
{
// log.debug("unreceived size estimate over limit = " + unreceivedSize);
@@ -1172,8 +1167,8 @@
// Wait on the send pause barrier for the limit to be re-established.
try
{
- // _sendPauseBarrier.await();
- _sendPauseMonitor.wait(1000);
+ _sendPauseMonitor.wait(100);
+ numWaits++;
}
catch (InterruptedException e)
{
@@ -1181,10 +1176,17 @@
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
- /*catch (BrokenBarrierException e)
+
+ // Fail the test if the send has had to wait more than the maximum allowed number of times.
+ if (numWaits >= waitLimit)
{
- throw new RuntimeException(e);
- }*/
+ String errorMessage =
+ "Send has had to wait for the unreceivedSize (" + unreceivedSize
+ + ") to come below the maxPendingSize (" + _maxPendingSize + ") more that " + waitLimit
+ + " times.";
+ log.warn(errorMessage);
+ throw new RuntimeException(errorMessage);
+ }
}
else
{