net.grinder.console.model
Class SampleModelImplementation

java.lang.Object
  extended by net.grinder.console.model.SampleModelImplementation
All Implemented Interfaces:
SampleModel

public final class SampleModelImplementation
extends Object
implements SampleModel

Collate test reports into samples and distribute to listeners.

When notifying listeners of changes to the number of tests we send copies of the new index arrays. This helps because most listeners are Swing dispatched and so can't guarantee the model is in a reasonable state when they call back.

Author:
Philip Aston

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.grinder.console.model.SampleModel
SampleModel.AbstractListener, SampleModel.Listener, SampleModel.State
 
Constructor Summary
SampleModelImplementation(ConsoleProperties properties, StatisticsServices statisticsServices, Timer timer, Resources resources, ErrorHandler errorHandler)
          Creates a new SampleModelImplementation instance.
 
Method Summary
 void addModelListener(SampleModel.Listener listener)
          Add a new model listener.
 void addSampleListener(Test test, SampleListener listener)
          Add a new sample listener for the specific test.
 void addTestReport(TestStatisticsMap testStatisticsMap)
          Add a new test report.
 void addTotalSampleListener(SampleListener listener)
          Add a new total sample listener.
 StatisticExpression getPeakTPSExpression()
          Get the expression for peak TPS.
 SampleModel.State getState()
          Get the current model state.
 StatisticsSet getTotalCumulativeStatistics()
          Get the cumulative statistics for this model.
 StatisticsSet getTotalLatestStatistics()
          Get the total statistics for the latest sample.
 StatisticExpression getTPSExpression()
          Get the statistics expression for TPS.
 void registerTests(Collection<Test> tests)
          Register new tests.
 void reset()
          Discard all of the information held by the model.
 void start()
          Start the model.
 void stop()
          Stop the model.
 void zeroStatistics()
          Zero the statistics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleModelImplementation

public SampleModelImplementation(ConsoleProperties properties,
                                 StatisticsServices statisticsServices,
                                 Timer timer,
                                 Resources resources,
                                 ErrorHandler errorHandler)
                          throws GrinderException
Creates a new SampleModelImplementation instance.

Parameters:
properties - The console properties.
statisticsServices - Statistics services.
timer - A timer.
resources - Console resources.
errorHandler - Error handler
Throws:
GrinderException - if an error occurs
Method Detail

getTPSExpression

public StatisticExpression getTPSExpression()
Get the statistics expression for TPS.

Specified by:
getTPSExpression in interface SampleModel
Returns:
The TPS expression for this model.

getPeakTPSExpression

public StatisticExpression getPeakTPSExpression()
Get the expression for peak TPS.

Specified by:
getPeakTPSExpression in interface SampleModel
Returns:
The peak TPS expression for this model.

registerTests

public void registerTests(Collection<Test> tests)
Register new tests.

Specified by:
registerTests in interface SampleModel
Parameters:
tests - The new tests.

getTotalCumulativeStatistics

public StatisticsSet getTotalCumulativeStatistics()
Get the cumulative statistics for this model.

Specified by:
getTotalCumulativeStatistics in interface SampleModel
Returns:
The cumulative statistics.

getTotalLatestStatistics

public StatisticsSet getTotalLatestStatistics()
Get the total statistics for the latest sample.

Specified by:
getTotalLatestStatistics in interface SampleModel
Returns:
The cumulative statistics.

addModelListener

public void addModelListener(SampleModel.Listener listener)
Add a new model listener.

Specified by:
addModelListener in interface SampleModel
Parameters:
listener - The listener.

addSampleListener

public void addSampleListener(Test test,
                              SampleListener listener)
Add a new sample listener for the specific test.

Specified by:
addSampleListener in interface SampleModel
Parameters:
test - The test to add the sample listener for.
listener - The sample listener.

addTotalSampleListener

public void addTotalSampleListener(SampleListener listener)
Add a new total sample listener.

Specified by:
addTotalSampleListener in interface SampleModel
Parameters:
listener - The sample listener.

reset

public void reset()
Discard all of the information held by the model.

This doesn't change the model state.

Specified by:
reset in interface SampleModel

zeroStatistics

public void zeroStatistics()
Zero the statistics.

Specified by:
zeroStatistics in interface SampleModel

start

public void start()
Start the model.

Specified by:
start in interface SampleModel

stop

public void stop()
Stop the model.

Specified by:
stop in interface SampleModel

addTestReport

public void addTestReport(TestStatisticsMap testStatisticsMap)
Add a new test report.

Specified by:
addTestReport in interface SampleModel
Parameters:
testStatisticsMap - The new test statistics.

getState

public SampleModel.State getState()
Get the current model state.

Specified by:
getState in interface SampleModel
Returns:
The model state.


Copyright © 2000-2013. All Rights Reserved.