use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class OverlappingIterationReference method createMatchingEntryAndExitEvents.
/**
* 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.
*
* @param entryCallSequenceModel
* entry call sequence model which is filled with events
* @param lengthOfSequence1
* length of the first sequence
* @param lengthOfSequence2
* length of the second sequence
* @param loopCount1
* loop counter 1
* @param loopCount2
* loop counter 2
*/
private static void createMatchingEntryAndExitEvents(final EntryCallSequenceModel entryCallSequenceModel, final int lengthOfSequence1, final int lengthOfSequence2, final int loopCount1, final int loopCount2) {
for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
// one is iterated threee times
if (lengthOfSequence1 >= lengthOfSequence2) {
EntryCallEvent entryCallEvent;
int entryTime = 1;
int exitTime = 2;
for (int k = 0; k < loopCount1; k++) {
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;
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;
}
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;
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;
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 entryCallEvent;
int entryTime = 1;
int exitTime = 2;
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;
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;
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;
for (int k = 0; k < loopCount2; k++) {
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;
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;
}
}
}
}
use of org.iobserve.stages.general.data.EntryCallEvent 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 EntryCallSequenceModel 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;
}
use of org.iobserve.stages.general.data.EntryCallEvent 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;
}
use of org.iobserve.stages.general.data.EntryCallEvent 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;
}
}
}
use of org.iobserve.stages.general.data.EntryCallEvent 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;
}
}
}
}
Aggregations