Search in sources :

Example 31 with EntryCallEvent

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

the class BranchModelCreator method createCallBranchModel.

/**
 * It creates a BranchModel from an EntryCallSequenceModel. At that the single sequences are
 * aggregated to a tree-like structure: Equal sequences are summarized to one sequence,
 * alternative sequences are represented via branches.
 *
 * @param entryCallSequenceModel
 *            whose call sequences are aggregated to a coherent CallBranchModel
 * @return a BranchModel corresponding to the passed EntryCallSequenceModel
 */
public BranchModel createCallBranchModel(final EntryCallSequenceModel entryCallSequenceModel) {
    // Sets the user group's specific workload intensity and likelihood
    final BranchModel branchModel = new BranchModel(entryCallSequenceModel.getWorkloadIntensity(), entryCallSequenceModel.getLikelihoodOfUserGroup());
    final List<UserSession> userSessions = entryCallSequenceModel.getUserSessions();
    // The initial branch that contains the root node
    // Every sequence passes this branch -> likelihood of reaching this branch is 1
    final Branch rootBranch = new Branch();
    rootBranch.setBranchLikelihood(1);
    rootBranch.setBranchId(1);
    rootBranch.setTreeLevel(0);
    // Descending sort by call sequence length
    Collections.sort(userSessions, BranchModelCreator.SORT_USER_SESSION_BY_CALL_SEQUENCE_SIZE);
    // Initializes the root sequence with the longest call sequence
    this.setBranchSequence(rootBranch, userSessions.get(0).getEvents(), 0);
    int numberOfBranches = 1;
    // loops over all userSession without the first user session that initialized the rootBranch
    for (int j = 1; j < userSessions.size(); j++) {
        final UserSession userSession = userSessions.get(j);
        // The branchGuide guides through the tree structure. It determines the recent regarded
        // branch
        final List<Integer> branchGuide = new ArrayList<>();
        // The position states the recent position within the branch sequence
        int positionInBranch = 0;
        for (int i = 0; i <= userSession.getEvents().size(); i++) {
            // Determines which branch is currently examined
            final Branch examinedBranch = this.getExaminedBranch(branchGuide, rootBranch);
            if (i < userSession.getEvents().size()) {
                final EntryCallEvent callEvent = userSession.getEvents().get(i);
                // currently examined branch
                if (this.checkPositionMatchInBranch(callEvent, examinedBranch, positionInBranch)) {
                    this.incrementCountOfBranchElement(examinedBranch, positionInBranch);
                    positionInBranch++;
                    continue;
                }
                // a child branch
                if (this.isPositionLastElementInBranchSequence(examinedBranch, positionInBranch)) {
                    final int indexOfMatchingChildBranch = this.getIndexOfMatchingChildBranch(callEvent, examinedBranch);
                    if (indexOfMatchingChildBranch > -1) {
                        // Continue with the same call event but switching to the new branch
                        branchGuide.add(indexOfMatchingChildBranch);
                        // NOCS
                        i--;
                        positionInBranch = 0;
                        continue;
                    }
                }
                // No match could be found --> Split branch into child branches
                numberOfBranches = this.splitBranch(examinedBranch, positionInBranch, numberOfBranches, false, userSession, i);
                break;
            } else {
                // End of sequence -> looking for an exit element
                if (this.checkIfBranchSequenceTerminates(examinedBranch, positionInBranch)) {
                    this.incrementCountOfBranchElement(examinedBranch, positionInBranch);
                    break;
                }
                // Checks if there is an exit branch
                if (this.isPositionLastElementInBranchSequence(examinedBranch, positionInBranch)) {
                    final int indexOfMatchingChildBranch = this.getIndexOfMatchingExitBranch(examinedBranch);
                    if (indexOfMatchingChildBranch > -1) {
                        // Iterate the exit state adding but switching to the new branch
                        branchGuide.add(indexOfMatchingChildBranch);
                        // NOCS
                        i--;
                        positionInBranch = 0;
                        continue;
                    }
                }
                // No matching exit element found --> Split branch into child branches
                numberOfBranches = this.splitBranch(examinedBranch, positionInBranch, numberOfBranches, true, null, 0);
                break;
            }
        }
    }
    branchModel.setRootBranch(rootBranch);
    branchModel.setNumberOfBranches(numberOfBranches);
    return branchModel;
}
Also used : Branch(org.iobserve.analysis.userbehavior.data.Branch) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList) BranchModel(org.iobserve.analysis.userbehavior.data.BranchModel)

Example 32 with EntryCallEvent

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

the class ClusteringPrePostProcessing method getCallCountModel.

/**
 * Transforms the passed user sessions to counts of called operation signatures that can be used
 * for the similarity calculation of the user group clustering. The objective is to transform
 * each user session to a list that contains the number of calls of each distinct operation
 * signature. It parses through the entry call sequences of each user session and counts the
 * calls of each distinct operation signature. The result is a list of user sessions whose call
 * sequence is represented as counts of calls.
 *
 * @param userSessions
 *            are transformed to counts of calls
 * @param listOfDistinctOperationSignatures
 *            are the distinct operation signatures whose calls are counted for each user
 *            session
 * @return the passed user sessions as counts of calls
 */
