jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1201437 - in /jmeter/trunk: bin/ src/core/org/apache/jmeter/samplers/ xdocs/
Date Sun, 13 Nov 2011 15:12:43 GMT
Author: pmouawad
Date: Sun Nov 13 15:12:43 2011
New Revision: 1201437

URL: http://svn.apache.org/viewvc?rev=1201437&view=rev
Log:
Bug 51886 - SampleSender configuration resolved partly on client and partly on server

Added:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampleSender.java   (with props)
Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/core/org/apache/jmeter/samplers/AsynchSampleSender.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/HoldSampleSender.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/StandardSampleSender.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sun Nov 13 15:12:43 2011
@@ -530,6 +530,10 @@ wmlParser.types=text/vnd.wap.wml 
 #---------------------------------------------------------------------------
 # Remote batching configuration
 #---------------------------------------------------------------------------
+# How is Sample sender implementations configured:
+# - true (default) means client configuration will be used
+# - false means server configuration will be used
+sample_sender_client_configured=false
 
 # Remote batching support
 # default is Standard, which returns each sample synchronously

Added: jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampleSender.java?rev=1201437&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampleSender.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampleSender.java Sun Nov 13
15:12:43 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.samplers;
+
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * Base class for SampleSender implementations
+ */
+public abstract class AbstractSampleSender implements SampleSender {
+    private final boolean isClientConfigured = JMeterUtils.getPropDefault("sample_sender_client_configured",
true); // $NON-NLS-1$
+
+	/**
+	 * @return boolean indicates how SampleSender configuration is done, true means use client
properties and send to servers, false means use server configurations
+	 */
+	public boolean isClientConfigured() {
+		return isClientConfigured;
+	}
+
+	/**
+	 * 
+	 */
+	public AbstractSampleSender() {
+		super();
+	}
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampleSender.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/AsynchSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/AsynchSampleSender.java?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/AsynchSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/AsynchSampleSender.java Sun Nov 13 15:12:43
2011
@@ -31,7 +31,7 @@ import org.apache.jorphan.logging.Loggin
 import org.apache.jorphan.util.JMeterError;
 import org.apache.log.Logger;
 
-public class AsynchSampleSender implements SampleSender, Serializable {
+public class AsynchSampleSender extends AbstractSampleSender implements Serializable {
 
     private static final long serialVersionUID = 251L;
 
@@ -39,16 +39,14 @@ public class AsynchSampleSender implemen
 
     // Create unique object as marker for end of queue
     private transient static final SampleEvent FINAL_EVENT = new SampleEvent();
+
+    private static final int serverConfiguredCapacity = JMeterUtils.getPropDefault("asynch.batch.queue.size",
100); // $NON-NLS-1$
     
-    private static final int capacity = JMeterUtils.getPropDefault("asynch.batch.queue.size",
100); // $NON-NLS-1$
+    private final int clientConfiguredCapacity = JMeterUtils.getPropDefault("asynch.batch.queue.size",
100); // $NON-NLS-1$
 
     // created by client 
     private final RemoteSampleListener listener;
 
-    static {
-        log.info("Using Asynch Remote Sampler for this test run, queue size "+capacity);
       
-    }
-
     private transient BlockingQueue<SampleEvent> queue; // created by server in readResolve
method
     
     private transient long queueWaits; // how many times we had to wait to queue a sample
@@ -60,6 +58,7 @@ public class AsynchSampleSender implemen
      * @throws ObjectStreamException  
      */
     private Object readResolve() throws ObjectStreamException{
+    	int capacity = getCapacity();
         log.debug("Using batch queue size (asynch.batch.queue.size): " + capacity);
         queue = new ArrayBlockingQueue<SampleEvent>(capacity);        
         Worker worker = new Worker(queue, listener);
@@ -73,15 +72,24 @@ public class AsynchSampleSender implemen
      */
     @Deprecated
     public AsynchSampleSender(){
+    	this(null);
         log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$
-        listener = null;
     }
 
     // Created by SampleSenderFactory
     protected AsynchSampleSender(RemoteSampleListener listener) {
         this.listener = listener;
+        log.info("Using Asynch Remote Sampler for this test run, queue size "+getCapacity());
 
     }
 
+    /**
+     * @return capacity
+     */
+    private int getCapacity() {
+    	return isClientConfigured() ? 
+    			clientConfiguredCapacity : serverConfiguredCapacity;
+    }
+    
     public void testEnded() { // probably not used in server mode
         log.debug("Test ended()");
         try {

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java Sun Nov 13 15:12:43
2011
@@ -31,7 +31,7 @@ import java.io.Serializable;
  * Implements batch reporting for remote testing.
  *
  */
-public class BatchSampleSender implements SampleSender, Serializable {
+public class BatchSampleSender extends AbstractSampleSender implements Serializable {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     private static final long serialVersionUID = 240L;
@@ -40,31 +40,33 @@ public class BatchSampleSender implement
 
     private static final long DEFAULT_TIME_THRESHOLD = 60000L;
 
-    private static final int NUM_SAMPLES_THRESHOLD = 
-        JMeterUtils.getPropDefault("num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
// $NON-NLS-1$
+    private final int clientConfiguredNumSamplesThreshold = 
+            JMeterUtils.getPropDefault("num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
// $NON-NLS-1$
 
-    private static final long TIME_THRESHOLD_MS =
+    private final long clientConfiguredTimeThresholdMs =
+            JMeterUtils.getPropDefault("time_threshold", DEFAULT_TIME_THRESHOLD); // $NON-NLS-1$
+
+    private static final int serverConfiguredNumSamplesThreshold = 
+            JMeterUtils.getPropDefault("num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
// $NON-NLS-1$
+    
+    private static final long serverConfiguredTimeThresholdMs =
         JMeterUtils.getPropDefault("time_threshold", DEFAULT_TIME_THRESHOLD); // $NON-NLS-1$
 
+
     private final RemoteSampleListener listener;
 
     private final List<SampleEvent> sampleStore = new ArrayList<SampleEvent>();
 
     private long batchSendTime = -1;
 
-    static {
-        log.info("Using batching for this run."
-                + " Thresholds: num=" + NUM_SAMPLES_THRESHOLD
-                + ", time=" + TIME_THRESHOLD_MS);        
-    }
 
     /**
      * @deprecated only for use by test code
      */
     @Deprecated
     public BatchSampleSender(){
+    	this(null);
         log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$
-        listener = null;
     }
     /**
      * Constructor
@@ -74,6 +76,9 @@ public class BatchSampleSender implement
      */
     protected BatchSampleSender(RemoteSampleListener listener) {
         this.listener = listener;
+        log.info("Using batching for this run."
+                + " Thresholds: num=" + getNumSamplesThreshold()
+                + ", time=" + getTimeThresholdMs()); 
     }
 
    /**
@@ -136,23 +141,25 @@ public class BatchSampleSender implement
      *            a Sample Event
      */
     public void sampleOccurred(SampleEvent e) {
+    	int numSamplesThreshold = getNumSamplesThreshold();
+    	long timeThresholdMs = getTimeThresholdMs();
         synchronized (sampleStore) {
             sampleStore.add(e);
             final int sampleCount = sampleStore.size();
 
             boolean sendNow = false;            
-            if (NUM_SAMPLES_THRESHOLD != -1) {
-                if (sampleCount >= NUM_SAMPLES_THRESHOLD) {
+            if (numSamplesThreshold != -1) {
+                if (sampleCount >= numSamplesThreshold) {
                     sendNow = true;
                 }
             }
 
             long now = 0;
-            if (TIME_THRESHOLD_MS != -1) {
+            if (timeThresholdMs != -1) {
                 now = System.currentTimeMillis();
                 // Checking for and creating initial timestamp to check against
                 if (batchSendTime == -1) {
-                    this.batchSendTime = now + TIME_THRESHOLD_MS;
+                    this.batchSendTime = now + timeThresholdMs;
                 }
                 if (batchSendTime < now && sampleCount > 0) {
                     sendNow = true;
@@ -164,8 +171,8 @@ public class BatchSampleSender implement
                     log.debug("Firing sample");
                     listener.processBatch(sampleStore);
                     sampleStore.clear();
-                    if (TIME_THRESHOLD_MS != -1) {
-                        this.batchSendTime = now + TIME_THRESHOLD_MS;
+                    if (timeThresholdMs != -1) {
+                        this.batchSendTime = now + timeThresholdMs;
                     }
                 } catch (RemoteException err) {
                     log.error("sampleOccurred", err);
@@ -173,4 +180,20 @@ public class BatchSampleSender implement
             }
         } // synchronized(sampleStore)
     }
+    
+    /**
+     * @return time in ms when a send will occur if limit is breached
+     */
+    private long getTimeThresholdMs() {
+    	return isClientConfigured() ?
+    			clientConfiguredTimeThresholdMs : serverConfiguredTimeThresholdMs;
+    }
+    
+    /**
+     * @return number of samples threshold over which results will be sent
+     */
+    private int getNumSamplesThreshold() {
+    	return isClientConfigured() ?
+    			clientConfiguredNumSamplesThreshold: serverConfiguredNumSamplesThreshold;
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java Sun Nov
13 15:12:43 2011
@@ -31,7 +31,7 @@ import org.apache.log.Logger;
  *
  *
  */
-public class DataStrippingSampleSender implements SampleSender, Serializable {
+public class DataStrippingSampleSender extends AbstractSampleSender implements Serializable
{
     private static final long serialVersionUID = 1;
     private static final Logger log = LoggingManager.getLoggerForClass();
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/HoldSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/HoldSampleSender.java?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/HoldSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/HoldSampleSender.java Sun Nov 13 15:12:43
2011
@@ -30,7 +30,7 @@ import java.io.Serializable;
  * caching functionality (sampleStore).
  */
 
-public class HoldSampleSender implements SampleSender, Serializable {
+public class HoldSampleSender extends AbstractSampleSender implements Serializable {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     private static final long serialVersionUID = 240L;

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/StandardSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/StandardSampleSender.java?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/StandardSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/StandardSampleSender.java Sun Nov 13
15:12:43 2011
@@ -29,7 +29,7 @@ import java.io.Serializable;
  * Default behaviour for remote testing.
  */
 
-public class StandardSampleSender implements SampleSender, Serializable {
+public class StandardSampleSender extends AbstractSampleSender implements Serializable {
     private static final long serialVersionUID = 240L;
 
     private static final Logger log = LoggingManager.getLoggerForClass();

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java Sun Nov
13 15:12:43 2011
@@ -33,7 +33,7 @@ import java.util.Map;
  * Implements batch reporting for remote testing.
  *
  */
-public class StatisticalSampleSender implements SampleSender, Serializable {
+public class StatisticalSampleSender extends AbstractSampleSender implements Serializable
{
     private static final long serialVersionUID = 240L;
 
     private static final Logger log = LoggingManager.getLoggerForClass();
@@ -42,15 +42,24 @@ public class StatisticalSampleSender imp
 
     private static final long DEFAULT_TIME_THRESHOLD = 60000L;
 
-    private static final int NUM_SAMPLES_THRESHOLD = JMeterUtils.getPropDefault(
+    private final int clientConfiguredNumSamplesThreshold = JMeterUtils.getPropDefault(
             "num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
 
-    private static final long TIME_THRESHOLD_MS = JMeterUtils.getPropDefault("time_threshold",
+    private final long clientConfiguredTimeThresholdMs = JMeterUtils.getPropDefault("time_threshold",
             DEFAULT_TIME_THRESHOLD);
 
     // should the samples be aggregated on thread name or thread group (default) ?
-    private static boolean KEY_ON_THREADNAME = JMeterUtils.getPropDefault("key_on_threadname",
false);
+    private boolean clientConfiguredKeyOnThreadName = JMeterUtils.getPropDefault("key_on_threadname",
false);
+
+    private static final int serverConfiguredNumSamplesThreshold = JMeterUtils.getPropDefault(
+            "num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
+
+    private static final long serverConfiguredTimeThresholdMs = JMeterUtils.getPropDefault("time_threshold",
+            DEFAULT_TIME_THRESHOLD);
     
+    // should the samples be aggregated on thread name or thread group (default) ?
+    private static boolean serverConfiguredKeyOnThreadName = JMeterUtils.getPropDefault("key_on_threadname",
false);
+
     private final RemoteSampleListener listener;
 
     private final List<SampleEvent> sampleStore = new ArrayList<SampleEvent>();
@@ -62,19 +71,13 @@ public class StatisticalSampleSender imp
 
     private long batchSendTime = -1;
 
-    static {
-        log.info("Using statistical sampling for this run." + " Thresholds: num="
-                + NUM_SAMPLES_THRESHOLD + ", time=" + TIME_THRESHOLD_MS
-                + ". Key uses ThreadName: " + KEY_ON_THREADNAME);        
-    }
-
     /**
      * @deprecated only for use by test code
      */
     @Deprecated
     public StatisticalSampleSender(){
+    	this(null);
         log.warn("Constructor only intended for use in testing");
-        listener = null;
     }
 
     /**
@@ -84,6 +87,10 @@ public class StatisticalSampleSender imp
      */
     StatisticalSampleSender(RemoteSampleListener listener) {
         this.listener = listener;
+        log.info("Using statistical sampling for this run." + " Thresholds: num="
+                + getNumSamplesThreshold() + ", time=" + getTimeThresholdMs()
+                + ". Key uses ThreadName: " + getKeyOnThreadName());        
+
     }
 
     /**
@@ -128,12 +135,15 @@ public class StatisticalSampleSender imp
      * @param e a Sample Event
      */
     public void sampleOccurred(SampleEvent e) {
-        synchronized (sampleStore) {
+    	int numSamplesThreshold = getNumSamplesThreshold();
+    	long timeThresholdMs = getTimeThresholdMs();
+    	boolean keyOnThreadName = getKeyOnThreadName();
+    	synchronized (sampleStore) {
             // Locate the statistical sample colector
-            String key = StatisticalSampleResult.getKey(e, KEY_ON_THREADNAME);
+            String key = StatisticalSampleResult.getKey(e, keyOnThreadName);
             StatisticalSampleResult statResult = sampleTable.get(key);
             if (statResult == null) {
-                statResult = new StatisticalSampleResult(e.getResult(), KEY_ON_THREADNAME);
+                statResult = new StatisticalSampleResult(e.getResult(), keyOnThreadName);
                 // store the new statistical result collector
                 sampleTable.put(key, statResult);
                 // add a new wrapper samplevent
@@ -143,18 +153,18 @@ public class StatisticalSampleSender imp
             statResult.add(e.getResult());
             sampleCount++;
             boolean sendNow = false;
-            if (NUM_SAMPLES_THRESHOLD != -1) {
-                if (sampleCount >= NUM_SAMPLES_THRESHOLD) {
+            if (numSamplesThreshold != -1) {
+                if (sampleCount >= numSamplesThreshold) {
                     sendNow = true;
                 }
             }
 
             long now = 0;
-            if (TIME_THRESHOLD_MS != -1) {
+            if (timeThresholdMs != -1) {
                 now = System.currentTimeMillis();
                 // Checking for and creating initial timestamp to check against
                 if (batchSendTime == -1) {
-                    this.batchSendTime = now + TIME_THRESHOLD_MS;
+                    this.batchSendTime = now + timeThresholdMs;
                 }
                 if (batchSendTime < now) {
                     sendNow = true;
@@ -166,8 +176,8 @@ public class StatisticalSampleSender imp
                         log.debug("Firing sample");
                     }
                     sendBatch();
-                    if (TIME_THRESHOLD_MS != -1) {
-                        this.batchSendTime = now + TIME_THRESHOLD_MS;
+                    if (timeThresholdMs != -1) {
+                        this.batchSendTime = now + timeThresholdMs;
                     }
                 } catch (RemoteException err) {
                     log.warn("sampleOccurred", err);
@@ -184,4 +194,28 @@ public class StatisticalSampleSender imp
             sampleCount = 0;
         }
     }
+    
+    /**
+     * @return time in ms when a send will occur if limit is breached
+     */
+    private long getTimeThresholdMs() {
+    	return isClientConfigured() ?
+    			clientConfiguredTimeThresholdMs : serverConfiguredTimeThresholdMs;
+    }
+    
+    /**
+     * @return number of samples threshold over which results will be sent
+     */
+    private int getNumSamplesThreshold() {
+    	return isClientConfigured() ?
+    			clientConfiguredNumSamplesThreshold: serverConfiguredNumSamplesThreshold;
+    }
+    
+    /**
+     * @return boolean indicating wether samples should be aggregated on thread name or thread
group (default) ?
+     */
+    private boolean getKeyOnThreadName() {
+    	return isClientConfigured() ?
+    			clientConfiguredKeyOnThreadName: serverConfiguredKeyOnThreadName;
+    }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1201437&r1=1201436&r2=1201437&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Nov 13 15:12:43 2011
@@ -80,6 +80,10 @@ Mirror server now uses default port 8081
 TCP Sampler handles SocketTimeoutException, SocketException and InterruptedIOException differently
since 2.5.2, when
 these occurs, Sampler is marked as failed.
 </p>
+<p>
+Sample Sender implementations know resolve their configuration on Client side since 2.5.2.
+This behaviour can be changed with property sample_sender_client_configured (set it to false).
+</p>
 <!-- =================== Bug fixes =================== -->
 
 <h2>Bug fixes</h2>
@@ -208,6 +212,7 @@ these occurs, Sampler is marked as faile
 <li>Bug 52116 - Allow to add (paste) entries from the clipboard to an arguments list</li>
 <li>Bug 51091 - New function returning the name of the current "Test Plan"</li>
 <li>Bug 52160 - Don't display TestBeanGui items which are flagged as hidden</li>
+<li>Bug 51886 - SampleSender configuration resolved partly on client and partly on
server</li>
 </ul>
 
 <h2>Non-functional changes</h2>



Mime
View raw message