|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.performance.ClientThread
public abstract class ClientThread
Base for performance / load test clients.
The run method executes init, then setup-execute-cleanup in a loop,
gathering performance statistics, with time between executions based
on configuration parameters. See nextDelay() for details on
inter-arrival time computation.
Subclasses must implement execute, which
is the basic client request action that is executed, and timed,
repeatedly. If per-request setup is required, and you do not want the time
associated with this setup to be included in the reported timings, implement
setUp and put the setup code there. Similarly for
cleanUp. Initialization code that needs to be executed once
only, before any requests are initiated, should be put into
init.
| Field Summary | |
|---|---|
protected int |
cycleState
Cycle state |
protected java.lang.String |
cycleType
Cycle type |
protected java.lang.String |
delayType
Delay type - determines how next start times are computed |
protected long |
iterations
Number of iterations |
protected double |
lastMean
Last mean delay |
protected java.util.logging.Logger |
logger
Logger shared by client threads |
protected long |
maxDelay
Maxiimum mean time between requests |
protected long |
minDelay
Minimum mean time between requests |
protected static int |
PEAK_LOAD
|
protected long |
peakPeriod
Peak length for cyclic mean delay |
protected long |
periodStart
Start time of current period |
protected static int |
RAMPING_DOWN
|
protected static int |
RAMPING_UP
Cycle state constants |
protected long |
rampPeriod
Ramp length for cyclic mean delay |
protected java.lang.String |
rampType
Ramp type |
protected org.apache.commons.math.random.RandomData |
randomData
Random data generator |
protected double |
sigma
Standard deviation of delay distribution |
protected long |
startTime
Start time of run |
protected Statistics |
stats
Statistics container |
protected static int |
TROUGH_LOAD
|
protected long |
troughPeriod
Trough length for cyclic mean delay |
| Constructor Summary | |
|---|---|
ClientThread(long iterations,
long minDelay,
long maxDelay,
double sigma,
java.lang.String delayType,
long rampPeriod,
long peakPeriod,
long troughPeriod,
java.lang.String cycleType,
java.lang.String rampType,
java.util.logging.Logger logger,
Statistics stats)
Create a client thread. |
|
| Method Summary | |
|---|---|
protected void |
adjustState(long currentTime)
Adjusts cycleState, periodStart and lastMean if a cycle state transition needs to happen. |
protected void |
cleanUp()
Executed in finally block of iteration try-catch |
protected double |
computeCyclicDelay(long currentTime,
double min,
double max)
|
abstract void |
execute()
Core iteration code. |
protected void |
finalize()
Executed once after the run finishes |
protected void |
init()
Executed once at the beginning of the run |
protected long |
nextDelay()
Computes the next interarrival time (time to wait between requests) based on configured values for min/max delay, delay type, cycle type, ramp type and period. |
void |
run()
|
protected void |
setUp()
Executed at the beginning of each iteration |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected long minDelay
protected long maxDelay
protected double sigma
protected java.lang.String delayType
protected long rampPeriod
protected long peakPeriod
protected long troughPeriod
protected java.lang.String cycleType
protected java.lang.String rampType
protected long iterations
protected long startTime
protected long periodStart
protected double lastMean
protected static final int RAMPING_UP
protected static final int RAMPING_DOWN
protected static final int PEAK_LOAD
protected static final int TROUGH_LOAD
protected int cycleState
protected org.apache.commons.math.random.RandomData randomData
protected Statistics stats
protected java.util.logging.Logger logger
| Constructor Detail |
|---|
public ClientThread(long iterations,
long minDelay,
long maxDelay,
double sigma,
java.lang.String delayType,
long rampPeriod,
long peakPeriod,
long troughPeriod,
java.lang.String cycleType,
java.lang.String rampType,
java.util.logging.Logger logger,
Statistics stats)
iterations - number of iterationsminDelay - minumum mean time between client requestsmaxDelay - maximum mean time between client requestsdelayType - distribution of time between client requestsrampPeriod - ramp period of cycle for cyclic loadpeakOeriod - peak period of cycle for cyclic loadtroughPeriod - trough period of cycle for cyclic loadcycleType - type of cycle for mean delayrampType - type of ramp (linear or random jumps)logger - common logger shared by all clientsstatsList - List of SummaryStatistics to add results to| Method Detail |
|---|
public void run()
run in interface java.lang.Runnable
protected void init()
throws java.lang.Exception
java.lang.Exception
protected void setUp()
throws java.lang.Exception
java.lang.Exception
protected void cleanUp()
throws java.lang.Exception
java.lang.Exception
protected void finalize()
throws java.lang.Exception
finalize in class java.lang.Objectjava.lang.Exception
public abstract void execute()
throws java.lang.Exception
java.lang.Exception
protected long nextDelay()
throws ConfigurationException
Computes the next interarrival time (time to wait between requests)
based on configured values for min/max delay, delay type, cycle type,
ramp type and period. Currently supports constant (always returning
minDelay delay time), Poisson and Gaussian distributed
random time delays, linear and random ramps, and oscillating /
non-oscillating cycle types.
loadType determines whether returned times are
deterministic or random. If loadType is not "constant",
a random value with the specified distribution and mean determined by
the other parameters is returned. For "gaussian" loadType,
sigma is used as used as the standard deviation.
cycleType determines how the returned times vary
over time. "oscillating", means times ramp up and down between
minDelay and maxDelay. Ramp type is controlled
by rampType. Linear rampType means the means
increase or decrease linearly over the time of the period. Random
makes random jumps up or down toward the next peak or trough. "None" for
rampType under oscillating cycleType makes the
means alternate between peak (minDelay) and trough
(maxDelay) with no ramp between.
Oscillating loads cycle through RAMPING_UP, PEAK_LOAD, RAMPING_DOWN
and TROUGH_LOAD states, with the amount of time spent in each state
determined by rampPeriod (time spent increasing on the way
up and decreasing on the way down), peakPeriod (time spent
at peak load, i.e., minDelay mean delay) and
troughPeriod (time spent at minimum load, i.e.,
maxDelay mean delay). All times are specified in
milliseconds.
Examples:
delayType = "constant" minDelay = 250 maxDelay = 500 cycleType = "oscillating" rampType = "linear" rampPeriod = 10000 peakPeriod = 20000 troughPeriod = 30000load will start at one request every 500 ms, which is "trough load." Load then ramps up linearly over the next 10 seconds unil it reaches one request per 250 milliseconds, which is "peak load." Peak load is sustained for 20 seconds and then load ramps back down, again taking 10 seconds to get down to "trough load," which is sustained for 30 seconds. The cycle then repeats.
delayType = "gaussian" minDelay = 250 maxDelay = 500 cycleType = "oscillating" rampType = "linear" rampPeriod = 10000 peakPeriod = 20000 troughPeriod = 30000 sigma = 100produces a load pattern similar to example 1, but in this case the computed delay value is fed into a gaussian random number generator as the mean and 100 as the standard deviation - i.e.,
nextDelay returns random, gaussian distributed values with
means moving according to the cyclic pattern in example 1.delayType = "constant" minDelay = 250 maxDelay = 500 cycleType = "none" rampType = "linear" rampPeriod = 10000produces a load pattern that increases linearly from one request every 500ms to one request every 250ms and then stays constant at that level until the run is over. Other parameters are ignored in this case.
delayType = "poisson" minDelay = 250 maxDelay = 500 cycleType = "none" rampType = "none"produces inter-arrival times that are poisson distributed with mean 250ms. Note that when rampType is "none," the value of
minDelay is used as the (constant) mean delay.
ConfigurationExceptionprotected void adjustState(long currentTime)
currentTime - current time
protected double computeCyclicDelay(long currentTime,
double min,
double max)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||