Class AbstractThreadGroup
-
- All Implemented Interfaces:
-
java.io.Serializable
,java.lang.Cloneable
,org.apache.jmeter.control.Controller
,org.apache.jmeter.gui.Searchable
,org.apache.jmeter.testelement.TestElement
,org.apache.jmeter.threads.JMeterThreadMonitor
,org.apache.jmeter.threads.TestCompilerHelper
public abstract class AbstractThreadGroup extends AbstractTestElement implements Serializable, Controller, JMeterThreadMonitor, TestCompilerHelper
ThreadGroup holds the settings for a JMeter thread group. This class is intended to be ThreadSafe.
-
-
Field Summary
Fields Modifier and Type Field Description public final static Duration
DEFAULT_THREAD_STOP_TIMEOUT
public final static String
ON_SAMPLE_ERROR
public final static String
ON_SAMPLE_ERROR_CONTINUE
public final static String
ON_SAMPLE_ERROR_START_NEXT_LOOP
public final static String
ON_SAMPLE_ERROR_STOPTHREAD
public final static String
ON_SAMPLE_ERROR_STOPTEST
public final static String
ON_SAMPLE_ERROR_STOPTEST_NOW
public final static String
NUM_THREADS
public final static String
MAIN_CONTROLLER
public final static String
IS_SAME_USER_ON_NEXT_ITERATION
private transient boolean
runningVersion
public transient JMeterContext
threadContext
public transient String
threadName
public final static TestElement.Companion
Companion
public final static String
NAME
public final static String
GUI_CLASS
public final static String
ENABLED
public final static String
TEST_CLASS
public final static String
COMMENTS
-
Constructor Summary
Constructors Constructor Description AbstractThreadGroup()
-
Method Summary
Modifier and Type Method Description AbstractThreadGroupSchema
getSchema()
PropertiesAccessor<out AbstractThreadGroup, out AbstractThreadGroupSchema>
getProps()
Allows type-safe accessors to the properties of the current element. boolean
isDone()
Indicates whether the Controller is done delivering Samplers for the rest of the test. Sampler
next()
Delivers the next Sampler or null Controller
getSamplerController()
Get the sampler controller. void
setSamplerController(LoopController c)
Set the sampler controller. void
addTestElement(TestElement child)
Add a test element. final boolean
addTestElementOnce(TestElement child)
Add child test element only if it has not already been added. void
addIterationListener(LoopIterationListener lis)
Controllers have to notify listeners of when they begin an iteration through their sub-elements. void
removeIterationListener(LoopIterationListener iterationListener)
Unregister IterationListener void
initialize()
Called to initialize a controller at the beginning of a test iteration. void
startNextLoop()
Start next iteration after an error void
triggerEndOfLoop()
NOOP void
setNumThreads(int numThreads)
Set the total number of threads to start int
getNumberOfThreads()
Get the number of active threads int
getNumThreads()
Get the number of threads. boolean
getOnErrorStartNextLoop()
Check if a sampler error should cause thread to start next loop. boolean
getOnErrorStopThread()
Check if a sampler error should cause thread to stop. boolean
getOnErrorStopTest()
Check if a sampler error should cause test to stop. boolean
getOnErrorStopTestNow()
Check if a sampler error should cause test to stop now. abstract boolean
stopThread(String threadName, boolean now)
Hard or graceful stop depending on now flag abstract int
numberOfActiveThreads()
abstract void
start(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine)
Start the ThreadGroup abstract JMeterThread
addNewThread(int delay, StandardJMeterEngine engine)
Add a new JMeterThread to this ThreadGroup for engine abstract boolean
verifyThreadsStopped()
abstract void
waitThreadsStopped()
Wait for all Group Threads to stop after a graceful stop abstract void
tellThreadsToStop()
This immediately stop threads of Group by interrupting them. abstract void
stop()
This gracefully stops threads of Group void
breakThreadLoop()
void
setIsSameUserOnNextIteration(boolean isSameUserOnNextIteration)
Set the kind of user boolean
isSameUserOnNextIteration()
Get kind of user: - true means same user running multiple iterations
- false means a different user for each iteration
static ListedHashTree
cloneTree(ListedHashTree tree)
-
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
canRemove, clear, clearTestElementChildren, clone, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
-
Methods inherited from class org.apache.jmeter.threads.JMeterThreadMonitor
threadFinished
-
Methods inherited from class org.apache.jmeter.testelement.TestElement
canRemove, clear, clearTestElementChildren, clone, get, get, get, get, get, get, get, get, get, getComment, getName, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyOrNull, getString, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, removed, set, setComment, setEnabled, setName, setProperty, setTemporary, traverse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getSchema
AbstractThreadGroupSchema getSchema()
-
getProps
@NotNull() PropertiesAccessor<out AbstractThreadGroup, out AbstractThreadGroupSchema> getProps()
Allows type-safe accessors to the properties of the current element. Note: when overriding the method, ensure you emit wildcards. For instance: JMeterElementInstance<? extends TestPlanClass> getProps() { return ... }
-
isDone
boolean isDone()
Indicates whether the Controller is done delivering Samplers for the rest of the test. When the top-level controller returns true to JMeterThread, the thread is complete.
-
getSamplerController
Controller getSamplerController()
Get the sampler controller.
- Returns:
the sampler controller.
-
setSamplerController
void setSamplerController(LoopController c)
Set the sampler controller.
- Parameters:
c
- the sampler controller.
-
addTestElement
void addTestElement(TestElement child)
Add a test element.
- Parameters:
child
- the test element to add.
-
addTestElementOnce
final boolean addTestElementOnce(TestElement child)
Add child test element only if it has not already been added.
Only for use by TestCompiler.
-
addIterationListener
void addIterationListener(LoopIterationListener lis)
Controllers have to notify listeners of when they begin an iteration through their sub-elements.
-
removeIterationListener
void removeIterationListener(LoopIterationListener iterationListener)
Unregister IterationListener
-
initialize
void initialize()
Called to initialize a controller at the beginning of a test iteration.
-
startNextLoop
void startNextLoop()
Start next iteration after an error
-
triggerEndOfLoop
void triggerEndOfLoop()
NOOP
-
setNumThreads
void setNumThreads(int numThreads)
Set the total number of threads to start
- Parameters:
numThreads
- the number of threads.
-
getNumberOfThreads
int getNumberOfThreads()
Get the number of active threads
- Returns:
the number of active threads
-
getNumThreads
int getNumThreads()
Get the number of threads.
- Returns:
the number of threads.
-
getOnErrorStartNextLoop
boolean getOnErrorStartNextLoop()
Check if a sampler error should cause thread to start next loop.
- Returns:
true if thread should start next loop
-
getOnErrorStopThread
boolean getOnErrorStopThread()
Check if a sampler error should cause thread to stop.
- Returns:
true if thread should stop
-
getOnErrorStopTest
boolean getOnErrorStopTest()
Check if a sampler error should cause test to stop.
- Returns:
true if test (all threads) should stop
-
getOnErrorStopTestNow
boolean getOnErrorStopTestNow()
Check if a sampler error should cause test to stop now.
- Returns:
true if test (all threads) should stop immediately
-
stopThread
abstract boolean stopThread(String threadName, boolean now)
Hard or graceful stop depending on now flag
- Parameters:
threadName
- String thread namenow
- if true interrupt Thread- Returns:
boolean true if stop succeeded
-
numberOfActiveThreads
abstract int numberOfActiveThreads()
- Returns:
int number of active threads
-
start
abstract void start(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine)
Start the ThreadGroup
- Parameters:
groupCount
- group numbernotifier
- ListenerNotifierthreadGroupTree
- ListedHashTreeengine
- StandardJMeterEngine
-
addNewThread
abstract JMeterThread addNewThread(int delay, StandardJMeterEngine engine)
Add a new JMeterThread to this ThreadGroup for engine
- Parameters:
delay
- Delay in millisecondsengine
- StandardJMeterEngine- Returns:
-
verifyThreadsStopped
abstract boolean verifyThreadsStopped()
- Returns:
true if threads were correctly stopped
-
waitThreadsStopped
abstract void waitThreadsStopped()
Wait for all Group Threads to stop after a graceful stop
-
tellThreadsToStop
abstract void tellThreadsToStop()
This immediately stop threads of Group by interrupting them. It differs from stop by being a hard stop
-
stop
abstract void stop()
This gracefully stops threads of Group
-
breakThreadLoop
void breakThreadLoop()
-
setIsSameUserOnNextIteration
void setIsSameUserOnNextIteration(boolean isSameUserOnNextIteration)
Set the kind of user
- Parameters:
isSameUserOnNextIteration
- true is the same user on next iteration of loop false is a different user on next iteration of loop
-
isSameUserOnNextIteration
boolean isSameUserOnNextIteration()
Get kind of user:
- true means same user running multiple iterations
- false means a different user for each iteration
- Returns:
the kind of user.
-
cloneTree
@API(status = API.Status.EXPERIMENTAL, since = "5.5") static ListedHashTree cloneTree(ListedHashTree tree)
- Parameters:
tree
- ListedHashTree- Returns:
a clone of tree
-
-
-