uk.ac.soton.itinnovation.grid.service.sla.bizfacade
Class UsageSummaryFacadeImpl

java.lang.Object
  extended by uk.ac.soton.itinnovation.grid.service.sla.bizfacade.UsageSummaryFacadeImpl
All Implemented Interfaces:
UsageSummaryFacade

public class UsageSummaryFacadeImpl
extends Object
implements UsageSummaryFacade


Field Summary
 
Fields inherited from interface uk.ac.soton.itinnovation.grid.service.sla.bizfacade.UsageSummaryFacade
USAGE_SUMMARY_CREATION_LOCK
 
Constructor Summary
UsageSummaryFacadeImpl()
           
 
Method Summary
protected  void addActivityCumulativeUsageReport(UsageSummary usageSummary, UsageReport report)
           
protected  void addActivityInstantUsageReport(UsageSummary usageSummary, UsageReport report)
           
protected  void addActivityRateReport(UsageSummary usageSummary, UsageReport report)
           
 void addActivityUsageReport(Long usageSummaryId, UsageReport report)
          Add a UsageReport to a usage summary uniquely identified by usageSummaryId.
protected  UsageSummaryElement addElementForInstantUsageReport(UsageSummary usageSummary, long instant, double usageDelta)
           
 UsageSummaryElement addElementForRateReport(UsageSummaryElement element, UsageSummaryElement prevEl, double prevRate, UsageSummary usageSummary, double rateDelta)
           
protected  void addInstantUsageToElementAndLaterElements(UsageSummaryElement element, double deltaUsage)
           
 void addRate(Long usageSummaryId, long instant, double rateDelta)
          This can be used to add a rate directly to a UsageSummary at a particular instant.
protected  Long createUsageSummary(ResourceWithUsageByMetric res, Long parentUsageSummaryId, Metric metric)
           
 Map<ResourceAndMetric,Long> getOrCreateUsageSummaries(Set<ResourceAndMetric> resourceAndMetrics, Map<ResourceAndMetric,Throwable> errors)
          Get or create a UsageSummary instance, as required, for each of the ResourceWithMetric pairs in the resourceAndMetrics set.
 Long getOrCreateUsageSummary(Long resourceEntityId, Metric metric)
          Get or create a UsageSummary instance, as required.
 ResourceWithUsageByMetricDAO getResDao()
           
 UsageSummaryDAO getUsDao()
           
 UsageSummaryElementDAO getUseDao()
           
 void setResDao(ResourceWithUsageByMetricDAO resDao)
           
 void setUsDao(UsageSummaryDAO usDao)
           
 void setUseDao(UsageSummaryElementDAO useDao)
           
protected  void updateRateDependentUsageOnLaterElements(UsageSummaryElement prevElement, UsageSummaryElement currentElement, double prevElRate)
          This method updates rate-dependent usage on later elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UsageSummaryFacadeImpl

public UsageSummaryFacadeImpl()
Method Detail

getUsDao

public UsageSummaryDAO getUsDao()

setUsDao

public void setUsDao(UsageSummaryDAO usDao)

getUseDao

public UsageSummaryElementDAO getUseDao()

setUseDao

public void setUseDao(UsageSummaryElementDAO useDao)

getResDao

public ResourceWithUsageByMetricDAO getResDao()

setResDao

public void setResDao(ResourceWithUsageByMetricDAO resDao)

getOrCreateUsageSummary

public Long getOrCreateUsageSummary(Long resourceEntityId,
                                    Metric metric)
Description copied from interface: UsageSummaryFacade
Get or create a UsageSummary instance, as required.

Note that this method understands the ResourcePool-SLA-Activity hierarchy and will create a UsageSummary for each ancestor resource where appropriate.

Specified by:
getOrCreateUsageSummary in interface UsageSummaryFacade
Parameters:
resourceEntityId - the entity ID for the resource
metric - the metric
Returns:
the entity id of the UsageSummary

getOrCreateUsageSummaries

