Class ContextWrapper
- java.lang.Object
-
- org.palladiosimulator.solver.transformations.ContextWrapper
-
- All Implemented Interfaces:
Cloneable
public class ContextWrapper extends Object implements Cloneable
For convenient implementation of model transformations in Java from PCM instances to performance models, the DS provides a so-called ContextWrapper. It hides all specified and computed context models from the transformation and assists the traversal of a PCM instance. A transformation can instantiate a new ContextWrapper upon visiting an EntryLevelSystemCall or ExternalCallAction as it is specific for each RDSEFF call. Transformations must instantiate a ContextWrapper initially when visiting the first EntryLevelSystemCall by calling its constructor and passing a reference to the current PCM instance, which already includes the specified contexts as well as the computed contexts from a former run of the DS. Thus, from an EntryLevelSystemCall and the given PCM instance, the ContextWrapper can retrieve the called assembly context, allocation context, computed usage context, and computed allocation context internally. The ContextWrapper also includes functions to retrieve the RDSEFF called by an EntryLevelSystemCall or ExternalCallAction, which a transformation needs to continue traversing a PCM instance. These functions (getNextSEFF) hide the context-dependent traversal through the model via delegation and assembly connectors from the transformation. When a model transformation visits RDSEFF actions, it may call the Context- Wrapper for performance annotations, such as branch probabilities, loop iteration numbers, or timing values. This information is not contained in the parameterized RDSEFF, but only in the computed contexts. The ContextWrapper retrieves the information from the computed contexts given for example an AbstractBranchTransition or ParametricResourceDemand. TODO: This class is way too big and needs refactoring. For many methods, it would make sense to re-write them so that they only depend on their input parameters (and not on the state of the object). This should make it much easier to understand the code. Moreover, context-independent methods can be outsourced into helper classes.
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.log4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description ContextWrapper(PCMInstance pcmInstance)
Creates an empty ContextWrapper instance based only on the given PCM model instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Copies this ContextWrapper.org.palladiosimulator.pcm.allocation.AllocationContext
getAllCtx()
org.palladiosimulator.pcm.core.composition.AssemblyContext
getAssCtx()
List<org.palladiosimulator.pcm.core.composition.AssemblyContext>
getAssCtxList()
Double
getBranchProbability(org.palladiosimulator.pcm.seff.AbstractBranchTransition abt)
ComputedAllocationContext
getCompAllCtx()
ComputedUsageContext
getCompUsgCtx()
org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification
getConcreteLinkingResource(org.palladiosimulator.pcm.seff.ExternalCallAction eca, org.palladiosimulator.pcm.allocation.AllocationContext targetAllocationContext)
org.palladiosimulator.pcm.repository.PassiveResource
getConcretePassiveResource(org.palladiosimulator.pcm.seff.AcquireAction aa)
org.palladiosimulator.pcm.repository.PassiveResource
getConcretePassiveResource(org.palladiosimulator.pcm.seff.ReleaseAction ra)
org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification
getConcreteProcessingResource(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
List<ContextWrapper>
getContextWrapperFor(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
FIXME: This method changes the current ContextWrapper this, but returns aList
of newContextWrapper
instances created based on this one.static List<ContextWrapper>
getContextWrapperFor(org.palladiosimulator.pcm.seff.ExternalCallAction eca, ComputedUsageContext cuc, ComputedAllocationContext cac, ContextWrapper oldContextWrapper)
Attention: This constructor modifies the passed ContextWrapper!List<ContextWrapper>
getContextWrapperFor(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall elsa)
FIXME: This method changes the current ContextWrapper this, but returns aList
of newContextWrapper
instances created based on this one.static List<ContextWrapper>
getContextWrapperFor(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall elsa, PCMInstance pcm)
Creates a List ofContextWrapper
s to handle the givenEntryLevelSystemCall
.de.uka.ipd.sdq.probfunction.math.ManagedPDF
getDelayOnLinkingResource(org.palladiosimulator.pcm.seff.ExternalCallAction eca, org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification clrs)
List<org.palladiosimulator.pcm.reliability.ExternalFailureOccurrenceDescription>
getFailureOccurrenceDescriptionsForSystemExternalCall(org.palladiosimulator.pcm.seff.ExternalCallAction externalCallAction)
Retrieves the list of FailureOccurrenceDescriptions for the given system external call.boolean
getIsOriginalPDFFor(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
de.uka.ipd.sdq.probfunction.math.ManagedPMF
getLoopIterations(org.palladiosimulator.pcm.seff.AbstractLoopAction ala)
Double
getMeanTimeConsumption(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
Gets the mean time demanded by prd on its processor in this context.Double
getMeanTotalInputParameterBytesize(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
Double
getMeanTotalOutputParameterBytesize(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
org.palladiosimulator.pcm.seff.ServiceEffectSpecification
getNextSEFF(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
Finds the next SEFF for a given external call action and its referenced signature.org.palladiosimulator.pcm.seff.ServiceEffectSpecification
getNextSEFF(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall elsc)
PCMInstance
getPcmInstance()
de.uka.ipd.sdq.probfunction.math.ManagedPDF
getTimeConsumptionAsPDF(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
Gets the time demanded by prd on its processor in this context.String
getTimeConsumptionSpecification(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
void
setAllCtx(org.palladiosimulator.pcm.allocation.AllocationContext allCtx)
void
setAssCtxList(List<org.palladiosimulator.pcm.core.composition.AssemblyContext> assCtxList)
Set the internal list ofAssemblyContext
s.void
setCompAllCtx(ComputedAllocationContext compAllCtx)
void
setCompUsgCtx(ComputedUsageContext compUsgCtx)
void
setPcmInstance(PCMInstance pcmInstance)
-
-
-
Constructor Detail
-
ContextWrapper
public ContextWrapper(PCMInstance pcmInstance)
Creates an empty ContextWrapper instance based only on the given PCM model instance.- Parameters:
pcmInstance
- the PCM model instance
-
-
Method Detail
-
getContextWrapperFor
public static List<ContextWrapper> getContextWrapperFor(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall elsa, PCMInstance pcm)
Creates a List ofContextWrapper
s to handle the givenEntryLevelSystemCall
. OneContextWrapper
is created for eachAllocationContext
the receiving component is allocated to. Thus, callers must handle multiple component allocation instances of the called component. One ContextWrapper then handles the context of that particular component instance (i.e. one replica) These are new ContextWrappers without any previous context information.
-
getContextWrapperFor
public static List<ContextWrapper> getContextWrapperFor(org.palladiosimulator.pcm.seff.ExternalCallAction eca, ComputedUsageContext cuc, ComputedAllocationContext cac, ContextWrapper oldContextWrapper)
Attention: This constructor modifies the passed ContextWrapper!- Parameters:
eca
-cuc
-cac
-oldContextWrapper
- IS MODIFIED!
-
clone
public Object clone()
Copies this ContextWrapper. Sets references to the PCM model elements and the computed context objects, so that the context can be shared (e.g. retrieving branch probabilities of earlier context wrapper traversals).
-
getAllCtx
public org.palladiosimulator.pcm.allocation.AllocationContext getAllCtx()
- Returns:
-
getAssCtx
public org.palladiosimulator.pcm.core.composition.AssemblyContext getAssCtx()
- Returns:
-
getAssCtxList
public List<org.palladiosimulator.pcm.core.composition.AssemblyContext> getAssCtxList()
- Returns:
- The
AssemblyContext
thisContextWrapper
describes plus all the containingAssemblyContext
s: If the components are composite components, oneAssemblyContext
does not define the context within aSystem
, you need allAssemblyContext
s up to theSystem
. The currentAssemblyContext
is the last in the list, the previous one is its "parent", and so on.
-
getBranchProbability
public Double getBranchProbability(org.palladiosimulator.pcm.seff.AbstractBranchTransition abt)
- Parameters:
abt
-- Returns:
-
getCompAllCtx
public ComputedAllocationContext getCompAllCtx()
- Returns:
-
getCompUsgCtx
public ComputedUsageContext getCompUsgCtx()
- Returns:
-
getConcreteLinkingResource
public org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification getConcreteLinkingResource(org.palladiosimulator.pcm.seff.ExternalCallAction eca, org.palladiosimulator.pcm.allocation.AllocationContext targetAllocationContext)
- Parameters:
eca
-targetAllocationContext
-- Returns:
-
getConcretePassiveResource
public org.palladiosimulator.pcm.repository.PassiveResource getConcretePassiveResource(org.palladiosimulator.pcm.seff.AcquireAction aa)
- Parameters:
aa
-- Returns:
-
getConcretePassiveResource
public org.palladiosimulator.pcm.repository.PassiveResource getConcretePassiveResource(org.palladiosimulator.pcm.seff.ReleaseAction ra)
- Parameters:
ra
-- Returns:
-
getConcreteProcessingResource
public org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification getConcreteProcessingResource(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
- Parameters:
prd
-- Returns:
-
getContextWrapperFor
public List<ContextWrapper> getContextWrapperFor(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall elsa)
FIXME: This method changes the current ContextWrapper this, but returns aList
of newContextWrapper
instances created based on this one. It needs to use the current context in order to retain information such as branch probabilities- Parameters:
elsa
-- Returns:
-
getContextWrapperFor
public List<ContextWrapper> getContextWrapperFor(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
FIXME: This method changes the current ContextWrapper this, but returns aList
of newContextWrapper
instances created based on this one. It needs to use the current context in order to retain information such as branch probabilities- Parameters:
eca
-- Returns:
- A
List
of newContextWrapper
instances, but also changes this one.
-
getDelayOnLinkingResource
public de.uka.ipd.sdq.probfunction.math.ManagedPDF getDelayOnLinkingResource(org.palladiosimulator.pcm.seff.ExternalCallAction eca, org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification clrs)
- Parameters:
eca
-clrs
-- Returns:
-
getFailureOccurrenceDescriptionsForSystemExternalCall
public List<org.palladiosimulator.pcm.reliability.ExternalFailureOccurrenceDescription> getFailureOccurrenceDescriptionsForSystemExternalCall(org.palladiosimulator.pcm.seff.ExternalCallAction externalCallAction)
Retrieves the list of FailureOccurrenceDescriptions for the given system external call. The FailureOccurrenceDescriptions may be given to the system as a SpecifiedReliabilityAnnotation. If no SpecifiedReliabilityAnnotation for the system external call is found, an empty list is returned.- Parameters:
externalCallAction
- the system externall call- Returns:
- the list of FailureOccurrenceDescriptions
-
getIsOriginalPDFFor
public boolean getIsOriginalPDFFor(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
- Parameters:
prd
-- Returns:
-
getLoopIterations
public de.uka.ipd.sdq.probfunction.math.ManagedPMF getLoopIterations(org.palladiosimulator.pcm.seff.AbstractLoopAction ala)
- Parameters:
ala
-- Returns:
-
getMeanTimeConsumption
public Double getMeanTimeConsumption(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
Gets the mean time demanded by prd on its processor in this context. Note that the processing rate has already been taken into account here.- Parameters:
prd
-- Returns:
- A Double representing the mean time demanded by prd
-
getMeanTotalInputParameterBytesize
public Double getMeanTotalInputParameterBytesize(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
- Parameters:
eca
-- Returns:
-
getMeanTotalOutputParameterBytesize
public Double getMeanTotalOutputParameterBytesize(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
- Parameters:
eca
-- Returns:
-
getNextSEFF
public org.palladiosimulator.pcm.seff.ServiceEffectSpecification getNextSEFF(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall elsc)
- Parameters:
elsc
-- Returns:
-
getNextSEFF
public org.palladiosimulator.pcm.seff.ServiceEffectSpecification getNextSEFF(org.palladiosimulator.pcm.seff.ExternalCallAction eca)
Finds the next SEFF for a given external call action and its referenced signature. Uses the current assembly context ids from the context wrapper as reference.- Parameters:
eca
-- Returns:
-
getPcmInstance
public PCMInstance getPcmInstance()
- Returns:
-
getTimeConsumptionAsPDF
public de.uka.ipd.sdq.probfunction.math.ManagedPDF getTimeConsumptionAsPDF(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
Gets the time demanded by prd on its processor in this context. Note that the processing rate has already been taken into account here.- Parameters:
prd
-- Returns:
- A ManagedPDF representing the time demanded by prd
-
getTimeConsumptionSpecification
public String getTimeConsumptionSpecification(org.palladiosimulator.pcm.seff.seff_performance.ParametricResourceDemand prd)
- Parameters:
prd
-- Returns:
-
setAllCtx
public void setAllCtx(org.palladiosimulator.pcm.allocation.AllocationContext allCtx)
- Parameters:
allCtx
-
-
setAssCtxList
public void setAssCtxList(List<org.palladiosimulator.pcm.core.composition.AssemblyContext> assCtxList)
Set the internal list ofAssemblyContext
s. This list contains theAssemblyContext
thisContextWrapper
describes plus all the containingAssemblyContext
s: If the components are composite components, oneAssemblyContext
does not define the context within aSystem
, you need allAssemblyContext
s up to theSystem
.- Parameters:
assCtxList
-
-
setCompAllCtx
public void setCompAllCtx(ComputedAllocationContext compAllCtx)
- Parameters:
compAllCtx
-
-
setCompUsgCtx
public void setCompUsgCtx(ComputedUsageContext compUsgCtx)
- Parameters:
compUsgCtx
-
-
setPcmInstance
public void setPcmInstance(PCMInstance pcmInstance)
- Parameters:
pcmInstance
-
-
-