use of org.iobserve.analysis.clustering.filter.models.EntryCallNode in project iobserve-analysis by research-iobserve.
the class ModelComparisonStage method execute.
/*
* (non-Javadoc)
*
* @see teetime.framework.AbstractStage#execute()
*/
@Override
protected void execute() throws Exception {
/**
* We cannot user else if here, as (a) there could be an input at each input port, (b) there
* could be a model at testModel but not at the referenceModel input, in an if-then-else
* style, the test model would not be received until we have a reference model, which
* unnecessarily would imply a sequence between both ports.
*/
if (this.referenceModel == null) {
this.referenceModel = this.referenceModelInputPort.receive();
}
if (this.testModel == null) {
this.testModel = this.testModelInputPort.receive();
}
/**
* We still have to check both, as there could be nothing a both ports.
*/
if (this.referenceModel != null && this.testModel != null) {
final ComparisonResult result = new ComparisonResult();
result.getBaselineNodes().addAll(this.referenceModel.getNodes());
result.getBaselineEdges().addAll(this.referenceModel.getEdges());
result.getTestModelNodes().addAll(this.testModel.getNodes());
result.getTestModelEdges().addAll(this.testModel.getEdges());
/**
* Missing nodes.
*/
for (final EntryCallNode baselineNode : this.referenceModel.getNodes()) {
final EntryCallNode testModelNode = this.findMatchingModelNode(this.testModel.getNodes(), baselineNode);
if (testModelNode == null) {
result.getMissingNodes().add(baselineNode);
} else {
result.getSimilarNodes().add(baselineNode);
/**
* Compute mismatch in call information.
*/
final List<CallInformation> missingInformation = this.computeAdditionalInformation(baselineNode.getEntryCallInformation(), testModelNode.getEntryCallInformation());
final List<CallInformation> additionalInformation = this.computeAdditionalInformation(testModelNode.getEntryCallInformation(), baselineNode.getEntryCallInformation());
result.getNodeDifferences().add(new NodeDifference(baselineNode, testModelNode, missingInformation, additionalInformation));
}
}
/**
* Additional nodes.
*/
for (final EntryCallNode testModelNode : this.testModel.getNodes()) {
final EntryCallNode baselineNode = this.findMatchingModelNode(this.referenceModel.getNodes(), testModelNode);
if (baselineNode == null) {
result.getAdditionalNodes().add(testModelNode);
}
}
/**
* Missing edges.
*/
int missingEdgeCount = 0;
for (final EntryCallEdge baselineEdge : this.referenceModel.getEdges()) {
final EntryCallEdge testModelEdge = this.findMatchingModelEdge(this.testModel.getEdges(), baselineEdge);
if (testModelEdge == null) {
missingEdgeCount += (int) baselineEdge.getCalls();
} else {
missingEdgeCount += Math.abs((int) (baselineEdge.getCalls() - testModelEdge.getCalls()));
}
}
result.setMissingEdgeCount(missingEdgeCount);
/**
* Additional edges.
*/
int additionalEdgeCount = 0;
for (final EntryCallEdge testModelEdge : this.testModel.getEdges()) {
final EntryCallEdge baselineEdge = this.findMatchingModelEdge(this.referenceModel.getEdges(), testModelEdge);
if (baselineEdge == null) {
additionalEdgeCount += (int) testModelEdge.getCalls();
} else {
additionalEdgeCount += Math.abs((int) (baselineEdge.getCalls() - testModelEdge.getCalls()));
}
}
result.setAdditionalEdgeCount(additionalEdgeCount);
/**
* Forget models after processing to be able to process the next elements.
*/
this.referenceModel = null;
this.testModel = null;
/**
* Add baseline and testModelNodes
*/
this.resultPort.send(result);
}
}
Aggregations