org.jminor.common.model
Class LoadTestModel<T>

java.lang.Object
  extended by org.jminor.common.model.LoadTestModel<T>
Type Parameters:
T - the type of the applications this load test uses
All Implemented Interfaces:
LoadTest
Direct Known Subclasses:
EntityLoadTestModel, QueryLoadTestModel

public abstract class LoadTestModel<T>
extends Object
implements LoadTest

A default LoadTest implementation.


Nested Class Summary
static class LoadTestModel.AbstractUsageScenario<T>
          An abstract usage scenario.
 
Nested classes/interfaces inherited from interface org.jminor.common.model.LoadTest
LoadTest.ScenarioException, LoadTest.UsageScenario<T>
 
Field Summary
static int DEFAULT_CHART_DATA_UPDATE_INTERVAL_MS
           
static int DEFAULT_WARNING_TIME_MS
           
protected static org.slf4j.Logger LOG
           
protected static Random RANDOM
           
 
Constructor Summary
LoadTestModel(User user, Collection<? extends LoadTest.UsageScenario<T>> usageScenarios, int maximumThinkTime, int loginDelayFactor, int applicationBatchSize)
          Constructs a new LoadTestModel.
LoadTestModel(User user, Collection<? extends LoadTest.UsageScenario<T>> usageScenarios, int maximumThinkTime, int loginDelayFactor, int applicationBatchSize, int warningTime)
          Constructs a new LoadTestModel.
LoadTestModel(User user, int maximumThinkTime, int loginDelayFactor, int applicationBatchSize)
          Constructs a new LoadTestModel.
LoadTestModel(User user, int maximumThinkTime, int loginDelayFactor, int applicationBatchSize, int warningTime)
          Constructs a new LoadTestModel.
 
Method Summary
 void addApplicationBatch()
          Adds a batch of applications.
protected  void addExitListener(ActionListener listener)
           
 EventObserver applicationBatchSizeObserver()
          
 EventObserver applicationCountObserver()
          
 EventObserver collectChartDataObserver()
          
protected abstract  void disconnectApplication(T application)
           
 void exit()
          Removes all applications and exits
 int getApplicationBatchSize()
          
 int getApplicationCount()
          
 int getLoginDelayFactor()
          Sets the with which to multiply the think time when logging in, this helps spread the application logins when creating a batch of application.
 int getMaximumThinkTime()
          
 org.jfree.data.xy.XYSeriesCollection getMemoryUsageDataset()
          
 int getMinimumThinkTime()
          
 EventObserver getMinimumThinkTimeObserver()
          
 org.jfree.data.xy.XYSeriesCollection getNumberOfApplicationsDataset()
          
 EventObserver getPauseObserver()
          
 ItemRandomizer<LoadTest.UsageScenario> getScenarioChooser()
          
 org.jfree.data.xy.YIntervalSeriesCollection getScenarioDurationDataset(String name)
          
protected  int getThinkTime()
           
 org.jfree.data.xy.XYSeriesCollection getThinkTimeDataset()
          
 int getUpdateInterval()
          
 LoadTest.UsageScenario<T> getUsageScenario(String usageScenarioName)
          
 org.jfree.data.xy.XYSeriesCollection getUsageScenarioDataset()
          
 org.jfree.data.xy.XYSeriesCollection getUsageScenarioFailureDataset()
          
 Collection<String> getUsageScenarios()
          
 User getUser()
          
 int getWarningTime()
          
 EventObserver getWarningTimeObserver()
          
protected abstract  T initializeApplication()
           
 boolean isCollectChartData()
          
 boolean isPaused()
          
 boolean isScenarioEnabled(String scenarioName)
          
 EventObserver maximumThinkTimeObserver()
          
 void removeApplicationBatch()
          Removes one batch of applications.
 void resetChartData()
          Resets the accumulated chart data
