* @see LoopIterationListener#iterationStart(LoopIterationEvent)
*/
public synchronized void iterationStart(LoopIterationEvent event)
{
// Cannot use getThreadContext() as not cloned per thread
JMeterVariables variables =
JMeterContextService.getContext().getVariables();
int start = getStart(), end = getEnd(), increment = getIncrement();
if (!isPerUser())
{
if (globalCounter == -1 || globalCounter > end)
{
globalCounter = start;
}
variables.put(getVarName(), Integer.toString(globalCounter));
globalCounter += increment;
}
else
{
String value = variables.get(getVarName());
if (value == null)
{
variables.put(getVarName(), Integer.toString(start));
value = variables.get(getVarName());
}
else
{
try
{
int current = Integer.parseInt(value);
current += increment;
if (current > end)
{
current = start;
}
variables.put(getVarName(), Integer.toString(current));
}
catch (NumberFormatException e)
{
log.info("Bad number in Counter config", e);
}