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 aPRMRecorder
dedicated to forwarding measurements resulting from aMeasurementDrivenAggregation
to theRuntimeMeasurementModel
. 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 invokeddecrementCounter()
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 invokedresetCounter()
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 associatedMeasurementDrivenAggregation
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
-
-
-
-
Method Detail
-
resetCounter
protected final void resetCounter()
Resets the counter for the next aggregation to the value specified by the 'Frequency' attribute of the associatedMeasurementDrivenAggregation
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 afteronPostAggregate()
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:// check whether received measurement is compliant with expected metric
collectMeasurement(MeasuringValue)
is invokeddecrementCounter()
is invoked-
// check whether counter for next upcoming aggregation has reached zero && aggregationRequired() == true
onPreAggregate()
is invoked// the actual aggregation is performed
onPostAggregate()
is invokedresetCounter()
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 interfaceorg.palladiosimulator.measurementframework.listener.IMeasurementSourceListener
- Throws:
NullPointerException
- In casenewMeasurement == 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 interfaceorg.palladiosimulator.measurementframework.listener.IMeasurementSourceListener
- See Also:
clear()
-
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 aftercollectMeasurement(MeasuringValue)
anddecrementCounter()
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 ofonPreAggregate()
and followed by the invocation ofonPostAggregate()
andresetCounter()
.- Returns:
true
if an aggregation of the collected measurements shall be triggered,false
otherwise.- See Also:
newMeasurementAvailable(MeasuringValue)
,onPreAggregate()
,onPostAggregate()
-
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
- AMeasuringValue
denoting the measurement to include for aggregation.
It is ensured that the measurement passed here is notnull
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
- AMeasuringValue
representing the measurement.- Returns:
- The corresponding point in time, expressed in terms of an
Amount
.
-
-