org.apache.commons.performance
Class LoadGenerator

java.lang.Object
  extended by org.apache.commons.performance.LoadGenerator
Direct Known Subclasses:
DBCPSoak, HttpSoak, PoolSoak

public abstract class LoadGenerator
extends java.lang.Object

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. Sublasses 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  java.lang.String configFile
           
protected  java.lang.String cycleType
           
protected  java.lang.String delayType
           
protected  org.apache.commons.digester.Digester digester
           
protected static java.util.logging.Logger logger
          logger
protected  long maxDelay
           
protected  long minDelay
           
protected  long peakPeriod
           
protected  long rampPeriod
           
protected  java.lang.String rampType
           
protected  double sigma
           
protected  long troughPeriod
           
 
Constructor Summary
LoadGenerator()
           
 
Method Summary
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(java.lang.String iterations, java.lang.String clients, java.lang.String minDelay, java.lang.String maxDelay, java.lang.String sigma, java.lang.String delayType, java.lang.String rampType, java.lang.String rampPeriod, java.lang.String peakPeriod, java.lang.String troughPeriod, java.lang.String cycleType)
           
 void execute()
          Invokes configure() to load digester rules, then digster.parse, then init() to initialize configuration members.
 java.lang.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, 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)
           
protected  void parseConfigFile()
           
 void setConfigFile(java.lang.String configFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final java.util.logging.Logger logger
logger


minDelay

protected long minDelay

maxDelay

protected long maxDelay

sigma

protected double sigma

delayType

protected java.lang.String delayType

rampType

protected java.lang.String rampType

rampPeriod

protected long rampPeriod

peakPeriod

protected long peakPeriod

troughPeriod

protected long troughPeriod

cycleType

protected java.lang.String cycleType

digester

protected org.apache.commons.digester.Digester digester

configFile

protected java.lang.String configFile
Constructor Detail

LoadGenerator

public LoadGenerator()
Method Detail

execute

public void execute()
             throws java.lang.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.

Subclasses should not need to override this method, but must implement makeClientThread and may override configure and init to prepare data to pass to makeClientThread.

Throws:
java.lang.Exception

makeClientThread

protected abstract ClientThread makeClientThread(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)

init

protected void init()
             throws java.lang.Exception
This method is invoked by 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.

Throws:
java.lang.Exception

configureRun

public void configureRun(java.lang.String iterations,
                         java.lang.String clients,
                         java.lang.String minDelay,
                         java.lang.String maxDelay,
                         java.lang.String sigma,
                         java.lang.String delayType,
                         java.lang.String rampType,
                         java.lang.String rampPeriod,
                         java.lang.String peakPeriod,
                         java.lang.String troughPeriod,
                         java.lang.String cycleType)
                  throws ConfigurationException
Throws:
ConfigurationException

configure

protected void configure()
                  throws java.lang.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.

Throws:
java.lang.Exception

parseConfigFile

protected void parseConfigFile()
                        throws java.lang.Exception
Throws:
java.lang.Exception

getConfigFile

public java.lang.String getConfigFile()
Returns:
the configFile

setConfigFile

public void setConfigFile(java.lang.String configFile)
Parameters:
configFile - the configFile to set

getDigester

public org.apache.commons.digester.Digester getDigester()
Returns:
the digester

getStatistics

public Statistics getStatistics()
Returns:
statistics


Copyright © 2007-2008 The Apache Software Foundation. All Rights Reserved.