Search in sources :

Example 36 with UserSession

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

the class TSessionOperationsFilter method execute.

@Override
protected void execute(final UserSession session) throws Exception {
    final UserSession filteredUserSession = new UserSession(session.getHost(), session.getSessionId());
    session.getEvents().stream().filter(this.filter::isAllowed).forEach(filteredUserSession::add);
    this.outputPort.send(filteredUserSession);
}
Also used : UserSession(org.iobserve.analysis.session.data.UserSession)

Example 37 with UserSession

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

the class ClusteringPrePostProcessing method getForEachUserGroupAnEntryCallSequenceModel.

/**
 * It creates for each cluster(user group) its own entryCallSequenceModel. For that, each
 * entryCallSequenceModel receives exclusively the user group's assigned user sessions obtained
 * via the clustering. Additionally each entryCallSequenceModel receives the user group's
 * occurrence likelihood within the considered user sessions.
 *
 * @param clusteringResults
 *            hold the assignments of the clustering and the number of clusters
 * @param callSequenceModel
 *            is the input entryCallSequenceModel that holds all user sessions
 * @return for each cluster one entryCallSequenceModel. Each contains exclusively the cluster's
 *         assigned user sessions
 */
public List<UserSessionCollectionModel> getForEachUserGroupAnEntryCallSequenceModel(final ClusteringResults clusteringResults, final UserSessionCollectionModel callSequenceModel) {
    final int numberOfClusters = clusteringResults.getNumberOfClusters();
    final int[] assignments = clusteringResults.getAssignments();
    final List<UserSessionCollectionModel> entryCallSequenceModels = new ArrayList<>(numberOfClusters);
    final double countOfAbsoluteUserSessions = callSequenceModel.getUserSessions().size();
    for (int k = 0; k < numberOfClusters; k++) {
        final List<UserSession> sessions = new ArrayList<>();
        int instanceNumber = 0;
        double countOfAssigendUserSessions = 0;
        for (final int clusterNum : assignments) {
            if (clusterNum == k) {
                sessions.add(callSequenceModel.getUserSessions().get(instanceNumber));
                countOfAssigendUserSessions++;
            }
            instanceNumber++;
        }
        if (sessions.isEmpty()) {
            continue;
        }
        final double relativeFrequencyOfUserGroup = countOfAssigendUserSessions / countOfAbsoluteUserSessions;
        entryCallSequenceModels.add(new UserSessionCollectionModel(sessions, relativeFrequencyOfUserGroup));
    }
    return entryCallSequenceModels;
}
Also used : UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList)

Example 38 with UserSession

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

the class ClusteringEvaluation method performClustering.

/**
 * Executes the approach's extraction of user groups process and counts the assignments of user
 * sessions of each user group within each cluster to be able to calculate the misclassification
 * rate. Returns the sum of squared error of the clustering
 *
 * @return the sum of squared error of the executed clustering
 * @throws IOException
 */
private double performClustering() throws IOException {
    final UserGroupExtraction userGroupExtraction = new UserGroupExtraction(this.entryCallSequenceModel, 3, ClusteringEvaluation.VARIANCE_VALUE, true);
    userGroupExtraction.extractUserGroups();
    final List<UserSessionCollectionModel> entryCallSequenceModelsOfUserGroups = userGroupExtraction.getEntryCallSequenceModelsOfUserGroups();
    this.listOfClusterAssignmentsCounter = new ArrayList<>();
    for (int i = 0; i < entryCallSequenceModelsOfUserGroups.size(); i++) {
        final ClusterAssignmentsCounter clusterAssignments = new ClusterAssignmentsCounter();
        this.listOfClusterAssignmentsCounter.add(clusterAssignments);
    }
    int index = 0;
    for (final UserSessionCollectionModel entryCallSequence : entryCallSequenceModelsOfUserGroups) {
        for (final UserSession userSession : entryCallSequence.getUserSessions()) {
            if (userSession.getSessionId().equals(ClusteringEvaluation.CUSTOMER_TAG)) {
                this.listOfClusterAssignmentsCounter.get(index).increaseNumberOfUserGroupCustomer();
            } else if (userSession.getSessionId().equals(ClusteringEvaluation.STORE_MANAGER_TAG)) {
                this.listOfClusterAssignmentsCounter.get(index).increaseNumberOfUserGroupStoreManager();
            } else if (userSession.getSessionId().equals(ClusteringEvaluation.STOCK_MANAGER_TAG)) {
                this.listOfClusterAssignmentsCounter.get(index).increaseNumberOfUserGroupStockManager();
            }
        }
        index++;
    }
    return userGroupExtraction.getClusteringResults().getClusteringMetrics().getSumOfSquaredErrors();
}
Also used : UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) UserGroupExtraction(org.iobserve.analysis.behavior.karlsruhe.UserGroupExtraction) UserSession(org.iobserve.analysis.session.data.UserSession)

Example 39 with UserSession

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

the class TestHelper method getUserSessions.

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

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