jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1215337 - /jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java
Date Fri, 16 Dec 2011 23:23:55 GMT
Author: sebb
Date: Fri Dec 16 23:23:55 2011
New Revision: 1215337

URL: http://svn.apache.org/viewvc?rev=1215337&view=rev
Log:
Make listener final

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

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=1215337&r1=1215336&r2=1215337&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/BatchSampleSender.java Fri Dec 16 23:23:55
2011
@@ -41,24 +41,31 @@ public class BatchSampleSender extends A
 
     private static final long DEFAULT_TIME_THRESHOLD = 60000L;
 
+    // Static fields are resolved on the server
+    private static final int NUM_SAMPLES_THRESHOLD = 
+        JMeterUtils.getPropDefault("num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
// $NON-NLS-1$
+
+    private static final long TIME_THRESHOLD_MS =
+        JMeterUtils.getPropDefault("time_threshold", DEFAULT_TIME_THRESHOLD); // $NON-NLS-1$
+
+    // instance fields are copied from the client instance
     private final int clientConfiguredNumSamplesThreshold = 
             JMeterUtils.getPropDefault("num_sample_threshold", DEFAULT_NUM_SAMPLE_THRESHOLD);
// $NON-NLS-1$
 
     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;
+    // Server-only work item
+    private transient long batchSendTime = -1;
+
+    // Configuration items, set up by readResolve
+    private transient volatile int numSamplesThreshold;
+
+    private transient volatile long timeThresholdMs;
 
 
     /**
@@ -78,9 +85,13 @@ public class BatchSampleSender extends A
     // protected added: Bug 50008 - allow BatchSampleSender to be subclassed
     protected BatchSampleSender(RemoteSampleListener listener) {
         this.listener = listener;
-        log.info("Using batching for this run."
-                + " Thresholds: num=" + getNumSamplesThreshold()
-                + ", time=" + getTimeThresholdMs()); 
+        if (isClientConfigured()) {
+            log.info("Using batching (client settings) for this run."
+                    + " Thresholds: num=" + clientConfiguredNumSamplesThreshold
+                    + ", time=" + clientConfiguredTimeThresholdMs);
+        } else {
+            log.info("Using batching (server settings) for this run.");
+        }
     }
 
    /**
@@ -130,8 +141,6 @@ public class BatchSampleSender extends A
      *            a Sample Event
      */
     public void sampleOccurred(SampleEvent e) {
-    	int numSamplesThreshold = getNumSamplesThreshold();
-    	long timeThresholdMs = getTimeThresholdMs();
         synchronized (sampleStore) {
             sampleStore.add(e);
             final int sampleCount = sampleStore.size();
@@ -171,29 +180,20 @@ public class BatchSampleSender extends A
     }
     
     /**
-     * @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;
-    }
-
-    /**
      * Processed by the RMI server code; acts as testStarted().
      * @throws ObjectStreamException  
      */
     private Object readResolve() throws ObjectStreamException{
+        if (isClientConfigured()) {
+            numSamplesThreshold = clientConfiguredNumSamplesThreshold;
+            timeThresholdMs = clientConfiguredTimeThresholdMs;
+        } else {
+            numSamplesThreshold =  NUM_SAMPLES_THRESHOLD;
+            timeThresholdMs = TIME_THRESHOLD_MS;
+        }
         log.info("Using batching for this run."
-                + " Thresholds: num=" + getNumSamplesThreshold()
-                + ", time=" + getTimeThresholdMs()); 
+                + " Thresholds: num=" + numSamplesThreshold
+                + ", time=" + timeThresholdMs); 
         return this;
     }
 }



Mime
View raw message