|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.performance.LoadGenerator
public abstract class LoadGenerator
Base class for load / peformance test runners.
Uses Commons Digester to parse and load configuration and spawns
ClientThread
instances to generate load and gather statistics.
Subclasses must
implement makeClientThread
to
create client thread instances to be kicked off by execute.
Subclasses will also in general override configure
to load
additional configuration parameters and pass them on to the client in
makeClientThread.
Implementations of configure
should start with a super()
call so that the base configuration
parameters are loaded. This method should also set the configFile
property to a valid URI or filespec (suitable argument for Digester's parse
method). Setup code that needs to be executed before any client threads are
spawned should be put in init
See
DBCPSoak and its
sample configuration file for an example. As in that example, additional
sections of the config file should be parsed and loaded in the overridden
configure
method. The "run" section is required by the base
implementation. That example also illustrates how init
can be used to set up resources or data structures required by the client
threads.
Field Summary | |
---|---|
protected String |
configFile
|
protected String |
cycleType
|
protected String |
delayType
|
protected org.apache.commons.digester.Digester |
digester
|
protected static Logger |
logger
logger |
protected long |
maxDelay
|
protected long |
minDelay
|
protected long |
peakPeriod
|
protected long |
rampPeriod
|
protected String |
rampType
|
protected double |
sigma
|
protected long |
troughPeriod
|
Constructor Summary | |
---|---|
LoadGenerator()
|
Method Summary | |
---|---|
protected void |
cleanUp()
This method is invoked by execute() after all spawned threads
have terminated. |
protected void |
configure()
Starts preparing Digester to parse the configuration file, pushing *this onto the stack and loading rules to configure basic "run" parameters. |
void |
configureRun(String iterations,
String clients,
String minDelay,
String maxDelay,
String sigma,
String delayType,
String rampType,
String rampPeriod,
String peakPeriod,
String troughPeriod,
String cycleType)
Configures basic run parameters. |
void |
execute()
Invokes configure() to load digester rules, then digster.parse,
then init() to initialize configuration members. |
String |
getConfigFile()
|
org.apache.commons.digester.Digester |
getDigester()
|
Statistics |
getStatistics()
|
protected void |
init()
This method is invoked by execute() after configure()
and digester parse, just before client threads are created. |
protected abstract ClientThread |
makeClientThread(long iterations,
long minDelay,
long maxDelay,
double sigma,
String delayType,
long rampPeriod,
long peakPeriod,
long troughPeriod,
String cycleType,
String rampType,
Logger logger,
Statistics stats)
|
protected void |
parseConfigFile()
|
void |
setConfigFile(String configFile)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Logger logger
protected long minDelay
protected long maxDelay
protected double sigma
protected String delayType
protected String rampType
protected long rampPeriod
protected long peakPeriod
protected long troughPeriod
protected String cycleType
protected org.apache.commons.digester.Digester digester
protected String configFile
Constructor Detail |
---|
public LoadGenerator()
Method Detail |
---|
public void execute() throws Exception
Invokes configure()
to load digester rules, then digster.parse,
then init()
to initialize configuration members. Then spawns and
executes numClients
ClientThreads using makeClientThread(long, long, long, double, java.lang.String, long, long, long, java.lang.String, java.lang.String, java.util.logging.Logger, org.apache.commons.performance.Statistics)
to create the ClientThread instances. Waits for all spawned threads to
terminate and then logs accumulated statistics, using
Statistics.displayOverallSummary()
Subclasses should not need to override this method, but must implement
makeClientThread(long, long, long, double, java.lang.String, long, long, long, java.lang.String, java.lang.String, java.util.logging.Logger, org.apache.commons.performance.Statistics)
and may override configure()
and
init()
to prepare data to pass to makeClientThread
,
and cleanUp()
to clean up after all threads terminate.
Exception
protected abstract ClientThread makeClientThread(long iterations, long minDelay, long maxDelay, double sigma, String delayType, long rampPeriod, long peakPeriod, long troughPeriod, String cycleType, String rampType, Logger logger, Statistics stats)
protected void init() throws Exception
execute()
after configure()
and digester parse, just before client threads are created. Objects that
need to be created and passed to client threads using configuration info
parsed from the config file should be created in this method.
Exception
protected void cleanUp() throws Exception
execute()
after all spawned threads
have terminated. Override to clean up any resources allocated in
init()
.
Exception
public void configureRun(String iterations, String clients, String minDelay, String maxDelay, String sigma, String delayType, String rampType, String rampPeriod, String peakPeriod, String troughPeriod, String cycleType) throws ConfigurationException
configure()
.
iterations
- number of iterationsclients
- number of client threadsminDelay
- minimum delay between client thread requests (ms)maxDelay
- maximum delay between client thread requests (ms)sigma
- standard deviation of delaydelayType
- type of delay (constant, gaussian, poisson)rampType
- type of ramp (none, linear, random)rampPeriod
- rampup/rampdown timepeakPeriod
- peak periodtroughPeriod
- trough periodcycleType
- cycle type (none, oscillating)
ConfigurationException
protected void configure() throws Exception
Starts preparing Digester to parse the configuration file, pushing *this onto the stack and loading rules to configure basic "run" parameters.
Subclasses can override this, using super()
to load base
parameters and then adding additional addCallMethod
sequences for additional parameters.
Exception
protected void parseConfigFile() throws Exception
Exception
public String getConfigFile()
public void setConfigFile(String configFile)
configFile
- the configFile to setpublic org.apache.commons.digester.Digester getDigester()
public Statistics getStatistics()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |