Search in sources :

Example 1 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class BehaviorModelCreationStage method createNode.

/**
 * Creates an node from a node representing attribute string and value.
 *
 * @param name
 *            attribute name
 * @param value
 *            attribute value
 *
 * @return EntryCallNode
 */
private Optional<EntryCallNode> createNode(final String name, final Double value) {
    final String[] signatures = this.splitSignature(AbstractBehaviorModelTable.INFORMATION_INDICATOR_PATTERN, AbstractBehaviorModelTable.INFORMATION_DIVIDER_PATTERN, name);
    if (signatures.length == 2) {
        final EntryCallNode node = new EntryCallNode(signatures[0]);
        final CallInformation callInformation = new CallInformation(signatures[1], value.toString());
        node.mergeCallInformation(callInformation);
        return Optional.of(node);
    } else {
        return Optional.empty();
    }
}
Also used : CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Example 2 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class BehaviorModelCreationStage method createEdge.

/**
 * Creates an edge from an edge representing attribute string and value.
 *
 * @param name
 *            attribute name
 * @param value
 *            attribute value
 *
 * @return EntryCallEdge
 */
private Optional<EntryCallEdge> createEdge(final String name, final Double value) {
    // only create relevant edges
    final double roundedValue = Math.floor(value);
    if (roundedValue > 0.5) {
        final String[] nodeNames = this.splitSignature(AbstractBehaviorModelTable.EDGE_INDICATOR_PATTERN, AbstractBehaviorModelTable.EDGE_DIVIDER_PATTERN, name);
        if (nodeNames.length == 2) {
            final EntryCallNode from = new EntryCallNode(nodeNames[0]);
            final EntryCallNode to = new EntryCallNode(nodeNames[1]);
            // rount
            final EntryCallEdge edge = new EntryCallEdge(from, to, roundedValue);
            return Optional.of(edge);
        }
    }
    return Optional.empty();
}
Also used : EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Example 3 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class IntersectionModelGenerationStrategy method intersect.

private BehaviorModel intersect(final BehaviorModel a, final BehaviorModel b) {
    final BehaviorModel result = new BehaviorModel();
    Optional<EntryCallEdge> matchingEdge;
    for (final EntryCallEdge edgeA : a.getEdges()) {
        matchingEdge = b.findEdge(edgeA.getSource().getSignature(), edgeA.getTarget().getSignature());
        if (matchingEdge.isPresent()) {
            final EntryCallNode newSource = this.intersectNode(edgeA.getSource(), matchingEdge.get().getSource());
            final EntryCallNode newTarget = this.intersectNode(edgeA.getTarget(), matchingEdge.get().getTarget());
            final int edgeCount = (int) Math.min(edgeA.getCalls(), matchingEdge.get().getCalls());
            final EntryCallEdge newEdge = new EntryCallEdge(newSource, newTarget, edgeCount);
            result.addEdge(newEdge, false);
        }
    }
    return result;
}
Also used : EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) BehaviorModel(org.iobserve.analysis.behavior.models.extended.BehaviorModel)

Example 4 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class IntersectionModelGenerationStrategy method intersectNode.

private EntryCallNode intersectNode(final EntryCallNode a, final EntryCallNode b) {
    final EntryCallNode result = new EntryCallNode();
    result.setSignature(a.getSignature());
    Optional<CallInformation> matchingInfo;
    for (final CallInformation infoA : a.getEntryCallInformation()) {
        matchingInfo = b.findCallInformation(infoA.getInformationSignature(), infoA.getInformationParameter());
        if (matchingInfo.isPresent()) {
            final int newCalls = Math.min(infoA.getCount(), matchingInfo.get().getCount());
            final CallInformation newInfo = new CallInformation(infoA.getInformationSignature(), infoA.getInformationParameter(), newCalls);
            result.mergeCallInformation(newInfo);
        }
    }
    return result;
}
Also used : CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Example 5 with EntryCallNode

use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.

the class SessionToBehaviorModelTransformation method convert.

/**
 * Convert a user session into a behavior model.
 *
 * @param session
 *            user session
 * @return returns a behavior model
 */
public BehaviorModel convert(final UserSession session) {
    final BehaviorModel model = new BehaviorModel();
    model.setName(this.prefix);
    final List<EntryCallEvent> entryCalls = session.getEvents();
    final Iterator<EntryCallEvent> iterator = entryCalls.iterator();
    // Assume list has at least one element
    if (iterator.hasNext()) {
        EntryCallNode lastNode = this.createNode((PayloadAwareEntryCallEvent) iterator.next());
        EntryCallNode currentNode;
        while (iterator.hasNext()) {
            currentNode = this.createNode((PayloadAwareEntryCallEvent) iterator.next());
            model.addNode(currentNode, true);
            model.addEdge(new EntryCallEdge(lastNode, currentNode), false);
            lastNode = currentNode;
        }
        return model;
    } else {
        SessionToBehaviorModelTransformation.LOGGER.error("Empty user session creates empty model");
        return model;
    }
}
Also used : PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) BehaviorModel(org.iobserve.analysis.behavior.models.extended.BehaviorModel)

Aggregations

EntryCallNode (org.iobserve.analysis.behavior.models.extended.EntryCallNode)19 CallInformation (org.iobserve.analysis.behavior.models.extended.CallInformation)9 EntryCallEdge (org.iobserve.analysis.behavior.models.extended.EntryCallEdge)9 BehaviorModel (org.iobserve.analysis.behavior.models.extended.BehaviorModel)6 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)3 Branch (org.palladiosimulator.pcm.usagemodel.Branch)3 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)3 Loop (org.palladiosimulator.pcm.usagemodel.Loop)3 Stop (org.palladiosimulator.pcm.usagemodel.Stop)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 SingleOrNoneCollector (org.iobserve.analysis.behavior.SingleOrNoneCollector)2 NodeDifference (org.iobserve.evaluation.data.NodeDifference)2 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)2 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)2