New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It should be easier to plug a custom SampleSender in jmeter #2249
Comments
benoit.wiart (migrated from Bugzilla): add a new optionnal parameter in the config file (ex : sample.sender.class) Benoit Wiart |
Sebb (migrated from Bugzilla): Regarding properties: I don't think it's necessary to add yet another property; just set hold=false and mode=classname. If the class is not found, I think the run should fail rather than reverting to StandardSampler. Please submit a patch. Ideally this should cover the factory class, jmeter.properties and the user documentation. |
benoit.wiart (migrated from Bugzilla): SampleSenderFactory.java.patchIndex: src/core/org/apache/jmeter/samplers/SampleSenderFactory.java
===================================================================
--- src/core/org/apache/jmeter/samplers/SampleSenderFactory.java (revision 780105)
+++ src/core/org/apache/jmeter/samplers/SampleSenderFactory.java (working copy)
@@ -18,10 +18,16 @@
package org.apache.jmeter.samplers;
+import java.lang.reflect.Constructor;
+
import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jmeter.samplers.StatisticalSampleSender;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
public class SampleSenderFactory {
+
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
/**
* Checks for the Jmeter property mode and returns the required class.
*
@@ -45,9 +51,24 @@
} else if (type.equalsIgnoreCase("Statistical")) {
StatisticalSampleSender s = new StatisticalSampleSender(listener);
return s;
- } else {
+ } else if (type.equalsIgnoreCase("Standard")) {
StandardSampleSender s = new StandardSampleSender(listener);
return s;
+ } else {
+ // should be a user provided class name
+ SampleSender s = null;
+ try {
+ Class clazz = Class.forName(type);
+ Constructor cons = clazz.getConstructor(new Class[] {RemoteSampleListener.class});
+ s = (SampleSender) cons.newInstance(new Object [] {listener});
+ } catch (Exception e) {
+ // houston we have a problem !!
+ log.error("Unable to create a sample sender from class "+type, e);
+ throw new IllegalArgumentException(e.getMessage());
+ }
+
+ return s;
}
+
}
} |
benoit.wiart (migrated from Bugzilla): jmeter.properties.patchIndex: bin/jmeter.properties
===================================================================
--- bin/jmeter.properties (revision 786693)
+++ bin/jmeter.properties (working copy)
@@ -459,11 +459,13 @@
# Batch returns samples in batches
# Statistical returns sample stats
# hold_samples was originally defined as a separate property,
-# but can now also be defined using remote.mode
+# but can now also be defined using mode=Hold
+# mode can also be the class name of an implementation of org.apache.jmeter.samplers.SampleSender
#mode=Standard
#mode=Batch
#mode=Hold
#mode=Statistical
+#mode=org.example.load.MySampleSender
#hold_samples=true
#num_sample_threshold=100
#time_threshold=60000 |
benoit.wiart (migrated from Bugzilla): remote-test.xml.patchIndex: xdocs/usermanual/remote-test.xml
===================================================================
--- xdocs/usermanual/remote-test.xml (revision 786693)
+++ xdocs/usermanual/remote-test.xml (working copy)
@@ -216,6 +216,8 @@
</ul>
Other fields that vary between samples are lost.
</li>
+ <li>Custom implementation : set the mode parameter to your custom sample sender class name
+ </li>
</ul>
</ul>
<p>The following properties apply to the Batch and Statistical modes:</p> |
Sebb (migrated from Bugzilla): URL: http://svn.apache.org/viewvc?rev=786747&view=rev The updated code will be in nightly builds after r786747. |
benoit.wiart (Bug 47394):
It's not possible to plug a custom SampleSender without making change in SampleSenderFactory and recompiling jmeter.
It should be possible to provide the implementation class in the config file
If the jmeter dev / comitters thing are willing to accept this change then I will provide a patch (keeping backward compatibility)
Severity: normal
OS: All
The text was updated successfully, but these errors were encountered: