Package de.fzi.power.interpreter
Class ConsumptionContext
- java.lang.Object
-
- de.fzi.power.interpreter.ConsumptionContext
-
- All Implemented Interfaces:
PowerModelRegistryChangeListener
public final class ConsumptionContext extends Object implements PowerModelRegistryChangeListener
Subsumes all the required information for evaluating the power consumption of a software system.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Since the ConsumptionContext registers change listener to the referenced PowerModelRegistry it is important to call cleanUp before discarding the ConsumptionContext instance.static ConsumptionContext
createConsumptionContext(PowerBindingRepository bindingRepository, AbstractEvaluationScope initialScope, PowerModelRegistry powerModelRegistry)
Creates a consumption context.static ConsumptionContext
createConsumptionContext(PowerProvidingEntity ppe, AbstractEvaluationScope initialScope, PowerModelRegistry powerModelRegistry)
Creates a consumption context.void
distributionPowerModelChanged(AbstractDistributionPowerModelCalculator calculator, PowerProvidingEntity affectedEntity)
Method is called just before a new calculator is set for a power providing entity.org.jscience.physics.amount.Amount<javax.measure.quantity.Power>
evaluateDistributionPowerConsumption(PowerConsumingProvidingEntity powerConsumingProvidingEntity, Map<PowerConsumingEntity,org.jscience.physics.amount.Amount<javax.measure.quantity.Power>> consumers)
Evaluates the consumed power which is supplied by the given power providing entity.org.jscience.physics.amount.Amount<javax.measure.quantity.Power>
evaluateResourcePowerConsumption(AbstractPowerConsumingResource resource)
Evaluates the power consumption of a passed resource.org.jscience.physics.amount.Amount<javax.measure.quantity.Power>
evaluateStatefulResourcePowerConsumption(StatefulPowerConsumingResourceSet resource)
Evaluates the power consumption of a passed stateful resource.PowerBindingRepository
getPowerBindingRepository()
Get the PowerBindingRepository associated with the ConsumptionCotext.void
resourcePowerModelChanged(IResourcePowerModelCalculator calculator, AbstractPowerConsumingResource affectedResource)
Method is called just before a new calculator is set for a power consuming resource.
-
-
-
Method Detail
-
createConsumptionContext
public static ConsumptionContext createConsumptionContext(PowerBindingRepository bindingRepository, AbstractEvaluationScope initialScope, PowerModelRegistry powerModelRegistry)
Creates a consumption context. Attention: the creation of the consumption context registers a listener upon the powerModelRegistry. Therefore it is necessary to call cleanUp() after usage.- Parameters:
bindingRepository
- The Binding repository for which the consumption context is created.initialScope
- The initial scope for which the consumption prediction is performed.powerModelRegistry
- The registry that keeps track of the power models on a per-resource basis.- Returns:
- The newly created consumption context.
- Throws:
IllegalArgumentException
- In case any of the parameters isnull
.
-
createConsumptionContext
public static ConsumptionContext createConsumptionContext(PowerProvidingEntity ppe, AbstractEvaluationScope initialScope, PowerModelRegistry powerModelRegistry)
Creates a consumption context. Calling this method is equivalent to callingcreateConsumptionContext(ppe.getDistributionPowerAssemblyContext().getPowerBindingRepository(), initialScope, powerModelRegistry)
.
Attention: the creation of the consumption context registers a listener upon the powerModelRegistry. Therefore it is necessary to call cleanUp() after usage.- Parameters:
ppe
- The givenPowerProvidingEntity
is used to obtain thePowerBindingRepository
for the new consumption context.initialScope
- The initial scope for which the consumption prediction is performed.powerModelRegistry
- The registry that keeps track of the power models on a per-resource basis.- Returns:
- The newly created consumption context.
- See Also:
createConsumptionContext(PowerBindingRepository, AbstractEvaluationScope, PowerModelRegistry)
-
evaluateResourcePowerConsumption
public org.jscience.physics.amount.Amount<javax.measure.quantity.Power> evaluateResourcePowerConsumption(AbstractPowerConsumingResource resource)
Evaluates the power consumption of a passed resource. The consumption is evaluated in context to the current EvaluationScope.- Parameters:
resource
- The PowerConsumingResource for which the power consumption is being evaluated.- Returns:
- The power consumed by the resource.
-
evaluateStatefulResourcePowerConsumption
public org.jscience.physics.amount.Amount<javax.measure.quantity.Power> evaluateStatefulResourcePowerConsumption(StatefulPowerConsumingResourceSet resource)
Evaluates the power consumption of a passed stateful resource. The consumption is evaluated in context to the current EvaluationScope.- Parameters:
resource
- The PowerConsumingResource for which the power consumption is being evaluated.- Returns:
- The power consumed by the resource.
-
evaluateDistributionPowerConsumption
public org.jscience.physics.amount.Amount<javax.measure.quantity.Power> evaluateDistributionPowerConsumption(PowerConsumingProvidingEntity powerConsumingProvidingEntity, Map<PowerConsumingEntity,org.jscience.physics.amount.Amount<javax.measure.quantity.Power>> consumers)
Evaluates the consumed power which is supplied by the given power providing entity.- Parameters:
powerConsumingProvidingEntity
- ThePowerConsumingProvidingEntity
which supplies power to consumersconsumers
- AMap
that contains the currently consumed power of allPowerConsumingEntity
which are supplied by the given power providing entity.- Returns:
- The total power usage of the providing entity, expressed in terms of an
Amount
, according to the underlyingDistributionPowerModelSpecification
. - Throws:
IllegalArgumentException
- In case noDistributionPowerModelSpecification
(more precisely, noAbstractDistributionPowerModelCalculator
) could be found.IllegalArgumentException
- In case any of thePowerConsumingEntity
s passed in theconsumers
map is not supplied by the givenpowerConsumingProvidingEntity
.NullPointerException
- In case either of the arguments isnull
.
-
getPowerBindingRepository
public PowerBindingRepository getPowerBindingRepository()
Get the PowerBindingRepository associated with the ConsumptionCotext.- Returns:
- The ConsumptionContext for which the power consumption is being evaluated.
-
cleanUp
public void cleanUp()
Since the ConsumptionContext registers change listener to the referenced PowerModelRegistry it is important to call cleanUp before discarding the ConsumptionContext instance.
-
resourcePowerModelChanged
public void resourcePowerModelChanged(IResourcePowerModelCalculator calculator, AbstractPowerConsumingResource affectedResource)
Description copied from interface:PowerModelRegistryChangeListener
Method is called just before a new calculator is set for a power consuming resource.- Specified by:
resourcePowerModelChanged
in interfacePowerModelRegistryChangeListener
- Parameters:
calculator
- the new calculatoraffectedResource
- the affected resource
-
distributionPowerModelChanged
public void distributionPowerModelChanged(AbstractDistributionPowerModelCalculator calculator, PowerProvidingEntity affectedEntity)
Description copied from interface:PowerModelRegistryChangeListener
Method is called just before a new calculator is set for a power providing entity.- Specified by:
distributionPowerModelChanged
in interfacePowerModelRegistryChangeListener
- Parameters:
calculator
- the new calculatoraffectedEntity
- the affected resource
-
-