uk.ac.soton.itinnovation.grid.service.sla.dao
Interface UsageSummaryDAO

All Superinterfaces:
GenericDAO<UsageSummary,Long>
All Known Implementing Classes:
UsageSummaryDAOImpl

public interface UsageSummaryDAO
extends GenericDAO<UsageSummary,Long>


Method Summary
 UsageSummary findByIdWithMinimalSelect(Long usageSummaryId)
          Find a UsageSummary by its id, but load only certain primitive properties.
 List<Long> findByNonZeroRateAtInstant(String resourceId, long instant)
          Find entity IDs for UsageSummarys belonging to the resource identified by resourceId and having a non-zero absolute rate at time instant instant
 UsageSummary findByResourceAndMetric(Long entityId, Long metricId)
          Find by the owning ResourceWithUsageByMetric and a Metric.
 List<UsageSummary> findByResourceId(String resourceId)
          Find all UsageSummarys belonging to the owning ResourceWithUsageByMetric that has a resource id of resourceId.
 UsageSummary findByResourceIdAndMetric(String resourceId, Long metricId)
          Find by the owning ResourceWithUsageByMetric and a Metric.
 UsageSummaryElement findElementByInstant(Long usageSummaryId, long instant)
          Find the child UsageSummaryElement at an instant in time.
 Long findIdByResourceAndMetric(Long entityId, Long metricId)
          Find by the owning ResourceWithUsageByMetric and a Metric, but select only the entity id.
 Long findIdByResourceIdAndMetric(String resourceId, Long metricId)
          Find by the owning ResourceWithUsageByMetric and a Metric, but select only the entity id.
 List<Metric> findMetricsForResource(Long entityId)
          Get a list of Metrics associated witht the ResourceWithUsageByMetric identified by entityId.
 UsageSummaryElement findNextElement(Long usageSummaryId, long instant)
          Find the next UsageSummaryElement after an instant in time.
 UsageSummaryElement findNextElementWithNonZeroRate(Long usageSummaryId, long instant)
          Find the next UsageSummaryElement with a non zero rate after an instant in time.
 UsageSummaryElement findPreviousElement(Long usageSummaryId, long instant)
          Find the previous UsageSummaryElement before an instant in time.
 long getPreviousInstant(Long usageSummaryId, long instant)
          Get the time instant of the UsageSummaryElement previous to instant.
 double getRate(Long usageSummaryId)
          Calculate the current rate for the UsageSummary identified by usageSummaryId.
 double getRate(Long usageSummaryId, long instant)
          Calculate the rate at an instant in time, for the UsageSummary identified by usageSummaryId and at the time instant, instant,
 double getTotalPositiveRateChange(Long usageSummaryId, long startInstant, long endInstant)
          Aggregate all positive rate changes between startInstant and endInstant for the for the UsageSummary identified by usageSummaryId.
 double getUsage(Long usageSummaryId)
          Calculate the current usage for the UsageSummary identified by usageSummaryId.
 double getUsage(Long usageSummaryId, long instant)
          Calculate the usage at an instant in time, for the UsageSummary identified by usageSummaryId and at the time instant, instant,
 boolean isElementAtInstant(Long usageSummaryId, long instant)
          Determine if there is a UsageSummaryElement whose time instant at instant.
 void updateLastElement(UsageSummary usageSummary, long latestElementId, long latestElementInstant)
          Update the record for the latest element (by time instant, not time report received).
 void updateTotalRate(UsageSummary usageSummary, double totalRate)
          Each UsageSummary maintains an aggregation of the total rate over the UsageSummaryElements it contains.
 
Methods inherited from interface uk.ac.soton.itinnovation.grid.service.sla.dao.GenericDAO
delete, findAll, findById, findById, saveOrUpdate
 

Method Detail

findByIdWithMinimalSelect

UsageSummary findByIdWithMinimalSelect(Long usageSummaryId)
Find a UsageSummary by its id, but load only certain primitive properties. This is a more efficient finder than findById, for when only these fields are required.

Parameters:
usageSummaryId - the id of the UsageSummary
Returns:
the entity or null.

findByResourceId

List<UsageSummary> findByResourceId(String resourceId)
Find all UsageSummarys belonging to the owning ResourceWithUsageByMetric that has a resource id of resourceId. A minimal select only occurs.

Parameters:
resourceId -
Returns:
list of UsageSummary entities for the resource

findMetricsForResource

List<Metric> findMetricsForResource(Long entityId)
Get a list of Metrics associated witht the ResourceWithUsageByMetric identified by entityId.

Parameters:
entityId - the id for the owning ResourceWithUsageByMetric
Returns:
List of Metrics associated with the resource

findByResourceAndMetric

UsageSummary findByResourceAndMetric(Long entityId,
                                     Long metricId)
Find by the owning ResourceWithUsageByMetric and a Metric.

Parameters:
entityId - the id for the owning ResourceWithUsageByMetric
metricId - the id for the Metric
Returns:
the entity or null.

findIdByResourceAndMetric

Long findIdByResourceAndMetric(Long entityId,
                               Long metricId)
Find by the owning ResourceWithUsageByMetric and a Metric, but select only the entity id.

Parameters:
entityId - the id for the owning ResourceWithUsageByMetric
metricId - the id for the Metric
Returns:
the entity id or null.

findIdByResourceIdAndMetric

Long findIdByResourceIdAndMetric(String resourceId,
                                 Long metricId)
Find by the owning ResourceWithUsageByMetric and a Metric, but select only the entity id.

Parameters:
resourceId - the resource id for the owning ResourceWithUsageByMetric
metricId - the id for the Metric
Returns:
the entity id or null.

findByResourceIdAndMetric

UsageSummary findByResourceIdAndMetric(String resourceId,
                                       Long metricId)
