You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by frank sander <fr...@hotmail.com> on 2003/11/14 17:16:07 UTC

How to write a date controller for jmeter 1.9.1 ?

Hello friends,

I'm new in JMeter and struggle with some problems. I want to write a 
controller which executes Samples only at service times (e.g. 7 am to 7 pm). 
I want to have a continous test, so there will be no termination of the test 
at all.

I did following:
I wrote a JMeterTimeController class inherited from GenericController and a 
JMeterTimeControllerGui inherited from AbstractControllerGui.

My understanding is, that the Sample, I want to test, is nested inside this 
Controller.
I implemented the "public Sample next()" method, which returns the Sample at 
service time and returns null, if not (e.g. at 12 am).

Code is following:
    public Sampler next() {
		Date date = new Date(System.currentTimeMillis());
		Sampler currentElement = super.next();
		if (date.getHours()>6 || date.getHours()<20 ) {
			return currentElement;
		} else {
			return null;
		}
    }

setDone(true) isn't called, because I don't want the Test stopped.
I saw similar code in IfController.java and I wonder, why I get allways a 
"StackOverflow" Exception.

The tree in the Gui is following:

TestPlan
+-Thread
   +-Time Controller (the one I wrote)
      +-Sample
      +-Config
      +-Constant Throughput Timer

What did I miss ?

Thank you for your help and suggestions,

Greetings,

Frank

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to write a date controller for jmeter 1.9.1 ?

Posted by ms...@apache.org.
Sounds to me that you would be better served by making a new Timer element that delays 
execution of the test until a certain absolute time has arrived.  Call it, say, AbsoluteTimer.

Timers are far simpler to write than controllers - all you'd have to do is calculate how long to 
delay until the correct time.

As far as why your method causes a StackOverflow, I have no idea.  But, it might have 
something to do with the fact that your test is whizzing by at Java's top speed through a loop 
that looks like this:

while(true)
{
	while(x != null) // x is always null
	{}
	fireSomeIterEvents()
}

Since your controller is virtually always return null, your processor is hot and heavy to do this 
loop, and maybe the stack is getting filled faster than the JVM can deal with it.  Just a guess - 
I really don't know, but I do know the above plan is not a good one.

Make the AbsoluteTimer instead.

-Mike

On 14 Nov 2003 at 16:16, frank sander wrote:

> Hello friends,
> 
> I'm new in JMeter and struggle with some problems. I want to write a 
> controller which executes Samples only at service times (e.g. 7 am to 7 pm). 
> I want to have a continous test, so there will be no termination of the test 
> at all.
> 
> I did following:
> I wrote a JMeterTimeController class inherited from GenericController and a 
> JMeterTimeControllerGui inherited from AbstractControllerGui.
> 
> My understanding is, that the Sample, I want to test, is nested inside this 
> Controller.
> I implemented the "public Sample next()" method, which returns the Sample at 
> service time and returns null, if not (e.g. at 12 am).
> 
> Code is following:
>     public Sampler next() {
> 		Date date = new Date(System.currentTimeMillis());
> 		Sampler currentElement = super.next();
> 		if (date.getHours()>6 || date.getHours()<20 ) {
> 			return currentElement;
> 		} else {
> 			return null;
> 		}
>     }
> 
> setDone(true) isn't called, because I don't want the Test stopped.
> I saw similar code in IfController.java and I wonder, why I get allways a 
> "StackOverflow" Exception.
> 
> The tree in the Gui is following:
> 
> TestPlan
> +-Thread
>    +-Time Controller (the one I wrote)
>       +-Sample
>       +-Config
>       +-Constant Throughput Timer
> 
> What did I miss ?
> 
> Thank you for your help and suggestions,
> 
> Greetings,
> 
> Frank
> 
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE* 
> http://join.msn.com/?page=features/junkmail
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 




--
Michael Stover
mstover1@apache.org
Yahoo IM: mstover_ya
ICQ: 152975688
AIM: mstover777

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org