jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1608020 - in /jmeter/trunk: src/components/org/apache/jmeter/timers/ xdocs/ xdocs/usermanual/
Date Sat, 05 Jul 2014 14:20:28 GMT
Author: pmouawad
Date: Sat Jul  5 14:20:27 2014
New Revision: 1608020

URL: http://svn.apache.org/r1608020
Log:
Bug 56691 - Synchronizing Timer : Add timeout on waiting
Bugzilla Id: 56691

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java
    jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java
    jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources.properties
    jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources_fr.properties
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java?rev=1608020&r1=1608019&r2=1608020&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java Sat Jul  5 14:20:27
2014
@@ -21,12 +21,16 @@ package org.apache.jmeter.timers;
 import java.io.Serializable;
 import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.jmeter.testbeans.TestBean;
 import org.apache.jmeter.testelement.AbstractTestElement;
 import org.apache.jmeter.testelement.TestStateListener;
 import org.apache.jmeter.testelement.ThreadListener;
 import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
 
 /**
  * The purpose of the SyncTimer is to block threads until X number of threads
@@ -35,6 +39,7 @@ import org.apache.jmeter.threads.JMeterC
  *
  */
 public class SyncTimer extends AbstractTestElement implements Timer, Serializable, TestBean,
TestStateListener, ThreadListener {
+    private static final Logger LOGGER = LoggingManager.getLoggerForClass();
 
     /**
      * Wrapper to {@link CyclicBarrier} to allow lazy init of CyclicBarrier when SyncTimer
is configured with 0
@@ -67,16 +72,30 @@ public class SyncTimer extends AbstractT
             }
         }
 
+
         /**
-         * @see CyclicBarrier#await()
          * @return int
          * @throws InterruptedException
          * @throws BrokenBarrierException
+         * @throws TimeoutException 
          * @see java.util.concurrent.CyclicBarrier#await()
          */
-        public int await() throws InterruptedException, BrokenBarrierException {
+        public int await() throws InterruptedException, BrokenBarrierException{
             return barrier.await();
         }
+        
+        /**
+         * @param timeout
+         * @param timeUnit
+         * @return int
+         * @throws InterruptedException
+         * @throws BrokenBarrierException
+         * @throws TimeoutException 
+         * @see java.util.concurrent.CyclicBarrier#await()
+         */
+        public int await(long timeout, TimeUnit timeUnit) throws InterruptedException, BrokenBarrierException,
TimeoutException {
+            return barrier.await(timeout, timeUnit);
+        }
 
         /**
          * @see java.util.concurrent.CyclicBarrier#reset()
@@ -106,6 +125,8 @@ public class SyncTimer extends AbstractT
     private transient BarrierWrapper barrier;
 
     private int groupSize;
+    
+    private long timeoutInMs;
 
     // Ensure transient object is created by the server
     private Object readResolve(){
@@ -136,11 +157,18 @@ public class SyncTimer extends AbstractT
         if(getGroupSize()>=0) {
             int arrival = 0;
             try {
-                arrival = this.barrier.await();
+                if(timeoutInMs==0) {
+                    arrival = this.barrier.await();                    
+                } else {
+                    arrival = this.barrier.await(timeoutInMs, TimeUnit.MILLISECONDS);
+                }
             } catch (InterruptedException e) {
                 return 0;
             } catch (BrokenBarrierException e) {
                 return 0;
+            } catch (TimeoutException e) {
+                LOGGER.warn("SyncTimer "+ getName() + " timeouted waiting for users after:"+getTimeoutInMs()+"ms");
+                return 0;
             } finally {
                 if(arrival == 0) {
                     barrier.reset();
@@ -219,4 +247,18 @@ public class SyncTimer extends AbstractT
     public void threadFinished() {
         // NOOP
     }
+
+    /**
+     * @return the timeoutInMs
+     */
+    public long getTimeoutInMs() {
+        return timeoutInMs;
+    }
+
+    /**
+     * @param timeoutInMs the timeoutInMs to set
+     */
+    public void setTimeoutInMs(long timeoutInMs) {
+        this.timeoutInMs = timeoutInMs;
+    }
 }

Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java?rev=1608020&r1=1608019&r2=1608020&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java Sat Jul  5
14:20:27 2014
@@ -27,11 +27,16 @@ public class SyncTimerBeanInfo extends B
     public SyncTimerBeanInfo() {
         super(SyncTimer.class);
 
-        createPropertyGroup("grouping", new String[] { "groupSize" });
+        createPropertyGroup("grouping", new String[] { "groupSize", "timeoutInMs" });
 
         PropertyDescriptor p = property("groupSize");
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
         p.setValue(DEFAULT, Integer.valueOf(0));
+
+        p = property("timeoutInMs");
+        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+        p.setValue(DEFAULT, Long.valueOf(0));
+
     }
 
 }

Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources.properties?rev=1608020&r1=1608019&r2=1608020&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources.properties (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources.properties Sat
Jul  5 14:20:27 2014
@@ -16,4 +16,6 @@
 displayName=Synchronizing Timer
 grouping.displayName=Grouping
 groupSize.displayName=Number of Simulated Users to Group by
-groupSize.shortDescription=Define how many simulated users trigger the release of the synchronizing
block (default value of '0' means all users)
\ No newline at end of file
+groupSize.shortDescription=Define how many simulated users trigger the release of the synchronizing
block (default value of '0' means all users)
+timeoutInMs.displayName=Timeout in milliseconds
+timeoutInMs.shortDescription=If set to 0, not timeout will occurs, if superior to 0, then
if ater the timeout interval the number of users waiting is not reached, timer will stop waiting
\ No newline at end of file

Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources_fr.properties?rev=1608020&r1=1608019&r2=1608020&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources_fr.properties
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerResources_fr.properties
Sat Jul  5 14:20:27 2014
@@ -18,3 +18,5 @@ displayName=Compteur de synchronisation
 groupSize.displayName=Nombre d'utilisateurs simul\u00E9s \u00E0 grouper 
 groupSize.shortDescription=D\u00E9fini combien d'utilisateurs simul\u00E9s d\u00E9clenchent
la lib\u00E9ration synchronis\u00E9e du bloc (d\u00E9faut \: la valeur '0' signifie tous les
utilisateurs)
 grouping.displayName=Regroupement
+timeoutInMs.displayName=Timeout en millisecondes
+timeoutInMs.shortDescription=Si \u00E9gal \u00E0 0, aucun timeout n'aura lieu, sinon les
threads en attente sur le Compteur de synchronisation attendront au max la valeur de timeout
\ No newline at end of file

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1608020&r1=1608019&r2=1608020&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Jul  5 14:20:27 2014
@@ -207,6 +207,7 @@ A workaround is to use a Java 7 update 4
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
+<li><bugzilla>56691</bugzilla> - Synchronizing Timer : Add timeout on waiting</li>
 </ul>
 
 <h3>Functions</h3>

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1608020&r1=1608019&r2=1608020&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Jul  5 14:20:27 2014
@@ -4713,8 +4713,12 @@ points of the test plan.
 <properties>
   <property name="Name" required="No">Descriptive name for this timer that is shown
in the tree. </property>
   <property name="Number of Simultaneous Users to Group by" required="Yes">Number of
threads to release at once. Setting it to 0 is equivalent to setting it to Number of threads
in Thread Group.</property>
+  <property name="Timeout in milliseconds" required="No">If set to 0, Timer will wait
for the number of threads to reach the value in "Number of Simultaneous Users to Group", if
superior to 0, then timer will wait at max "Timeout in milliseconds" if number of Threads
does not reach if ater the timeout interval the number of users waiting is not reached, timer
will stop waiting. Defaults to 0</property>
 </properties>
-
+<note>
+If timeout in milliseconds is set to 0 and number of threads never reaches "Number of Simultaneous
Users to Group by" then Test will pause infinitely.
+Only a forced stop will stop it. Setting Timeout in milliseconds is an option to consider
in this case.
+</note>
 </component>
 
 <component name="BeanShell Timer" index="&sect-num;.6.6"  width="846" height="636"
screenshot="timers/beanshell_timer.png">



Mime
View raw message