Search in sources :

Example 1 with UserSessionCollectionModel

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

the class UserGroupExtraction method extractUserGroups.

/**
 * Function to extract user groups.
 */
public void extractUserGroups() {
    final ClusteringPrePostProcessing clusteringProcessing = new ClusteringPrePostProcessing();
    final XMeansClustering xMeansClustering = new XMeansClustering();
    ClusteringResults xMeansClusteringResults;
    /**
     * 1. Extraction of distinct system operations. Creates a list of the distinct operation
     * signatures occurring within the entryCallSequenceModel. It is required to transform each
     * user session to counts of its called operations. The counts are used to determine the
     * similarity between the user sessions
     */
    final List<String> listOfDistinctOperationSignatures = clusteringProcessing.getListOfDistinctOperationSignatures(this.entryCallSequenceModel.getUserSessions());
    /**
     * 2. Transformation to the call count model. Transforms the call sequences of the user
     * sessions to a list of counts of calls that state the number of calls of each distinct
     * operation signature for each user session
     */
    final List<UserSessionAsCountsOfCalls> callCountModel = clusteringProcessing.getCallCountModel(this.entryCallSequenceModel.getUserSessions(), listOfDistinctOperationSignatures);
    /**
     * 3. Clustering of user sessions. Clustering of the user sessions whose behavior is
     * represented as counts of their called operation signatures to obtain user groups
     */
    final Instances instances = xMeansClustering.createInstances(callCountModel, listOfDistinctOperationSignatures);
    /*
         * The clustering is performed 5 times and the best result is taken. The quality of a
         * clustering result is determined by the value of the sum of squared error (SSE) of the
         * clustering. The lower the SSE is the better the clustering result.
         */
    for (int i = 0; i < 5; i++) {
        xMeansClusteringResults = xMeansClustering.clusterSessionsWithXMeans(instances, this.numberOfUserGroupsFromInputUsageModel, this.varianceOfUserGroups, i);
        if (this.clusteringResults == null) {
            this.clusteringResults = xMeansClusteringResults;
        } else if (xMeansClusteringResults.getClusteringMetrics().getSumOfSquaredErrors() < this.clusteringResults.getClusteringMetrics().getSumOfSquaredErrors()) {
            this.clusteringResults = xMeansClusteringResults;
        }
    }
    /**
     * 4. Obtaining the user groups' call sequence models. Creates for each cluster resp. user
     * group its own entry call sequence model that exclusively contains its assigned user
     * sessions
     */
    final List<UserSessionCollectionModel> entryCallSequenceModelsOfXMeansClustering = clusteringProcessing.getForEachUserGroupAnEntryCallSequenceModel(this.clusteringResults, this.entryCallSequenceModel);
    /**
     * 5. Obtaining the user groups' workload intensity. Calculates and sets for each user group
     * its specific workload intensity parameters
     */
    clusteringProcessing.setTheWorkloadIntensityForTheEntryCallSequenceModels(entryCallSequenceModelsOfXMeansClustering, this.isClosedWorkload);
    /**
     * Sets the resulting entryCallSequenceModels that can be retrieved via the getter method
     */
    this.entryCallSequenceModelsOfUserGroups = entryCallSequenceModelsOfXMeansClustering;
}
Also used : Instances(weka.core.Instances) UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) UserSessionAsCountsOfCalls(org.iobserve.analysis.behavior.karlsruhe.data.UserSessionAsCountsOfCalls) ClusteringResults(org.iobserve.analysis.behavior.karlsruhe.data.ClusteringResults)

Example 2 with UserSessionCollectionModel

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

the class UserSessionsScalabilityReferenceModelBuilder method getIncreasingUserSessionsScalabilityReferenceModel.

/**
 * It creates the passed number of user sessions. Thereby, two user groups are distinguished.
 * Each user session of a user group contains the same call sequence. The call sequences between
 * the user groups differ from each other by their operation signatures. It is used to evaluate
 * the approach's response times with an increasing number of user sessions (RQ-3.1) It returns
 * user session that are used to execute the approach and to measure the response time Thereby,
 * this method is called repeatedly to constantly increase the number of UserSessions
 *
 * @param numberOfUserSessions
 *            defines the number of user sessions to create
 * @return user sessions with a fixed user behavior
 */
public static ReferenceElements getIncreasingUserSessionsScalabilityReferenceModel(final int numberOfUserSessions) {
    final ReferenceElements testElements = new ReferenceElements();
    final UserSessionCollectionModel entryCallSequenceModel = new UserSessionCollectionModel(TestHelper.getUserSessions(numberOfUserSessions));
    int entryTime = 1;
    int exitTime = 2;
    // sessions
    for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
        final double userGroupDecisioner = (double) i / (double) numberOfUserSessions;
        // by their operation signatures
        if (userGroupDecisioner < 0.3) {
            // One single call
            EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
            // An iterated call to represent a loop
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
            // Alternative calls to represent a branch
            final int branchDecisioner = TestHelper.getRandomInteger(2, 1);
            if (branchDecisioner == 1) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
            } else {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
            }
            // An equal call to merge the branch transitions
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
        } else {
            // One single call
            EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
            // An iterated call to represent a loop
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
            // Alternative calls to represent a branch
            final int branchDecisioner = TestHelper.getRandomInteger(2, 1);
            if (branchDecisioner == 1) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
            } else {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
            }
            // An equal call to merge the branch transitions
            entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
            entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
            entryTime += 2;
            exitTime += 2;
        }
    }
    // Returns the created user sessions. Now our approach can be executed and the response
    // times can be measured
    testElements.setEntryCallSequenceModel(entryCallSequenceModel);
    return testElements;
}
Also used : UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent)

Example 3 with UserSessionCollectionModel

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

the class CallSequenceScalabilityReferenceHelper method getModel.

/**
 * It creates a fixed number of user sessions. The number of calls per user session is
 * determined by the passed numberOfIterations parameter. It defines how often a fixed call
 * sequence is added to the call sequence of each user session. It is used to evaluate the
 * approach's response times with an increasing number of calls (RQ-3.2). It returns user
 * session that are used to execute the approach and to measure the response time. Thereby, this
 * method is called repeatedly to constantly increase the number of calls per UserSession.
 *
 * @param numberOfIterations
 *            defines how many calls per user session are created
 * @return user sessions
 */
public static ReferenceElements getModel(final int numberOfIterations) {
    final ReferenceElements testElements = new ReferenceElements();
    final int numberOfUserSessions = 50;
    final UserSessionCollectionModel entryCallSequenceModel = new UserSessionCollectionModel(TestHelper.getUserSessions(numberOfUserSessions));
    boolean branchDecisionerUserGroup1 = true;
    boolean branchDecisionerUserGroup2 = true;
    for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
        final double userGroupDecisioner = (double) i / (double) numberOfUserSessions;
        int entryTime = 1;
        int exitTime = 2;
        // by their operation signatures
        if (userGroupDecisioner < 0.3) {
            branchDecisionerUserGroup1 = !branchDecisionerUserGroup1;
            // each user session is iterated and thus the number of calls per user session
            for (int j = 0; j < numberOfIterations; j++) {
                // One single call
                EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                // An iterated call to represent a loop
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                // Alternative calls to represent a branch
                final int branchDecisioner = TestHelper.getRandomInteger(2, 1);
                if (branchDecisioner == 1) {
                    entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
                    entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                    entryTime += 2;
                    exitTime += 2;
                } else {
                    entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
                    entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                    entryTime += 2;
                    exitTime += 2;
                }
                // An equal call to merge the branch transitions
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2], ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
            }
        } else {
            branchDecisionerUserGroup2 = !branchDecisionerUserGroup2;
            // each user session is iterated and thus the number of calls per user session
            for (int j = 0; j < numberOfIterations; j++) {
                // One single call
                EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                // An iterated call to represent a loop
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
                // Alternative calls to represent a branch
                final int branchDecisioner = TestHelper.getRandomInteger(2, 1);
                if (branchDecisioner == 1) {
                    entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
                    entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                    entryTime += 2;
                    exitTime += 2;
                } else {
                    entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
                    entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                    entryTime += 2;
                    exitTime += 2;
                }
                // An equal call to merge the branch transitions
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime += 2;
                exitTime += 2;
            }
        }
    }
    // Returns the created user sessions. Now our approach can be executed and the response
    // times can be measured
    testElements.setEntryCallSequenceModel(entryCallSequenceModel);
    return testElements;
}
Also used : UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) ReferenceElements(org.iobserve.analysis.test.userbehavior.ReferenceElements)

Example 4 with UserSessionCollectionModel

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

the class LoopWithinLoopReference method getLoopWithinLoopReferenceModel.

/**
 * It creates a reference usage model that contains loops within loops. Accordingly, user
 * sessions whose call sequences contain iterated segments that again contain iterated segments
 * are created.(RQ-1.7)
 *
 * @param referenceUsageModelFileName
 *            file name of the reference model to store its result
 * @param repositoryLookupModel
 *            repository model provider
 * @param correspondenceModel
 *            correspondence model
 *
 * @return reference usage model and corresponding user sessions
 * @throws IOException
 *             on error
 */
