Author: sebb
Date: Fri Sep 23 11:49:31 2011
New Revision: 1174675

URL: http://svn.apache.org/viewvc?rev=1174675&view=rev
Log:
Bug 51880 - The shutdown command is not working if I invoke it before all the 
thread are started.

Modified:
    jakarta/jmeter/trunk/bin/jmeter.properties
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: jakarta/jmeter/trunk/bin/jmeter.properties
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/jmeter.properties?rev=1174675&r1=1174674&r2=1174675&view=diff
==============================================================================
--- jakarta/jmeter/trunk/bin/jmeter.properties (original)
+++ jakarta/jmeter/trunk/bin/jmeter.properties Fri Sep 23 11:49:31 2011
@@ -760,6 +760,9 @@ beanshell.server.file=../extras/startup.
 # (to disable searching, set the value less than or equal to the .port 
property)
 #jmeterengine.nongui.maxport=4455
 
+# How often to check for shutdown during ramp-up (milliseconds)
+#jmeterthread.rampup.granularity=1000
+
 #Should JMeter expand the tree when loading a test plan?
 #onload.expandtree=true
 

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=1174675&r1=1174674&r2=1174675&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java 
Fri Sep 23 11:49:31 2011
@@ -70,6 +70,10 @@ public class JMeterThread implements Run
 
     private static final String TRUE = Boolean.toString(true); // i.e. "true"
 
+    /** How often to check for shutdown during ramp-up, default 1000ms */
+    private static final int RAMPUP_GRANULARITY =
+            JMeterUtils.getPropDefault("jmeterthread.rampup.granularity", 
1000); // $NON-NLS-1$
+
     private final Controller controller;
 
     private final HashTree testTree;
@@ -746,11 +750,22 @@ public class JMeterThread implements Run
     private void rampUpDelay() {
         if (initialDelay > 0) {
             long start = System.currentTimeMillis();
-            try {
-                Thread.sleep(initialDelay);
-            } catch (InterruptedException e) {
-                long actual = System.currentTimeMillis() - start;
-                log.warn("RampUp delay for "+threadName+" was interrupted. 
Waited "+actual+" milli-seconds out of "+initialDelay);
+            long end = start + initialDelay;
+            long now=0;
+            long pause = RAMPUP_GRANULARITY;
+            while(running && (now = System.currentTimeMillis()) < end) {
+                long togo = end - now;
+                if (togo < pause) {
+                    pause = togo;
+                }
+                try {
+                    Thread.sleep(pause); // delay between checks
+                } catch (InterruptedException e) {
+                    if (running) { // Don't bother reporting stop test 
interruptions
+                        log.warn("RampUp delay for "+threadName+" was 
interrupted. Waited "+(now - start)+" milli-seconds out of "+initialDelay);
+                    }
+                    break;
+                }
             }
         }
     }

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1174675&r1=1174674&r2=1174675&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Fri Sep 23 11:49:31 2011
@@ -135,6 +135,7 @@ This can be overridden by setting the JM
 <li>Bug 51839 - "... end of run" printed prematurely</li>
 <li>Bug 51847 - Some Junit tests are Locale sensitive and fail if Locale is 
different from US</li>
 <li>Bug 51855 - Parent samples may have slightly inaccurate elapsed times</li>
+<li>Bug 51880 - The shutdown command is not working if I invoke it before all 
the thread are started</li>
 </ul>
 
 <!-- ==================================================== -->



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to