Class SlidingWindow

    • Constructor Detail

      • SlidingWindow

        public SlidingWindow​(javax.measure.Measure<Double,​javax.measure.quantity.Duration> windowLength,
                             org.palladiosimulator.metricspec.MetricDescription acceptedMetrics,
                             ISlidingWindowMoveOnStrategy moveOnStrategy)
        Initializes a new instance of the SlidingWindow class with the given parameters.
        Parameters:
        windowLength - The length of the window, given in any arbitrary Duration. Additionally, this measure also denotes the window increment.
        acceptedMetrics - As each window only accepts measurements that adhere to a certain metric, a MetricDescription of must be specified.
        moveOnStrategy - The ISlidingWindowMoveOnStrategy instance that defines how the collected data (i.e., the measurements) is adjusted when the window moves forward.
        Throws:
        IllegalArgumentException - In one of the following cases:
        • given window length is negative
        • acceptedMetrics or moveOnStrategy is null
        See Also:
        SlidingWindow(Measure, Measure, MetricDescription, ISlidingWindowMoveOnStrategy)
      • SlidingWindow

        public SlidingWindow​(javax.measure.Measure<Double,​javax.measure.quantity.Duration> windowLength,
                             javax.measure.Measure<Double,​javax.measure.quantity.Duration> increment,
                             org.palladiosimulator.metricspec.MetricDescription acceptedMetrics,
                             ISlidingWindowMoveOnStrategy moveOnStrategy)
        Initializes a new instance of the SlidingWindow class with the given parameters.
        Parameters:
        windowLength - The length of the window, given in any arbitrary Duration.
        increment - This Measure indicates the increment by what the window is moved on, given in any arbitrary Duration.
        acceptedMetrics - As each window only accepts measurements that adhere to a certain metric, a MetricDescription of must be specified.
        moveOnStrategy - The ISlidingWindowMoveOnStrategy instance that defines how the collected data (i.e., the measurements) is adjusted when the window moves forward.
        Throws:
        IllegalArgumentException - In one of the following cases:
        • given window length or increment is negative
        • acceptedMetrics or moveOnStrategy is null
      • SlidingWindow

        public SlidingWindow​(javax.measure.Measure<Double,​javax.measure.quantity.Duration> windowLength,
                             javax.measure.Measure<Double,​javax.measure.quantity.Duration> increment,
                             javax.measure.Measure<Double,​javax.measure.quantity.Duration> initialLowerBound,
                             org.palladiosimulator.metricspec.MetricDescription acceptedMetrics,
                             ISlidingWindowMoveOnStrategy moveOnStrategy)
        Initializes a new instance of the SlidingWindow class with the given parameters.
        Parameters:
        windowLength - The length of the window, given in any arbitrary Duration.
        increment - This Measure indicates the increment by what the window is moved on, given in any arbitrary Duration.
        initialLowerBound - This Measure indicates the lower bound value at which the algorithm starts aggregating, given in any arbitrary Duration.
        acceptedMetrics - As each window only accepts measurements that adhere to a certain metric, a MetricDescription of must be specified.
        moveOnStrategy - The ISlidingWindowMoveOnStrategy instance that defines how the collected data (i.e., the measurements) is adjusted when the window moves forward.
        Throws:
        IllegalArgumentException - In one of the following cases:
        • given window length or increment is negative
        • acceptedMetrics or moveOnStrategy is null
    • Method Detail

      • onWindowFullEvent

        protected final void onWindowFullEvent()
        This method is invoked once the sliding window is full.
        All attached ISlidingWindowListener are notified and the window moves on by the specified increment.
      • addMeasurement

        public void addMeasurement​(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)
        Adds a new measurement to the data this window collects.
        Parameters:
        newMeasurement - The MeasuringValue instance to add.
        Throws:
        IllegalArgumentException - If the given measurement is null or does not adhere to the metric this window accepts.
      • checkAddMeasurementPrerequisites

        protected void checkAddMeasurementPrerequisites​(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)
        This method is intended to be overridden by subclasses. They might do so to check their additional (potentially more specific) prerequisites.
        Parameters:
        newMeasurement - The MeasuringValue to be added to the window data.
        Throws:
        IllegalArgumentException - If the given measurement is null or does not adhere to the metric this window accepts.
      • addMeasurementInternal

        protected final void addMeasurementInternal​(org.palladiosimulator.measurementframework.MeasuringValue newMeasurement)
        This method adds the given measurement to the window data. No prerequisite checks are performed.
        As this method is intended to be used by subclasses when they override addMeasurement(MeasuringValue), implementations should take care to call checkAddMeasurementPrerequisites(MeasuringValue) beforehand to ensure uncorrupt window data.
        Parameters:
        newMeasurement - The Measurement to be added.
      • flush

        public final void flush()
        Discards the data (i.e., the measurements) currently collected by this window.
      • getAcceptedMetric

        public final org.palladiosimulator.metricspec.MetricDescription getAcceptedMetric()
        Gets the metric this window accepts.
        Returns:
        A MetricDescription denoting the metric this window accepts.
        See Also:
        SlidingWindow#addMeasurement(Measurement)
      • acceptsBaseMetric

        protected final boolean acceptsBaseMetric()
        Gets whether the metric accepted by this window is a BaseMetricDescription. The same result is obtained by calling getAcceptedMetric() and then doing a type check.
        Returns:
        true if the metric is a base metric, otherwise false.
        See Also:
        getAcceptedMetric()
      • getCurrentLowerBound

        public final javax.measure.Measure<Double,​javax.measure.quantity.Duration> getCurrentLowerBound()
        Gets the current lower (i.e., left) bound of the window.
        Returns:
        A Measure denoting the current upper bound.
        See Also:
        getEffectiveWindowLength(), getCurrentUpperBound()
      • getCurrentUpperBound

        public javax.measure.Measure<Double,​javax.measure.quantity.Duration> getCurrentUpperBound()
        Gets the current upper bound of the window.
        Returns:
        A Measure denoting the current upper bound.
        See Also:
        SimulationGovernedSlidingWindow#getEffectiveWindowLength()
      • isEmpty

        public final boolean isEmpty()
        Indicates if there are currently measurements available.
        Returns:
        false, if yes, otherwise true
      • getNumberOfElements

        public final int getNumberOfElements()
        Gets the number of currently collected measurements.
        Returns:
        A nonnegative value denoting the number of elements.