protected  void runScenario(String usageScenarioName, T application)
          Runs the scenario with the given name on the given application
 void setApplicationBatchSize(int applicationBatchSize)
          
 void setCollectChartData(boolean value)
          
 void setLoginDelayFactor(int loginDelayFactor)
          Sets the with which to multiply the think time when logging in, this helps spread the application logins when creating a batch of application.
 void setMaximumThinkTime(int maximumThinkTime)
          
 void setMinimumThinkTime(int minimumThinkTime)
          
 void setPaused(boolean value)
          
 void setScenarioEnabled(String scenarioName, boolean value)
          
 void setUpdateInterval(int updateInterval)
          
 void setUser(User user)
          
 void setWarningTime(int warningTime)
          
 void setWeight(String scenarioName, int weight)
          Sets the random chooser weight for the given scenario
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHART_DATA_UPDATE_INTERVAL_MS

public static final int DEFAULT_CHART_DATA_UPDATE_INTERVAL_MS
See Also:
Constant Field Values

DEFAULT_WARNING_TIME_MS

public static final int DEFAULT_WARNING_TIME_MS
See Also:
Constant Field Values

LOG

protected static final org.slf4j.Logger LOG

RANDOM

protected static final Random RANDOM
Constructor Detail

LoadTestModel

public LoadTestModel(User user,
                     int maximumThinkTime,
                     int loginDelayFactor,
                     int applicationBatchSize)
Constructs a new LoadTestModel.

Parameters:
user - the default user to use when initializing applications
maximumThinkTime - the maximum think time, by default the minimum think time is max / 2
loginDelayFactor - the value with which to multiply the think time when delaying login
applicationBatchSize - the number of applications to add in a batch

LoadTestModel

public LoadTestModel(User user,
                     int maximumThinkTime,
                     int loginDelayFactor,
                     int applicationBatchSize,
                     int warningTime)
Constructs a new LoadTestModel.

Parameters:
user - the default user to use when initializing applications
maximumThinkTime - the maximum think time, by default the minimum think time is max / 2
loginDelayFactor - the value with which to multiply the think time when delaying login
applicationBatchSize - the number of applications to add in a batch
warningTime - a work request is considered 'delayed' if the time it takes to process it exceeds this value (ms)

LoadTestModel

public LoadTestModel(User user,
                     Collection<? extends LoadTest.UsageScenario<T>> usageScenarios,
                     int maximumThinkTime,
                     int loginDelayFactor,
                     int applicationBatchSize)
Constructs a new LoadTestModel.

Parameters:
user - the default user to use when initializing applications
usageScenarios - the usage scenarios to use
maximumThinkTime - the maximum think time, by default the minimum think time is max / 2
loginDelayFactor - the value with which to multiply the think time when delaying login
applicationBatchSize - the number of applications to add in a batch

LoadTestModel

public LoadTestModel(User user,
                     Collection<? extends LoadTest.UsageScenario<T>> usageScenarios,
                     int maximumThinkTime,
                     int loginDelayFactor,
                     int applicationBatchSize,
                     int warningTime)
Constructs a new LoadTestModel.

Parameters:
user - the default user to use when initializing applications
usageScenarios - the usage scenarios to use
maximumThinkTime - the maximum think time, by default the minimum think time is max / 2
loginDelayFactor - the value with which to multiply the think time when delaying login
applicationBatchSize - the number of applications to add in a batch
warningTime - a work request is considered 'delayed' if the time it takes to process it exceeds this value (ms)
Method Detail

getUser

public final User getUser()

Specified by:
getUser in interface LoadTest
Returns:
the user to use when initializing new application instances

setUser

public final void setUser(User user)

Specified by:
setUser in interface LoadTest
Parameters:
user - the user to use when initializing new application instances

getUsageScenario

public final LoadTest.UsageScenario<T> getUsageScenario(String usageScenarioName)

Specified by:
getUsageScenario in interface LoadTest
Parameters:
usageScenarioName - the scenario name
Returns:
the usage scenario

getUsageScenarios

public final Collection<String> getUsageScenarios()

Specified by:
getUsageScenarios in interface LoadTest
Returns:
the usage scenarios used by this load test;

setWeight

public final void setWeight(String scenarioName,
                            int weight)
Sets the random chooser weight for the given scenario

Specified by:
setWeight in interface LoadTest
Parameters:
scenarioName - the name of the scenario
weight - the new weight to assign to the scenario

isScenarioEnabled

public final boolean isScenarioEnabled(String scenarioName)

Specified by:
isScenarioEnabled in interface LoadTest
Parameters:
scenarioName - the scenario name
Returns:
true if the scenario is enabled

setScenarioEnabled

public final void setScenarioEnabled(String scenarioName,
                                     boolean value)

Specified by:
setScenarioEnabled in interface LoadTest
Parameters:
scenarioName - the scenario name
value - true if the scenario should be enabled

getScenarioChooser

public final ItemRandomizer<LoadTest.UsageScenario> getScenarioChooser()

Specified by:
getScenarioChooser in interface LoadTest
Returns:
the randomizer used to select scenarios

getScenarioDurationDataset

public final org.jfree.data.xy.YIntervalSeriesCollection getScenarioDurationDataset(String name)

Specified by:
getScenarioDurationDataset in interface LoadTest
Parameters:
name -
Returns:
a dataset plotting the average scenario duration

getThinkTimeDataset

public final org.jfree.data.xy.XYSeriesCollection getThinkTimeDataset()

Specified by:
getThinkTimeDataset in interface LoadTest
Returns:
a dataset plotting the think time

getNumberOfApplicationsDataset

public final org.jfree.data.xy.XYSeriesCollection getNumberOfApplicationsDataset()

Specified by:
getNumberOfApplicationsDataset in interface LoadTest
Returns:
a dataset plotting the number of active applications

getUsageScenarioDataset

public final org.jfree.data.xy.XYSeriesCollection getUsageScenarioDataset()

Specified by:
getUsageScenarioDataset in interface LoadTest
Returns:
a dataset plotting the number of runs each usage scenario is being run per second

getUsageScenarioFailureDataset

public final org.jfree.data.xy.XYSeriesCollection getUsageScenarioFailureDataset()

Specified by:
getUsageScenarioFailureDataset in interface LoadTest
Returns:
a dataset plotting the failure rate of each usage scenario

getMemoryUsageDataset

public final org.jfree.data.xy.XYSeriesCollection getMemoryUsageDataset()

Specified by:
getMemoryUsageDataset in interface LoadTest
Returns:
a dataset plotting the memory usage of this load test model

resetChartData

public final void resetChartData()
Resets the accumulated chart data

Specified by:
resetChartData in interface LoadTest

getWarningTime

public final int getWarningTime()

Specified by:
getWarningTime in interface LoadTest
Returns:
the the maximum time in milliseconds a work request has to finish

setWarningTime

public final void setWarningTime(int warningTime)

Specified by:
setWarningTime in interface LoadTest
Parameters:
warningTime - the the maximum time in milliseconds a work request has to finish

getUpdateInterval

public final int getUpdateInterval()

Specified by:
getUpdateInterval in interface LoadTest
Returns:
the chart data update interval

setUpdateInterval

public final void setUpdateInterval(int updateInterval)

Specified by:
setUpdateInterval in interface LoadTest
Parameters:
updateInterval - the chart data update interval

getApplicationCount

public final int getApplicationCount()

Specified by:
getApplicationCount in interface LoadTest
Returns:
the number of active applications

getApplicationBatchSize

public final int getApplicationBatchSize()

Specified by:
getApplicationBatchSize in interface LoadTest
Returns:
the number of applications to initialize per batch

setApplicationBatchSize

public final void setApplicationBatchSize(int applicationBatchSize)

Specified by:
setApplicationBatchSize in interface LoadTest
Parameters:
applicationBatchSize - the number of applications to initialize per batch

addApplicationBatch

public final void addApplicationBatch()
Adds a batch of applications.

Specified by:
addApplicationBatch in interface LoadTest
See Also:
LoadTest.setApplicationBatchSize(int)

removeApplicationBatch

public final void removeApplicationBatch()
Removes one batch of applications.

Specified by:
removeApplicationBatch in interface LoadTest
See Also:
LoadTest.setApplicationBatchSize(int)

isPaused

public final boolean isPaused()

Specified by:
isPaused in interface LoadTest
Returns:
true if the load testing is paused

setPaused

public final void setPaused(boolean value)

Specified by:
setPaused in interface LoadTest
Parameters:
value - true if load testing should be paused

