Search in sources :

Example 1 with EntryCallEvent

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

the class SimpleSequenceReference method getModel.

/**
 * Creates a reference model that contains a simple sequence of calls. Accordingly, user
 * sessions whose call sequences contain a simple call sequence are created. (RQ-1.1) It is also
 * used to evaluate the accuracy of workload specifications. Therefore, varying workload is
 * generated by random entry and exit times of the user sessions, a random number of user
 * sessions for a closed workload specification and a random mean inter arrival time for an open
 * workload specification (RQ-1.9)
 *
 * @param referenceUsageModelFileName
 *            file name of the reference model to store its result
 * @param repositoryLookupModel
 *            repository lookup model
 * @param correspondenceModel
 *            correspondence model
 * @param thinkTime
 *            of a closed workload.
 * @param isClosedWorkload
 *            decides whether a closed or an open workload is created
 * @return the reference usage model, a corresponding EntryCallSequenceModel and a reference
 *         workload
 * @throws IOException
 *             on error
 */
public static ReferenceElements getModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModel, final ICorrespondence correspondenceModel, final int thinkTime, final boolean isClosedWorkload) throws IOException {
    // Creates 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 numberOfUsersSessions = TestHelper.getRandomInteger(200, 1);
    final int numberOfCalls = TestHelper.getRandomInteger(5, 1);
    final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfUsersSessions));
    final ReferenceElements referenceElements = new ReferenceElements();
    // In the following the reference usage model is created
    final UsageModel usageModel = UsageModelFactory.createUsageModel();
    final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
    final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
    final Start start = UsageModelFactory.createAddStartAction("", scenarioBehaviour);
    final Stop stop = UsageModelFactory.createAddStopAction("", scenarioBehaviour);
    AbstractUserAction lastAction = start;
    Optional<Correspondent> correspondent;
    // created
    for (int i = 0; i < numberOfCalls; i++) {
        if (i >= 0 && i < 5) {
            correspondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
        } else {
            throw new IllegalArgumentException("Illegal value of model element parameter");
        }
        if (correspondent.isPresent()) {
            final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent.get());
            UsageModelFactory.addUserAction(scenarioBehaviour, entryLevelSystemCall);
            UsageModelFactory.connect(lastAction, entryLevelSystemCall);
            lastAction = entryLevelSystemCall;
        }
    }
    UsageModelFactory.connect(lastAction, stop);
    // 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 are set randomly
    // to evaluate a closed workload. For the evaluation of an open workload the mean inter
    // arrival time is set randomly
    int entryTime = 0;
    int exitTime = 1;
    final int meanInterArrivalTime = TestHelper.getRandomInteger(30, 1);
    for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
        if (isClosedWorkload) {
            entryTime = TestHelper.getRandomInteger(30, 1);
            exitTime = entryTime + 1;
        } else {
            entryTime += meanInterArrivalTime;
            exitTime += meanInterArrivalTime;
        }
        for (int k = 0; k < numberOfCalls; k++) {
            EntryCallEvent entryCallEvent = null;
            if (k >= 0 && k < 5) {
                entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[k], ReferenceUsageModelBuilder.CLASS_SIGNATURE[k], String.valueOf(i), "hostname");
            } else {
                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, the EntryCallSequenceModel
    // and the workload 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. Alike, the by our approach calculated workload can be matched against the
    // reference workload. This is done by {@link
    // org.iobserve.analysis.userbehavior.test.WorkloadEvaluation}
    TestHelper.saveModel(usageModel, referenceUsageModelFileName);
    referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
    referenceElements.setUsageModel(usageModel);
    referenceElements.setMeanInterArrivalTime(meanInterArrivalTime + numberOfCalls * 2);
    referenceElements.setMeanConcurrentUserSessions(SimpleSequenceReference.calculateTheNumberOfConcurrentUsers(entryCallSequenceModel.getUserSessions()));
    return referenceElements;
}
Also used : 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) EntryCallSequenceModel(org.iobserve.analysis.data.EntryCallSequenceModel) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Correspondent(org.iobserve.model.correspondence.Correspondent) ReferenceElements(org.iobserve.analysis.userbehavior.ReferenceElements)

Example 2 with EntryCallEvent

use of org.iobserve.stages.general.data.EntryCallEvent 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 EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(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 : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) EntryCallSequenceModel(org.iobserve.analysis.data.EntryCallSequenceModel)

Example 3 with EntryCallEvent

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

the class BranchWithinBranchReference method createBranch.

/**
 * Create a branch.
 *
 * @param branchTransitionCounter
 * @param entryTime
 * @param entryCallSequenceModel
 * @param numberOfTransitionsOfInteriorBranches
 * @param listOfbranchTransitionCounterInterior
 * @param userSessionIndex
 * @param operationId
 * @return
 */
private static int createBranch(final List<Integer> branchTransitionCounter, final int entryTime, final EntryCallSequenceModel entryCallSequenceModel, final int numberOfTransitionsOfInteriorBranches, final List<List<Integer>> listOfbranchTransitionCounterInterior, final int userSessionIndex, final int operationId) {
    final int countOfBranchTransition = branchTransitionCounter.get(operationId) + 1;
    branchTransitionCounter.set(operationId, countOfBranchTransition);
    final EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, entryTime + 1, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[operationId], ReferenceUsageModelBuilder.CLASS_SIGNATURE[operationId], String.valueOf(userSessionIndex), "hostname");
    entryCallSequenceModel.getUserSessions().get(userSessionIndex).add(entryCallEvent, true);
    int branchDecisioner = TestHelper.getRandomInteger(numberOfTransitionsOfInteriorBranches - 1, 0);
    for (int k = 0; k < numberOfTransitionsOfInteriorBranches; k++) {
        if (listOfbranchTransitionCounterInterior.get(operationId).get(k) == 0) {
            branchDecisioner = k;
            break;
        }
    }
    // Within the branch transition again a random branch transition is chosen
    if (branchDecisioner == 0) {
        return BranchWithinBranchReference.createEntryCallEventForBranch(userSessionIndex, operationId, 0, 0, entryCallSequenceModel, entryTime + 2, listOfbranchTransitionCounterInterior);
    } else if (branchDecisioner == 1) {
        return BranchWithinBranchReference.createEntryCallEventForBranch(userSessionIndex, operationId, 1, 3, entryCallSequenceModel, entryTime + 2, listOfbranchTransitionCounterInterior);
    } else if (branchDecisioner == 2) {
        return BranchWithinBranchReference.createEntryCallEventForBranch(userSessionIndex, operationId, 2, 4, entryCallSequenceModel, entryTime + 2, listOfbranchTransitionCounterInterior);
    } else {
        return entryTime + 2;
    }
}
Also used : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent)

Example 4 with EntryCallEvent

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

the class BranchWithinBranchReference method createEntryCallEventForBranch.

/**
 * Helper function to create and add an entry call event to a call sequence model.
 *
 * @param index
 *            user session index
 * @param branchDecisioner
 *            branch decision
 * @param entryCallSequenceModel
 *            the sequence call model
 * @param entryTime
 *            call entry time
 * @param exitTime
 *            call exit time
 * @param listOfbranchTransitionCounterInterior
 *            list of iterators
 */
private static int createEntryCallEventForBranch(final int index, final int iteratorId, final int branchDecisioner, final int signatureId, final EntryCallSequenceModel entryCallSequenceModel, final int entryTime, final List<List<Integer>> listOfbranchTransitionCounterInterior) {
    final int countOfBranchTransition = listOfbranchTransitionCounterInterior.get(iteratorId).get(branchDecisioner) + 1;
    listOfbranchTransitionCounterInterior.get(iteratorId).set(branchDecisioner, countOfBranchTransition);
    final EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, entryTime + 1, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[signatureId], ReferenceUsageModelBuilder.CLASS_SIGNATURE[signatureId], String.valueOf(index), "hostname");
    entryCallSequenceModel.getUserSessions().get(index).add(entryCallEvent, true);
    return entryTime + 2;
}
Also used : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent)

Example 5 with EntryCallEvent

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

the class SimpleBranchReference method sequenceConstructor.

/**
 * Sequence constructor.
 *
 * @param branchTransitionCounter
 * @param index
 * @param entryCallSequenceModel
 * @param loopCount
 */
private static void sequenceConstructor(final List<Integer> branchTransitionCounter, final int index, final EntryCallSequenceModel entryCallSequenceModel, final int loopCount, final int start, final int end) {
    final int countOfBranchTransition = branchTransitionCounter.get(index) + 1;
    branchTransitionCounter.set(index, countOfBranchTransition);
    final EntryCallEvent entryCallEvent = new EntryCallEvent(1, 2, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[start], ReferenceUsageModelBuilder.CLASS_SIGNATURE[start], String.valueOf(loopCount), "hostname");
    entryCallSequenceModel.getUserSessions().get(loopCount).add(entryCallEvent, true);
    final EntryCallEvent entryCallEvent2 = new EntryCallEvent(3, 4, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[end], ReferenceUsageModelBuilder.CLASS_SIGNATURE[end], String.valueOf(loopCount), "hostname");
    entryCallSequenceModel.getUserSessions().get(loopCount).add(entryCallEvent2, true);
}
Also used : EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent)

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