Search in sources :

Example 6 with UserSession

use of org.iobserve.analysis.session.data.UserSession 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 7 with UserSession

use of org.iobserve.analysis.session.data.UserSession in project iobserve-analysis by research-iobserve.

the class ClusteringEvaluation method createCallSequenceModelWithVaryingUserGroups.

/**
 * Creates for each user group user sessions with random behavior according to the
 * BehaviorModels and subsumes the user sessions within an EntryCallSequenceModel.
 *
 * @throws IOException
 */
private void createCallSequenceModelWithVaryingUserGroups() throws IOException {
    final List<UserSession> userSessionsOfGroupCustomer = this.getUserSessions(ClusteringEvaluation.NUMBER_OF_USER_SESSIONS_OF_USER_GROUP_CUSTOMER, ClusteringEvaluation.CUSTOMER_TAG);
    final List<UserSession> userSessionsOfGroupStockManager = this.getUserSessions(ClusteringEvaluation.NUMBER_OF_USER_SESSIONS_OF_USER_GROUP_STOCK_MANAGER, ClusteringEvaluation.STOCK_MANAGER_TAG);
    final List<UserSession> userSessionsOfGroupStoreManager = this.getUserSessions(ClusteringEvaluation.NUMBER_OF_USER_SESSIONS_OF_USER_GROUP_STORE_MANAGER, ClusteringEvaluation.STORE_MANAGER_TAG);
    this.createCallSequencesForUserGroupCustomer(userSessionsOfGroupCustomer);
    this.createCallSequencesForUserGroupStockManager(userSessionsOfGroupStockManager);
    this.createCallSequencesForUserGroupStoreManager(userSessionsOfGroupStoreManager);
    final List<UserSession> userSessions = new ArrayList<>();
    userSessions.addAll(userSessionsOfGroupStockManager);
    userSessions.addAll(userSessionsOfGroupStoreManager);
    userSessions.addAll(userSessionsOfGroupCustomer);
    final long seed = 5;
    Collections.shuffle(userSessions, new Random(seed));
    this.entryCallSequenceModel = new UserSessionCollectionModel(userSessions);
}
Also used : UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) Random(java.util.Random) UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList)

Example 8 with UserSession

use of org.iobserve.analysis.session.data.UserSession in project iobserve-analysis by research-iobserve.

the class ClusteringEvaluation method getUserSessions.

/**
 * Creates for the passed user group the passed number of user sessions.
 *
 * @param numberOfUserSessionsToCreate
 * @param userGroupId
 * @return user sessions tagged with their user group belonging
 */
private List<UserSession> getUserSessions(final int numberOfUserSessionsToCreate, final String userGroupId) {
    final List<UserSession> userSessions = new ArrayList<>();
    for (int i = 0; i < numberOfUserSessionsToCreate; i++) {
        final UserSession userSession = new UserSession("host", userGroupId);
        userSessions.add(userSession);
    }
    return userSessions;
}
Also used : UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList)

Example 9 with UserSession

use of org.iobserve.analysis.session.data.UserSession 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 10 with UserSession

use of org.iobserve.analysis.session.data.UserSession 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)

Aggregations

UserSession (org.iobserve.analysis.session.data.UserSession)39 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)16 ArrayList (java.util.ArrayList)14 UserSessionCollectionModel (org.iobserve.analysis.data.UserSessionCollectionModel)8 EntryCallSequenceModel (org.iobserve.analysis.data.EntryCallSequenceModel)5 HashMap (java.util.HashMap)3 List (java.util.List)3 PayloadAwareEntryCallEvent (org.iobserve.stages.general.data.PayloadAwareEntryCallEvent)3 Random (java.util.Random)2 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)2 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)2 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)2 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)2 Loop (org.palladiosimulator.pcm.usagemodel.Loop)2 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)2 Start (org.palladiosimulator.pcm.usagemodel.Start)2 Stop (org.palladiosimulator.pcm.usagemodel.Stop)2 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)2 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)2 HashSet (java.util.HashSet)1