isCollectChartData

public final boolean isCollectChartData()

Specified by:
isCollectChartData in interface LoadTest
Returns:
true if chart data is being collected

setCollectChartData

public final void setCollectChartData(boolean value)

Specified by:
setCollectChartData in interface LoadTest
Parameters:
value - true if chart data should be collected

exit

public final void exit()
Removes all applications and exits

Specified by:
exit in interface LoadTest

getMaximumThinkTime

public final int getMaximumThinkTime()

Specified by:
getMaximumThinkTime in interface LoadTest
Returns:
the maximum number of milliseconds that should pass between work requests

setMaximumThinkTime

public final void setMaximumThinkTime(int maximumThinkTime)

Specified by:
setMaximumThinkTime in interface LoadTest
Parameters:
maximumThinkTime - the maximum number of milliseconds that should pass between work requests

getMinimumThinkTime

public final int getMinimumThinkTime()

Specified by:
getMinimumThinkTime in interface LoadTest
Returns:
the minimum number of milliseconds that should pass between work requests

setMinimumThinkTime

public final void setMinimumThinkTime(int minimumThinkTime)

Specified by:
setMinimumThinkTime in interface LoadTest
Parameters:
minimumThinkTime - the minimum number of milliseconds that should pass between work requests

getLoginDelayFactor

public final int getLoginDelayFactor()
Sets the with which to multiply the think time when logging in, this helps spread the application logins when creating a batch of application.

Specified by:
getLoginDelayFactor in interface LoadTest
Returns:
the number with which to multiply the think time when logging in

setLoginDelayFactor

public final void setLoginDelayFactor(int loginDelayFactor)
Sets the with which to multiply the think time when logging in, this helps spread the application logins when creating a batch of application.

Specified by:
setLoginDelayFactor in interface LoadTest
Parameters:
loginDelayFactor - the number with which to multiply the think time when logging in

applicationBatchSizeObserver

public final EventObserver applicationBatchSizeObserver()

Specified by:
applicationBatchSizeObserver in interface LoadTest
Returns:
an observer notified each time the application batch size changes

applicationCountObserver

public final EventObserver applicationCountObserver()

Specified by:
applicationCountObserver in interface LoadTest
Returns:
an observer notified each time the application count changes

maximumThinkTimeObserver

public final EventObserver maximumThinkTimeObserver()

Specified by:
maximumThinkTimeObserver in interface LoadTest
Returns:
an observer notified each time the maximum think time changes

getMinimumThinkTimeObserver

public final EventObserver getMinimumThinkTimeObserver()

Specified by:
getMinimumThinkTimeObserver in interface LoadTest
Returns:
an observer notified each time the minimum think time changes

getPauseObserver

public final EventObserver getPauseObserver()

Specified by:
getPauseObserver in interface LoadTest
Returns:
an observer notified each time the paused state changes

collectChartDataObserver

public final EventObserver collectChartDataObserver()

Specified by:
collectChartDataObserver in interface LoadTest
Returns:
an observer notified each time the collect chart data state changes

getWarningTimeObserver

public final EventObserver getWarningTimeObserver()

Specified by:
getWarningTimeObserver in interface LoadTest
Returns:
an observer notified each time the warning time changes

runScenario

protected final void runScenario(String usageScenarioName,
                                 T application)
                          throws LoadTest.ScenarioException
Runs the scenario with the given name on the given application

Parameters:
usageScenarioName - the name of the scenario to run
application - the application to use
Throws:
ScenarioException - in case of an exception
LoadTest.ScenarioException

addExitListener

protected void addExitListener(ActionListener listener)
Parameters:
listener - a listener notified when this load test model has finished removing all applications

initializeApplication

protected abstract T initializeApplication()
                                    throws CancelException
Returns:
an initialized application.
Throws:
CancelException - in case the initialization was cancelled

disconnectApplication

protected abstract void disconnectApplication(T application)
Parameters:
application - the application to disconnect

getThinkTime

protected final int getThinkTime()
Returns:
a random think time in milliseconds based on the values of minimumThinkTime and maximumThinkTime
See Also:
setMinimumThinkTime(int), setMaximumThinkTime(int)