jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: 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 Sun, 20 Dec 2015 13:00:38 GMT
On 20 December 2015 at 12:13, Felix Schumacher
<felix.schumacher@internetallee.de> wrote:
>
>
> Am 19. Dezember 2015 16:51:14 MEZ, schrieb sebb@apache.org:
>>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) {
>
> The other methods declare sampler as final. This one does not. Any reason why?

See below.

> Regards,
> Felix
>
>>         if (debug) {
>>             LOG.debug(whoAmI("sampleStarting()", this));
>>         }
>>-        createTask();
>>+        createTask(sampler);
>>     }
>>
>>     @Override
>>-    public void sampleEnded() {
>>+    public void sampleEnded(final Sampler sampler) {

Does not need to be final.

>>         if (debug) {
>>             LOG.debug(whoAmI("sampleEnded()", this));
>>         }
>>         cancelTask();
>>     }
>>
>>-    private void createTask() {
>>+    private void createTask(final Sampler samp) {

Must be final because referenced from nested definition.

>>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