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

Worked on #15

parent be7a2313
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
Showing
with 262 additions and 21 deletions
......@@ -12,11 +12,12 @@ import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import kieker.analysis.trace.traversal.NamedGraph;
import kieker.tools.traceAnalysis.filter.visualization.util.dot.DotFactory;
import teetime.framework.AbstractConsumerStage;
public class DotGraphWriter extends AbstractConsumerStage<Graph> {
public class DotGraphWriter extends AbstractConsumerStage<NamedGraph> {
private final String outputDir;
......@@ -25,8 +26,8 @@ public class DotGraphWriter extends AbstractConsumerStage<Graph> {
}
@Override
protected void execute(final Graph graph) {
String dotGraph = createDotGraph(graph);
protected void execute(final NamedGraph graph) {
String dotGraph = createDotGraph(graph.getGraph());
try {
writeDotGraphFile(dotGraph);
......
......@@ -4,22 +4,24 @@ import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import kieker.analysis.trace.traversal.NamedGraph;
import kieker.analysis.traceanalysisdomain.AbstractOperationCall;
import kieker.analysis.traceanalysisdomain.AbstractTrace;
import teetime.stage.basic.AbstractTransformation;
//TODO: really necessary to have 2 type parameters?
public class GraphBuilder<T extends AbstractTrace<C>, C extends AbstractOperationCall<C>> extends AbstractTransformation<T, Graph> {
public class GraphBuilder<T extends AbstractTrace<C>, C extends AbstractOperationCall<C>> extends AbstractTransformation<T, NamedGraph> {
@Override
protected void execute(final T trace) {
Graph graph = new TinkerGraph();
String graphName = String.valueOf(trace.getRootOperationCall().hashCode());
transformOperationCallsRecurive(graph, trace.getRootOperationCall(), null);
this.getOutputPort().send(graph);
this.getOutputPort().send(new NamedGraph(graphName, graphName, graph));
}
private void transformOperationCallsRecurive(final Graph graph, final C operationCall, final Vertex parentVertex) {
......
......@@ -2,11 +2,11 @@ package kieker.analysis.stage.graphoutput;
import java.io.IOException;
import com.tinkerpop.blueprints.Graph;
import kieker.analysis.trace.traversal.NamedGraph;
import teetime.framework.AbstractConsumerStage;
public class GraphMLWriter extends AbstractConsumerStage<Graph> {
public class GraphMLWriter extends AbstractConsumerStage<NamedGraph> {
private final String outputDir;
......@@ -15,18 +15,17 @@ public class GraphMLWriter extends AbstractConsumerStage<Graph> {
}
@Override
protected void execute(final Graph graph) {
protected void execute(final NamedGraph graph) {
String outputFile = outputDir + "/traces.xml";
com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter writer = new com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter(graph);
com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter writer = new com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter(graph.getGraph());
writer.setNormalize(true);
try {
writer.outputGraph(outputFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new IllegalStateException(e);
}
}
......
......@@ -18,12 +18,10 @@ package kieker.analysis.stage.tracediagnosis;
import java.util.List;
import com.tinkerpop.blueprints.Graph;
import kieker.analysis.stage.graphoutput.DotGraphWriter;
import kieker.analysis.stage.graphoutput.GraphBuilder;
import kieker.analysis.stage.graphoutput.GraphMLWriter;
import kieker.analysis.traceanalysisdomain.AggregatedOperationCall;
import kieker.analysis.trace.traversal.AggrTraceTraverserStage;
import kieker.analysis.trace.traversal.NamedGraph;
import kieker.analysis.traceanalysisdomain.AggregatedTrace;
import kieker.analysis.traceanalysisdomain.Trace;
......@@ -57,17 +55,15 @@ public final class TraceAggregationComposite extends AbstractCompositeStage {
String graphFilesOutputDir = "example/event monitoring log/output"; // TODO Temp hard coded
final Distributor<AggregatedTrace> distributor = new Distributor<>(new CopyByReferenceStrategy());
// DotGraphWriterOld<AggregatedTrace, AggregatedOperationCall> callDotGraphWriter = new DotGraphWriterOld<>(); TODO Remove
GraphBuilder<AggregatedTrace, AggregatedOperationCall> aggregatedTraceGraphBuilder = new GraphBuilder<>();
final Distributor<Graph> graphDistributor = new Distributor<>(new CopyByReferenceStrategy());
AggrTraceTraverserStage aggrTraceTraverser = new AggrTraceTraverserStage();
final Distributor<NamedGraph> graphDistributor = new Distributor<>(new CopyByReferenceStrategy());
GraphMLWriter graphMLWriter = new GraphMLWriter(graphFilesOutputDir);
DotGraphWriter dotGraphWriter = new DotGraphWriter(graphFilesOutputDir);
super.connectPorts(this.statisticsDecorator.getOutputPort(), distributor.getInputPort());
super.connectPorts(distributor.getNewOutputPort(), this.tracesCollector.getInputPort());
// super.connectPorts(distributor.getNewOutputPort(), callDotGraphWriter.getInputPort()); TODO Remove
super.connectPorts(distributor.getNewOutputPort(), aggregatedTraceGraphBuilder.getInputPort());
super.connectPorts(aggregatedTraceGraphBuilder.getOutputPort(), graphDistributor.getInputPort());
super.connectPorts(distributor.getNewOutputPort(), aggrTraceTraverser.getInputPort());
super.connectPorts(aggrTraceTraverser.getOutputPort(), graphDistributor.getInputPort());
super.connectPorts(graphDistributor.getNewOutputPort(), graphMLWriter.getInputPort());
super.connectPorts(graphDistributor.getNewOutputPort(), dotGraphWriter.getInputPort());
......
package kieker.analysis.trace.traversal;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import kieker.analysis.traceanalysisdomain.AggregatedOperationCall;
public class AggrTrace2Blueprint extends OperationCallVisitor<AggregatedOperationCall> {
private final Graph graph;
public AggrTrace2Blueprint() {
super();
this.graph = new TinkerGraph();
}
@Override
public void visit(final AggregatedOperationCall operationCall) {
Vertex vertex = graph.addVertex(operationCall.hashCode());
vertex.setProperty("label", operationCall.getOperation());
// TODO maybe more properties?
AggregatedOperationCall parentCall = operationCall.getParent();
if (parentCall != null) {
Vertex parentVertex = graph.getVertex(operationCall.getParent().hashCode());
if (parentVertex != null) {
graph.addEdge(null, parentVertex, vertex, "");
}
}
}
public Graph getGraph() {
return graph;
}
}
package kieker.analysis.trace.traversal;
import kieker.analysis.traceanalysisdomain.AggregatedOperationCall;
import kieker.analysis.traceanalysisdomain.AggregatedTrace;
import teetime.stage.basic.AbstractTransformation;
public class AggrTraceTraverserStage extends AbstractTransformation<AggregatedTrace, NamedGraph> {
@Override
protected void execute(final AggregatedTrace trace) {
AggrTrace2Blueprint aggrTrace2Blueprint = new AggrTrace2Blueprint();
TraceTraverser<AggregatedTrace, AggregatedOperationCall> traverser = new TraceTraverser<>(aggrTrace2Blueprint);
traverser.traverse(trace);
String name = String.valueOf(trace.hashCode());
NamedGraph graph = new NamedGraph(name, name, aggrTrace2Blueprint.getGraph());
this.getOutputPort().send(graph);
}
}
package kieker.analysis.trace.traversal;
import com.tinkerpop.blueprints.Graph;
public class NamedGraph {
private String name;
private String fileName;
private Graph graph;
public NamedGraph(final String name, final String fileName, final Graph graph) {
this.name = name;
this.fileName = fileName;
this.graph = graph;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getFileName() {
return fileName;
}
public void setFileName(final String fileName) {
this.fileName = fileName;
}
public Graph getGraph() {
return graph;
}
public void setGraph(final Graph graph) {
this.graph = graph;
}
}
package kieker.analysis.trace.traversal;
import kieker.analysis.traceanalysisdomain.AbstractOperationCall;
public abstract class OperationCallVisitor<C extends AbstractOperationCall<C>> {
public abstract void visit(C operationCall);
}
package kieker.analysis.trace.traversal;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import kieker.analysis.traceanalysisdomain.OperationCall;
public class TraceToBlueprint extends OperationCallVisitor<OperationCall> {
private final Graph graph;
public TraceToBlueprint() {
super();
this.graph = new TinkerGraph();
}
@Override
public void visit(final OperationCall operationCall) {
Vertex vertex = graph.addVertex(operationCall.hashCode());
vertex.setProperty("label", operationCall.getOperation());
// TODO maybe more properties?
OperationCall parentCall = operationCall.getParent();
if (parentCall != null) {
Vertex parentVertex = graph.getVertex(operationCall.getParent().hashCode());
if (parentVertex != null) {
graph.addEdge(null, parentVertex, vertex, "");
}
}
}
public Graph getGraph() {
return graph;
}
}
package kieker.analysis.trace.traversal;
import java.util.ArrayList;
import java.util.List;
import kieker.analysis.traceanalysisdomain.AbstractOperationCall;
import kieker.analysis.traceanalysisdomain.AbstractTrace;
public class TraceTraverser<T extends AbstractTrace<C>, C extends AbstractOperationCall<C>> {
private List<OperationCallVisitor<C>> visitors;
public TraceTraverser() {
super();
this.visitors = new ArrayList<>();
}
public TraceTraverser(final OperationCallVisitor<C> visitor) {
this();
visitors.add(visitor);
}
public TraceTraverser(final List<OperationCallVisitor<C>> visitors) {
super();
this.visitors = visitors;
}
public void traverse(final T trace) {
handleOperationCallsRecursively(trace.getRootOperationCall());
}
private void handleOperationCallsRecursively(final C operationCall) {
handleOperationCall(operationCall);
for (C childOperationCall : operationCall.getChildren()) {
handleOperationCallsRecursively(childOperationCall);
}
}
private void handleOperationCall(final C operationCall) {
for (OperationCallVisitor<C> visitor : visitors) {
visitor.visit(operationCall);
}
}
public List<OperationCallVisitor<C>> getVisitors() {
return visitors;
}
public void setVisitors(final List<OperationCallVisitor<C>> visitors) {
this.visitors = visitors;
}
public void addVisitor(final OperationCallVisitor<C> visitor) {
visitors.add(visitor);
}
}
package kieker.analysis.trace.traversal;
import kieker.analysis.traceanalysisdomain.OperationCall;
import kieker.analysis.traceanalysisdomain.Trace;
import teetime.stage.basic.AbstractTransformation;
public class TraceTraverserStage extends AbstractTransformation<Trace, NamedGraph> {
@Override
protected void execute(final Trace trace) {
TraceToBlueprint traceToBlueprint = new TraceToBlueprint();
TraceTraverser<Trace, OperationCall> traverser = new TraceTraverser<>(traceToBlueprint);
traverser.traverse(trace);
String name = String.valueOf(trace.hashCode());
NamedGraph graph = new NamedGraph(name, name, traceToBlueprint.getGraph());
this.getOutputPort().send(graph);
}
}
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