You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/03/01 13:24:04 UTC

svn commit: r1733052 - /jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java

Author: pmouawad
Date: Tue Mar  1 12:24:03 2016
New Revision: 1733052

URL: http://svn.apache.org/viewvc?rev=1733052&view=rev
Log:
Bug 58736 - Add Sample Timeout support
Drop temporary property (implementation detail)
Bugzilla Id: 58736

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.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=1733052&r1=1733051&r2=1733052&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/modifiers/SampleTimeout.java Tue Mar  1 12:24:03 2016
@@ -39,7 +39,7 @@ import org.apache.log.Logger;
 /**
  * 
  * Sample timeout implementation using Executor threads
- *
+ * @since 3.0
  */
 public class SampleTimeout extends AbstractTestElement implements Serializable, ThreadListener, SampleMonitor {
 
@@ -49,8 +49,6 @@ public class SampleTimeout extends Abstr
 
     private static final String TIMEOUT = "InterruptTimer.timeout"; //$NON-NLS-1$
 
-    private final boolean useRunnable = JMeterUtils.getPropDefault("InterruptTimer.useRunnable", false);
-
     private static class TPOOLHolder {
         static final ScheduledExecutorService EXEC_SERVICE =
                 Executors.newScheduledThreadPool(1,
@@ -78,7 +76,6 @@ public class SampleTimeout extends Abstr
      * No-arg constructor.
      */
     public SampleTimeout() {
-//        LOG.setPriority(org.apache.log.Priority.DEBUG); // for local debugging when enabled
         debug = LOG.isDebugEnabled();
         execService = getExecutorService();
         if (debug) {
@@ -128,46 +125,25 @@ public class SampleTimeout extends Abstr
             return; // Cannot time out in this case
         }
         final Interruptible sampler = (Interruptible) samp;
-        
-        if (useRunnable) {
-            Runnable run=new Runnable() {
-                @Override
-                public void run() {
-                    long start = System.nanoTime();
-                    boolean interrupted = sampler.interrupt();
-                    String elapsed = Double.toString((double)(System.nanoTime()-start)/ 1000000000)+" secs";
-                    if (interrupted) {
-                        LOG.warn("Run Done interrupting " + getInfo(samp) + " took " + elapsed);
-                    } else {
-                        if (debug) {
-                            LOG.debug("Run Didn't interrupt: " + getInfo(samp) + " took " + elapsed);
-                        }
-                    }
-                }
-            };
-            // schedule the interrupt to occur and save for possible cancellation 
-            future = execService.schedule(run, timeout, TimeUnit.MILLISECONDS);
-        } else {
-            Callable<Object> call = new Callable<Object>() {
-                @Override
-                public Object call() throws Exception {
-                    long start = System.nanoTime();
-                    boolean interrupted = sampler.interrupt();
-                    String elapsed = Double.toString((double)(System.nanoTime()-start)/ 1000000000)+" secs";
-                    if (interrupted) {
-                        LOG.warn("Call Done interrupting " + getInfo(samp) + " took " + elapsed);
-                    } else {
-                        if (debug) {
-                            LOG.debug("Call Didn't interrupt: " + getInfo(samp) + " took " + elapsed);
-                        }
+
+        Callable<Object> call = new Callable<Object>() {
+            @Override
+            public Object call() throws Exception {
+                long start = System.nanoTime();
+                boolean interrupted = sampler.interrupt();
+                String elapsed = Double.toString((double)(System.nanoTime()-start)/ 1000000000)+" secs";
+                if (interrupted) {
+                    LOG.warn("Call Done interrupting " + getInfo(samp) + " took " + elapsed);
+                } else {
+                    if (debug) {
+                        LOG.debug("Call Didn't interrupt: " + getInfo(samp) + " took " + elapsed);
                     }
-                    return null;
                 }
-                
-            };
-            // schedule the interrupt to occur and save for possible cancellation 
-            future = execService.schedule(call, timeout, TimeUnit.MILLISECONDS);
-        }
+                return null;
+            }
+        };
+        // schedule the interrupt to occur and save for possible cancellation 
+        future = execService.schedule(call, timeout, TimeUnit.MILLISECONDS);
         if (debug) {
             LOG.debug("Scheduled timer: @" + System.identityHashCode(future) + " " + getInfo(samp));
         }