MetricDataCache (Hyperic HQ Plugin API)
Keywords: org.hyperic.hq.measurement.server.session.MetricDataCache class

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.hq.measurement.server.session
Class MetricDataCache

    java.lang.Object
      org.hyperic.hq.measurement.server.session.MetricDataCache

    public class MetricDataCache

extends java.lang.Object

The MetricDataCache caches the last measurement keyed on the derived measurement id. The purpose of this cache is to avoid needing to go to the database when looking up the last value for a metric. If this area of the code becomes a bottleneck, we may want to consider ditching ehcache and just using a straight HashMap -- the code is simpler, and locking straightforward. However, it is currently nice to keep ehcache, as it allows us to configure sizes and get stats.

Method Summary
`protected boolean` | `add(java.lang.Integer mid, MetricValue mval)` Add a MetricValue to the cache.
`java.util.Collection` | `bulkAdd(java.util.List data)` Add MetricValues to the cache.
`MetricValue` | `get(java.lang.Integer mid, long timestamp)` Get a MetricValue from the cache.
`java.util.Map` | `getAll(java.util.List mids, long timestamp)` Get `MetricValue`s from the cache within the specified time range, from timestamp to currentTimeMillis.
`static MetricDataCache` | `getInstance()`
`void` | `remove(java.lang.Integer mid)` Remove a MetricValue from cache

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

Method Detail

### getInstance

    public static MetricDataCache getInstance()

### bulkAdd

    public java.util.Collection bulkAdd(java.util.List data)

  Add MetricValues to the cache. This method checks the timestamp of each MetricValue to be added to ensure it's not an older data point than what is already cached.

  Parameters:
    `data` - The list of DataPoint objects representing each MetricValue.
  Returns:
    The list of DataPoint objects added to the cache. Any DataPoints older than what is already cached will NOT be contained in this list.

### add

    protected boolean add(java.lang.Integer mid,
                          MetricValue mval)

  Add a MetricValue to the cache. This method checks the timestamp of the MetricValue to be added to ensure it's not an older data point than what is already cached. Each invocation of this method is synchronized internally, so consider using the `bulk add` for batch updates to the cache.

  Parameters:
    `mid` - The measurement id.
    `mval` - The MetricValue to store.
  Returns:
    true if the MetricValue was added to the cache, false otherwise.

### getAll

    public java.util.Map getAll(java.util.List mids,
                                long timestamp)

  Get `MetricValue`s from the cache within the specified time range, from timestamp to currentTimeMillis.

  Parameters:
    `mids` - `List` of `Integer`s representing MeasurementIds.
    `timestamp` - the start of the time range (inclusive) in millis.
  Returns:
    `Map` of `Integer` of measurementIds to `MetricValue` from the cache. If the mid does not exist or the timestamp of value is out of the specified window the returned Map will not include any representation of the mid.

### get

    public MetricValue get(java.lang.Integer mid,
                           long timestamp)

  Get a MetricValue from the cache.

  Parameters:
    `mid` - The measurement id.
    `timestamp` - The beginning of the cache window.
  Returns:
    The MetricValue from the cache, or null if the element is not found, or the item in the cache is stale.

### remove

    public void remove(java.lang.Integer mid)

  Remove a MetricValue from cache

  Parameters:
    `mid` - The measurement id to remove.

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.