Class 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 Detail

      • logger

        protected static org.apache.log4j.Logger logger
    • 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 of ContextWrappers to handle the given EntryLevelSystemCall. One ContextWrapper is created for each AllocationContext 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.
      • 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).
        Overrides:
        clone in class Object
      • 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 this ContextWrapper describes plus all the containing AssemblyContexts: If the components are composite components, one AssemblyContext does not define the context within a System, you need all AssemblyContexts up to the System. The current AssemblyContext 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:
      • 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 a List of new ContextWrapper 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 a List of new ContextWrapper 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 new ContextWrapper 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 of AssemblyContexts. This list contains the AssemblyContext this ContextWrapper describes plus all the containing AssemblyContexts: If the components are composite components, one AssemblyContext does not define the context within a System, you need all AssemblyContexts up to the System.
        Parameters:
        assCtxList -
      • setCompUsgCtx

        public void setCompUsgCtx​(ComputedUsageContext compUsgCtx)
        Parameters:
        compUsgCtx -
      • setPcmInstance

        public void setPcmInstance​(PCMInstance pcmInstance)
        Parameters:
        pcmInstance -