You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/08/14 12:25:17 UTC
svn commit: r1372829 -
/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Author: sebb
Date: Tue Aug 14 10:25:17 2012
New Revision: 1372829
URL: http://svn.apache.org/viewvc?rev=1372829&view=rev
Log:
Arrange fields and methods
Drop unnecessary parameter to private method
Modified:
jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java?rev=1372829&r1=1372828&r2=1372829&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java Tue Aug 14 10:25:17 2012
@@ -41,6 +41,10 @@ public class ThreadGroup extends Abstrac
private static final long WAIT_TO_DIE = JMeterUtils.getPropDefault("jmeterengine.threadstop.wait", 5 * 1000); // 5 seconds
+ /** How often to check for shutdown during ramp-up, default 1000ms */
+ private static final int RAMPUP_GRANULARITY =
+ JMeterUtils.getPropDefault("jmeterthread.rampup.granularity", 1000); // $NON-NLS-1$
+
//+ JMX entries - do not change the string values
/** Ramp-up time */
@@ -66,14 +70,11 @@ public class ThreadGroup extends Abstrac
//- JMX entries
- /** How often to check for shutdown during ramp-up, default 1000ms */
- private static final int RAMPUP_GRANULARITY =
- JMeterUtils.getPropDefault("jmeterthread.rampup.granularity", 1000); // $NON-NLS-1$
-
private Thread threadStarter;
private JMeterThread[] jmThreads;
+ // List of active threads
private Map<JMeterThread, Thread> allThreads = new ConcurrentHashMap<JMeterThread, Thread>();
/**
@@ -92,7 +93,6 @@ public class ThreadGroup extends Abstrac
public ThreadGroup() {
}
-
/**
* Set whether scheduler is being used
*
@@ -102,10 +102,6 @@ public class ThreadGroup extends Abstrac
setProperty(new BooleanProperty(SCHEDULER, Scheduler));
}
- private boolean isDelayedStartup() {
- return getPropertyAsBoolean(DELAYED_START);
- }
-
/**
* Get whether scheduler is being used
*
@@ -210,6 +206,10 @@ public class ThreadGroup extends Abstrac
return getPropertyAsInt(ThreadGroup.RAMP_TIME);
}
+ private boolean isDelayedStartup() {
+ return getPropertyAsBoolean(DELAYED_START);
+ }
+
@Override
public void scheduleThread(JMeterThread thread)
{
@@ -262,24 +262,19 @@ public class ThreadGroup extends Abstrac
/**
* Wait for delay with RAMPUP_GRANULARITY
* @param delay delay in ms
- * @param type Delay type
*/
- private void delayBy(long delay, String type) {
+ private void delayBy(long delay) {
if (delay > 0) {
long start = System.currentTimeMillis();
long end = start + delay;
long now=0;
- long pause = RAMPUP_GRANULARITY;
+ long pause = RAMPUP_GRANULARITY; // maximum pause to use
while(running && (now = System.currentTimeMillis()) < end) {
long togo = end - now;
if (togo < pause) {
pause = togo;
}
- try {
- Thread.sleep(pause); // delay between checks
- } catch (InterruptedException e) {
- break;
- }
+ pause(pause); // delay between checks
}
}
}
@@ -487,6 +482,13 @@ public class ThreadGroup extends Abstrac
}
}
+ private void pause(long ms){
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ }
+ }
+
/**
* Starts Threads using ramp up
*/
@@ -505,11 +507,11 @@ public class ThreadGroup extends Abstrac
long now = System.currentTimeMillis();
// set the start time for the Thread
if (getDelay() > 0) {// Duration is in seconds
- delayBy(getDelay() * 1000, "start");
+ delayBy(getDelay() * 1000);
} else {
long start = getStartTime();
if (start >= now) {
- delayBy(start-now, "start");
+ delayBy(start-now);
}
// else start immediately
}
Re: svn commit: r1372829 - /jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Posted by Philippe Mouawad <ph...@gmail.com>.
Ok, clear for me now, thanks.
On Mon, Aug 20, 2012 at 2:30 AM, sebb <se...@gmail.com> wrote:
> On 19 August 2012 22:05, Philippe Mouawad <ph...@gmail.com>
> wrote:
> > Hello Sebb,
> > Looking at this commit, it seems to me it changes a little delayBy(...)
> > behaviour:
> >
> > - in older code, if InterruptedException happened delayBy would exit
> > - in new code, it will be ignored
> >
> > Is this voluntary ? why ?
>
> Yes, it was deliberate.
>
> AIUI, Thread.sleep can be interrupted for a variety of reasons.
> If the test is being stopped the loop will exit because of the running
> check.
> Otherwise, we want the delay to be continued.
>
> >
> > Thanks
> >
> > Regards
> >
> > Philippe
> >
> > On Tue, Aug 14, 2012 at 12:25 PM, <se...@apache.org> wrote:
> >
> >> Author: sebb
> >> Date: Tue Aug 14 10:25:17 2012
> >> New Revision: 1372829
> >>
> >> URL: http://svn.apache.org/viewvc?rev=1372829&view=rev
> >> Log:
> >> Arrange fields and methods
> >> Drop unnecessary parameter to private method
> >>
> >> Modified:
> >> jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
> >>
> >> Modified:
> jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
> >> URL:
> >>
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java?rev=1372829&r1=1372828&r2=1372829&view=diff
> >>
> >>
> ==============================================================================
> >> --- jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
> >> (original)
> >> +++ jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java Tue
> >> Aug 14 10:25:17 2012
> >> @@ -41,6 +41,10 @@ public class ThreadGroup extends Abstrac
> >>
> >> private static final long WAIT_TO_DIE =
> >> JMeterUtils.getPropDefault("jmeterengine.threadstop.wait", 5 * 1000);
> // 5
> >> seconds
> >>
> >> + /** How often to check for shutdown during ramp-up, default 1000ms
> */
> >> + private static final int RAMPUP_GRANULARITY =
> >> +
> JMeterUtils.getPropDefault("jmeterthread.rampup.granularity",
> >> 1000); // $NON-NLS-1$
> >> +
> >> //+ JMX entries - do not change the string values
> >>
> >> /** Ramp-up time */
> >> @@ -66,14 +70,11 @@ public class ThreadGroup extends Abstrac
> >>
> >> //- JMX entries
> >>
> >> - /** How often to check for shutdown during ramp-up, default 1000ms
> */
> >> - private static final int RAMPUP_GRANULARITY =
> >> -
> JMeterUtils.getPropDefault("jmeterthread.rampup.granularity",
> >> 1000); // $NON-NLS-1$
> >> -
> >> private Thread threadStarter;
> >>
> >> private JMeterThread[] jmThreads;
> >>
> >> + // List of active threads
> >> private Map<JMeterThread, Thread> allThreads = new
> >> ConcurrentHashMap<JMeterThread, Thread>();
> >>
> >> /**
> >> @@ -92,7 +93,6 @@ public class ThreadGroup extends Abstrac
> >> public ThreadGroup() {
> >> }
> >>
> >> -
> >> /**
> >> * Set whether scheduler is being used
> >> *
> >> @@ -102,10 +102,6 @@ public class ThreadGroup extends Abstrac
> >> setProperty(new BooleanProperty(SCHEDULER, Scheduler));
> >> }
> >>
> >> - private boolean isDelayedStartup() {
> >> - return getPropertyAsBoolean(DELAYED_START);
> >> - }
> >> -
> >> /**
> >> * Get whether scheduler is being used
> >> *
> >> @@ -210,6 +206,10 @@ public class ThreadGroup extends Abstrac
> >> return getPropertyAsInt(ThreadGroup.RAMP_TIME);
> >> }
> >>
> >> + private boolean isDelayedStartup() {
> >> + return getPropertyAsBoolean(DELAYED_START);
> >> + }
> >> +
> >> @Override
> >> public void scheduleThread(JMeterThread thread)
> >> {
> >> @@ -262,24 +262,19 @@ public class ThreadGroup extends Abstrac
> >> /**
> >> * Wait for delay with RAMPUP_GRANULARITY
> >> * @param delay delay in ms
> >> - * @param type Delay type
> >> */
> >> - private void delayBy(long delay, String type) {
> >> + private void delayBy(long delay) {
> >> if (delay > 0) {
> >> long start = System.currentTimeMillis();
> >> long end = start + delay;
> >> long now=0;
> >> - long pause = RAMPUP_GRANULARITY;
> >> + long pause = RAMPUP_GRANULARITY; // maximum pause to use
> >> while(running && (now = System.currentTimeMillis()) < end)
> {
> >> long togo = end - now;
> >> if (togo < pause) {
> >> pause = togo;
> >> }
> >> - try {
> >> - Thread.sleep(pause); // delay between checks
> >> - } catch (InterruptedException e) {
> >> - break;
> >> - }
> >> + pause(pause); // delay between checks
> >> }
> >> }
> >> }
> >> @@ -487,6 +482,13 @@ public class ThreadGroup extends Abstrac
> >> }
> >> }
> >>
> >> + private void pause(long ms){
> >> + try {
> >> + Thread.sleep(ms);
> >> + } catch (InterruptedException e) {
> >> + }
> >> + }
> >> +
> >> /**
> >> * Starts Threads using ramp up
> >> */
> >> @@ -505,11 +507,11 @@ public class ThreadGroup extends Abstrac
> >> long now = System.currentTimeMillis();
> >> // set the start time for the Thread
> >> if (getDelay() > 0) {// Duration is in seconds
> >> - delayBy(getDelay() * 1000, "start");
> >> + delayBy(getDelay() * 1000);
> >> } else {
> >> long start = getStartTime();
> >> if (start >= now) {
> >> - delayBy(start-now, "start");
> >> + delayBy(start-now);
> >> }
> >> // else start immediately
> >> }
> >>
> >>
> >>
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
>
--
Cordialement.
Philippe Mouawad.
Re: svn commit: r1372829 - /jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Posted by sebb <se...@gmail.com>.
On 19 August 2012 22:05, Philippe Mouawad <ph...@gmail.com> wrote:
> Hello Sebb,
> Looking at this commit, it seems to me it changes a little delayBy(...)
> behaviour:
>
> - in older code, if InterruptedException happened delayBy would exit
> - in new code, it will be ignored
>
> Is this voluntary ? why ?
Yes, it was deliberate.
AIUI, Thread.sleep can be interrupted for a variety of reasons.
If the test is being stopped the loop will exit because of the running check.
Otherwise, we want the delay to be continued.
>
> Thanks
>
> Regards
>
> Philippe
>
> On Tue, Aug 14, 2012 at 12:25 PM, <se...@apache.org> wrote:
>
>> Author: sebb
>> Date: Tue Aug 14 10:25:17 2012
>> New Revision: 1372829
>>
>> URL: http://svn.apache.org/viewvc?rev=1372829&view=rev
>> Log:
>> Arrange fields and methods
>> Drop unnecessary parameter to private method
>>
>> Modified:
>> jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
>>
>> Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java?rev=1372829&r1=1372828&r2=1372829&view=diff
>>
>> ==============================================================================
>> --- jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
>> (original)
>> +++ jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java Tue
>> Aug 14 10:25:17 2012
>> @@ -41,6 +41,10 @@ public class ThreadGroup extends Abstrac
>>
>> private static final long WAIT_TO_DIE =
>> JMeterUtils.getPropDefault("jmeterengine.threadstop.wait", 5 * 1000); // 5
>> seconds
>>
>> + /** How often to check for shutdown during ramp-up, default 1000ms */
>> + private static final int RAMPUP_GRANULARITY =
>> + JMeterUtils.getPropDefault("jmeterthread.rampup.granularity",
>> 1000); // $NON-NLS-1$
>> +
>> //+ JMX entries - do not change the string values
>>
>> /** Ramp-up time */
>> @@ -66,14 +70,11 @@ public class ThreadGroup extends Abstrac
>>
>> //- JMX entries
>>
>> - /** How often to check for shutdown during ramp-up, default 1000ms */
>> - private static final int RAMPUP_GRANULARITY =
>> - JMeterUtils.getPropDefault("jmeterthread.rampup.granularity",
>> 1000); // $NON-NLS-1$
>> -
>> private Thread threadStarter;
>>
>> private JMeterThread[] jmThreads;
>>
>> + // List of active threads
>> private Map<JMeterThread, Thread> allThreads = new
>> ConcurrentHashMap<JMeterThread, Thread>();
>>
>> /**
>> @@ -92,7 +93,6 @@ public class ThreadGroup extends Abstrac
>> public ThreadGroup() {
>> }
>>
>> -
>> /**
>> * Set whether scheduler is being used
>> *
>> @@ -102,10 +102,6 @@ public class ThreadGroup extends Abstrac
>> setProperty(new BooleanProperty(SCHEDULER, Scheduler));
>> }
>>
>> - private boolean isDelayedStartup() {
>> - return getPropertyAsBoolean(DELAYED_START);
>> - }
>> -
>> /**
>> * Get whether scheduler is being used
>> *
>> @@ -210,6 +206,10 @@ public class ThreadGroup extends Abstrac
>> return getPropertyAsInt(ThreadGroup.RAMP_TIME);
>> }
>>
>> + private boolean isDelayedStartup() {
>> + return getPropertyAsBoolean(DELAYED_START);
>> + }
>> +
>> @Override
>> public void scheduleThread(JMeterThread thread)
>> {
>> @@ -262,24 +262,19 @@ public class ThreadGroup extends Abstrac
>> /**
>> * Wait for delay with RAMPUP_GRANULARITY
>> * @param delay delay in ms
>> - * @param type Delay type
>> */
>> - private void delayBy(long delay, String type) {
>> + private void delayBy(long delay) {
>> if (delay > 0) {
>> long start = System.currentTimeMillis();
>> long end = start + delay;
>> long now=0;
>> - long pause = RAMPUP_GRANULARITY;
>> + long pause = RAMPUP_GRANULARITY; // maximum pause to use
>> while(running && (now = System.currentTimeMillis()) < end) {
>> long togo = end - now;
>> if (togo < pause) {
>> pause = togo;
>> }
>> - try {
>> - Thread.sleep(pause); // delay between checks
>> - } catch (InterruptedException e) {
>> - break;
>> - }
>> + pause(pause); // delay between checks
>> }
>> }
>> }
>> @@ -487,6 +482,13 @@ public class ThreadGroup extends Abstrac
>> }
>> }
>>
>> + private void pause(long ms){
>> + try {
>> + Thread.sleep(ms);
>> + } catch (InterruptedException e) {
>> + }
>> + }
>> +
>> /**
>> * Starts Threads using ramp up
>> */
>> @@ -505,11 +507,11 @@ public class ThreadGroup extends Abstrac
>> long now = System.currentTimeMillis();
>> // set the start time for the Thread
>> if (getDelay() > 0) {// Duration is in seconds
>> - delayBy(getDelay() * 1000, "start");
>> + delayBy(getDelay() * 1000);
>> } else {
>> long start = getStartTime();
>> if (start >= now) {
>> - delayBy(start-now, "start");
>> + delayBy(start-now);
>> }
>> // else start immediately
>> }
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
Re: svn commit: r1372829 - /jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Posted by Philippe Mouawad <ph...@gmail.com>.
Hello Sebb,
Looking at this commit, it seems to me it changes a little delayBy(...)
behaviour:
- in older code, if InterruptedException happened delayBy would exit
- in new code, it will be ignored
Is this voluntary ? why ?
Thanks
Regards
Philippe
On Tue, Aug 14, 2012 at 12:25 PM, <se...@apache.org> wrote:
> Author: sebb
> Date: Tue Aug 14 10:25:17 2012
> New Revision: 1372829
>
> URL: http://svn.apache.org/viewvc?rev=1372829&view=rev
> Log:
> Arrange fields and methods
> Drop unnecessary parameter to private method
>
> Modified:
> jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
>
> Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java?rev=1372829&r1=1372828&r2=1372829&view=diff
>
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
> (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java Tue
> Aug 14 10:25:17 2012
> @@ -41,6 +41,10 @@ public class ThreadGroup extends Abstrac
>
> private static final long WAIT_TO_DIE =
> JMeterUtils.getPropDefault("jmeterengine.threadstop.wait", 5 * 1000); // 5
> seconds
>
> + /** How often to check for shutdown during ramp-up, default 1000ms */
> + private static final int RAMPUP_GRANULARITY =
> + JMeterUtils.getPropDefault("jmeterthread.rampup.granularity",
> 1000); // $NON-NLS-1$
> +
> //+ JMX entries - do not change the string values
>
> /** Ramp-up time */
> @@ -66,14 +70,11 @@ public class ThreadGroup extends Abstrac
>
> //- JMX entries
>
> - /** How often to check for shutdown during ramp-up, default 1000ms */
> - private static final int RAMPUP_GRANULARITY =
> - JMeterUtils.getPropDefault("jmeterthread.rampup.granularity",
> 1000); // $NON-NLS-1$
> -
> private Thread threadStarter;
>
> private JMeterThread[] jmThreads;
>
> + // List of active threads
> private Map<JMeterThread, Thread> allThreads = new
> ConcurrentHashMap<JMeterThread, Thread>();
>
> /**
> @@ -92,7 +93,6 @@ public class ThreadGroup extends Abstrac
> public ThreadGroup() {
> }
>
> -
> /**
> * Set whether scheduler is being used
> *
> @@ -102,10 +102,6 @@ public class ThreadGroup extends Abstrac
> setProperty(new BooleanProperty(SCHEDULER, Scheduler));
> }
>
> - private boolean isDelayedStartup() {
> - return getPropertyAsBoolean(DELAYED_START);
> - }
> -
> /**
> * Get whether scheduler is being used
> *
> @@ -210,6 +206,10 @@ public class ThreadGroup extends Abstrac
> return getPropertyAsInt(ThreadGroup.RAMP_TIME);
> }
>
> + private boolean isDelayedStartup() {
> + return getPropertyAsBoolean(DELAYED_START);
> + }
> +
> @Override
> public void scheduleThread(JMeterThread thread)
> {
> @@ -262,24 +262,19 @@ public class ThreadGroup extends Abstrac
> /**
> * Wait for delay with RAMPUP_GRANULARITY
> * @param delay delay in ms
> - * @param type Delay type
> */
> - private void delayBy(long delay, String type) {
> + private void delayBy(long delay) {
> if (delay > 0) {
> long start = System.currentTimeMillis();
> long end = start + delay;
> long now=0;
> - long pause = RAMPUP_GRANULARITY;
> + long pause = RAMPUP_GRANULARITY; // maximum pause to use
> while(running && (now = System.currentTimeMillis()) < end) {
> long togo = end - now;
> if (togo < pause) {
> pause = togo;
> }
> - try {
> - Thread.sleep(pause); // delay between checks
> - } catch (InterruptedException e) {
> - break;
> - }
> + pause(pause); // delay between checks
> }
> }
> }
> @@ -487,6 +482,13 @@ public class ThreadGroup extends Abstrac
> }
> }
>
> + private void pause(long ms){
> + try {
> + Thread.sleep(ms);
> + } catch (InterruptedException e) {
> + }
> + }
> +
> /**
> * Starts Threads using ramp up
> */
> @@ -505,11 +507,11 @@ public class ThreadGroup extends Abstrac
> long now = System.currentTimeMillis();
> // set the start time for the Thread
> if (getDelay() > 0) {// Duration is in seconds
> - delayBy(getDelay() * 1000, "start");
> + delayBy(getDelay() * 1000);
> } else {
> long start = getStartTime();
> if (start >= now) {
> - delayBy(start-now, "start");
> + delayBy(start-now);
> }
> // else start immediately
> }
>
>
>
--
Cordialement.
Philippe Mouawad.