Search in sources :

Example 11 with UserSession

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

the class EntryCallSequence method removeExpiredSessions.

/**
 * removes all expired sessions from the filter and sends them to
 * tBehaviorModelPreperationOutputPort.
 */
private void removeExpiredSessions() {
    final long timeNow = System.currentTimeMillis() * 1000000;
    final Set<String> sessionsToRemove = new HashSet<>();
    for (final String sessionId : this.sessions.keySet()) {
        final UserSession session = this.sessions.get(sessionId);
        final long exitTime = session.getExitTime();
        final boolean isExpired = exitTime + EntryCallSequence.USER_SESSION_EXPIRATIONTIME < timeNow;
        if (isExpired) {
            this.userSessionOutputPort.send(session);
            sessionsToRemove.add(sessionId);
        }
    }
    for (final String sessionId : sessionsToRemove) {
        this.sessions.remove(sessionId);
    }
}
Also used : UserSession(org.iobserve.analysis.session.data.UserSession) HashSet(java.util.HashSet)

Example 12 with UserSession

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

the class EntryCallSequence method execute.

@Override
protected void execute() {
    final ISessionEvent sessionEvent = this.sessionEventInputPort.receive();
    if (sessionEvent != null) {
        if (sessionEvent instanceof SessionStartEvent) {
            this.sessions.put(UserSession.createUserSessionId(sessionEvent), new UserSession(sessionEvent.getHostname(), sessionEvent.getSessionId()));
        }
        if (sessionEvent instanceof SessionEndEvent) {
            final UserSession session = this.sessions.get(UserSession.createUserSessionId(sessionEvent));
            if (session != null) {
                this.userSessionOutputPort.send(session);
                this.sessions.remove(sessionEvent.getSessionId());
            }
        }
    }
    final PayloadAwareEntryCallEvent event = this.entryCallInputPort.receive();
    if (event != null) {
        /**
         * add the event to the corresponding user session in case the user session is not yet
         * available, create one.
         */
        final String userSessionId = UserSession.createUserSessionId(event);
        UserSession userSession = this.sessions.get(userSessionId);
        if (userSession == null) {
            userSession = new UserSession(event.getHostname(), event.getSessionId());
            this.sessions.put(userSessionId, userSession);
        // TODO this should trigger a warning.
        }
        userSession.add(event, true);
    }
// this.removeExpiredSessions();
}
Also used : PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) SessionStartEvent(org.iobserve.common.record.SessionStartEvent) SessionEndEvent(org.iobserve.common.record.SessionEndEvent) UserSession(org.iobserve.analysis.session.data.UserSession) ISessionEvent(org.iobserve.common.record.ISessionEvent)

Example 13 with UserSession

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

the class TEntryCallSequenceWithPCM method execute.

@Override
protected void execute(final PayloadAwareEntryCallEvent event) {
    /**
     * check if operationEvent is from an known object
     */
    if (CorrespondenceUtility.findModelElementForOperation(this.correspondenceModel, Repository.class, event.getClassSignature(), event.getOperationSignature()) != null) {
        // add the event to the corresponding user session
        // in case the user session is not yet available, create one
        final String userSessionId = UserSession.createUserSessionId(event);
        UserSession userSession = this.sessions.get(userSessionId);
        if (userSession == null) {
            userSession = new UserSession(event.getHostname(), event.getSessionId());
            this.sessions.put(userSessionId, userSession);
        }
        // do not sort since TEntryEventSequence will sort any ways
        userSession.add(event, false);
        // collect all user sessions which have more elements as a defined threshold and send
        // them
        // to the next filter
        final List<UserSession> listToSend = this.sessions.values().stream().filter(session -> session.size() > TEntryCallSequenceWithPCM.USER_SESSION_THRESHOLD).collect(Collectors.toList());
        if (!listToSend.isEmpty()) {
            this.outputPort.send(new UserSessionCollectionModel(listToSend));
        }
    }
}
Also used : CorrespondenceUtility(org.iobserve.model.CorrespondenceUtility) UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) List(java.util.List) AbstractConsumerStage(teetime.framework.AbstractConsumerStage) UserSession(org.iobserve.analysis.session.data.UserSession) Map(java.util.Map) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel) HashMap(java.util.HashMap) Repository(org.palladiosimulator.pcm.repository.Repository) Collectors(java.util.stream.Collectors) OutputPort(teetime.framework.OutputPort) PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) Repository(org.palladiosimulator.pcm.repository.Repository) UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) UserSession(org.iobserve.analysis.session.data.UserSession)

Example 14 with UserSession

use of org.iobserve.analysis.session.data.UserSession 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 UserSessionCollectionModel 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.behavior.karlsruhe.data.Branch) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList) BranchModel(org.iobserve.analysis.behavior.karlsruhe.data.BranchModel)

Example 15 with UserSession

use of org.iobserve.analysis.session.data.UserSession 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.behavior.karlsruhe.data.UserSessionAsCountsOfCalls) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) 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