Class AbstractMeasurementAggregator

java.lang.Object
org.palladiosimulator.simulizar.metrics.PRMRecorder
org.palladiosimulizar.aggregation.aggregators.AbstractMeasurementAggregator
All Implemented Interfaces:
org.palladiosimulator.measurementframework.listener.IMeasurementSourceListener
Direct Known Subclasses:
FixedSizeMeasurementsAggregator, VariableSizeMeasurementAggregator

public abstract class AbstractMeasurementAggregator extends PRMRecorder implements org.palladiosimulator.measurementframework.listener.IMeasurementSourceListener
This class implements a PRMRecorder dedicated to forwarding measurements resulting from a MeasurementDrivenAggregation to the RuntimeMeasurementModel. Most of the implementation is left open for concrete subclasses by the main feature of this class, a template method for the handling of new, incoming measurements.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
    This method has to be implemented by all subclasses.
    abstract void
    Discards all measurements collected for aggregation.
    protected abstract void
    collectMeasurement(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)
    This method has to be implemented by subclasses to collect a new measurement for aggregation.
    protected final void
    Decrements the counter for the next upcoming aggregation.
    This method is invoked directly after the collection of a new measurement.
    protected abstract Iterable<org.palladiosimulator.measurementframework.MeasuringValue>
    Gets the sequence of measurements to be aggregated.
    protected final org.palladiosimulator.metricspec.NumericalBaseMetricDescription
    Gets the numerical base metric description of the measurements that are to be forwarded to the runtime measurements model.
    protected abstract org.jscience.physics.amount.Amount<javax.measure.quantity.Duration>
    Gets the right (upper) bound of the interval that all measurements that are aggregated lie in.
    protected abstract org.jscience.physics.amount.Amount<javax.measure.quantity.Duration>
    Gets the left (lower) bound of the interval that all measurements that are aggregated lie in.
    protected static org.jscience.physics.amount.Amount<javax.measure.quantity.Duration>
    getPointInTimeOfMeasurement(org.palladiosimulator.measurementframework.MeasuringValue measurement)
    Convenience method for all subclasses to obtain the point in time (which is assumed to be present) a measurement was taken.
    final void
    newMeasurementAvailable(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)

    This method is implemented as a template method, where some steps are to be (re-)implemented by the subclasses: // check whether received measurement is compliant with expected metric collectMeasurement(MeasuringValue) is invoked decrementCounter() is invoked // check whether counter for next upcoming aggregation has reached zero && aggregationRequired() == true In case of an upcoming aggregation, the following steps are carried out additionally: onPreAggregate() is invoked // the actual aggregation is performed onPostAggregate() is invoked resetCounter() is invoked (Note: Each time the counter has reached zero this method is invoked, whether or not an aggregation was performed.)
    protected void
    This method is invoked directly after an aggregation of the measurements has been performed and is intended to be overriden by subclasses to include implementation-specific behavior.
    protected void
    This method is invoked directly before an aggregation of the measurements is to be performed and is intended to be overriden by subclasses to include implementation-specific behavior.
    void

    In particular, all measurements that are currently collected for aggregation are discarded upon unregistering.
    protected final void
    Resets the counter for the next aggregation to the value specified by the 'Frequency' attribute of the associated MeasurementDrivenAggregation model element.
    This method is called upon object construction and after the counter reached zero.

    Methods inherited from class org.palladiosimulator.simulizar.metrics.PRMRecorder

    detachFromPRM, getMeasurementSpecification, getPRMMeasurement, getPrmModel, updateMeasurementValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • resetCounter

      protected final void resetCounter()
      Resets the counter for the next aggregation to the value specified by the 'Frequency' attribute of the associated MeasurementDrivenAggregation model element.
      This method is called upon object construction and after the counter reached zero. In the latter case, if an aggregation was done, the call directly happens after onPostAggregate() is invoked.
      See Also:
    • decrementCounter

      protected final void decrementCounter()
      Decrements the counter for the next upcoming aggregation.
      This method is invoked directly after the collection of a new measurement.
      See Also:
    • newMeasurementAvailable

      public final void newMeasurementAvailable(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)

      This method is implemented as a template method, where some steps are to be (re-)implemented by the subclasses:
      1. // check whether received measurement is compliant with expected metric
      2. collectMeasurement(MeasuringValue) is invoked
      3. decrementCounter() is invoked
      4. // check whether counter for next upcoming aggregation has reached zero && aggregationRequired() == true
      In case of an upcoming aggregation, the following steps are carried out additionally:
      1. onPreAggregate() is invoked
      2. // the actual aggregation is performed
      3. onPostAggregate() is invoked
      4. resetCounter() is invoked (Note: Each time the counter has reached zero this method is invoked, whether or not an aggregation was performed.)
      Specified by:
      newMeasurementAvailable in interface org.palladiosimulator.measurementframework.listener.IMeasurementSourceListener
      Throws:
      NullPointerException - In case newMeasurement == null.
      IllegalStateException - In case the received measurement is not compliant with the expected metric.
    • preUnregister

      public void preUnregister()

      In particular, all measurements that are currently collected for aggregation are discarded upon unregistering.
      Specified by:
      preUnregister in interface org.palladiosimulator.measurementframework.listener.IMeasurementSourceListener
      See Also:
    • clear

      public abstract void clear()
      Discards all measurements collected for aggregation.
    • aggregationRequired

      protected abstract boolean aggregationRequired()
      This method has to be implemented by all subclasses. It is invoked by this instance each time a new measurements has been collected, i.e., directly after collectMeasurement(MeasuringValue) and decrementCounter() have been invoked, and the counter for the next upcoming aggregation has reached zero.
      In case an aggregation is required, it is directly performed hereafter, yet preceded by the invocation of onPreAggregate() and followed by the invocation of onPostAggregate() and resetCounter().
      Returns:
      true if an aggregation of the collected measurements shall be triggered, false otherwise.
      See Also:
    • getIntervalStartTime

      protected abstract org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> getIntervalStartTime()
      Gets the left (lower) bound of the interval that all measurements that are aggregated lie in.
      Returns:
      A non-negative Amount denoting the left bound of the interval.
      See Also:
    • getIntervalEndTime

      protected abstract org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> getIntervalEndTime()
      Gets the right (upper) bound of the interval that all measurements that are aggregated lie in.
      Returns:
      A non-negative Amount denoting the right bound of the interval.
      See Also:
    • getDataToAggregate

      protected abstract Iterable<org.palladiosimulator.measurementframework.MeasuringValue> getDataToAggregate()
      Gets the sequence of measurements to be aggregated.
      Returns:
      An Iterable encapsulating the sequence of measurements to be aggregated.
    • collectMeasurement

      protected abstract void collectMeasurement(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)
      This method has to be implemented by subclasses to collect a new measurement for aggregation.
      Parameters:
      newMeasurement - A MeasuringValue denoting the measurement to include for aggregation.
      It is ensured that the measurement passed here is not null and adheres to the expected metric, hence no more checks with regards to this have to be done by the implementations.
      See Also:
    • onPreAggregate

      protected void onPreAggregate()
      This method is invoked directly before an aggregation of the measurements is to be performed and is intended to be overriden by subclasses to include implementation-specific behavior.
      The default implementation does nothing.
      See Also:
    • onPostAggregate

      protected void onPostAggregate()
      This method is invoked directly after an aggregation of the measurements has been performed and is intended to be overriden by subclasses to include implementation-specific behavior.
      The default implementation does nothing.
      See Also:
    • getExpectedMetric

      protected final org.palladiosimulator.metricspec.NumericalBaseMetricDescription getExpectedMetric()
      Gets the numerical base metric description of the measurements that are to be forwarded to the runtime measurements model.
      Returns:
      The expected NumericalBaseMetricDescription.
    • getPointInTimeOfMeasurement

      protected static org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> getPointInTimeOfMeasurement(org.palladiosimulator.measurementframework.MeasuringValue measurement)
      Convenience method for all subclasses to obtain the point in time (which is assumed to be present) a measurement was taken.
      Parameters:
      measurement - A MeasuringValue representing the measurement.
      Returns:
      The corresponding point in time, expressed in terms of an Amount.