sebb 2004/07/02 11:05:00
Modified: src/core/org/apache/jmeter/engine Tag: rel-2_0
StandardJMeterEngine.java
Log:
Add stopThreadNow() method
Revision Changes Path
No revision
No revision
1.43.2.4 +24 -2
jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java
Index: StandardJMeterEngine.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java,v
retrieving revision 1.43.2.3
retrieving revision 1.43.2.4
diff -u -r1.43.2.3 -r1.43.2.4
--- StandardJMeterEngine.java 29 Jun 2004 01:34:40 -0000 1.43.2.3
+++ StandardJMeterEngine.java 2 Jul 2004 18:05:00 -0000 1.43.2.4
@@ -65,8 +65,11 @@
// Allow engine and threads to be stopped from outside a thread
// e.g. from beanshell server
+ // Assumes that there is only one instance of the engine
+ // at any one time so it is not guaranteed to work ...
private static transient Map allThreadNames;
private static StandardJMeterEngine engine;
+ private static Map allThreadsSave;
public static void stopEngineNow()
{
engine.stopTest();
@@ -77,6 +80,14 @@
}
public static boolean stopThread(String threadName)
{
+ return stopThread(threadName,false);
+ }
+ public static boolean stopThreadNow(String threadName)
+ {
+ return stopThread(threadName,true);
+ }
+ private static boolean stopThread(String threadName, boolean now)
+ {
if (allThreadNames == null) return false;// e.g. not yet started
JMeterThread thrd;
try {
@@ -88,6 +99,15 @@
if (thrd!= null)
{
thrd.stop();
+ if (now)
+ {
+ Thread t = (Thread) allThreadsSave.get(thrd);
+ if (t != null)
+ {
+ t.interrupt();
+ }
+
+ }
return true;
}
else
@@ -95,12 +115,14 @@
return false;
}
}
+ // End of code to allow engine to be controlled remotely
public StandardJMeterEngine()
{
allThreads = new HashMap();
engine=this;
allThreadNames = new HashMap();
+ allThreadsSave = allThreads;
}
public StandardJMeterEngine(String host)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]