Apache JMeter

org.apache.jmeter.threads
Class ThreadGroup

java.lang.Object
  extended byorg.apache.jmeter.testelement.AbstractTestElement
      extended byorg.apache.jmeter.threads.ThreadGroup
All Implemented Interfaces:
Cloneable, Controller, Serializable, TestElement

public class ThreadGroup
extends AbstractTestElement
implements Serializable, Controller

ThreadGroup holds the settings for a JMeter thread group. This class is intended to be ThreadSafe.

See Also:
Serialized Form

Field Summary
static String DELAY
          Scheduler start delay, overrides start time
static String DURATION
          Scheduler duration, overrides end time
static String END_TIME
          Scheduler absolute end time
static String MAIN_CONTROLLER
           
static String NUM_THREADS
          Number of threads in the thread group
static String ON_SAMPLE_ERROR
          Action to be taken when a Sampler error occurs
static String ON_SAMPLE_ERROR_CONTINUE
          Continue, i.e. ignore sampler errors
static String ON_SAMPLE_ERROR_STOPTEST
          Stop test (all threads) if sampler error occurs
static String ON_SAMPLE_ERROR_STOPTEST_NOW
          Stop test NOW (all threads) if sampler error occurs
static String ON_SAMPLE_ERROR_STOPTHREAD
          Stop current thread if sampler error occurs
static String RAMP_TIME
          Ramp-up time
static String SCHEDULER
          Whether scheduler is being used
static String START_TIME
          Scheduler absolute start time
 
Fields inherited from interface org.apache.jmeter.testelement.TestElement
COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS
 
Constructor Summary
ThreadGroup()
          No-arg constructor.
 
Method Summary
 void addIterationListener(LoopIterationListener lis)
          Controllers have to notify listeners of when they begin an iteration through their sub-elements.
 void addTestElement(TestElement child)
          Add a test element.
 long getDelay()
          Get the startup delay
 long getDuration()
          Get the desired duration of the thread group test run
 long getEndTime()
          Get the end time value.
 int getNumberOfThreads()
          Get the number of active threads
 int getNumThreads()
          Get the number of threads.
 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.
 boolean getOnErrorStopThread()
          Check if a sampler error should cause thread to stop.
 int getRampUp()
          Get the ramp-up value.
 Controller getSamplerController()
          Get the sampler controller.
 boolean getScheduler()
          Get whether scheduler is being used
 long getStartTime()
          Get the absolute start time value.
 void initialize()
          Called to initialize a controller at the beginning of a test iteration.
 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.
 Sampler next()
          Delivers the next Sampler or null
 void setDelay(long delay)
          Set the startup delay
 void setDuration(long duration)
          Set the desired duration of the thread group test run
 void setEndTime(long etime)
          Set the EndTime value.
 void setNumThreads(int numThreads)
          Set the total number of threads to start
 void setRampUp(int rampUp)
          Set the ramp-up value.
 void setSamplerController(LoopController c)
          Set the sampler controller.
 void setScheduler(boolean Scheduler)
          Set whether scheduler is being used
 void setStartTime(long stime)
          Set the absolute StartTime value.
 
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addProperty, canRemove, clear, clearTemporary, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jmeter.testelement.TestElement
canRemove, clear, clone, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
 

Field Detail

NUM_THREADS

public static final String NUM_THREADS
Number of threads in the thread group

See Also:
Constant Field Values

RAMP_TIME

public static final String RAMP_TIME
Ramp-up time

See Also:
Constant Field Values

MAIN_CONTROLLER

public static final String MAIN_CONTROLLER
See Also:
Constant Field Values

SCHEDULER

public static final String SCHEDULER
Whether scheduler is being used

See Also:
Constant Field Values

START_TIME

public static final String START_TIME
Scheduler absolute start time

See Also:
Constant Field Values

END_TIME

public static final String END_TIME
Scheduler absolute end time

See Also:
Constant Field Values

DURATION

public static final String DURATION
Scheduler duration, overrides end time

See Also:
Constant Field Values

DELAY

public static final String DELAY
Scheduler start delay, overrides start time

See Also:
Constant Field Values

ON_SAMPLE_ERROR

public static final String ON_SAMPLE_ERROR
Action to be taken when a Sampler error occurs

See Also:
Constant Field Values

ON_SAMPLE_ERROR_CONTINUE

public static final String ON_SAMPLE_ERROR_CONTINUE
Continue, i.e. ignore sampler errors

See Also:
Constant Field Values

ON_SAMPLE_ERROR_STOPTHREAD

public static final String ON_SAMPLE_ERROR_STOPTHREAD
Stop current thread if sampler error occurs

See Also:
Constant Field Values

ON_SAMPLE_ERROR_STOPTEST

public static final String ON_SAMPLE_ERROR_STOPTEST
Stop test (all threads) if sampler error occurs

See Also:
Constant Field Values

ON_SAMPLE_ERROR_STOPTEST_NOW

public static final String ON_SAMPLE_ERROR_STOPTEST_NOW
Stop test NOW (all threads) if sampler error occurs

See Also:
Constant Field Values
Constructor Detail

ThreadGroup

public ThreadGroup()
No-arg constructor.

Method Detail

setNumThreads

public void setNumThreads(int numThreads)
Set the total number of threads to start

Parameters:
numThreads - the number of threads.

getNumberOfThreads

public int getNumberOfThreads()
Get the number of active threads


isDone

public 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.

Specified by:
isDone in interface Controller
Returns:
boolean

next

public Sampler next()
Delivers the next Sampler or null

Specified by:
next in interface Controller
Returns:
org.apache.jmeter.samplers.Sampler or null

setScheduler

public void setScheduler(boolean Scheduler)
Set whether scheduler is being used

Parameters:
Scheduler - true is scheduler is to be used

getScheduler

public boolean getScheduler()
Get whether scheduler is being used

Returns:
true if scheduler is being used

setStartTime

public void setStartTime(long stime)
Set the absolute StartTime value.

Parameters:
stime - - the StartTime value.

getStartTime

public long getStartTime()
Get the absolute start time value.

Returns:
the start time value.

getDuration

public long getDuration()
Get the desired duration of the thread group test run

Returns:
the duration (in secs)

setDuration

public void setDuration(long duration)
Set the desired duration of the thread group test run

Parameters:
duration - in seconds

getDelay

public long getDelay()
Get the startup delay

Returns:
the delay (in secs)

setDelay

public void setDelay(long delay)
Set the startup delay

Parameters:
delay - in seconds

setEndTime

public void setEndTime(long etime)
Set the EndTime value.

Parameters:
etime - - the EndTime value.

getEndTime

public long getEndTime()
Get the end time value.

Returns:
the end time value.

setRampUp

public void setRampUp(int rampUp)
Set the ramp-up value.

Parameters:
rampUp - the ramp-up value.

getRampUp

public int getRampUp()
Get the ramp-up value.

Returns:
the ramp-up value.

getSamplerController

public Controller getSamplerController()
Get the sampler controller.

Returns:
the sampler controller.

setSamplerController

public void setSamplerController(LoopController c)
Set the sampler controller.

Parameters:
c - the sampler controller.

getNumThreads

public int getNumThreads()
Get the number of threads.

Returns:
the number of threads.

addTestElement

public void addTestElement(TestElement child)
Add a test element.

Specified by:
addTestElement in interface TestElement
Overrides:
addTestElement in class AbstractTestElement
Parameters:
child - the test element to add.

addIterationListener

public void addIterationListener(LoopIterationListener lis)
Controllers have to notify listeners of when they begin an iteration through their sub-elements.

Specified by:
addIterationListener in interface Controller

initialize

public void initialize()
Called to initialize a controller at the beginning of a test iteration.

Specified by:
initialize in interface Controller

getOnErrorStopThread

public boolean getOnErrorStopThread()
Check if a sampler error should cause thread to stop.

Returns:
true if thread should stop

getOnErrorStopTest

public boolean getOnErrorStopTest()
Check if a sampler error should cause test to stop.

Returns:
true if test (all threads) should stop

getOnErrorStopTestNow

public boolean getOnErrorStopTestNow()
Check if a sampler error should cause test to stop now.

Returns:
true if test (all threads) should stop immediately

Apache JMeter

Copyright © 1998-2009 Apache Software Foundation. All Rights Reserved.