public Map<ResourceAndMetric,Long> getOrCreateUsageSummaries(Set<ResourceAndMetric> resourceAndMetrics,
                                                             Map<ResourceAndMetric,Throwable> errors)
Description copied from interface: UsageSummaryFacade
Get or create a UsageSummary instance, as required, for each of the ResourceWithMetric pairs in the resourceAndMetrics set.

Note that this method understands the ResourcePool-SLA-Activity hierarchy and gets or creates a UsageSummary for each ancestor resource also.

Therefore, if an Activity and a Metric are passed as a ResourceAndMetric, three UsageSummarys will be retrieved or created: one each for the Activity, its parent SLA, and the SLAs parent ResourcePool's usagePool.

This method does not throw an exception if there is a ResourceAndMetric passed in the resourceAndMetrics argument for which there is no corresponding resource in the database. In this case, there will be no corresponding value in the returned Map.

Specified by:
getOrCreateUsageSummaries in interface UsageSummaryFacade
Parameters:
resourceAndMetrics - the list of ResourceWithMetric pairs.
errors - Map of ResourceAndMetric to Throwable. If errors are generated when getting or retrieving a UsageSummary and entry is added to the map. This allows processing of other elements in the list to continue.
Returns:
map of ResourceAndMetric to UsageSummaryId:Long

createUsageSummary

protected Long createUsageSummary(ResourceWithUsageByMetric res,
                                  Long parentUsageSummaryId,
                                  Metric metric)

addActivityUsageReport

public void addActivityUsageReport(Long usageSummaryId,
                                   UsageReport report)
Description copied from interface: UsageSummaryFacade
Add a UsageReport to a usage summary uniquely identified by usageSummaryId.

Note that this method understands the ResourcePool-SLA-Activity hierarchy and adds the UsageReport for each ancestor resource also.

Specified by:
addActivityUsageReport in interface UsageSummaryFacade
Parameters:
usageSummaryId - the ID for the UsageSummary
report - the usage report to add

addRate

public void addRate(Long usageSummaryId,
                    long instant,
                    double rateDelta)
Description copied from interface: UsageSummaryFacade
This can be used to add a rate directly to a UsageSummary at a particular instant. The rate delta will also be added to parent UsageSummarys.

Currently, this is used when creating an SLA and associating it with a ResourcePool's allocation pool only.

Specified by:
addRate in interface UsageSummaryFacade

addActivityRateReport

protected void addActivityRateReport(UsageSummary usageSummary,
                                     UsageReport report)

addActivityInstantUsageReport

protected void addActivityInstantUsageReport(UsageSummary usageSummary,
                                             UsageReport report)

addElementForInstantUsageReport

protected UsageSummaryElement addElementForInstantUsageReport(UsageSummary usageSummary,
                                                              long instant,
                                                              double usageDelta)

addInstantUsageToElementAndLaterElements

protected void addInstantUsageToElementAndLaterElements(UsageSummaryElement element,
                                                        double deltaUsage)

addActivityCumulativeUsageReport

protected void addActivityCumulativeUsageReport(UsageSummary usageSummary,
                                                UsageReport report)

addElementForRateReport

public UsageSummaryElement addElementForRateReport(UsageSummaryElement element,
                                                   UsageSummaryElement prevEl,
                                                   double prevRate,
                                                   UsageSummary usageSummary,
                                                   double rateDelta)

updateRateDependentUsageOnLaterElements

protected void updateRateDependentUsageOnLaterElements(UsageSummaryElement prevElement,
                                                       UsageSummaryElement currentElement,
                                                       double prevElRate)
This method updates rate-dependent usage on later elements. It calculates the usage from the total rate at the previous element, the difference in time between the previous element and the current element, and the total usage at the previous element. This method does not take into account usage from instant usage reports. This is a separate component of the usage and is taken into account elsewhere.

Parameters:
prevElement - the previous element. This is the newly inserted element on the first round
currentElement - the next element (this can be null). If null it will be discovered.
prevElRate - the absolute rate at prevElement


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