Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util.stats
Class TimeWindowCollector

    java.lang.Object
      org.hyperic.util.stats.TimeWindowCollector

    public class TimeWindowCollector

extends java.lang.Object

Maintains a list of `DataPoint`s which all lie within a specific time range. This class is useful for storing 'the last 30 minutes of data' and rolling the oldest data points off. This class relies on datapoints being placed into the collector in time-sorted order.

Constructor Summary
`TimeWindowCollector(long windowSize)`

Method Summary
`void` | `addPoint(DataPoint pt)`
`void` | `addPoint(long time, double value)` Add a new datapoint to the collection -- does not roll off old datapoints.
`double` | `getSum()` Get a sum of all the encapsulated data points
`boolean` | `hasRolled()` Returns true if data has been rolled off the back of the time-window.
`void` | `removeOldPoints()` Remove old datapoints.
`void` | `removeOldPoints(long currentTime)` Remove old datapoints.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TimeWindowCollector

    public TimeWindowCollector(long windowSize)

Parameters:
  `windowSize` - The size of the window (in millis) that all the encapsulated datapoints should be within.

Method Detail

### addPoint

    public void addPoint(long time,
                         double value)

  Add a new datapoint to the collection -- does not roll off old datapoints.

### addPoint

    public void addPoint(DataPoint pt)

  See Also:
    `addPoint(long, double)`

### hasRolled

    public boolean hasRolled()

  Returns true if data has been rolled off the back of the time-window. (i.e. removeOldPoints() has been invoked and removed something)

### getSum

    public double getSum()

  Get a sum of all the encapsulated data points

### removeOldPoints

    public void removeOldPoints()

  Remove old datapoints. This method uses the time of the most recent datapoint as the end of the time range. All datapoints older than datapoints[-1] - windowSize will be removed.

### removeOldPoints

    public void removeOldPoints(long currentTime)

  Remove old datapoints. All datapoints older than currentTime - windowSize will be removed.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.