Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.measurement.server.session
Class DataManagerEJBImpl

java.lang.Object
  extended by org.hyperic.hq.measurement.server.session.SessionEJB
      extended by org.hyperic.hq.measurement.server.session.DataManagerEJBImpl
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class DataManagerEJBImpl
extends SessionEJB
implements javax.ejb.SessionBean

The DataManagerEJB class is a stateless session bean that can be used to retrieve measurement data points

See Also:
Serialized Form

Field Summary
 java.lang.String ALL_EVENTS_INTERESTING_PROP
           
 
Fields inherited from class org.hyperic.hq.measurement.server.session.SessionEJB
_mpm, DATASOURCE_NAME
 
Constructor Summary
DataManagerEJBImpl()
           
 
Method Summary
 void addData(java.lang.Integer mid, MetricValue mv, boolean overwrite)
          Save the new MetricValue to the database
 boolean addData(java.util.List data)
          Write metric data points to the DB with transaction
 void addData(java.util.List data, boolean overwrite)
          Write metric datapoints to the DB without transaction
 void ejbActivate()
           
 void ejbCreate()
           
 void ejbPassivate()
           
 void ejbPostCreate()
           
 void ejbRemove()
           
 double[] getAggregateData(java.util.List measurements, long begin, long end)
          Aggregate data across the given metric IDs, returning max, min, avg, and count of number of unique metric IDs
 java.util.Map getAggregateDataByMetric(java.lang.Integer[] tids, java.lang.Integer[] iids, long begin, long end, boolean useAggressiveRollup)
          Fetch a map of aggregate data values keyed by metrics given a start and stop time range
 java.util.Map getAggregateDataByMetric(java.util.List measurements, long begin, long end, boolean useAggressiveRollup)
          Fetch a map of aggregate data values keyed by metrics given a start and stop time range
 java.util.Map getAggregateDataByTemplate(java.util.List measurements, long begin, long end)
          Fetch the list of historical data points, grouped by template, given a begin and end time range.
 double[] getBaselineData(Measurement meas, long begin, long end)
          Get a Baseline data.
 java.util.ArrayList getCachedDataPoints(java.lang.Integer[] ids, java.util.Map data, long timestamp)
          Get data points from cache only
 PageList getHistoricalData(java.util.List measurements, long begin, long end, long interval, int type, boolean returnMetricNulls, PageControl pc)
          Fetch the list of historical data points given a start and stop time range and interval
 PageList getHistoricalData(Measurement m, long begin, long end, PageControl pc)
          Fetch the list of historical data points given a begin and end time range.
 PageList getHistoricalData(Measurement m, long begin, long end, PageControl pc, boolean prependAvailUnknowns)
          Fetch the list of historical data points given a begin and end time range.
 java.util.Map getLastDataPoints(java.util.List measurements, long timestamp)
          Fetch the most recent data point for particular Measurements.
 MetricValue getLastHistoricalData(Measurement m)
          Get the last MetricValue for the given Measurement.
static org.hyperic.hq.measurement.shared.DataManagerLocal getOne()
           
 java.util.Collection getRawData(Measurement m, long begin, long end, java.util.concurrent.atomic.AtomicLong publishedInterval)
           
 void setSessionContext(javax.ejb.SessionContext ctx)
           
 
Methods inherited from class org.hyperic.hq.measurement.server.session.SessionEJB
checkDeletePermission, checkModifyPermission, checkTimeArguments, deleteMetricProblems, getAgent, getAgent, getAgentMan, getAuthzSubjectManager, getAvailabilityDataDAO, getBaselineDAO, getCategoryDAO, getDataMan, getInitialContext, getMeasurementDAO, getMeasurementTemplateDAO, getMetricProblemDAO, getMonitorableTypeDAO, getMPM, getProductMan, getResource, getScheduleRevNumDAO, getSRNManager, getTemplateMan
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_EVENTS_INTERESTING_PROP

public final java.lang.String ALL_EVENTS_INTERESTING_PROP
See Also:
Constant Field Values
Constructor Detail

DataManagerEJBImpl

public DataManagerEJBImpl()
Method Detail

addData

public void addData(java.lang.Integer mid,
                    MetricValue mv,
                    boolean overwrite)
Save the new MetricValue to the database

Parameters:
dp - the new MetricValue
Throws:
java.lang.NumberFormatException - if the value from the DataPoint.getMetricValue() cannot instantiate a BigDecimal

addData

public boolean addData(java.util.List data)
Write metric data points to the DB with transaction

Parameters:
data - a list of DataPoints
Throws:
java.lang.NumberFormatException - if the value from the DataPoint.getMetricValue() cannot instantiate a BigDecimal

addData

public void addData(java.util.List data,
                    boolean overwrite)
Write metric datapoints to the DB without transaction

Parameters:
data - a list of DataPoints
overwrite - If true, attempt to over-write values when an insert of the data fails (i.e. it already exists). You may not want to over-write values when, for instance, the back filler is inserting data.
Throws:
java.lang.NumberFormatException - if the value from the DataPoint.getMetricValue() cannot instantiate a BigDecimal

getHistoricalData

public PageList getHistoricalData(Measurement m,
                                  long begin,
                                  long end,
                                  PageControl pc,
                                  boolean prependAvailUnknowns)
Fetch the list of historical data points given a begin and end time range. Returns a PageList of DataPoints without begin rolled into time windows.