public ReferenceElements getLoopWithinLoopReferenceModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModel, final CorrespondenceModel 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 countOfLoop1 = TestHelper.getRandomInteger(4, 2);
    final int countOfLoop2 = TestHelper.getRandomInteger(4, 2);
    final int lengthOfSubsequentLoopSequence = TestHelper.getRandomInteger(2, 1);
    // 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.createStart("");
    UsageModelFactory.addUserAction(scenarioBehaviour, start);
    final Stop stop = UsageModelFactory.createStop("");
    UsageModelFactory.addUserAction(scenarioBehaviour, stop);
    lastAction = start;
    // The exterior loop is created
    final Loop loop = UsageModelFactory.createLoop("", scenarioBehaviour);
    UsageModelFactory.connect(lastAction, loop);
    UsageModelFactory.connect(loop, stop);
    final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
    pcmLoopIteration.setSpecification(String.valueOf(countOfLoop1));
    loop.setLoopIteration_Loop(pcmLoopIteration);
    final Start loopStart = UsageModelFactory.createStart("");
    UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStart);
    final Stop loopStop = UsageModelFactory.createStop("");
    UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStop);
    lastAction = loopStart;
    // The interior loop is created
    final Loop loop2 = UsageModelFactory.createLoop("", loop.getBodyBehaviour_Loop());
    UsageModelFactory.connect(lastAction, loop2);
    final PCMRandomVariable pcmLoop2Iteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
    pcmLoop2Iteration.setSpecification(String.valueOf(countOfLoop2));
    loop2.setLoopIteration_Loop(pcmLoop2Iteration);
    final Start loop2Start = UsageModelFactory.createStart("");
    UsageModelFactory.addUserAction(loop2.getBodyBehaviour_Loop(), loop2Start);
    final Stop loop2Stop = UsageModelFactory.createStop("");
    UsageModelFactory.addUserAction(loop2.getBodyBehaviour_Loop(), loop2Stop);
    lastAction = loop2Start;
    final OperationSignature operationSignature = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2]);
    if (operationSignature != null) {
        final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, operationSignature);
        UsageModelFactory.addUserAction(loop2.getBodyBehaviour_Loop(), entryLevelSystemCall);
        UsageModelFactory.connect(lastAction, entryLevelSystemCall);
        lastAction = entryLevelSystemCall;
    }
    UsageModelFactory.connect(lastAction, loop2Stop);
    lastAction = loop2;
    // The sequence that exclusively belongs to the exterior loop is created
    for (int i = 0; i < lengthOfSubsequentLoopSequence; i++) {
        final OperationSignature operationSignature2;
        switch(i) {
            case 0:
                operationSignature2 = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3]);
                break;
            case 1:
                operationSignature2 = CorrespondenceUtility.findModelElementForOperation(correspondenceModel, Repository.class, ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4]);
                break;
            default:
                throw new IllegalArgumentException("Illegal value of model element parameter");
        }
        if (operationSignature2 != null) {
            final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, operationSignature2);
            UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), entryLevelSystemCall);
            UsageModelFactory.connect(lastAction, entryLevelSystemCall);
            lastAction = entryLevelSystemCall;
        }
    }
    UsageModelFactory.connect(lastAction, loopStop);
    final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 1);
    final UserSessionCollectionModel entryCallSequenceModel = new UserSessionCollectionModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
    // 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;
        // Represents the exterior loop of the reference usage model
        for (int k = 0; k < countOfLoop1; k++) {
            // Represents the interior loop of the reference usage model
            for (int j = 0; j < countOfLoop2; j++) {
                final EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2], ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], String.valueOf(i), "hostname");
                entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
                entryTime = entryTime + 2;
                exitTime = exitTime + 2;
            }
            // Calls of the exterior loop
            for (int j = 0; j < lengthOfSubsequentLoopSequence; j++) {
                EntryCallEvent entryCallEvent = null;
                switch(j) {
                    case 0:
                        entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
                        break;
                    case 1:
                        entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
                        break;
                    default:
                        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
    final ReferenceElements referenceElements = new ReferenceElements();
    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) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) Repository(org.palladiosimulator.pcm.repository.Repository) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) ReferenceElements(org.iobserve.analysis.test.userbehavior.ReferenceElements)

Example 5 with UserSessionCollectionModel

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

Aggregations

UserSessionCollectionModel (org.iobserve.analysis.data.UserSessionCollectionModel)21 UserSession (org.iobserve.analysis.session.data.UserSession)8 ReferenceElements (org.iobserve.analysis.test.userbehavior.ReferenceElements)8 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)8 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)7 UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)7 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)6 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)6 Start (org.palladiosimulator.pcm.usagemodel.Start)6 Stop (org.palladiosimulator.pcm.usagemodel.Stop)6 ArrayList (java.util.ArrayList)5 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)5 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)5 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)4 Loop (org.palladiosimulator.pcm.usagemodel.Loop)4 List (java.util.List)3 Repository (org.palladiosimulator.pcm.repository.Repository)3 HashMap (java.util.HashMap)2 Branch (org.palladiosimulator.pcm.usagemodel.Branch)2 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)2