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.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final List<Probe>
    List of probes
  • 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

    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
     
    org.palladiosimulator.edp2.models.measuringpoint.MeasuringPoint
    Returns the measuring point serving as the source of measurements.
    int
     
    void
    Call-back method to be informed about new probe measurements.
    void
    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

    Methods inherited from class org.palladiosimulator.metricspec.metricentity.MetricEntity

    getMetricDesciption, isCompatibleWith, setMetricDescription

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • probes

      protected final List<Probe> probes
      List of probes
  • Constructor Details

    • 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 Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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 interface IProbeListener
      Parameters:
      probeMeasurement - The last ProbeMeasurement that was received from an observed probe.
      See Also: