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

Merge branch 'Trace-Aggr-Analysis' of...

Merge branch 'Trace-Aggr-Analysis' of gitlab@build.se.informatik.uni-kiel.de:teetime/kieker-teetime-stages.git into Trace-Aggr-Analysis
parents 26b3dd0c 903eaa64
No related branches found
No related tags found
1 merge request!24Trace aggr analysis
package kieker.analysis.softwaresystem.dependencygraphs.dot;
import java.util.function.Function;
import kieker.analysis.util.graph.Vertex;
class ClusterLabelMapper implements Function<Vertex, String> {
private final boolean useShortNamesIfExists;
public ClusterLabelMapper(final boolean useShortNamesIfExists) {
this.useShortNamesIfExists = useShortNamesIfExists;
}
@Override
public String apply(final Vertex vertex) {
final StringBuilder label = new StringBuilder();
if (vertex.getProperty("Type") != null) {
label.append(vertex.getProperty("Type").toString());
label.append("\\n");
}
if (this.useShortNamesIfExists && vertex.getProperty("ShortName") != null) {
label.append(vertex.getProperty("ShortName").toString());
} else {
label.append(vertex.getProperty("Name").toString());
}
return label.toString();
}
}
package kieker.analysis.softwaresystem.dependencygraphs.dot; package kieker.analysis.softwaresystem.dependencygraphs.dot;
import kieker.analysis.util.graph.export.dot.DotExportConfiguration; import kieker.analysis.util.graph.export.dot.DotExportConfiguration;
import kieker.analysis.util.graph.export.dot.DotFileWriterStage; import kieker.analysis.util.graph.export.dot.DotFileWriterStage;
import kieker.analysis.util.graph.util.dot.attributes.DotClusterAttribute; import kieker.analysis.util.graph.util.dot.attributes.DotClusterAttribute;
import kieker.analysis.util.graph.util.dot.attributes.DotEdgeAttribute; import kieker.analysis.util.graph.util.dot.attributes.DotEdgeAttribute;
import kieker.analysis.util.graph.util.dot.attributes.DotGraphAttribute; import kieker.analysis.util.graph.util.dot.attributes.DotGraphAttribute;
import kieker.analysis.util.graph.util.dot.attributes.DotNodeAttribute; import kieker.analysis.util.graph.util.dot.attributes.DotNodeAttribute;
public class DotDependencyGraphExporterFactory { /**
* This class provides factory methods for creating {@link DotFileWriterStage}s
private final boolean useShortNames = true; // TODO Temp * with given {@link DotExportConfiguration}s.
*
private final VertexLabelMapper vertexLabelMapper = new VertexLabelMapper(useShortNames); * @author Sören Henning
private final ClusterLabelMapper clusterLabelMapper = new ClusterLabelMapper(useShortNames); *
*/
public DotFileWriterStage getAssemblyComponentExporter(final String outputDirectory) { public class DotDependencyGraphExporterFactory {
DotExportConfiguration configuration = getNewBaseConfiguration();
private final boolean useShortNames = true; // TODO Temp
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, this.vertexLabelMapper); private final VertexLabelMapper vertexLabelMapper = new VertexLabelMapper(useShortNames, true);
private final VertexLabelMapper clusterLabelMapper = new VertexLabelMapper(useShortNames, false);
return createStage(outputDirectory, configuration);
} public DotFileWriterStage getAssemblyComponentExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration();
public DotFileWriterStage getAssemblyOperationExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, this.vertexLabelMapper);
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, this.clusterLabelMapper); return createStage(outputDirectory, configuration);
}
return createStage(outputDirectory, configuration);
} public DotFileWriterStage getAssemblyOperationExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration();
public DotFileWriterStage getDeploymentContainerExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, this.clusterLabelMapper);
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box3d");
return createStage(outputDirectory, configuration);
return createStage(outputDirectory, configuration); }
}
public DotFileWriterStage getDeploymentContainerExporter(final String outputDirectory) {
public DotFileWriterStage getDeploymentComponentExporter(final String outputDirectory) { DotExportConfiguration configuration = getNewBaseConfiguration();
DotExportConfiguration configuration = getNewBaseConfiguration();
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box3d");
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, this.clusterLabelMapper); return createStage(outputDirectory, configuration);
}
return createStage(outputDirectory, configuration);
} public DotFileWriterStage getDeploymentComponentExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration();
public DotFileWriterStage getDeploymentOperationExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, this.clusterLabelMapper);
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, this.clusterLabelMapper); return createStage(outputDirectory, configuration);
}
return createStage(outputDirectory, configuration);
} public DotFileWriterStage getDeploymentOperationExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration();
private DotExportConfiguration getNewBaseConfiguration() {
DotExportConfiguration configuration = new DotExportConfiguration(); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, this.clusterLabelMapper);
configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, this.vertexLabelMapper); return createStage(outputDirectory, configuration);
configuration.addEdgeAttribute(DotEdgeAttribute.LABEL, (e -> e.getProperty("calls").toString())); }
return configuration; private DotExportConfiguration getNewBaseConfiguration() {
} DotExportConfiguration configuration = new DotExportConfiguration();
private DotFileWriterStage createStage(final String outputDirectory, final DotExportConfiguration configuration) { configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
return new DotFileWriterStage(outputDirectory, configuration); configuration.addNodeAttribute(DotNodeAttribute.LABEL, this.vertexLabelMapper);
} configuration.addEdgeAttribute(DotEdgeAttribute.LABEL, (e -> e.getProperty("calls").toString()));
} return configuration;
}
private DotFileWriterStage createStage(final String outputDirectory, final DotExportConfiguration configuration) {
return new DotFileWriterStage(outputDirectory, configuration);
}
}
package kieker.analysis.softwaresystem.dependencygraphs.dot; package kieker.analysis.softwaresystem.dependencygraphs.dot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import kieker.analysis.util.graph.Vertex; import kieker.analysis.util.graph.Graph;
import kieker.analysis.util.graph.Vertex;
class VertexLabelMapper implements Function<Vertex, String> { import kieker.analysis.util.graph.export.dot.DotExportConfiguration;
private final boolean useShortNamesIfExists; /**
* This function maps Vertices ({@code Vertex}) to label strings. It can be
public VertexLabelMapper(final boolean useShortNamesIfExists) { * used with a {@link DotExportConfiguration} when creating Dot files from
this.useShortNamesIfExists = useShortNamesIfExists; * {@link Graph}s.
} *
* @author Sören Henning
@Override *
public String apply(final Vertex vertex) { */
final StringBuilder statistics = new StringBuilder(); class VertexLabelMapper implements Function<Vertex, String> {
if (vertex.getProperty("Type") != null) {
statistics.append(vertex.getProperty("Type").toString()); private final boolean useShortNamesIfExists;
statistics.append("\\n"); private final boolean setStatistics;
}
if (this.useShortNamesIfExists && vertex.getProperty("ShortName") != null) { public VertexLabelMapper(final boolean useShortNamesIfExists, final boolean setStatistics) {
statistics.append(vertex.getProperty("ShortName").toString()); this.useShortNamesIfExists = useShortNamesIfExists;
} else { this.setStatistics = setStatistics;
statistics.append(vertex.getProperty("Name").toString()); }
}
statistics.append("\\n"); @Override
statistics.append(generateStatistics(vertex)); public String apply(final Vertex vertex) {
return statistics.toString(); final StringBuilder label = new StringBuilder();
} if (vertex.getProperty("Type") != null) {
label.append(vertex.getProperty("Type").toString());
private String generateStatistics(final Vertex vertex) { label.append("\\n");
final String temporalUnit = vertex.getProperty("DurationTimeUnit").toString(); }
if (this.useShortNamesIfExists && vertex.getProperty("ShortName") != null) {
final List<String> statisticStrings = new ArrayList<>(5); label.append(vertex.getProperty("ShortName").toString());
if (vertex.getProperty("MinDuration") != null) { } else {
statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit); label.append(vertex.getProperty("Name").toString());
} }
if (vertex.getProperty("MaxDuration") != null) { if (this.setStatistics) {
statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit); label.append("\\n");
} label.append(generateStatistics(vertex));
if (vertex.getProperty("TotalDuration") != null) { }
statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit); return label.toString();
} }
if (vertex.getProperty("MeanDuration") != null) {
statisticStrings.add("avg: " + vertex.getProperty("MeanDuration").toString() + temporalUnit); private String generateStatistics(final Vertex vertex) {
} final String temporalUnit = vertex.getProperty("DurationTimeUnit").toString();
if (vertex.getProperty("MedianDuration") != null) {
statisticStrings.add("med: " + vertex.getProperty("MedianDuration").toString() + temporalUnit); final List<String> statisticStrings = new ArrayList<>(5);
} if (vertex.getProperty("MinDuration") != null) {
statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit);
// If there are more than 3 statistics elements add a line break before the 2nd last }
if (statisticStrings.size() > 3) { if (vertex.getProperty("MaxDuration") != null) {
final int secondLast = statisticStrings.size() - 2; statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit);
statisticStrings.set(secondLast, "\\n" + statisticStrings.get(secondLast)); }
} if (vertex.getProperty("TotalDuration") != null) {
statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit);
return statisticStrings.stream().collect(Collectors.joining(", ")); }
} if (vertex.getProperty("MeanDuration") != null) {
statisticStrings.add("avg: " + vertex.getProperty("MeanDuration").toString() + temporalUnit);
} }
if (vertex.getProperty("MedianDuration") != null) {
statisticStrings.add("med: " + vertex.getProperty("MedianDuration").toString() + temporalUnit);
}
// If there are more than 3 statistics elements add a line break before the 2nd last
if (statisticStrings.size() > 3) {
final int secondLast = statisticStrings.size() - 2;
statisticStrings.set(secondLast, "\\n" + statisticStrings.get(secondLast));
}
return statisticStrings.stream().collect(Collectors.joining(", "));
}
}
package kieker.analysis.util.blueprintsgraph;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.util.wrappers.wrapped.WrappedGraph;
public class NamedGraph<T extends Graph> extends WrappedGraph<T> {
private String name;
private String fileName;
public NamedGraph(final String name, final String fileName, final T baseGraph) {
super(baseGraph);
this.name = name;
this.fileName = fileName;
}
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;
}
}
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