org.rhq.enterprise.server.measurement.util
Class MeasurementDataManagerUtility

java.lang.Object
  extended by org.rhq.enterprise.server.measurement.util.MeasurementDataManagerUtility

public class MeasurementDataManagerUtility
extends Object

This is purposefully not TimeZone sensitive. It makes it easier for it to deal with clusters with servers in different timezones, but it means that we can't rely on table maintenance in the middle of the night. That's ok, we're going to do this like the rest of the maintenance - on the hour. It does mean that even with 12 hour tables we may have data in one from 10 am to 10 pm local instead of 12 to 12.

Due to the leap seconds, it's possible some tables will technically span more than MILLISECONDS_PER_TABLE of real time. This is an irrelevant quirk.

Author:
Greg Hinkle, Joseph Marques

Field Summary
static int BUFFER_TABLES
           
static int DEFAULT_NUM_DATA_POINTS
          For methods taking a number of data points, the default if the passed value is invalid (<=0).
static int LIVE_TABLES
           
static long MILLISECONDS_PER_TABLE
           
static long RAW_PURGE
           
static int STORED_DAYS
           
static int TABLE_COUNT
           
static int TABLES_PER_DAY
           
 
Constructor Summary
MeasurementDataManagerUtility()
           
 
Method Summary
 MeasurementAggregate getAggregateByDefinitionAndContext(long beginTime, long endTime, int definitionId, org.rhq.core.domain.common.EntityContext context)
           
 MeasurementAggregate getAggregateByScheduleId(long beginTime, long endTime, long scheduleId)
           
static String[] getAllRawTables()
           
static String[] getAllRawTables(int startIndex)
          The raw tables starting at the specified index.
static String getCurrentRawTable()
           
static String getDeadTable(long time)
           
static MeasurementDataManagerUtility getInstance(DataSource dataSource)
           
 org.rhq.core.domain.measurement.MeasurementDataNumeric getLatestValueForSchedule(int scheduleId)
           
 List<List<org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite>> getMeasurementDataAggregatesForContext(long beginTime, long endTime, org.rhq.core.domain.common.EntityContext context, int definitionId, int numDataPoints)
           
static String getNextRotationTime()
           
 long getPurge1d()
           
 long getPurge1h()
           
 long getPurge6h()
           
 long getPurgeAlert()
           
 long getPurgeRt()
           
static long getRawTimePeriodStart(long end)
           
static String getTable(long time)
           
static int getTableNameIndex(String tableName)
           
static String[] getTables(long beginTime, long endTime)
           
static String[] getTables(long beginTime, long endTime, long now)
           
static String getTableString(String table, String valuesClause, String conditions)
           
static boolean isRawTable(String tableName)
           
static boolean isRawTimePeriod(long beginTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORED_DAYS

public static final int STORED_DAYS
See Also:
Constant Field Values

TABLES_PER_DAY

public static final int TABLES_PER_DAY
See Also:
Constant Field Values

BUFFER_TABLES

public static final int BUFFER_TABLES
See Also:
Constant Field Values

LIVE_TABLES

public static final int LIVE_TABLES
See Also:
Constant Field Values

TABLE_COUNT

public static final int TABLE_COUNT
See Also:
Constant Field Values

MILLISECONDS_PER_TABLE

public static final long MILLISECONDS_PER_TABLE
See Also:
Constant Field Values

RAW_PURGE

public static final long RAW_PURGE
See Also:
Constant Field Values

DEFAULT_NUM_DATA_POINTS

public static final int DEFAULT_NUM_DATA_POINTS
For methods taking a number of data points, the default if the passed value is invalid (<=0).

See Also:
Constant Field Values
Constructor Detail

MeasurementDataManagerUtility

public MeasurementDataManagerUtility()
Method Detail

getInstance

public static MeasurementDataManagerUtility getInstance(DataSource dataSource)

getMeasurementDataAggregatesForContext

public List<List<org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite>> getMeasurementDataAggregatesForContext(long beginTime,
                                                                                                                                           long endTime,
                                                                                                                                           org.rhq.core.domain.common.EntityContext context,
                                                                                                                                           int definitionId,
                                                                                                                                           int numDataPoints)
                                                                                                                                    throws MeasurementNotFoundException
Throws:
MeasurementNotFoundException

getAggregateByScheduleId

public MeasurementAggregate getAggregateByScheduleId(long beginTime,
                                                     long endTime,
                                                     long scheduleId)
                                              throws MeasurementNotFoundException
Throws:
MeasurementNotFoundException

getAggregateByDefinitionAndContext

public MeasurementAggregate getAggregateByDefinitionAndContext(long beginTime,
                                                               long endTime,
                                                               int definitionId,
                                                               org.rhq.core.domain.common.EntityContext context)
                                                        throws MeasurementNotFoundException
Throws:
MeasurementNotFoundException

getLatestValueForSchedule

public org.rhq.core.domain.measurement.MeasurementDataNumeric getLatestValueForSchedule(int scheduleId)

getTableString

public static String getTableString(String table,
                                    String valuesClause,
                                    String conditions)

getTable

public static String getTable(long time)

getAllRawTables

public static String[] getAllRawTables()

getAllRawTables

public static String[] getAllRawTables(int startIndex)
The raw tables starting at the specified index. Can be useful for getting the tables in a necessary time order (like oldest data first.

Parameters:
startIndex - >= 0. If >= TABLE_COUNT normalized via modulo.
Returns:
Array of raw table names starting with the table with the specified index.

getTables

public static String[] getTables(long beginTime,
                                 long endTime)

getTables

public static String[] getTables(long beginTime,
                                 long endTime,
                                 long now)

getDeadTable

public static String getDeadTable(long time)

getCurrentRawTable

public static String getCurrentRawTable()

getNextRotationTime

public static String getNextRotationTime()

getTableNameIndex

public static int getTableNameIndex(String tableName)

getPurge1h

public long getPurge1h()

getPurge6h

public long getPurge6h()

getPurge1d

public long getPurge1d()

getPurgeRt

public long getPurgeRt()

getPurgeAlert

public long getPurgeAlert()

getRawTimePeriodStart

public static long getRawTimePeriodStart(long end)

isRawTimePeriod

public static boolean isRawTimePeriod(long beginTime)

isRawTable

public static boolean isRawTable(String tableName)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.