|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.soton.itinnovation.grid.service.sla.dao.GenericHibernateDAO<UsageSummary,Long>
uk.ac.soton.itinnovation.grid.service.sla.dao.hibernate.UsageSummaryDAOImpl
public class UsageSummaryDAOImpl
| Constructor Summary | |
|---|---|
UsageSummaryDAOImpl()
|
|
| 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 |
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 class uk.ac.soton.itinnovation.grid.service.sla.dao.GenericHibernateDAO |
|---|
delete, findAll, findByCriteria, findById, findById, getPersistentClass, saveOrUpdate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface uk.ac.soton.itinnovation.grid.service.sla.dao.GenericDAO |
|---|
delete, findAll, findById, findById, saveOrUpdate |
| Constructor Detail |
|---|
public UsageSummaryDAOImpl()
| Method Detail |
|---|
public UsageSummary findByIdWithMinimalSelect(Long usageSummaryId)
UsageSummaryDAOUsageSummary by its id, but load only
certain primitive properties. This is a more efficient finder
than findById, for when only these fields are required.
findByIdWithMinimalSelect in interface UsageSummaryDAOusageSummaryId - the id of the UsageSummary
null.public List<UsageSummary> findByResourceId(String resourceId)
UsageSummaryDAOUsageSummarys belonging to the
owning ResourceWithUsageByMetric that has a resource
id of resourceId. A minimal select only occurs.
findByResourceId in interface UsageSummaryDAOpublic List<Metric> findMetricsForResource(Long entityId)
UsageSummaryDAOMetrics associated witht the
ResourceWithUsageByMetric identified by entityId.
findMetricsForResource in interface UsageSummaryDAOentityId - the id for the owning ResourceWithUsageByMetric
List of Metrics associated with the resource
public UsageSummary findByResourceAndMetric(Long entityId,
Long metricId)
UsageSummaryDAOResourceWithUsageByMetric and a Metric.
findByResourceAndMetric in interface UsageSummaryDAOentityId - the id for the owning ResourceWithUsageByMetricmetricId - the id for the Metric
null.
public Long findIdByResourceAndMetric(Long entityId,
Long metricId)
UsageSummaryDAOResourceWithUsageByMetric and a Metric,
but select only the entity id.
findIdByResourceAndMetric in interface UsageSummaryDAOentityId - the id for the owning ResourceWithUsageByMetricmetricId - the id for the Metric
null.
public Long findIdByResourceIdAndMetric(String resourceId,
Long metricId)
UsageSummaryDAOResourceWithUsageByMetric and a Metric,
but select only the entity id.
findIdByResourceIdAndMetric in interface UsageSummaryDAOresourceId - the resource id for the owning ResourceWithUsageByMetricmetricId - the id for the Metric
null.
public UsageSummary findByResourceIdAndMetric(String resourceId,
Long metricId)
UsageSummaryDAOResourceWithUsageByMetric and a Metric.
findByResourceIdAndMetric in interface UsageSummaryDAOresourceId - the resource id for the owning ResourceWithUsageByMetricmetricId - the id for the Metric
null.
public List<Long> findByNonZeroRateAtInstant(String resourceId,
long instant)
UsageSummaryDAOUsageSummarys belonging to the resource identified
by resourceId and having a non-zero absolute rate at time instant
instant
findByNonZeroRateAtInstant in interface UsageSummaryDAOresourceId - the resource id for the owning ResourceWithUsageByMetricinstant - the time instant for which there may be a non zero rate.public double getRate(Long usageSummaryId)
UsageSummaryDAOUsageSummary
identified by usageSummaryId.
getRate in interface UsageSummaryDAOusageSummaryId - the id of the UsageSummary
public double getUsage(Long usageSummaryId)
UsageSummaryDAOUsageSummary
identified by usageSummaryId.
getUsage in interface UsageSummaryDAOusageSummaryId - the id of the UsageSummary
public double getRate(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummary
identified by usageSummaryId and at the time instant,
instant,
getRate in interface UsageSummaryDAOusageSummaryId - the id of the UsageSummaryinstant - the time instant in milliseconds
public double getTotalPositiveRateChange(Long usageSummaryId,
long startInstant,
long endInstant)
UsageSummaryDAOstartInstant 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.
getTotalPositiveRateChange in interface UsageSummaryDAOusageSummaryId - the id of the UsageSummarystartInstant - the time instant in milliseconds at the start of the periodendInstant - the time instant in milliseconds at the end of the period
public double getUsage(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummary
identified by usageSummaryId and at the time instant,
instant,
getUsage in interface UsageSummaryDAOusageSummaryId - the id of the UsageSummaryinstant - the time instant in milliseconds
public long getPreviousInstant(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummaryElement previous
to instant.
Note that if there is a UsageSummaryElement whose time
instant is actually at instant, it is ignored.
- Specified by:
getPreviousInstant in interface UsageSummaryDAO
- Parameters:
usageSummaryId - the id of the owning UsageSummaryinstant - the time instant in milliseconds
- Returns:
- the instant of the previous
UsageSummaryElement
or -1, if there is not a previous element.
public boolean isElementAtInstant(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummaryElement whose time
instant at instant.
isElementAtInstant in interface UsageSummaryDAOusageSummaryId - the id of the owning UsageSummaryinstant - the time instant in milliseconds
- Returns:
true if there is an element at instant, or
false, if there is not.
public UsageSummaryElement findElementByInstant(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummaryElement at an instant
in time.
findElementByInstant in interface UsageSummaryDAOusageSummaryId - the id of the owning UsageSummaryinstant - the time instant in milliseconds
UsageSummaryElement or null
public UsageSummaryElement findPreviousElement(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummaryElement before an instant
in time.
Note that the UsageSummaryElement whose time instant is actually at
instant (if any), is excluded from the search.
findPreviousElement in interface UsageSummaryDAOusageSummaryId - the id of the owning UsageSummaryinstant - the time instant in milliseconds
UsageSummaryElement or null
public UsageSummaryElement findNextElement(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummaryElement after an instant
in time.
Note that the UsageSummaryElement whose time instant is actually at
instant (if any), is excluded from the search.
findNextElement in interface UsageSummaryDAOusageSummaryId - the id of the owning UsageSummaryinstant - the time instant in milliseconds
UsageSummaryElement or null
public UsageSummaryElement findNextElementWithNonZeroRate(Long usageSummaryId,
long instant)
UsageSummaryDAOUsageSummaryElement 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.
findNextElementWithNonZeroRate in interface UsageSummaryDAOusageSummaryId - the id of the owning UsageSummaryinstant - the time instant in milliseconds
UsageSummaryElement or null
public void updateLastElement(UsageSummary usageSummary,
long latestElementId,
long latestElementInstant)
UsageSummaryDAOUsageSummary
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.
updateLastElement in interface UsageSummaryDAOusageSummary - the owning UsageSummarylatestElementId - the entity id for the latest elementlatestElementInstant - the time instant in millis for the latest element
public void updateTotalRate(UsageSummary usageSummary,
double totalRate)
UsageSummaryDAOUsageSummary 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.
updateTotalRate in interface UsageSummaryDAOusageSummary - the UsageSummary to updatetotalRate - the new total rate for the usage summary
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||