Class 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

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract boolean aggregationRequired()
      This method has to be implemented by all subclasses.
      abstract void clear()
      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 void decrementCounter()
      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> getDataToAggregate()
      Gets the sequence of measurements to be aggregated.
      protected org.palladiosimulator.metricspec.NumericalBaseMetricDescription getExpectedMetric()
      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> getIntervalEndTime()
      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> getIntervalStartTime()
      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.
      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 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.
      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.
      void preUnregister()

      In particular, all measurements that are currently collected for aggregation are discarded upon unregistering.
      protected 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.
    • Method Detail

      • 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:
        MeasurementDrivenAggregation.getFrequency(), decrementCounter(), onPostAggregate()
      • 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:
        collectMeasurement(MeasuringValue), resetCounter(), MeasurementDrivenAggregation.getFrequency()
      • 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()
      • clear

        public abstract void clear()
        Discards all measurements collected for aggregation.
      • 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()
      • 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:
        getIntervalStartTime()
      • 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:
        decrementCounter()
      • 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:
        aggregationRequired()
      • 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:
        aggregationRequired()
      • 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.