Class GenericController
- All Implemented Interfaces:
Serializable,Cloneable,Controller,Searchable,org.apache.jmeter.testelement.TestElement,TestCompilerHelper
- Direct Known Subclasses:
CriticalSectionController,ForeachController,IfController,IncludeController,InterleaveControl,LoopController,ModuleController,OnceOnlyController,ProxyControl,RandomOrderController,RecordingController,RunTime,SwitchController,TestFragmentController,ThroughputController,TransactionController,WhileController
This class is the basis for all the controllers. It also implements SimpleController.
The main entry point is next(), which is called by JMeterThread as follows:
while (running && (sampler = controller.next()) != null)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.jmeter.testelement.TestElement
org.apache.jmeter.testelement.TestElement.Companion -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intIndex of current sub controller or samplerprotected List<org.apache.jmeter.testelement.TestElement>Fields inherited from interface org.apache.jmeter.testelement.TestElement
COMMENTS, Companion, ENABLED, GUI_CLASS, NAME, TEST_CLASS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidControllers have to notify listeners of when they begin an iteration through their sub-elements.voidaddTestElement(org.apache.jmeter.testelement.TestElement child) final booleanaddTestElementOnce(org.apache.jmeter.testelement.TestElement child) Add child test element only if it has not already been added.protected voidIf the controller is done, remove it from the list, otherwise increment to next entry in list.protected voidprotected voidprotected org.apache.jmeter.testelement.TestElementGets the element indicated by thecurrentindex, if one exists, from thesubControllersAndSamplerslist.protected intorg.apache.jmeter.testelement.schema.PropertiesAccessor<? extends GenericController,? extends org.apache.jmeter.control.GenericControllerSchema> getProps()org.apache.jmeter.control.GenericControllerSchemaprotected List<org.apache.jmeter.testelement.TestElement>Gets the SubControllers attribute of the GenericController objectprotected voidIncrements the current pointer; called by currentReturnedNull to move the controller on to its next child.protected voidvoidCalled to initialize a controller at the beginning of a test iteration.protected void(re)Initializes sub controllers See Bug 50032booleanisDone()Indicates whether the Controller is done delivering Samplers for the rest of the test.protected booleanisFirst()next()Determines the next sampler to be processed.protected SamplernextIsAController(Controller controller) Called bynext()if the element is a Controller, and returns the next sampler from the controller.protected SamplernextIsASampler(Sampler element) Increment the current pointer and return the element.protected Samplerprotected Objectprotected voidResets the controller (called after execution of last child of controller): resetCurrent() (i.e.protected voidvoidremoveIterationListener(LoopIterationListener iterationListener) Remove listenerprotected voidprotected voidprotected voidsetCurrentElement(org.apache.jmeter.testelement.TestElement currentElement) Empty implementation - does nothing.protected voidsetDone(boolean done) voidsetFirst(boolean b) If b is true, it means first is reset which means Controller has executed all its childrenvoidTrigger end of loop condition on controller (used by Start Next Loop feature)Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addPropertiesValues, addProperty, addProperty, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traversePropertyMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getPropertyOrNull, getString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removed, removeProperty, removeProperty, set, set, set, set, set, set, set, set, set, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
-
Field Details
-
subControllersAndSamplers
-
current
protected transient int currentIndex of current sub controller or sampler
-
-
Constructor Details
-
GenericController
public GenericController()Creates a Generic Controller
-
-
Method Details
-
getSchema
public org.apache.jmeter.control.GenericControllerSchema getSchema()- Specified by:
getSchemain interfaceorg.apache.jmeter.testelement.TestElement
-
getProps
public org.apache.jmeter.testelement.schema.PropertiesAccessor<? extends GenericController,? extends org.apache.jmeter.control.GenericControllerSchema> getProps()- Specified by:
getPropsin interfaceorg.apache.jmeter.testelement.TestElement
-
initialize
public void initialize()Description copied from interface:ControllerCalled to initialize a controller at the beginning of a test iteration.- Specified by:
initializein interfaceController
-
initializeSubControllers
protected void initializeSubControllers()(re)Initializes sub controllers See Bug 50032 -
reInitialize
protected void reInitialize()Resets the controller (called after execution of last child of controller):- resetCurrent() (i.e. current=0)
- increment iteration count
- sets first=true
- recoverRunningVersion() to set the controller back to the initial state
-
next
Determines the next sampler to be processed.
If
isDone()istrue, returns null.Gets the list element using current pointer. If this is
null, callsnextIsNull().If the list element is a
Sampler, callsnextIsASampler(Sampler), otherwise callsnextIsAController(Controller)If any of the called methods throws
NextIsNullException, returnsnull, otherwise the value obtained above is returned.- Specified by:
nextin interfaceController- Returns:
- the next sampler or
null
-
isDone
public boolean isDone()Description copied from interface:ControllerIndicates 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:
isDonein interfaceController- Returns:
- boolean
- See Also:
-
setDone
protected void setDone(boolean done) -
isFirst
protected boolean isFirst()- Returns:
- true if it's the controller is returning the first of its children
-
setFirst
public void setFirst(boolean b) If b is true, it means first is reset which means Controller has executed all its children- Parameters:
b- The flag, whether first is reseted
-
nextIsAController
Called bynext()if the element is a Controller, and returns the next sampler from the controller. If this isnull, then updates the current pointer and makes recursive call tonext().- Parameters:
controller- the current next element- Returns:
- the next sampler
- Throws:
NextIsNullException- when the end of the list has already been reached
-
nextIsASampler
Increment the current pointer and return the element. Called bynext()if the element is a sampler. (May be overridden by sub-classes).- Parameters:
element- the current next element- Returns:
- input element
- Throws:
NextIsNullException- when the end of the list has already been reached
-
nextIsNull
- Returns:
- null (always, for this class)
- Throws:
NextIsNullException- when the end of the list has already been reached
-
triggerEndOfLoop
public void triggerEndOfLoop()Trigger end of loop condition on controller (used by Start Next Loop feature)- Specified by:
triggerEndOfLoopin interfaceController
-
currentReturnedNull
If the controller is done, remove it from the list, otherwise increment to next entry in list.- Parameters:
c- controller
-
getSubControllers
Gets the SubControllers attribute of the GenericController object- Returns:
- the SubControllers value
-
setCurrentElement
protected void setCurrentElement(org.apache.jmeter.testelement.TestElement currentElement) throws NextIsNullException Empty implementation - does nothing.- Parameters:
currentElement- the current element- Throws:
NextIsNullException- when the list has been completed already
-
getCurrentElement
Gets the element indicated by the
currentindex, if one exists, from thesubControllersAndSamplerslist.If the
subControllersAndSamplerslist is empty, then set done = true, and throw NextIsNullException.- Returns:
- the current element - or null if current index too large
- Throws:
NextIsNullException- if list is empty
-
removeCurrentElement
protected void removeCurrentElement() -
incrementCurrent
protected void incrementCurrent()Increments the current pointer; called by currentReturnedNull to move the controller on to its next child. -
resetCurrent
protected void resetCurrent() -
addTestElement
public void addTestElement(org.apache.jmeter.testelement.TestElement child) Description copied from class:AbstractTestElement- Specified by:
addTestElementin interfaceorg.apache.jmeter.testelement.TestElement- Overrides:
addTestElementin classAbstractTestElement
-
addTestElementOnce
public final boolean addTestElementOnce(org.apache.jmeter.testelement.TestElement child) Add child test element only if it has not already been added.Only for use by TestCompiler.
- Specified by:
addTestElementOncein interfaceTestCompilerHelper- Parameters:
child- theTestElementto be added- Returns:
trueif the child was added
-
addIterationListener
Description copied from interface:ControllerControllers have to notify listeners of when they begin an iteration through their sub-elements.- Specified by:
addIterationListenerin interfaceController- Parameters:
lis- TheLoopIterationListenerto add
-
removeIterationListener
Remove listener- Specified by:
removeIterationListenerin interfaceController- Parameters:
iterationListener-LoopIterationListener
-
fireIterEvents
protected void fireIterEvents() -
fireIterationStart
protected void fireIterationStart() -
getIterCount
protected int getIterCount() -
incrementIterCount
protected void incrementIterCount() -
resetIterCount
protected void resetIterCount() -
readResolve
-