Find by the owning ResourceWithUsageByMetric and a Metric.

Parameters:
resourceId - the resource id for the owning ResourceWithUsageByMetric
metricId - the id for the Metric
Returns:
the entity or null.

findByNonZeroRateAtInstant

List<Long> findByNonZeroRateAtInstant(String resourceId,
                                      long instant)
Find entity IDs for UsageSummarys belonging to the resource identified by resourceId and having a non-zero absolute rate at time instant instant

Parameters:
resourceId - the resource id for the owning ResourceWithUsageByMetric
instant - the time instant for which there may be a non zero rate.

getRate

double getRate(Long usageSummaryId)
Calculate the current rate for the UsageSummary identified by usageSummaryId.

Parameters:
usageSummaryId - the id of the UsageSummary
Returns:
the current rate

getUsage

double getUsage(Long usageSummaryId)
Calculate the current usage for the UsageSummary identified by usageSummaryId.

Parameters:
usageSummaryId - the id of the UsageSummary
Returns:
the current usage.

getRate

double getRate(Long usageSummaryId,
               long instant)
Calculate the rate at an instant in time, for the UsageSummary identified by usageSummaryId and at the time instant, instant,

Parameters:
instant - the time instant in milliseconds
usageSummaryId - the id of the UsageSummary
Returns:
the rate at the time instant

getUsage

double getUsage(Long usageSummaryId,
                long instant)
Calculate the usage at an instant in time, for the UsageSummary identified by usageSummaryId and at the time instant, instant,

Parameters:
instant - the time instant in milliseconds
usageSummaryId - the id of the UsageSummary
Returns:
the usage at the time instant

getTotalPositiveRateChange

double getTotalPositiveRateChange(Long usageSummaryId,
                                  long startInstant,
                                  long endInstant)
Aggregate all positive rate changes between startInstant and endInstant for the for the UsageSummary identified by usageSummaryId.

Note that only positive rate changes are included in the result. Also, a rate change at startInstant is excluded whereas a rate change at endInstant is included.

Parameters:
usageSummaryId - the id of the UsageSummary
startInstant - the time instant in milliseconds at the start of the period
endInstant - the time instant in milliseconds at the end of the period
Returns:
the total of positive rate changes in the time period

getPreviousInstant

long getPreviousInstant(Long usageSummaryId,
                        long instant)
Get the time instant of the UsageSummaryElement previous to instant.

Note that if there is a UsageSummaryElement whose time instant is actually at instant, it is ignored.

Parameters:
usageSummaryId - the id of the owning UsageSummary
instant - the time instant in milliseconds
Returns:
the instant of the previous UsageSummaryElement or -1, if there is not a previous element.

isElementAtInstant

boolean isElementAtInstant(Long usageSummaryId,
                           long instant)
Determine if there is a UsageSummaryElement whose time instant at instant.

Parameters:
usageSummaryId - the id of the owning UsageSummary
instant - the time instant in milliseconds
Returns:
true if there is an element at instant, or false, if there is not.

findElementByInstant

UsageSummaryElement findElementByInstant(Long usageSummaryId,
                                         long instant)
Find the child UsageSummaryElement at an instant in time.

Parameters:
usageSummaryId - the id of the owning UsageSummary
instant - the time instant in milliseconds
Returns:
the child UsageSummaryElement or null

findPreviousElement

UsageSummaryElement findPreviousElement(Long usageSummaryId,
                                        long instant)
Find the previous UsageSummaryElement before an instant in time.

Note that the UsageSummaryElement whose time instant is actually at instant (if any), is excluded from the search.

Parameters:
usageSummaryId - the id of the owning UsageSummary
instant - the time instant in milliseconds
Returns:
the previous UsageSummaryElement or null

findNextElement

UsageSummaryElement findNextElement(Long usageSummaryId,
                                    long instant)
Find the next UsageSummaryElement after an instant in time.

Note that the UsageSummaryElement whose time instant is actually at instant (if any), is excluded from the search.

Parameters:
usageSummaryId - the id of the owning UsageSummary
instant - the time instant in milliseconds
Returns:
the next UsageSummaryElement or null

findNextElementWithNonZeroRate

UsageSummaryElement findNextElementWithNonZeroRate(Long usageSummaryId,
                                                   long instant)
Find the next UsageSummaryElement with a non zero rate after an instant in time.

Note that the UsageSummaryElement whose time instant is actually at instant (if any), is excluded from the search.

Parameters:
usageSummaryId - the id of the owning UsageSummary
instant - the time instant in milliseconds
Returns:
the next UsageSummaryElement or null

updateLastElement

void updateLastElement(UsageSummary usageSummary,
                       long latestElementId,
                       long latestElementInstant)
Update the record for the latest element (by time instant, not time report received). This method updates the database appropriately. It also updates the in-memory UsageSummary argument. This is because the implementation uses SQL to update the database rather than using hibernate, so that the UsageSummary can be partially loaded for efficiency. We therefore have to be careful to update the in memory object also.

Parameters:
usageSummary - the owning UsageSummary
latestElementId - the entity id for the latest element
latestElementInstant - the time instant in millis for the latest element

updateTotalRate

void updateTotalRate(UsageSummary usageSummary,
                     double totalRate)
Each UsageSummary maintains an aggregation of the total rate over the UsageSummaryElements it contains. This method updates the database appropriately. It also updates the in-memory UsageSummary argument. This is because the implementation uses SQL to update the database rather than using hibernate, so that the UsageSummary can be partially loaded for efficiency. We therefore have to be careful to update the in memory object also.

Parameters:
usageSummary - the UsageSummary to update
totalRate - the new total rate for the usage summary


Copyright © 2001-2008 University of Southampton IT Innovation Centre. All Rights Reserved.