jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1720944 - in /jmeter/trunk/src: components/org/apache/jmeter/modifiers/SampleTimeout.java core/org/apache/jmeter/samplers/SampleMonitor.java core/org/apache/jmeter/threads/JMeterThread.java
Date Sat, 19 Dec 2015 15:51:14 GMT
Author: sebb
Date: Sat Dec 19 15:51:13 2015
New Revision: 1720944

URL: http://svn.apache.org/viewvc?rev=1720944&view=rev
Log:
Add Sample Timeout support
It's cheaper to pass the sample to the methods; no need to use the context
Bugzilla Id: 58736

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleMonitor.java
    jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java?rev=1720944&r1=1720943&r2=1720944&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java Sat Dec 19
15:51:13 2015
@@ -32,8 +32,6 @@ import org.apache.jmeter.samplers.Sample
 import org.apache.jmeter.testelement.AbstractTestElement;
 import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.testelement.ThreadListener;
-import org.apache.jmeter.threads.JMeterContext;
-import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -70,8 +68,6 @@ public class SampleTimeout extends Abstr
         return TPOOLHolder.EXEC_SERVICE;
     }
 
-    private JMeterContext context; // Cache this here to avoid refetching
-
     private ScheduledFuture<?> future;
     
     private final transient ScheduledExecutorService execService;
@@ -108,27 +104,26 @@ public class SampleTimeout extends Abstr
     }
 
     @Override
-    public void sampleStarting() {
+    public void sampleStarting(Sampler sampler) {
         if (debug) {
             LOG.debug(whoAmI("sampleStarting()", this));
         }
-        createTask();
+        createTask(sampler);
     }
 
     @Override
-    public void sampleEnded() {
+    public void sampleEnded(final Sampler sampler) {
         if (debug) {
             LOG.debug(whoAmI("sampleEnded()", this));
         }
         cancelTask();
     }
 
-    private void createTask() {
+    private void createTask(final Sampler samp) {
         long timeout = getPropertyAsLong(TIMEOUT); // refetch each time so it can be a variable
         if (timeout <= 0) {
             return;
         }
-        final Sampler samp = context.getCurrentSampler();
         if (!(samp instanceof Interruptible)) { // may be applied to a whole test 
             return; // Cannot time out in this case
         }
@@ -183,7 +178,6 @@ public class SampleTimeout extends Abstr
         if (debug) {
             LOG.debug(whoAmI("threadStarted()", this));
         }
-        context = JMeterContextService.getContext();
      }
 
     @Override
@@ -191,7 +185,7 @@ public class SampleTimeout extends Abstr
         if (debug) {
             LOG.debug(whoAmI("threadFinished()", this));
         }
-        cancelTask(); // cancel final if any
+        cancelTask(); // cancel future if any
      }
 
     /**

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleMonitor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleMonitor.java?rev=1720944&r1=1720943&r2=1720944&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleMonitor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleMonitor.java Sat Dec 19 15:51:13
2015
@@ -27,10 +27,10 @@ public interface SampleMonitor {
     /**
      * A sample is about to start
      */
-    void sampleStarting();
+    void sampleStarting(Sampler sampler);
 
     /**
      * A sample has just finished
      */
-    void sampleEnded();
+    void sampleEnded(Sampler sampler);
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=1720944&r1=1720943&r2=1720944&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java Sat Dec 19 15:51:13
2015
@@ -439,14 +439,14 @@ public class JMeterThread implements Run
         // Perform the actual sample
         currentSampler = sampler;
         for(SampleMonitor monitor : sampleMonitors) {
-            monitor.sampleStarting();
+            monitor.sampleStarting(sampler);
         }
         SampleResult result = null;
         try {
             result = sampler.sample(null); // TODO: remove this useless Entry parameter
         } finally {
             for(SampleMonitor monitor : sampleMonitors) {
-                monitor.sampleEnded();
+                monitor.sampleEnded(sampler);
             }            
         }
         currentSampler = null;



Mime
View raw message