Class Calculator
- java.lang.Object
-
- org.palladiosimulator.metricspec.metricentity.MetricEntity
-
- org.palladiosimulator.measurementframework.listener.MeasurementSource
-
- org.palladiosimulator.probeframework.calculator.Calculator
-
- All Implemented Interfaces:
org.palladiosimulator.commons.designpatterns.IAbstractObservable<org.palladiosimulator.measurementframework.listener.IMeasurementSourceListener>
,org.palladiosimulator.metricspec.metricentity.IMetricEntity
,IProbeListener
- Direct Known Subclasses:
TimeSpanCalculator
,UnaryCalculator
public abstract class Calculator extends org.palladiosimulator.measurementframework.listener.MeasurementSource implements IProbeListener
This class is the abstract super class for all calculator implementations. All specific calculators have to inherit from this class.
Because calculators have to observe probes, they implement the IProbeListener interface. They also inherit from MeasurementSource, thus, making them to observable objects on their own. For instance, they can provide newly calculated measurements to recorders (recorders implement the IMeasurementSourceListener interface).
Furthermore, calculators expect a list of probes to be measured before they can do their calculation. For example, a response time calculator needs a measurement series of two probe measurements (one for start time and one for end time of an operation call). For this measurement series, calculators maintain a memory to store measurements of the observed probes. As soon as the last sample arrives, calculators start their calculation by invoking the template method
calculate(List)
.When a sample originating from the first probe arrives (after a measurement series has started and before it ended with the last probe), an exception is thrown because the first series of measurements has to be finished first.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Calculator(org.palladiosimulator.metricspec.MetricDescription computedMetric, org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint, List<Probe> childProbes)
Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract org.palladiosimulator.measurementframework.MeasuringValue
calculate(List<ProbeMeasurement> probeMeasurements)
Calculates a measurement based on a given set of probe measurements.boolean
equals(Object obj)
org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint
getMeasuringPoint()
Returns the measuring point serving as the source of measurements.int
hashCode()
void
newProbeMeasurementAvailable(ProbeMeasurement probeMeasurement)
Call-back method to be informed about new probe measurements.void
preUnregister()
This method informs calculators before they are unregistered in the calculator factory.-
Methods inherited from class org.palladiosimulator.measurementframework.listener.MeasurementSource
addObserver, getMeasurementSourceListeners, notifyMeasurementSourceListener, removeObserver
-
-
-
-
Constructor Detail
-
Calculator
protected Calculator(org.palladiosimulator.metricspec.MetricDescription computedMetric, org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint measuringPoint, List<Probe> childProbes)
Default constructor. Creates the observed list of probes and initializes the measurement memory.- Parameters:
computedMetric
- Metric calculated by this calculator.measuringPoint
- The measuring point serving as the source of measurements.childProbes
- List of probes.
-
-
Method Detail
-
calculate
protected abstract org.palladiosimulator.measurementframework.MeasuringValue calculate(List<ProbeMeasurement> probeMeasurements) throws CalculatorException
Calculates a measurement based on a given set of probe measurements.- Parameters:
probeMeasurements
- Probe measurements conforming to the registered probes of this calculator.- Returns:
- AbstractMeasureProvider that conforms to the static declaration of the metric of this class of calculators.
- Throws:
CalculatorException
- In case something during the execution of the calculator went wrong.
-
getMeasuringPoint
public org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint getMeasuringPoint()
Returns the measuring point serving as the source of measurements.- Returns:
- The measuring point.
-
preUnregister
public void preUnregister()
This method informs calculators before they are unregistered in the calculator factory. This information gives them the chance to remove themselves from observed probes as well as to inform and remove their own observers about being unregistered.
-
newProbeMeasurementAvailable
public void newProbeMeasurementAvailable(ProbeMeasurement probeMeasurement)
Call-back method to be informed about new probe measurements.- Specified by:
newProbeMeasurementAvailable
in interfaceIProbeListener
- Parameters:
probeMeasurement
- The last ProbeMeasurement that was received from an observed probe.- See Also:
IProbeListener.newProbeMeasurementAvailable(org.palladiosimulator.probeframework.measurement.ProbeMeasurement)
-
-