public List<UserSessionAsCountsOfCalls> getCallCountModel(final List<UserSession> userSessions, final List<String> listOfDistinctOperationSignatures) {
    final List<UserSessionAsCountsOfCalls> callCountModel = new ArrayList<>();
    // during the user session
    for (final UserSession userSession : userSessions) {
        final UserSessionAsCountsOfCalls absoluteCountOfCalls = new UserSessionAsCountsOfCalls(userSession.getSessionId(), listOfDistinctOperationSignatures.size());
        final List<EntryCallEvent> callSequence = userSession.getEvents();
        for (int i = 0; i < callSequence.size(); i++) {
            final String currentCall = callSequence.get(i).getOperationSignature();
            final int indexOfCurrentCall = listOfDistinctOperationSignatures.indexOf(currentCall);
            absoluteCountOfCalls.getAbsoluteCountOfCalls()[indexOfCurrentCall] = absoluteCountOfCalls.getAbsoluteCountOfCalls()[indexOfCurrentCall] + 1;
        }
        callCountModel.add(absoluteCountOfCalls);
    }
    return callCountModel;
}
Also used : UserSessionAsCountsOfCalls(org.iobserve.analysis.userbehavior.data.UserSessionAsCountsOfCalls) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList)

Example 33 with EntryCallEvent

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

the class ClusteringEvaluation method createCallSequencesForUserGroupCustomer.

/**
 * Behavior Model of user group Customer. It creates for each user session a random user
 * behavior according to the BehaviorModel it describes
 *
 * @param userSessions
 */
private void createCallSequencesForUserGroupCustomer(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", "1", "hostname");
        userSession.add(entryCallEvent, true);
        entryTime += 2;
        exitTime += 2;
        entryCallEvent = new EntryCallEvent(entryTime, exitTime, "buyProduct", "class", "1", "hostname");
        userSession.add(entryCallEvent, true);
        entryTime += 2;
        exitTime += 2;
        while (!entryCallEvent.getOperationSignature().equals("logout")) {
            if (this.getRandomDouble(1, 0) <= 0.7) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "buyProduct", "class", "1", "hostname");
                userSession.add(entryCallEvent, true);
            } else {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "logout", "class", "1", "hostname");
                userSession.add(entryCallEvent, true);
            }
            entryTime += 2;
            exitTime += 2;
        }
    }
}
Also used : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession)

Example 34 with EntryCallEvent

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

the class ClusteringEvaluation method createCallSequencesForUserGroupStockManager.

/**
 * Behavior Model of user group Stock Manager. It creates for each user session a random user
 * behavior according to the BehaviorModel it describes
 *
 * @param userSessions
 */
private void createCallSequencesForUserGroupStockManager(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", "3", "hostname");
        userSession.add(entryCallEvent, true);
        entryTime += 2;
        exitTime += 2;
        entryCallEvent = new EntryCallEvent(entryTime, exitTime, "checkDelivery", "class", "3", "hostname");
        userSession.add(entryCallEvent, true);
        entryTime += 2;
        exitTime += 2;
        while (!entryCallEvent.getOperationSignature().equals("logout")) {
            final double callDecisioner = this.getRandomDouble(1, 0);
            if (entryCallEvent.getOperationSignature().equals("checkDelivery") && callDecisioner <= 0.3) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "checkDelivery", "class", "3", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("checkDelivery") && callDecisioner > 0.3) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "updateStock", "class", "3", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("updateStock") && callDecisioner <= 0.4) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "checkDelivery", "class", "3", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
            if (entryCallEvent.getOperationSignature().equals("updateStock") && callDecisioner > 0.4) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "confirm", "class", "3", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, "logout", "class", "3", "hostname");
                userSession.add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                continue;
            }
        }
    }
}
Also used : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession)

Example 35 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)

Aggregations

EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)45 UserSession (org.iobserve.analysis.session.data.UserSession)16 ArrayList (java.util.ArrayList)10 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)8 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)8 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)8 Start (org.palladiosimulator.pcm.usagemodel.Start)8 Stop (org.palladiosimulator.pcm.usagemodel.Stop)8 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)8 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)8 EntryCallSequenceModel (org.iobserve.analysis.data.EntryCallSequenceModel)6 UserSessionCollectionModel (org.iobserve.analysis.data.UserSessionCollectionModel)6 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)6 Loop (org.palladiosimulator.pcm.usagemodel.Loop)6 ReferenceElements (org.iobserve.analysis.test.userbehavior.ReferenceElements)5 ReferenceElements (org.iobserve.analysis.userbehavior.ReferenceElements)5 Correspondent (org.iobserve.model.correspondence.Correspondent)4 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)4 HashMap (java.util.HashMap)2 List (java.util.List)2