sebb 2003/10/09 11:51:08
Modified: src/core/org/apache/jmeter/samplers
RemoteListenerWrapper.java
Log:
Added sample caching code
Revision Changes Path
1.9 +61 -3
jakarta-jmeter/src/core/org/apache/jmeter/samplers/RemoteListenerWrapper.java
Index: RemoteListenerWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/samplers/RemoteListenerWrapper.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- RemoteListenerWrapper.java 7 Sep 2003 18:54:53 -0000 1.8
+++ RemoteListenerWrapper.java 9 Oct 2003 18:51:08 -0000 1.9
@@ -9,10 +9,18 @@
import org.apache.jmeter.testelement.TestListener;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
+import org.apache.jmeter.util.JMeterUtils;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
/**
* @author unascribed
- * @version $Revision$
+ *
+ * Lars-Erik Helander provided the idea (and original implementation)
+ * for the caching functionality (sampleStore).
+ *
+ * @version $Revision$ Updated on: $Date$
*/
public class RemoteListenerWrapper
extends AbstractTestElement
@@ -20,21 +28,35 @@
{
transient private static Logger log = LoggingManager.getLoggerForClass();
RemoteSampleListener listener;
+
+ private boolean holdSamples; //Hold samples to end of test?
+ private List sampleStore; // Samples stored here
+
+ private void setUpStore(){
+ holdSamples = JMeterUtils.getPropDefault("hold_samples",false);
+ if (holdSamples){
+ sampleStore = new ArrayList();
+ log.info("Using Sample store for this test run");
+ }
+ }
public RemoteListenerWrapper(RemoteSampleListener l)
{
listener = l;
}
- public RemoteListenerWrapper()
+
+ public RemoteListenerWrapper() //TODO: not used - make private?
{
}
public void testStarted()
{
+ log.info("Test Started()"); // should this be debug?
+ setUpStore();
try
{
- listener.testStarted();
+ listener.testStarted();
}
catch (Exception ex)
{
@@ -44,9 +66,18 @@
}
public void testEnded()
{
+ log.debug("Test ended");
try
{
+ if (holdSamples){
+ Iterator i = sampleStore.iterator();
+ while (i.hasNext()) {
+ SampleEvent se = (SampleEvent) i.next();
+ listener.sampleOccurred(se);
+ }
+ }
listener.testEnded();
+ sampleStore = null;
}
catch (Exception ex)
{
@@ -55,6 +86,8 @@
}
public void testStarted(String host)
{
+ log.info("Test Started on "+host); // should this be debug?
+ setUpStore();
try
{
listener.testStarted(host);
@@ -66,9 +99,18 @@
}
public void testEnded(String host)
{
+ log.info("Test Ended"); // should this be debug?
try
{
+ if (holdSamples){
+ Iterator i = sampleStore.iterator();
+ while (i.hasNext()) {
+ SampleEvent se = (SampleEvent) i.next();
+ listener.sampleOccurred(se);
+ }
+ }
listener.testEnded(host);
+ sampleStore = null;
}
catch (Exception ex)
{
@@ -78,17 +120,32 @@
public void sampleOccurred(SampleEvent e)
{
+ log.debug("Sample occurred");
try
{
+ if (holdSamples) {
+ sampleStore.add(e);
+ } else {
listener.sampleOccurred(e);
+ }
}
catch (RemoteException err)
{
log.error("", err);
}
}
+
+// Note that sampleStarted() and sampleStopped() is not made to appear
+// in synch with sampleOccured() when replaying held samples.
+// For now this is not critical since sampleStarted() and sampleStopped()
+// is not used, but it may become an issue in the future. Then these
+// events must also be stored so that replay of all events may occur and
+// in the right order. Each stored event must then be tagged with something
+// that lets you distinguish between occured, started and ended.
+
public void sampleStarted(SampleEvent e)
{
+ log.debug("Sample started");
try
{
listener.sampleStarted(e);
@@ -100,6 +157,7 @@
}
public void sampleStopped(SampleEvent e)
{
+ log.debug("Sample stopped");
try
{
listener.sampleStopped(e);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]