Search in sources :

Example 6 with EntryCallNode

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

the class SessionToBehaviorModelTransformation method createNode.

private EntryCallNode createNode(final PayloadAwareEntryCallEvent event) {
    final String signature = event.getOperationSignature();
    final EntryCallNode node = new EntryCallNode(signature);
    final String[] parameters = event.getParameters();
    final String[] values = event.getValues();
    for (int i = 0; i < parameters.length; i++) {
        node.mergeCallInformation(new CallInformation(parameters[i], values[i]));
    }
    return node;
}
Also used : CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Example 7 with EntryCallNode

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

the class GeneralStructureMetric method caclulateNodeDistance.

/**
 * Calculate node distance.
 *
 * @param a
 *            first model
 * @param b
 *            second model
 */
private double caclulateNodeDistance(final BehaviorModel a, final BehaviorModel b) {
    // Get amount of shared nodes
    double sharedNodes = 0;
    for (final EntryCallNode nodeA : a.getNodes()) {
        for (final EntryCallNode nodeB : b.getNodes()) {
            if (nodeA.equals(nodeB)) {
                sharedNodes++;
                // There cannot be multiple nodes with the same signature in a model
                break;
            }
        }
    }
    final double nodesInA = a.getNodes().size();
    final double nodesInB = b.getNodes().size();
    return (nodesInA + nodesInB - sharedNodes) / (nodesInA + nodesInB);
}
Also used : EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode)

Example 8 with EntryCallNode

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

the class ComparisonOutputStage method execute.

@Override
protected void execute(final ComparisonResult result) throws IOException {
    final BufferedWriter writer = Files.newBufferedWriter(this.outputFile.toPath(), StandardCharsets.UTF_8, StandardOpenOption.WRITE);
    final int baselineNodeCount = result.getBaselineNodes().size();
    final int testModelNodeCount = result.getTestModelNodes().size();
    final int missingNodeCount = result.getMissingNodes().size();
    final int additionalNodeCount = result.getAdditionalNodes().size();
    final int baselineEdgeCount = result.getBaselineEdges().size();
    final int testModelEdgeCount = result.getTestModelEdges().size();
    final int missingEdgeCount = result.getMissingEdgeCount();
    final int additionalEdgeCount = result.getAdditionalEdgeCount();
    writer.write("CP;" + this.outputFile.getName() + ";" + baselineNodeCount + ";" + baselineEdgeCount + ";" + testModelNodeCount + ";" + testModelEdgeCount + ";" + missingNodeCount + ";" + additionalNodeCount + ";" + missingEdgeCount + ";" + additionalEdgeCount + ";" + (double) missingNodeCount / (double) baselineNodeCount + ";" + (double) additionalNodeCount / (double) baselineNodeCount + ";" + (double) missingEdgeCount / (double) baselineEdgeCount + ";" + (double) additionalEdgeCount / (double) baselineEdgeCount + "\n");
    final List<EntryCallNode> allNodes = this.createAllNodesList(result.getBaselineNodes(), result.getTestModelNodes());
    final List<EntryCallEdge> allEdges = this.createAllEdgesList(result.getBaselineEdges(), result.getTestModelEdges());
    this.generateNodeCallInformation(writer, "baseline;" + this.outputFile.getName() + ";", allNodes, result.getBaselineNodes());
    this.generateNodeCallInformation(writer, "compared;" + this.outputFile.getName() + ";", allNodes, result.getTestModelNodes());
    writer.write("baseline;------------------------------------------ edges\n");
    writer.write("compared;------------------------------------------ edges\n");
    this.generateEdges(writer, "baseline;" + this.outputFile.getName() + ";", allEdges, result.getBaselineEdges());
    this.generateEdges(writer, "compared;" + this.outputFile.getName() + ";", allEdges, result.getTestModelEdges());
    writer.write("Nodes:\n\tmissing=" + result.getMissingNodes().size() + "\n\tadditional=" + result.getAdditionalNodes().size() + "\n");
    for (final EntryCallNode node : result.getMissingNodes()) {
        writer.write("\t - " + node.getSignature() + "\n");
    }
    for (final EntryCallNode node : result.getAdditionalNodes()) {
        writer.write("\t + " + node.getSignature() + "\n");
    }
    for (final EntryCallNode node : result.getSimilarNodes()) {
        writer.write("\t = " + node.getSignature() + "\n");
    }
    writer.write("Edges:\n\tmissing=" + result.getMissingEdgeCount() + "\n\tadditional=" + result.getAdditionalEdgeCount() + "\n");
    writer.write("Node differences:\n");
    for (final NodeDifference difference : result.getNodeDifferences()) {
        writer.write("\tNode " + difference.getReferenceNode().getSignature() + "\n");
        writer.write("\t\tMissing");
        String separator = "=";
        for (final CallInformation callInformation : difference.getMissingInformation()) {
            writer.write(separator + callInformation);
            separator = ", ";
        }
        writer.write("\n");
        writer.write("\t\tAdditional");
        separator = "=";
        for (final CallInformation callInformation : difference.getMissingInformation()) {
            writer.write(separator + callInformation);
            separator = ", ";
        }
        writer.write("\n");
    }
    writer.close();
}
Also used : EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) NodeDifference(org.iobserve.evaluation.data.NodeDifference) BufferedWriter(java.io.BufferedWriter)

Example 9 with EntryCallNode

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

the class BehaviorModelJSONReader method execute.

