jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1215158 - /jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
Date Fri, 16 Dec 2011 14:43:32 GMT
Author: sebb
Date: Fri Dec 16 14:43:32 2011
New Revision: 1215158

URL: http://svn.apache.org/viewvc?rev=1215158&view=rev
Log:
Fetch settings once in readResolve rather than on each sample
Fix misleading log message
Make server only fields transient - no point in copying them from the client

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java

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=1215158&r1=1215157&r2=1215158&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java Fri Dec
16 14:43:32 2011
@@ -64,7 +64,7 @@ public class StatisticalSampleSender ext
             DEFAULT_TIME_THRESHOLD);
 
     // should the samples be aggregated on thread name or thread group (default) ?
-    private boolean clientConfiguredKeyOnThreadName = JMeterUtils.getPropDefault("key_on_threadname",
false);
+    private final boolean clientConfiguredKeyOnThreadName = JMeterUtils.getPropDefault("key_on_threadname",
false);
 
     private final RemoteSampleListener listener;
 
@@ -73,9 +73,20 @@ public class StatisticalSampleSender ext
     //@GuardedBy("sampleStore") TODO perhaps use ConcurrentHashMap ?
     private final Map<String, StatisticalSampleResult> sampleTable = new HashMap<String,
StatisticalSampleResult>();
 
-    private int sampleCount; // maintain separate count of samples for speed
+    // Settings; readResolve sets these from the server/client values as appropriate
+    // TODO would be nice to make these final; not 100% sure volatile is needed as not changed
after creation
+    private transient volatile int numSamplesThreshold;
 
-    private long batchSendTime = -1;
+    private transient volatile long timeThresholdMs;
+
+    private transient volatile boolean keyOnThreadName;
+
+
+    // variables maintained by server code
+    // @GuardedBy("sampleStore")
+    private transient int sampleCount; // maintain separate count of samples for speed
+
+    private transient long batchSendTime = -1; // @GuardedBy("sampleStore")
 
     /**
      * @deprecated only for use by test code
@@ -87,15 +98,20 @@ public class StatisticalSampleSender ext
     }
 
     /**
-     * Constructor
+     * Constructor, only called by client code.
      *
      * @param listener that the List of sample events will be sent to.
      */
     StatisticalSampleSender(RemoteSampleListener listener) {
         this.listener = listener;
-        log.info("Using StatisticalSampleSender for this run." + " Thresholds: num="
-                + getNumSamplesThreshold() + ", time=" + getTimeThresholdMs()
-                + ". Key uses ThreadName: " + getKeyOnThreadName());        
+        if (isClientConfigured()) {
+            log.info("Using StatisticalSampleSender (client settings) for this run."
+                    + " Thresholds: num=" + clientConfiguredNumSamplesThreshold
+                    + ", time=" + clientConfiguredTimeThresholdMs
+                    + ". Key uses ThreadName: " + clientConfiguredKeyOnThreadName);
+        } else {
+            log.info("Using StatisticalSampleSender (server settings) for this run.");
+        }
     }
 
     /**
@@ -126,9 +142,6 @@ public class StatisticalSampleSender ext
      * @param e a Sample Event
      */
     public void sampleOccurred(SampleEvent e) {
-    	int numSamplesThreshold = getNumSamplesThreshold();
-    	long timeThresholdMs = getTimeThresholdMs();
-    	boolean keyOnThreadName = getKeyOnThreadName();
     	synchronized (sampleStore) {
             // Locate the statistical sample colector
             String key = StatisticalSampleResult.getKey(e, keyOnThreadName);
@@ -185,39 +198,26 @@ public class StatisticalSampleSender ext
             sampleCount = 0;
         }
     }
-    
-    /**
-     * @return time in ms when a send will occur if limit is breached
-     */
-    private long getTimeThresholdMs() {
-    	return isClientConfigured() ?
-    			clientConfiguredTimeThresholdMs : TIME_THRESHOLD_MS;
-    }
-    
-    /**
-     * @return number of samples threshold over which results will be sent
-     */
-    private int getNumSamplesThreshold() {
-    	return isClientConfigured() ?
-    			clientConfiguredNumSamplesThreshold: NUM_SAMPLES_THRESHOLD;
-    }
-    
-    /**
-     * @return boolean indicating wether samples should be aggregated on thread name or thread
group (default) ?
-     */
-    private boolean getKeyOnThreadName() {
-    	return isClientConfigured() ?
-    			clientConfiguredKeyOnThreadName: KEY_ON_THREADNAME;
-    }
 
     /**
      * Processed by the RMI server code; acts as testStarted().
-     * @throws ObjectStreamException  
+     * @throws ObjectStreamException
      */
     private Object readResolve() throws ObjectStreamException{
-        log.info("Using StatisticalSampleSender for this run." + " Thresholds: num="
-                + getNumSamplesThreshold() + ", time=" + getTimeThresholdMs()
-                + ". Key uses ThreadName: " + getKeyOnThreadName());        
+        if (isClientConfigured()) {
+            numSamplesThreshold = clientConfiguredNumSamplesThreshold;
+            timeThresholdMs = clientConfiguredTimeThresholdMs;
+            keyOnThreadName = clientConfiguredKeyOnThreadName;
+        } else {
+            numSamplesThreshold = NUM_SAMPLES_THRESHOLD;
+            timeThresholdMs = TIME_THRESHOLD_MS;
+            keyOnThreadName = KEY_ON_THREADNAME;
+        }
+        log.info("Using StatisticalSampleSender for this run."
+                + (isClientConfigured() ? " Client config: " : " Server config: ")
+                + " Thresholds: num=" + numSamplesThreshold
+                + ", time=" + timeThresholdMs
+                + ". Key uses ThreadName: " + keyOnThreadName);
         return this;
     }
 }



Mime
View raw message