Parameters:
m - The Measurement
begin - the start of the time range
end - the end of the time range
prependUnknowns - determines whether to prepend AVAIL_UNKNOWN if the corresponding time window is not accounted for in the database. Since availability is contiguous this will not occur unless the time range precedes the first availability point.
Returns:
the list of data points

getHistoricalData

public PageList getHistoricalData(Measurement m,
                                  long begin,
                                  long end,
                                  PageControl pc)
Fetch the list of historical data points given a begin and end time range. Returns a PageList of DataPoints without begin rolled into time windows.

Parameters:
m - The Measurement
begin - the start of the time range
end - the end of the time range
Returns:
the list of data points

getRawData

public java.util.Collection getRawData(Measurement m,
                                       long begin,
                                       long end,
                                       java.util.concurrent.atomic.AtomicLong publishedInterval)
Parameters:
publishedInterval - AtomicLong interval, in millis, of the dataset which is returned from the api. For example for queries that are a month long HQ will use a daily rollup table to retrieve the data from. In this case publishedInterval would be set with an interval that represents one day.
Returns:
array of MetricValue representing the raw metric data collected. Since Availability just keeps state changes this does not apply, therefore one MetricValue will be returned per interval.

getAggregateData

public double[] getAggregateData(java.util.List measurements,
                                 long begin,
                                 long end)
Aggregate data across the given metric IDs, returning max, min, avg, and count of number of unique metric IDs

Parameters:
measurements - List of Measurements
begin - The start of the time range
end - The end of the time range
Returns:
the An array of aggregate values

getAggregateDataByTemplate

public java.util.Map getAggregateDataByTemplate(java.util.List measurements,
                                                long begin,
                                                long end)
Fetch the list of historical data points, grouped by template, given a begin and end time range. Does not return an entry for templates with no associated data. PLEASE NOTE: The MeasurementConstants.IND_LAST_TIME index in the double[] part of the returned map does not contain the real last value. Instead it is an averaged value calculated from the last 1/60 of the specified time range. If this becomes an issue the best way I can think of to solve is to pass in a boolean "getRealLastTime" and issue another query to get the last value if this is set. It is much better than the alternative of always querying the last metric time because not all pages require this value.

Parameters:
measurements - The List of Measurements to query
begin - The start of the time range
end - The end of the time range
Returns:
the Map of Integer to double[] which represents templateId to data points
See Also:
org.hyperic.hq.measurement.server.session.AvailabilityManagerEJBImpl#getHistoricalData()

getHistoricalData

public PageList getHistoricalData(java.util.List measurements,
                                  long begin,
                                  long end,
                                  long interval,
                                  int type,
                                  boolean returnMetricNulls,
                                  PageControl pc)
Fetch the list of historical data points given a start and stop time range and interval

Parameters:
measurements - The List of Measurements to query
begin - The start of the time range
end - The end of the time range
interval - Interval for the time range
type - Collection type for the metric
returnMetricNulls - Specifies whether intervals with no data should be return as HighLowMetricValue with the value set as Double.NaN
Returns:
the list of data points
See Also:
org.hyperic.hq.measurement.server.session.AvailabilityManagerEJBImpl#getHistoricalData()

getLastHistoricalData

public MetricValue getLastHistoricalData(Measurement m)
Get the last MetricValue for the given Measurement.

Parameters:
m - The Measurement
Returns:
The MetricValue or null if one does not exist.

getLastDataPoints

public java.util.Map getLastDataPoints(java.util.List measurements,
                                       long timestamp)
Fetch the most recent data point for particular Measurements.

Parameters:
measurements - The List of Measurements to query. In the list of Measurements null values are allowed as placeholders.
timestamp - Only use data points with collection times greater than the given timestamp.
Returns:
A Map of measurement ids to MetricValues. TODO: We should change this method to now allow NULL values. This is legacy and only used by the Metric viewer and Availabilty Summary portlets.

getCachedDataPoints

public java.util.ArrayList getCachedDataPoints(java.lang.Integer[] ids,
                                               java.util.Map data,
                                               long timestamp)
Get data points from cache only


getBaselineData

public double[] getBaselineData(Measurement meas,
                                long begin,
                                long end)
Get a Baseline data.


getAggregateDataByMetric

public java.util.Map getAggregateDataByMetric(java.lang.Integer[] tids,
                                              java.lang.Integer[] iids,
                                              long begin,
                                              long end,
                                              boolean useAggressiveRollup)
Fetch a map of aggregate data values keyed by metrics given a start and stop time range

Parameters:
tids - The template id's of the Measurement
iids - The instance id's of the Measurement
begin - The start of the time range
end - The end of the time range
useAggressiveRollup - uses a measurement rollup table to fetch the data if the time range spans more than one data table's max timerange
Returns:
the Map of data points

getAggregateDataByMetric

public java.util.Map getAggregateDataByMetric(java.util.List measurements,
                                              long begin,
                                              long end,
                                              boolean useAggressiveRollup)
Fetch a map of aggregate data values keyed by metrics given a start and stop time range

Parameters:
measurements - The id's of the Measurement
begin - The start of the time range
end - The end of the time range
useAggressiveRollup - uses a measurement rollup table to fetch the data if the time range spans more than one data table's max timerange
Returns:
the map of data points

getOne

public static org.hyperic.hq.measurement.shared.DataManagerLocal getOne()

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Throws:
javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate()

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
Specified by:
setSessionContext in interface javax.ejb.SessionBean

Hyperic HQ Plugin API v. 4.4.0.2

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