@Override
protected void execute() throws Exception {
    final ObjectMapper mapper = new ObjectMapper();
    /**
     * Have to read the model by hand
     */
    final JsonNode tree = mapper.readTree(this.inputFile);
    if (!(tree instanceof ObjectNode)) {
        throw new IOException("Wrong format while reading model.");
    }
    final ObjectNode modelNode = (ObjectNode) tree;
    final BehaviorModel model = new BehaviorModel();
    /**
     * Read name.
     */
    final JsonNode name = modelNode.get("name");
    if (name.isTextual()) {
        model.setName(name.textValue());
    }
    // Read nodes
    final JsonNode nodesNode = modelNode.get("nodes");
    if (nodesNode.isArray()) {
        final ArrayNode nodesArray = (ArrayNode) nodesNode;
        final Iterator<JsonNode> nodesIter = nodesArray.elements();
        while (nodesIter.hasNext()) {
            final EntryCallNode newECNode = new EntryCallNode();
            final ObjectNode node = (ObjectNode) nodesIter.next();
            newECNode.setSignature(node.get("signature").textValue());
            final ArrayNode callInfos = (ArrayNode) node.get("entryCallInformation");
            final Iterator<JsonNode> callInfoIter = callInfos.elements();
            while (callInfoIter.hasNext()) {
                final ObjectNode ciNode = (ObjectNode) callInfoIter.next();
                final CallInformation info = new CallInformation(ciNode.get("informationSignature").textValue(), ciNode.get("informationCode").textValue(), ciNode.get("count").asInt());
                newECNode.mergeCallInformation(info);
            }
            model.addNode(newECNode, false);
        }
    }
    final ArrayNode edgesNode = (ArrayNode) modelNode.findValue("edges");
    final Iterator<JsonNode> edgesIter = edgesNode.elements();
    while (edgesIter.hasNext()) {
        final ObjectNode edge = (ObjectNode) edgesIter.next();
        final ObjectNode source = (ObjectNode) edge.get("source");
        final ObjectNode target = (ObjectNode) edge.get("target");
        final EntryCallNode sourceECNode = model.findNode(source.get("signature").textValue()).get();
        final EntryCallNode targetECNode = model.findNode(target.get("signature").textValue()).get();
        final EntryCallEdge newECEdge = new EntryCallEdge(sourceECNode, targetECNode, edge.get("calls").asInt());
        model.addEdge(newECEdge, false);
    }
    this.outputPort.send(model);
    this.workCompleted();
}
Also used : CallInformation(org.iobserve.analysis.behavior.models.extended.CallInformation) EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) BehaviorModel(org.iobserve.analysis.behavior.models.extended.BehaviorModel) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 10 with EntryCallNode

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

the class UsageModelToBehaviorModelStage method traverseAction.

private Map<EntryCallNode, Double> traverseAction(final BehaviorModel behaviorModel, final Optional<Map<EntryCallNode, Double>> optPreviousNodes, final AbstractUserAction action) {
    if (action instanceof Branch) {
        final Branch branch = (Branch) action;
        return this.traverseBranch(behaviorModel, optPreviousNodes, branch);
    } else if (action instanceof Loop) {
        final Loop loop = (Loop) action;
        return this.traverseLoop(behaviorModel, optPreviousNodes, loop);
    } else if (action instanceof EntryLevelSystemCall) {
        final Map<EntryCallNode, Double> endNodes = new HashMap<>();
        final EntryLevelSystemCall entryLevelSystemCall = (EntryLevelSystemCall) action;
        final EntryCallNode entryCallNode = this.createEntryCallNode(entryLevelSystemCall);
        behaviorModel.addNode(entryCallNode, true);
        if (optPreviousNodes.isPresent()) {
            optPreviousNodes.get().keySet().stream().map(previousNode -> new EntryCallEdge(previousNode, entryCallNode, optPreviousNodes.get().get(previousNode))).forEach(node -> behaviorModel.addEdge(node, true));
        }
        endNodes.put(entryCallNode, 1.0);
        return this.traverseAction(behaviorModel, Optional.of(endNodes), action.getSuccessor());
    } else if (action instanceof Stop) {
        return optPreviousNodes.isPresent() ? optPreviousNodes.get() : new HashMap<>();
    } else {
        // skip action
        return this.traverseAction(behaviorModel, optPreviousNodes, action.getSuccessor());
    }
}
Also used : Loop(org.palladiosimulator.pcm.usagemodel.Loop) BehaviorModel(org.iobserve.analysis.behavior.models.extended.BehaviorModel) BranchTransition(org.palladiosimulator.pcm.usagemodel.BranchTransition) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) HashMap(java.util.HashMap) OutputPort(teetime.framework.OutputPort) AbstractUserAction(org.palladiosimulator.pcm.usagemodel.AbstractUserAction) List(java.util.List) SingleOrNoneCollector(org.iobserve.analysis.behavior.SingleOrNoneCollector) AbstractConsumerStage(teetime.framework.AbstractConsumerStage) Map(java.util.Map) Optional(java.util.Optional) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) Branch(org.palladiosimulator.pcm.usagemodel.Branch) Start(org.palladiosimulator.pcm.usagemodel.Start) Loop(org.palladiosimulator.pcm.usagemodel.Loop) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) Stop(org.palladiosimulator.pcm.usagemodel.Stop) EntryCallEdge(org.iobserve.analysis.behavior.models.extended.EntryCallEdge) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) EntryCallNode(org.iobserve.analysis.behavior.models.extended.EntryCallNode) HashMap(java.util.HashMap) Stop(org.palladiosimulator.pcm.usagemodel.Stop) Branch(org.palladiosimulator.pcm.usagemodel.Branch)

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