Skip to content
Snippets Groups Projects
Commit 04a7c739 authored by Sören Henning's avatar Sören Henning
Browse files

worked on #19

parent eff8623e
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
......@@ -20,6 +20,9 @@ public class DependencyCreatorStage extends AbstractTransformation<AggregatedTra
// TODO Update Statistics
operationsDependency.printDependcies();
// operationsDependency.printOperations();
this.getOutputPort().send(operationsDependency);
super.onTerminating();
......
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import kieker.analysis.traceanalysisdomain.AggregatedOperationCall;
......@@ -11,54 +12,135 @@ public class OperationsDependency {
// TODO Move to Domain package
private final Map<String, List<AggregatedOperationCall>> operations = new HashMap<>();
private final Map<OperationCallWrapper, List<AggregatedOperationCall>> operations = new HashMap<>();
private final Map<String, OperationsDependencyRelation> calls = new HashMap<>();
private final Map<OperationsDependencyRelation, Integer> calls = new HashMap<>();
public void addCall(final AggregatedOperationCall call) {
// TODO
if (!operations.containsKey("Key")) {
operations.put("Key", new ArrayList<>());
// TODO Handle failed OCs as own OC? -> currently yes
OperationCallWrapper key = new OperationCallWrapper(
new AggregatedOperationCall(call.getContainer(), call.getComponent(), call.getOperation(), 0, call.getFailedCause()));
OperationCallWrapper parentKey = null;
if (call.getParent() != null) {
parentKey = new OperationCallWrapper(new AggregatedOperationCall(call.getParent().getContainer(), call.getParent().getComponent(),
call.getParent().getOperation(), 0, call.getParent().getFailedCause()));
}
if (!operations.containsKey(key)) {
operations.put(key, new ArrayList<>());
}
operations.get(key).add(call);
operations.get("Key").add(call);
OperationsDependencyRelation keyEdge = new OperationsDependencyRelation(key, parentKey);
if (!calls.containsKey("Key")) {
calls.put("Key", new OperationsDependencyRelation(call.getParent(), call, call.getCalls()));
if (!calls.containsKey(keyEdge)) {
calls.put(keyEdge, 0);
}
calls.replace(keyEdge, (calls.get(keyEdge) + call.getCalls()));
}
// TODO Just for debugging
public void printOperations() {
System.out.println("Operations:");
System.out.println();
for (Entry<OperationCallWrapper, List<AggregatedOperationCall>> call : operations.entrySet()) {
calls.get("Key").addToCalls(call.getCalls());
System.out.println("Key:" + call.getKey().getOperationCall().getOperation() + " / " + call.getKey().getOperationCall().getFailedCause());
System.out.println("Calls:");
for (AggregatedOperationCall call2 : call.getValue()) {
System.out.println(call2.getOperation());
// System.out.println(call2.getFailedCause());
}
System.out.println();
}
}
private class OperationsDependencyRelation {
// TODO Just for debugging
private final AggregatedOperationCall caller;
public void printDependcies() {
private final AggregatedOperationCall callee;
System.out.println("Dependcies");
System.out.println("Size" + calls.size());
private int calls;
for (Entry<OperationsDependencyRelation, Integer> call : calls.entrySet()) {
public OperationsDependencyRelation(final AggregatedOperationCall caller, final AggregatedOperationCall callee, final int calls) {
this.caller = caller;
this.callee = callee;
this.calls = calls;
System.out.println("Set begin");
System.out.println(call.getKey().getCaller().getOperationCall().getOperation());
System.out.println(call.getKey().getCallee().getOperationCall().getOperation());
System.out.println(call.getValue());
System.out.println("Set end");
System.out.println();
}
}
/**
* Wrapper class for {@link AggregatedOperationCall} for calculating the hash code and check equality of two {@link AggregatedOperationCall}.
*
* @author Sören Henning
*
*/
private static class OperationCallWrapper {
public void addToCalls(final int calls) {
this.calls += calls;
private final AggregatedOperationCall operationCall;
public OperationCallWrapper(final AggregatedOperationCall operationCall) {
this.operationCall = operationCall;
}
public AggregatedOperationCall getOperationCall() {
return operationCall;
}
@Override
public int hashCode() {
return this.operationCall.calculateHashCode();
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof OperationCallWrapper)) {
return false;
}
return this.operationCall.isEqualTo(((OperationCallWrapper) obj).operationCall);
}
}
/**
* Relation between two {@link AggregatedOperationCall}. If this class will be
* extended by more attributes, new hashCode() and equals() methods are required.
*
* @author Sören Henning
*
*/
private class OperationsDependencyRelation {
private final OperationCallWrapper caller;
private final OperationCallWrapper callee;
public OperationsDependencyRelation(final OperationCallWrapper caller, final OperationCallWrapper callee) {
this.caller = caller;
this.callee = callee;
}
public AggregatedOperationCall getCaller() {
public OperationCallWrapper getCaller() {
return caller;
}
public AggregatedOperationCall getCallee() {
public OperationCallWrapper getCallee() {
return callee;
}
public int getCalls() {
return calls;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment