Search in sources :

Example 21 with EntryCallEvent

use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.

the class ClusteringEvaluation method createCallSequencesForUserGroupStoreManager.

/**
 * Behavior Model of user group Store Manager. It creates for each user session a random user
 * behavior according to the BehaviorModel it describes
 *
 * @param userSessions
 */
private void createCallSequencesForUserGroupStoreManager(final List<UserSession> userSessions) {
    EntryCallEvent entryCallEvent;
    for (final UserSession userSession : userSessions) {
        int entryTime = this.getRandomInteger(30, 1);
        int exitTime = entryTime + 1;
        entryCallEvent = new EntryCallEvent(entryTime, exitTime, "login", "class", "2", "hostname");
        userSession.add(entryCallEvent, true);
        entryTime += 2;
        exitTime += 2;
        double callDecisioner = this.getRandomDouble(1, 0);
        if (callDecisioner <= 0.5) {
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, "changePrice", "class", "2", "hostname");
            userSession.add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
        } else {
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, "orderProduct", "class", "2", "hostname");
            userSession.add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
        }
        while (!entryCallEvent.getOperationSignature().equals("commit")) {
            callDecisioner = this.getRandomDouble(1, 0);
            if (entryCallEvent.getOperationSignature().equals("changePrice") && callDecisioner <= 0.3) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "changePrice", "class", "2", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("changePrice") && callDecisioner > 0.3 && callDecisioner <= 0.6) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "orderProduct", "class", "2", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("changePrice") && callDecisioner > 0.6) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "commit", "class", "2", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("orderProduct") && callDecisioner <= 0.3) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "changePrice", "class", "2", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("orderProduct") && callDecisioner > 0.3 && callDecisioner <= 0.6) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "orderProduct", "class", "2", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("orderProduct") && callDecisioner > 0.6) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "commit", "class", "2", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
        }
        entryCallEvent = new EntryCallEvent(entryTime, exitTime, "logout", "class", "2", "hostname");
        userSession.add(entryCallEvent, true);
    }
}
Also used : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession)

Example 22 with EntryCallEvent

use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.

the class SimpleLoopReference method getModel.

/**
 * Creates a reference model that contains a loop element. Accordingly, user sessions whose call
 * sequences contain iterated calls are created.(RQ-1.3)
 *
 * @param referenceUsageModelFileName
 *            reference usage model file name
 * @param repositoryLookupModelProvider
 *            repository model provider
 * @param correspondenceModel
 *            correspondence model
 *
 * @return the reference usage model and a corresponding EntryCallSequenceModel
 * @throws IOException
 *             on error
 */
public static ReferenceElements getModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModelProvider, final ICorrespondence correspondenceModel) throws IOException {
    // Create 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 numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 1);
    final int loopCount = TestHelper.getRandomInteger(5, 2);
    final int numberOfIteratedCalls = TestHelper.getRandomInteger(5, 1);
    final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
    final ReferenceElements referenceElements = new ReferenceElements();
    // In the following the reference usage model is created
    AbstractUserAction lastAction;
    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);
    // A loop is created and the loop count is set
    final Loop loop = UsageModelFactory.createLoop("", scenarioBehaviour);
    UsageModelFactory.connect(start, loop);
    final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
    pcmLoopIteration.setSpecification(String.valueOf(loopCount));
    loop.setLoopIteration_Loop(pcmLoopIteration);
    UsageModelFactory.connect(loop, stop);
    // The EntryLevelSystemCalls that are iterated are added to the loop element
    final Start loopStart = UsageModelFactory.createAddStartAction("", loop.getBodyBehaviour_Loop());
    final Stop loopStop = UsageModelFactory.createAddStopAction("", loop.getBodyBehaviour_Loop());
    lastAction = loopStart;
    Optional<Correspondent> optionCorrespondent;
    // iterated calls to the loop
    for (int i = 0; i < numberOfIteratedCalls; i++) {
        if (i >= 0 && i < 5) {
            optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
        } else {
            throw new IllegalArgumentException("Illegal value of model element parameter");
        }
        if (optionCorrespondent.isPresent()) {
            final Correspondent correspondent = optionCorrespondent.get();
            final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondent);
            UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), entryLevelSystemCall);
            UsageModelFactory.connect(lastAction, entryLevelSystemCall);
            lastAction = entryLevelSystemCall;
        }
    }
    UsageModelFactory.connect(lastAction, loopStop);
    // 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 enable that the
    // calls within the user sessions are ordered according to the reference usage model
    int entryTime = 1;
    int exitTime = 2;
    for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
        entryTime = 1;
        exitTime = 2;
        // number of iterated calls
        for (int k = 0; k < loopCount; k++) {
            for (int j = 0; j < numberOfIteratedCalls; j++) {
                EntryCallEvent entryCallEvent = null;
                if (j >= 0 && j < 5) {
                    entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[j], ReferenceUsageModelBuilder.CLASS_SIGNATURE[j], 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 and the EntryCallSequenceModel
    // 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
    TestHelper.saveModel(usageModel, referenceUsageModelFileName);
    referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
    referenceElements.setUsageModel(usageModel);
    return referenceElements;
}
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) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) EntryCallSequenceModel(org.iobserve.analysis.data.EntryCallSequenceModel) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable) 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)

Aggregations

EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)22 UserSession (org.iobserve.analysis.session.data.UserSession)8 EntryCallSequenceModel (org.iobserve.analysis.data.EntryCallSequenceModel)6 ArrayList (java.util.ArrayList)5 ReferenceElements (org.iobserve.analysis.userbehavior.ReferenceElements)5 Correspondent (org.iobserve.model.correspondence.Correspondent)4 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)4 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)4 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)4 Start (org.palladiosimulator.pcm.usagemodel.Start)4 Stop (org.palladiosimulator.pcm.usagemodel.Stop)4 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)4 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)4 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)3 Loop (org.palladiosimulator.pcm.usagemodel.Loop)3 HashMap (java.util.HashMap)1 List (java.util.List)1 BehaviorModelTable (org.iobserve.analysis.clustering.filter.models.BehaviorModelTable)1 Branch (org.iobserve.analysis.userbehavior.data.Branch)1 BranchModel (org.iobserve.analysis.userbehavior.data.BranchModel)1