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

refactored export factory

parent af5d809f
No related branches found
No related tags found
No related merge requests found
...@@ -13,9 +13,7 @@ import kieker.analysis.dev.dependencygraphs.AssemblyDependencyGraphCreatorStage; ...@@ -13,9 +13,7 @@ import kieker.analysis.dev.dependencygraphs.AssemblyDependencyGraphCreatorStage;
import kieker.analysis.dev.dependencygraphs.AssemblyDependencyGraphLevel; import kieker.analysis.dev.dependencygraphs.AssemblyDependencyGraphLevel;
import kieker.analysis.dev.dependencygraphs.DeploymentDependencyGraphCreatorStage; import kieker.analysis.dev.dependencygraphs.DeploymentDependencyGraphCreatorStage;
import kieker.analysis.dev.dependencygraphs.DeploymentDependencyGraphLevel; import kieker.analysis.dev.dependencygraphs.DeploymentDependencyGraphLevel;
import kieker.analysis.dev.dependencygraphs.DotComponentsDependencyExportStage; import kieker.analysis.dev.dependencygraphs.dot.DotDependencyGraphExporterFactory;
import kieker.analysis.dev.dependencygraphs.DotContainersDependencyExportStage;
import kieker.analysis.dev.dependencygraphs.DotOperationsDependencyExportStage;
import kieker.analysis.domain.AggregatedTrace; import kieker.analysis.domain.AggregatedTrace;
import kieker.analysis.domain.Trace; import kieker.analysis.domain.Trace;
import kieker.analysis.domain.systemdependency.SoftwareSystem; import kieker.analysis.domain.systemdependency.SoftwareSystem;
...@@ -28,6 +26,7 @@ import kieker.analysis.trace.graphoutput.DotTraceGraphFileWriterStage; ...@@ -28,6 +26,7 @@ import kieker.analysis.trace.graphoutput.DotTraceGraphFileWriterStage;
import kieker.analysis.trace.traversal.AggrTraceTraverserStage; import kieker.analysis.trace.traversal.AggrTraceTraverserStage;
import kieker.analysis.trace.traversal.TraceTraverserStage; import kieker.analysis.trace.traversal.TraceTraverserStage;
import kieker.analysis.util.graph.Graph; import kieker.analysis.util.graph.Graph;
import kieker.analysis.util.graph.export.dot.DotFileWriterStage;
import kieker.analysis.util.graph.export.graphml.GraphMLFileWriterStage; import kieker.analysis.util.graph.export.graphml.GraphMLFileWriterStage;
import kieker.common.record.IMonitoringRecord; import kieker.common.record.IMonitoringRecord;
...@@ -51,6 +50,8 @@ public class TraceAnalysisConfiguration extends Configuration { ...@@ -51,6 +50,8 @@ public class TraceAnalysisConfiguration extends Configuration {
public TraceAnalysisConfiguration(final File importDirectory) { public TraceAnalysisConfiguration(final File importDirectory) {
final DotDependencyGraphExporterFactory dotDependencyGraphExporterFactory = new DotDependencyGraphExporterFactory();
// Create the stages // Create the stages
final ReadingComposite reader = new ReadingComposite(importDirectory); final ReadingComposite reader = new ReadingComposite(importDirectory);
final MultipleInstanceOfFilter<IMonitoringRecord> typeFilter = new MultipleInstanceOfFilter<>(); final MultipleInstanceOfFilter<IMonitoringRecord> typeFilter = new MultipleInstanceOfFilter<>();
...@@ -108,11 +109,11 @@ public class TraceAnalysisConfiguration extends Configuration { ...@@ -108,11 +109,11 @@ public class TraceAnalysisConfiguration extends Configuration {
Distributor<SoftwareSystem> x2SoftwareSystemDistributor = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required Distributor<SoftwareSystem> x2SoftwareSystemDistributor = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required
// ContainerStatisticsDecoratorStage containersStatisticsDecorator = new ContainerStatisticsDecoratorStage(); //TODO remove // ContainerStatisticsDecoratorStage containersStatisticsDecorator = new ContainerStatisticsDecoratorStage(); //TODO remove
DeploymentDependencyGraphCreatorStage operationsDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.OPERATION); DeploymentDependencyGraphCreatorStage operationsDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.OPERATION);
DotOperationsDependencyExportStage dotOperationsDependencyExporter = new DotOperationsDependencyExportStage(graphFilesOutputDir); DotFileWriterStage dotOperationsDependencyExporter = dotDependencyGraphExporterFactory.getDeploymentOperationExporter(graphFilesOutputDir);
DeploymentDependencyGraphCreatorStage componentDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.COMPONENT); DeploymentDependencyGraphCreatorStage componentDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.COMPONENT);
DotComponentsDependencyExportStage dotComponentDependencyExporter = new DotComponentsDependencyExportStage(graphFilesOutputDir); DotFileWriterStage dotComponentDependencyExporter = dotDependencyGraphExporterFactory.getDeploymentComponentExporter(graphFilesOutputDir);
DeploymentDependencyGraphCreatorStage containerDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.CONTAINER); DeploymentDependencyGraphCreatorStage containerDependencyGraphCreator = new DeploymentDependencyGraphCreatorStage(DeploymentDependencyGraphLevel.CONTAINER);
DotContainersDependencyExportStage dotContainerDependencyExporter = new DotContainersDependencyExportStage(graphFilesOutputDir); DotFileWriterStage dotContainerDependencyExporter = dotDependencyGraphExporterFactory.getDeploymentContainerExporter(graphFilesOutputDir);
SoftwareSystemAggregatorStage softwareSystemAggregator = new SoftwareSystemAggregatorStage(); SoftwareSystemAggregatorStage softwareSystemAggregator = new SoftwareSystemAggregatorStage();
OperationsStatisticsDecoratorStage operationsStatisticsDecoratorAss = new OperationsStatisticsDecoratorStage(); OperationsStatisticsDecoratorStage operationsStatisticsDecoratorAss = new OperationsStatisticsDecoratorStage();
...@@ -120,9 +121,9 @@ public class TraceAnalysisConfiguration extends Configuration { ...@@ -120,9 +121,9 @@ public class TraceAnalysisConfiguration extends Configuration {
ComponentStatisticsDecoratorStage componentsStatisticsDecoratorAss = new ComponentStatisticsDecoratorStage(); ComponentStatisticsDecoratorStage componentsStatisticsDecoratorAss = new ComponentStatisticsDecoratorStage();
Distributor<SoftwareSystem> x2SoftwareSystemDistributorAss = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required Distributor<SoftwareSystem> x2SoftwareSystemDistributorAss = new Distributor<>(new CopyByReferenceStrategy()); // TODO name required
AssemblyDependencyGraphCreatorStage operationsDependencyGraphCreatorAss = new AssemblyDependencyGraphCreatorStage(AssemblyDependencyGraphLevel.OPERATION); AssemblyDependencyGraphCreatorStage operationsDependencyGraphCreatorAss = new AssemblyDependencyGraphCreatorStage(AssemblyDependencyGraphLevel.OPERATION);
DotOperationsDependencyExportStage dotOperationsDependencyExporterAss = new DotOperationsDependencyExportStage(graphFilesOutputDir); DotFileWriterStage dotOperationsDependencyExporterAss = dotDependencyGraphExporterFactory.getAssemblyOperationExporter(graphFilesOutputDir);
AssemblyDependencyGraphCreatorStage componentDependencyGraphCreatorAss = new AssemblyDependencyGraphCreatorStage(AssemblyDependencyGraphLevel.COMPONENT); AssemblyDependencyGraphCreatorStage componentDependencyGraphCreatorAss = new AssemblyDependencyGraphCreatorStage(AssemblyDependencyGraphLevel.COMPONENT);
DotComponentsDependencyExportStage dotComponentDependencyExporterAss = new DotComponentsDependencyExportStage(graphFilesOutputDir); DotFileWriterStage dotComponentDependencyExporterAss = dotDependencyGraphExporterFactory.getAssemblyComponentExporter(graphFilesOutputDir);
super.connectPorts(aggregatedTraceDistributor.getNewOutputPort(), softwareSystemCreator.getInputPort()); super.connectPorts(aggregatedTraceDistributor.getNewOutputPort(), softwareSystemCreator.getInputPort());
super.connectPorts(softwareSystemCreator.getOutputPort(), softwareSystemDistributor.getInputPort()); super.connectPorts(softwareSystemCreator.getOutputPort(), softwareSystemDistributor.getInputPort());
......
package kieker.analysis.dev.dependencygraphs.dot;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import kieker.analysis.util.graph.Vertex;
class ClusterLabelMapper implements Function<Vertex, String> {
private final List<String> annotations;
public ClusterLabelMapper(final String... annotations) {
this.annotations = Arrays.asList(annotations);
}
@Override
public String apply(final Vertex vertex) {
return this.annotations.get(vertex.getDepth()) + "\\n" + vertex.getProperty("Name").toString();
}
}
package kieker.analysis.dev.dependencygraphs; package kieker.analysis.dev.dependencygraphs.dot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -12,6 +12,7 @@ import kieker.analysis.util.graph.util.dot.attributes.DotEdgeAttribute; ...@@ -12,6 +12,7 @@ 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;
@Deprecated
public class DotComponentsDependencyExportStage extends DotFileWriterStage { public class DotComponentsDependencyExportStage extends DotFileWriterStage {
public DotComponentsDependencyExportStage(final String outputDirectory) { public DotComponentsDependencyExportStage(final String outputDirectory) {
......
package kieker.analysis.dev.dependencygraphs; package kieker.analysis.dev.dependencygraphs.dot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -12,6 +12,7 @@ import kieker.analysis.util.graph.util.dot.attributes.DotEdgeAttribute; ...@@ -12,6 +12,7 @@ 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;
@Deprecated
public class DotContainersDependencyExportStage extends DotFileWriterStage { public class DotContainersDependencyExportStage extends DotFileWriterStage {
public DotContainersDependencyExportStage(final String outputDirectory) { public DotContainersDependencyExportStage(final String outputDirectory) {
......
package kieker.analysis.dev.dependencygraphs; package kieker.analysis.dev.dependencygraphs.dot;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import kieker.analysis.util.graph.Vertex;
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.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 DotDependencyGraphConfigurationFactory { public class DotDependencyGraphExporterFactory {
public DotExportConfiguration getAssemblyComponentConfiguration() { public DotFileWriterStage getAssemblyComponentExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); DotExportConfiguration configuration = getNewBaseConfiguration();
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box"); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<assembly component>>")); configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<assembly component>>"));
return configuration; return createStage(outputDirectory, configuration);
} }
public DotExportConfiguration getAssemblyOperationConfiguration() { public DotFileWriterStage getAssemblyOperationExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); DotExportConfiguration configuration = getNewBaseConfiguration();
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval"); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<assembly component>>")); configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<assembly component>>"));
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper()); configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper());
return configuration; return createStage(outputDirectory, configuration);
} }
public DotExportConfiguration getDeploymentContainerConfiguration() { public DotFileWriterStage getDeploymentContainerExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); DotExportConfiguration configuration = getNewBaseConfiguration();
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box3d"); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box3d");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<execution container>>")); configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<execution container>>"));
return configuration; return createStage(outputDirectory, configuration);
} }
public DotExportConfiguration getDeploymentComponentConfiguration() { public DotFileWriterStage getDeploymentComponentExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); DotExportConfiguration configuration = getNewBaseConfiguration();
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box"); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<execution container>>")); configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<execution container>>"));
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<deployment component>>")); configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<deployment component>>"));
return configuration; return createStage(outputDirectory, configuration);
} }
public DotExportConfiguration getDeploymentOperationConfiguration() { public DotFileWriterStage getDeploymentOperationExporter(final String outputDirectory) {
DotExportConfiguration configuration = getNewBaseConfiguration(); DotExportConfiguration configuration = getNewBaseConfiguration();
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval"); configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<execution container>>", "<<deployment component>>")); configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<execution container>>", "<<deployment component>>"));
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper()); configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper());
return configuration; return createStage(outputDirectory, configuration);
} }
private DotExportConfiguration getNewBaseConfiguration() { private DotExportConfiguration getNewBaseConfiguration() {
...@@ -72,76 +66,8 @@ public class DotDependencyGraphConfigurationFactory { ...@@ -72,76 +66,8 @@ public class DotDependencyGraphConfigurationFactory {
return configuration; return configuration;
} }
// TODO move outside private DotFileWriterStage createStage(final String outputDirectory, final DotExportConfiguration configuration) {
private class VertexLabelMapper implements Function<Vertex, String> { return new DotFileWriterStage(outputDirectory, configuration);
private final String annotation;
public VertexLabelMapper() {
this.annotation = null;
}
public VertexLabelMapper(final String annotation) {
this.annotation = annotation;
}
@Override
public String apply(final Vertex vertex) {
final StringBuilder statistics = new StringBuilder();
if (this.annotation != null) {
statistics.append(this.annotation);
statistics.append("\\n");
}
statistics.append(vertex.getProperty("Name").toString());
statistics.append("\\n");
statistics.append(generateStatistics(vertex));
return statistics.toString();
}
private String generateStatistics(final Vertex vertex) {
final String temporalUnit = "xs"; // TODO temp
final List<String> statisticStrings = new ArrayList<>(5);
if (vertex.getProperty("MinDuration") != null) {
statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit);
}
if (vertex.getProperty("MaxDuration") != null) {
statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit);
}
if (vertex.getProperty("TotalDuration") != null) {
statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit);
}
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 after the 3rd last
if (statisticStrings.size() > 3) {
final int thirdLast = statisticStrings.size() - 3;
statisticStrings.set(thirdLast, statisticStrings.get(thirdLast).concat("\\n"));
}
return statisticStrings.stream().collect(Collectors.joining(", "));
}
}
// TODO move outside
private class ClusterLabelMapper implements Function<Vertex, String> {
private final List<String> annotations;
public ClusterLabelMapper(final String... annotations) {
this.annotations = Arrays.asList(annotations);
}
@Override
public String apply(final Vertex vertex) {
return this.annotations.get(vertex.getDepth()) + "\\n" + vertex.getProperty("Name").toString();
}
} }
} }
package kieker.analysis.dev.dependencygraphs; package kieker.analysis.dev.dependencygraphs.dot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -12,6 +12,7 @@ import kieker.analysis.util.graph.util.dot.attributes.DotEdgeAttribute; ...@@ -12,6 +12,7 @@ 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;
@Deprecated
public class DotOperationsDependencyExportStage extends DotFileWriterStage { public class DotOperationsDependencyExportStage extends DotFileWriterStage {
public DotOperationsDependencyExportStage(final String outputDirectory) { public DotOperationsDependencyExportStage(final String outputDirectory) {
......
package kieker.analysis.dev.dependencygraphs.dot;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import kieker.analysis.util.graph.Vertex;
class VertexLabelMapper implements Function<Vertex, String> {
private final String annotation;
public VertexLabelMapper() {
this.annotation = null;
}
public VertexLabelMapper(final String annotation) {
this.annotation = annotation;
}
@Override
public String apply(final Vertex vertex) {
final StringBuilder statistics = new StringBuilder();
if (this.annotation != null) {
statistics.append(this.annotation);
statistics.append("\\n");
}
statistics.append(vertex.getProperty("Name").toString());
statistics.append("\\n");
statistics.append(generateStatistics(vertex));
return statistics.toString();
}
private String generateStatistics(final Vertex vertex) {
final String temporalUnit = "xs"; // TODO temp
final List<String> statisticStrings = new ArrayList<>(5);
if (vertex.getProperty("MinDuration") != null) {
statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit);
}
if (vertex.getProperty("MaxDuration") != null) {
statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit);
}
if (vertex.getProperty("TotalDuration") != null) {
statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit);
}
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 after the 3rd last
if (statisticStrings.size() > 3) {
final int thirdLast = statisticStrings.size() - 3;
statisticStrings.set(thirdLast, statisticStrings.get(thirdLast).concat("\\n"));
}
return statisticStrings.stream().collect(Collectors.joining(", "));
}
}
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