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

code clean up

parent 748ee7be
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
Pipeline #
Showing
with 22 additions and 440 deletions
...@@ -5,11 +5,6 @@ package kieker.analysis; ...@@ -5,11 +5,6 @@ package kieker.analysis;
import java.io.File; import java.io.File;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import teetime.framework.Execution; import teetime.framework.Execution;
/** /**
...@@ -26,19 +21,6 @@ public final class TraceAnalysis { ...@@ -26,19 +21,6 @@ public final class TraceAnalysis {
final Execution<TraceAnalysisConfiguration> analysis = new Execution<>(traceAnalysisConfiguration); final Execution<TraceAnalysisConfiguration> analysis = new Execution<>(traceAnalysisConfiguration);
analysis.executeBlocking(); analysis.executeBlocking();
/*
*
*
*
* TODO
*/
Graph graph = new TinkerGraph();
Vertex vertex = graph.addVertex(101);
Edge edge = vertex.addEdge("Label", vertex);
} }
} }
...@@ -106,14 +106,6 @@ public class TraceAnalysisConfiguration extends Configuration { ...@@ -106,14 +106,6 @@ public class TraceAnalysisConfiguration extends Configuration {
* *
*/ */
// TODO Temp Some examples for nested graphs
//
// final NestedGraphFactory nestedGraphFactory = new NestedGraphFactory();
// final ObjectProducer<NestedGraph<Graph>> nestedGraphProducerStage = new ObjectProducer<>(1, nestedGraphFactory);
// final NestedGraphPrinterStage nestedGraphPrinterStage = new NestedGraphPrinterStage();
//
// super.connectPorts(nestedGraphProducerStage.getOutputPort(), nestedGraphPrinterStage.getInputPort());
} }
public long getBeginTimestamp() { public long getBeginTimestamp() {
......
package kieker.analysis.dev.nestedgraph;
import java.util.HashSet;
import java.util.Set;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Features;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.GraphQuery;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.util.StringFactory;
import com.tinkerpop.blueprints.util.wrappers.WrapperGraph;
import com.tinkerpop.blueprints.util.wrappers.partition.PartitionGraph;
public class NestedGraph<T extends Graph> implements Graph, WrapperGraph<T> {
protected PartitionGraph<T> baseGraph;
private final Features features;
private static final String PARTITION_KEY = "__nested-graph-partition";
private static final String DEFAULT_PARTITION = "";
private final Set<NestedGraphPartition> partitions = new HashSet<>();
public NestedGraph(final T baseGraph) {
this.baseGraph = new PartitionGraph<>(baseGraph, PARTITION_KEY, DEFAULT_PARTITION);
this.features = this.baseGraph.getFeatures().copyFeatures();
this.features.isWrapper = true;
}
public void addPartition(final NestedGraphPartition partition) {
partitions.add(partition);
}
public Iterable<NestedGraphPartition> getPartitions() {
return partitions;
}
public Iterable<Vertex> getVerticesForPartition(final NestedGraphPartition partition) {
baseGraph.removeReadPartition(DEFAULT_PARTITION);
baseGraph.addReadPartition(partition.getName());
Set<Vertex> vertices = new HashSet<Vertex>();
for (Vertex vertex : baseGraph.getVertices()) {
vertices.add(vertex);
}
baseGraph.removeReadPartition(partition.getName());
baseGraph.addReadPartition(DEFAULT_PARTITION);
return vertices;
}
public Iterable<Edge> getEdgesForPartition(final NestedGraphPartition partition) {
baseGraph.removeReadPartition(DEFAULT_PARTITION);
baseGraph.addReadPartition(partition.getName());
Set<Edge> edges = new HashSet<Edge>();
for (Edge edge : baseGraph.getEdges()) {
edges.add(edge);
}
baseGraph.removeReadPartition(partition.getName());
baseGraph.addReadPartition(DEFAULT_PARTITION);
return edges;
}
public Vertex addVertexToPartition(final Object id, final NestedGraphPartition partition) {
baseGraph.setWritePartition(partition.getName());
Vertex vertex = baseGraph.addVertex(id);
baseGraph.setWritePartition(DEFAULT_PARTITION);
return vertex;
}
public Edge addEdgeToPartition(final Object id, final Vertex outVertex, final Vertex inVertex, final String label, final NestedGraphPartition partition) {
baseGraph.setWritePartition(partition.getName());
Edge edge = baseGraph.addEdge(id, outVertex, inVertex, label);
baseGraph.setWritePartition(DEFAULT_PARTITION);
return edge;
}
@Override
public Vertex addVertex(final Object id) {
return baseGraph.addVertex(id);
}
@Override
public Vertex getVertex(final Object id) {
return baseGraph.getVertex(id);
}
@Override
public Iterable<Vertex> getVertices() {
return this.baseGraph.getVertices();
}
@Override
public Iterable<Vertex> getVertices(final String key, final Object value) {
return this.baseGraph.getVertices(key, value);
}
@Override
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
return baseGraph.addEdge(id, outVertex, inVertex, label);
}
@Override
public Edge getEdge(final Object id) {
return baseGraph.getEdge(id);
}
@Override
public Iterable<Edge> getEdges() {
return baseGraph.getEdges();
}
@Override
public Iterable<Edge> getEdges(final String key, final Object value) {
return this.baseGraph.getEdges(key, value);
}
@Override
public void removeEdge(final Edge edge) {
baseGraph.removeEdge(edge);
}
@Override
public void removeVertex(final Vertex vertex) {
baseGraph.removeVertex(vertex);
}
@Override
public T getBaseGraph() {
return baseGraph.getBaseGraph();
}
@Override
public GraphQuery query() {
return this.baseGraph.query();
}
@Override
public String toString() {
return StringFactory.graphString(this, this.baseGraph.toString());
}
@Override
public Features getFeatures() {
return this.features;
}
@Override
public void shutdown() {
this.baseGraph.shutdown();
}
}
package kieker.analysis.dev.nestedgraph;
import java.util.HashSet;
import java.util.Set;
public class NestedGraphPartition {
private String name;
private String label;
private final Set<NestedGraphPartition> subPartitions = new HashSet<>();
public NestedGraphPartition(final String name) {
this(name, null);
}
public NestedGraphPartition(final String name, final String label) {
this.name = name;
this.label = label;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getLabel() {
return label;
}
public void setLabel(final String label) {
this.label = label;
}
public Iterable<NestedGraphPartition> getSubPartitions() {
return subPartitions;
}
public void addSubPartition(final NestedGraphPartition subPartition) {
subPartitions.add(subPartition);
}
}
package kieker.analysis.dev.nestedgraph;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Features;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.GraphQuery;
import com.tinkerpop.blueprints.Vertex;
//TODO implements
public class SubGraph implements Graph {
private final NestedGraph<Graph> mainGraph; // TODO has to be nestable Graph
public SubGraph(final NestedGraph<Graph> mainGraph) {
this.mainGraph = mainGraph;
// TODO subGraph beim mainGraph anmelden
}
public NestedGraph<Graph> getMainGraph() {
return mainGraph;
}
@Override
public Features getFeatures() {
// TODO Auto-generated method stub
return null;
}
@Override
public Vertex addVertex(final Object id) {
// TODO Auto-generated method stub
return null;
}
@Override
public Vertex getVertex(final Object id) {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeVertex(final Vertex vertex) {
// TODO Auto-generated method stub
}
@Override
public Iterable<Vertex> getVertices() {
// TODO Auto-generated method stub
return null;
}
@Override
public Iterable<Vertex> getVertices(final String key, final Object value) {
// TODO Auto-generated method stub
return null;
}
@Override
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
// TODO Auto-generated method stub
return null;
}
@Override
public Edge getEdge(final Object id) {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeEdge(final Edge edge) {
// TODO Auto-generated method stub
}
@Override
public Iterable<Edge> getEdges() {
// TODO Auto-generated method stub
return null;
}
@Override
public Iterable<Edge> getEdges(final String key, final Object value) {
// TODO Auto-generated method stub
return null;
}
@Override
public GraphQuery query() {
// TODO Auto-generated method stub
return null;
}
@Override
public void shutdown() {
// TODO Auto-generated method stub
}
}
package kieker.analysis.dev.nestedgraphstages;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import kieker.analysis.dev.nestedgraph.NestedGraph;
import kieker.analysis.dev.nestedgraph.NestedGraphPartition;
import teetime.util.ConstructorClosure;
public class NestedGraphFactory implements ConstructorClosure<NestedGraph<Graph>> {
@Override
public NestedGraph<Graph> create() {
NestedGraph<Graph> graph = new NestedGraph<Graph>(new TinkerGraph());
Vertex entry = graph.addVertex("Entry");
NestedGraphPartition partitionBookstore = new NestedGraphPartition("Bookstore");
graph.addPartition(partitionBookstore);
Vertex searchBook = graph.addVertexToPartition("searchBook()", partitionBookstore);
NestedGraphPartition partitionCRM = new NestedGraphPartition("CRM");
graph.addPartition(partitionCRM);
Vertex getOffers = graph.addVertexToPartition("getOffers()", partitionCRM);
Vertex customMethod = graph.addVertexToPartition("customMethod()", partitionCRM);
NestedGraphPartition partitionCatalog = new NestedGraphPartition("Catalog");
graph.addPartition(partitionCatalog);
Vertex getBook = graph.addVertexToPartition("getBook()", partitionCatalog);
graph.addEdge(null, entry, searchBook, "100");
graph.addEdge(null, searchBook, getBook, "100");
graph.addEdge(null, searchBook, getOffers, "100");
graph.addEdge(null, getOffers, getBook, "96");
graph.addEdge(null, getOffers, customMethod, "0");
return graph;
}
}
package kieker.analysis.dev.nestedgraphstages;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import kieker.analysis.dev.nestedgraph.NestedGraph;
import kieker.analysis.dev.nestedgraph.NestedGraphPartition;
import teetime.framework.AbstractConsumerStage;
public class NestedGraphPrinterStage extends AbstractConsumerStage<NestedGraph<Graph>> {
@Override
protected void execute(final NestedGraph<Graph> graph) {
System.out.println("TOP LEVEL:");
for (Vertex vertex : graph.getVertices()) {
System.out.println(vertex);
}
for (Edge edge : graph.getEdges()) {
System.out.println(edge);
}
for (NestedGraphPartition partition : graph.getPartitions()) {
System.out.println("PARTITION: " + partition.getName());
for (Vertex vertex : graph.getVerticesForPartition(partition)) {
System.out.println(vertex);
}
for (Edge edge : graph.getEdgesForPartition(partition)) {
System.out.println(edge);
}
}
}
}
...@@ -14,11 +14,19 @@ import com.tinkerpop.blueprints.Edge; ...@@ -14,11 +14,19 @@ import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph; import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.blueprints.Vertex;
import kieker.analysis.graph.export.dot.DotFileWriterStage;
import kieker.analysis.util.DotBuilder; import kieker.analysis.util.DotBuilder;
import kieker.analysis.util.graph.NamedGraph; import kieker.analysis.util.blueprintsgraph.NamedGraph;
import teetime.framework.AbstractConsumerStage; import teetime.framework.AbstractConsumerStage;
/**
* @deprecated use {@link DotFileWriterStage} instead.
*
* @author Sören Henning
*
*/
@Deprecated
public class DotGraphWriter extends AbstractConsumerStage<NamedGraph<Graph>> { public class DotGraphWriter extends AbstractConsumerStage<NamedGraph<Graph>> {
private final String outputDir; private final String outputDir;
......
...@@ -4,10 +4,18 @@ import java.io.IOException; ...@@ -4,10 +4,18 @@ import java.io.IOException;
import com.tinkerpop.blueprints.Graph; import com.tinkerpop.blueprints.Graph;
import kieker.analysis.util.graph.NamedGraph; import kieker.analysis.graph.export.graphml.GraphMLFileWriterComposite;
import kieker.analysis.util.blueprintsgraph.NamedGraph;
import teetime.framework.AbstractConsumerStage; import teetime.framework.AbstractConsumerStage;
/**
* @deprecated use {@link GraphMLFileWriterComposite} instead.
*
* @author Sören Henning
*
*/
@Deprecated
public class GraphMLWriter extends AbstractConsumerStage<NamedGraph<Graph>> { public class GraphMLWriter extends AbstractConsumerStage<NamedGraph<Graph>> {
private final String outputDir; private final String outputDir;
......
...@@ -6,10 +6,12 @@ import java.util.Map.Entry; ...@@ -6,10 +6,12 @@ import java.util.Map.Entry;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import kieker.analysis.graph.util.dot.DotGraphWriter;
/** /**
* Simple class for building and representing dot graph files. * Simple class for building and representing dot graph files.
* *
* @deprecated use {@link DotExporter.DotWriter} instead. * @deprecated use {@link DotGraphWriter} instead.
* *
* @author Sören Henning * @author Sören Henning
* *
...@@ -38,20 +40,17 @@ public class DotBuilder { ...@@ -38,20 +40,17 @@ public class DotBuilder {
this(graphName, DEFAULT_GRAPH_TYPE); this(graphName, DEFAULT_GRAPH_TYPE);
} }
// TODO graphType has to be one of "graph", "digraph" or "subgraph" so maybe use an enum
public DotBuilder(final String graphName, final String graphType) { public DotBuilder(final String graphName, final String graphType) {
start = graphType + " " + graphName + " " + START_BRACKET + "\n"; start = graphType + " " + graphName + " " + START_BRACKET + "\n";
end = END_BRACKET; end = END_BRACKET;
} }
// TODO Deprecated
public DotBuilder(final String name, final Map<String, String> defaultNodeProperties, final Map<String, String> defaultEdgeProperties) { public DotBuilder(final String name, final Map<String, String> defaultNodeProperties, final Map<String, String> defaultEdgeProperties) {
this(name); this(name);
this.defaultNodeProperties = defaultNodeProperties; this.defaultNodeProperties = defaultNodeProperties;
this.defaultEdgeProperties = defaultEdgeProperties; this.defaultEdgeProperties = defaultEdgeProperties;
} }
// TODO Deprecated
public DotBuilder(final String name, final Map<String, String> defaultNodeProperties, final Map<String, String> defaultEdgeProperties, public DotBuilder(final String name, final Map<String, String> defaultNodeProperties, final Map<String, String> defaultEdgeProperties,
final Map<String, String> defaultProperties) { final Map<String, String> defaultProperties) {
this(name, defaultNodeProperties, defaultEdgeProperties); this(name, defaultNodeProperties, defaultEdgeProperties);
......
package kieker.analysis.util.graph; package kieker.analysis.util.blueprintsgraph;
import com.tinkerpop.blueprints.Graph; import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.util.wrappers.wrapped.WrappedGraph; import com.tinkerpop.blueprints.util.wrappers.wrapped.WrappedGraph;
......
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