Search in sources :

Example 1 with Correspondent

use of org.iobserve.model.correspondence.Correspondent in project iobserve-analysis by research-iobserve.

the class SimpleSequenceReference method getModel.

/**
 * Creates a reference model that contains a simple sequence of calls. Accordingly, user
 * sessions whose call sequences contain a simple call sequence are created. (RQ-1.1) It is also
 * used to evaluate the accuracy of workload specifications. Therefore, varying workload is
 * generated by random entry and exit times of the user sessions, a random number of user
 * sessions for a closed workload specification and a random mean inter arrival time for an open
 * workload specification (RQ-1.9)
 *
 * @param referenceUsageModelFileName
 *            file name of the reference model to store its result
 * @param repositoryLookupModel
 *            repository lookup model
 * @param correspondenceModel
 *            correspondence model
 * @param thinkTime
 *            of a closed workload.
 * @param isClosedWorkload
 *            decides whether a closed or an open workload is created
 * @return the reference usage model, a corresponding EntryCallSequenceModel and a reference
 *         workload
 * @throws IOException
 *             on error
 */
public static ReferenceElements getModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModel, final ICorrespondence correspondenceModel, final int thinkTime, final boolean isClosedWorkload) throws IOException {
    // Creates a random number of user sessions and random model element parameters. The user
    // sessions' behavior will be created according to the reference usage model and
    // subsequently the user sessions are used to create a usage model. The created usage model
    // is matched against the reference usage model.
    final int numberOfUsersSessions = TestHelper.getRandomInteger(200, 1);
    final int numberOfCalls = TestHelper.getRandomInteger(5, 1);
    final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfUsersSessions));
    final ReferenceElements referenceElements = new ReferenceElements();
    // In the following the reference usage model is created
    final UsageModel usageModel = UsageModelFactory.createUsageModel();
    final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
    final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
    final Start start = UsageModelFactory.createAddStartAction("", scenarioBehaviour);
    final Stop stop = UsageModelFactory.createAddStopAction("", scenarioBehaviour);
    AbstractUserAction lastAction = start;
    Optional<Correspondent> correspondent;
    // created
    for (int i = 0; i < numberOfCalls; i++) {
        if (i >= 0 && i < 5) {
            correspondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
        } else {
            throw new IllegalArgumentException("Illegal value of model element parameter");
        }
        if (correspondent.isPresent()) {
            final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent.get());
            UsageModelFactory.addUserAction(scenarioBehaviour, entryLevelSystemCall);
            UsageModelFactory.connect(lastAction, entryLevelSystemCall);
            lastAction = entryLevelSystemCall;
        }
    }
    UsageModelFactory.connect(lastAction, stop);
    // According to the reference usage model user sessions are created that exactly represent
    // the user behavior of the reference usage model. The entry and exit times are set randomly
    // to evaluate a closed workload. For the evaluation of an open workload the mean inter
    // arrival time is set randomly
    int entryTime = 0;
    int exitTime = 1;
    final int meanInterArrivalTime = TestHelper.getRandomInteger(30, 1);
    for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
        if (isClosedWorkload) {
            entryTime = TestHelper.getRandomInteger(30, 1);
            exitTime = entryTime + 1;
        } else {
            entryTime += meanInterArrivalTime;
            exitTime += meanInterArrivalTime;
        }
        for (int k = 0; k < numberOfCalls; k++) {
            EntryCallEvent entryCallEvent = null;
            if (k >= 0 && k < 5) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[k], ReferenceUsageModelBuilder.CLASS_SIGNATURE[k], String.valueOf(i), "hostname");
            } else {
                throw new IllegalArgumentException("Illegal value of model element parameter");
            }
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime = entryTime + 2;
            exitTime = exitTime + 2;
        }
    }
    // Saves the reference usage model and sets the usage model, the EntryCallSequenceModel
    // and the workload as the reference elements. Our approach is now executed with the
    // EntryCallSequenceModel and the resulting usage model can be matched against the reference
    // usage model. Alike, the by our approach calculated workload can be matched against the
    // reference workload. This is done by {@link
    // org.iobserve.analysis.userbehavior.test.WorkloadEvaluation}
    TestHelper.saveModel(usageModel, referenceUsageModelFileName);
    referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
    referenceElements.setUsageModel(usageModel);
    referenceElements.setMeanInterArrivalTime(meanInterArrivalTime + numberOfCalls * 2);
    referenceElements.setMeanConcurrentUserSessions(SimpleSequenceReference.calculateTheNumberOfConcurrentUsers(entryCallSequenceModel.getUserSessions()));
    return referenceElements;
}
Also used : EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) Start(org.palladiosimulator.pcm.usagemodel.Start) Stop(org.palladiosimulator.pcm.usagemodel.Stop) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) EntryCallSequenceModel(org.iobserve.analysis.data.EntryCallSequenceModel) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Correspondent(org.iobserve.model.correspondence.Correspondent) ReferenceElements(org.iobserve.analysis.userbehavior.ReferenceElements)

Example 2 with Correspondent

use of org.iobserve.model.correspondence.Correspondent in project iobserve-analysis by research-iobserve.

the class BranchWithinLoopReference method createBranchTransition.

/**
 * Create a branch transition.
 *
 * @param callId
 *            id of the operation class and operation signature
 * @param repositoryLookupModel
 *            usage model builder
 * @param branch
 *            pcm branch element
 * @param correspondenceModel
 *            correspondence model data
 *
 * @return returns the created branch transition or null on error
 */
private static BranchTransition createBranchTransition(final int callId, final RepositoryLookupModelProvider repositoryLookupModel, final org.palladiosimulator.pcm.usagemodel.Branch branch, final ICorrespondence correspondenceModel) {
    final BranchTransition branchTransition = UsageModelFactory.createBranchTransition(branch);
    final ScenarioBehaviour branchTransitionBehaviour = branchTransition.getBranchedBehaviour_BranchTransition();
    final Start start = UsageModelFactory.createStart("");
    UsageModelFactory.addUserAction(branchTransitionBehaviour, start);
    final Stop stop = UsageModelFactory.createStop("");
    UsageModelFactory.addUserAction(branchTransitionBehaviour, stop);
    final Optional<Correspondent> optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[callId], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[callId]);
    if (optionCorrespondent.isPresent()) {
        final Correspondent correspondent = optionCorrespondent.get();
        final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent);
        UsageModelFactory.addUserAction(branchTransitionBehaviour, entryLevelSystemCall);
        UsageModelFactory.connect(start, entryLevelSystemCall);
        UsageModelFactory.connect(entryLevelSystemCall, stop);
        return branchTransition;
    } else {
        return null;
    }
}
Also used : EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) Start(org.palladiosimulator.pcm.usagemodel.Start) Stop(org.palladiosimulator.pcm.usagemodel.Stop) BranchTransition(org.palladiosimulator.pcm.usagemodel.BranchTransition) Correspondent(org.iobserve.model.correspondence.Correspondent)

Example 3 with Correspondent

use of org.iobserve.model.correspondence.Correspondent in project iobserve-analysis by research-iobserve.

the class LoopWithinBranchReference method createBranch.

/**
 * Creates a branch and branch transitions according to the random countOfBranchTransitions.
 *
 * @param scenarioBehaviour
 * @param repositoryLookupModel
 * @param correspondenceModel
 * @param numberOfBranchTransitions
 * @param lengthOfBranchSequence
 * @param countOfLoop
 * @return
 */
private static Branch createBranch(final RepositoryLookupModelProvider repositoryLookupModel, final ScenarioBehaviour scenarioBehaviour, final ICorrespondence correspondenceModel, final int numberOfBranchTransitions, final int lengthOfBranchSequence, final int countOfLoop) {
    final Start start = UsageModelFactory.createAddStartAction("", scenarioBehaviour);
    final Branch branch = UsageModelFactory.createBranch("", scenarioBehaviour);
    final Stop stop = UsageModelFactory.createAddStopAction("", scenarioBehaviour);
    UsageModelFactory.connect(start, branch);
    UsageModelFactory.connect(branch, stop);
    AbstractUserAction lastAction = start;
    // For each branch transition its calls are added to the branch transition
    for (int i = 0; i < numberOfBranchTransitions; i++) {
        final BranchTransition branchTransition = UsageModelFactory.createBranchTransition(branch);
        final ScenarioBehaviour branchTransitionBehaviour = branchTransition.getBranchedBehaviour_BranchTransition();
        final Start startBranchTransition = UsageModelFactory.createStart("");
        UsageModelFactory.addUserAction(branchTransitionBehaviour, startBranchTransition);
        final Stop stopBranchTransition = UsageModelFactory.createStop("");
        UsageModelFactory.addUserAction(branchTransitionBehaviour, stopBranchTransition);
        lastAction = startBranchTransition;
        if (i >= 0 && i < 3) {
            final Optional<Correspondent> optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
            if (optionCorrespondent.isPresent()) {
                final Correspondent correspondent = optionCorrespondent.get();
                final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent);
                UsageModelFactory.addUserAction(branchTransitionBehaviour, entryLevelSystemCall);
                UsageModelFactory.connect(lastAction, entryLevelSystemCall);
                lastAction = entryLevelSystemCall;
            }
        } else {
            throw new IllegalArgumentException("Illegal value of model element parameter");
        }
        if (lengthOfBranchSequence == 2) {
            final Optional<Correspondent> optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4]);
            if (optionCorrespondent.isPresent()) {
                final Correspondent correspondent = optionCorrespondent.get();
                final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent);
                UsageModelFactory.addUserAction(branchTransitionBehaviour, entryLevelSystemCall);
                UsageModelFactory.connect(lastAction, entryLevelSystemCall);
                lastAction = entryLevelSystemCall;
            }
        }
        // Within the branch transition a loop element is created
        final Loop loop = UsageModelFactory.createLoop("", branchTransitionBehaviour);
        UsageModelFactory.connect(lastAction, loop);
        final PCMRandomVariable pcmLoop2Iteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
        pcmLoop2Iteration.setSpecification(String.valueOf(countOfLoop));
        loop.setLoopIteration_Loop(pcmLoop2Iteration);
        final Start loopStart = UsageModelFactory.createStart("");
        UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStart);
        final Stop loopStop = UsageModelFactory.createStop("");
        UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStop);
        lastAction = loopStart;
        // The calls that are iterated are added to the loop
        final Optional<Correspondent> optionCorrespondent;
        switch(i) {
            case 0:
                optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1]);
                break;
            case 1:
                optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2]);
                break;
            case 2:
                optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0]);
                break;
            default:
                throw new IllegalArgumentException("Illegal value of model element parameter");
        }
        if (optionCorrespondent.isPresent()) {
            final Correspondent correspondent = optionCorrespondent.get();
            final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent);
            UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), entryLevelSystemCall);
            UsageModelFactory.connect(lastAction, entryLevelSystemCall);
            lastAction = entryLevelSystemCall;
        }
        UsageModelFactory.connect(lastAction, loopStop);
        UsageModelFactory.connect(loop, stopBranchTransition);
    }
    return branch;
}
Also used : Loop(org.palladiosimulator.pcm.usagemodel.Loop) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) Start(org.palladiosimulator.pcm.usagemodel.Start) Stop(org.palladiosimulator.pcm.usagemodel.Stop) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) Branch(org.palladiosimulator.pcm.usagemodel.Branch) BranchTransition(org.palladiosimulator.pcm.usagemodel.BranchTransition) Correspondent(org.iobserve.model.correspondence.Correspondent)

Example 4 with Correspondent

use of org.iobserve.model.correspondence.Correspondent in project iobserve-analysis by research-iobserve.

the class OverlappingIterationReference method createEntryLevelSystemCall.

/**
 * Create and link a user action into a sequence.
 *
 * @param repositoryLookupModelProvider
 *            repository model provider
 * @param correspondenceModel
 *            correspondence model
 * @param index
 *            correspondent index for string arrays
 * @param lastAction
 *            previous action
 * @param correspondent
 *            correspondent element
 * @param scenarioBehaviour
 *            behavior
 *
 * @return return this call
 */
private static AbstractUserAction createEntryLevelSystemCall(final RepositoryLookupModelProvider repositoryLookupModelProvider, final ICorrespondence correspondenceModel, final int index, final AbstractUserAction lastAction, final ScenarioBehaviour scenarioBehaviour) {
    final Optional<Correspondent> correspondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[index], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[index]);
    if (correspondent.isPresent()) {
        final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondent.get());
        UsageModelFactory.addUserAction(scenarioBehaviour, entryLevelSystemCall);
        UsageModelFactory.connect(lastAction, entryLevelSystemCall);
        return entryLevelSystemCall;
    } else {
        return lastAction;
    }
}
Also used : EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) Correspondent(org.iobserve.model.correspondence.Correspondent)

Example 5 with Correspondent

use of org.iobserve.model.correspondence.Correspondent in project iobserve-analysis by research-iobserve.

the class DeployPCMMapper method servletMapper.

private void servletMapper(final ServletDeployedEvent event) {
    final String service = event.getService();
    final String context = event.getContext();
    // build the containerAllocationEvent
    final String urlContext = context.replaceAll("\\.", "/");
    final String url = "http://" + service + '/' + urlContext;
    final Correspondent correspondent = this.correspondence.getCorrespondent(context).get();
    if (correspondent != null) {
        if (event instanceof Privacy_ServletDeployedEvent) {
            this.outputPort.send(new PCMDeployedEvent(service, correspondent, url, ((Privacy_ServletDeployedEvent) event).getCountryCode()));
        } else {
            this.outputPort.send(new PCMDeployedEvent(service, correspondent, url, (short) 0));
        }
    } else {
        DeployPCMMapper.LOGGER.info("No correspondent found for {}.", service);
    }
}
Also used : Privacy_ServletDeployedEvent(org.iobserve.common.record.Privacy_ServletDeployedEvent) PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) Correspondent(org.iobserve.model.correspondence.Correspondent)

Aggregations

Correspondent (org.iobserve.model.correspondence.Correspondent)14 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)10 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)9 Start (org.palladiosimulator.pcm.usagemodel.Start)9 Stop (org.palladiosimulator.pcm.usagemodel.Stop)9 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)7 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)6 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)6 EntryCallSequenceModel (org.iobserve.analysis.data.EntryCallSequenceModel)5 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)5 Loop (org.palladiosimulator.pcm.usagemodel.Loop)5 ReferenceElements (org.iobserve.analysis.userbehavior.ReferenceElements)4 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)4 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)4 PCMDeployedEvent (org.iobserve.analysis.deployment.data.PCMDeployedEvent)2 PCMUndeployedEvent (org.iobserve.analysis.deployment.data.PCMUndeployedEvent)2 Branch (org.palladiosimulator.pcm.usagemodel.Branch)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1