From 20c24bb71390f357302f6f46201fe422b4bf4158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <stu114708@informatik.uni-kiel.de> Date: Mon, 20 Jun 2016 16:09:21 +0200 Subject: [PATCH] worked on assembly dependency graphs --- .../AssemblyDependencyGraphCreator.java | 125 ++++++++++++++++++ .../AssemblyDependencyGraphCreatorStage.java | 28 ++++ .../AssemblyDependencyGraphLevel.java | 7 + ...otDependencyGraphConfigurationFactory.java | 48 +++++++ 4 files changed, 208 insertions(+) create mode 100644 src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java create mode 100644 src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreatorStage.java create mode 100644 src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphLevel.java create mode 100644 src/main/java/kieker/analysis/dev/dependencygraphs/DotDependencyGraphConfigurationFactory.java diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java new file mode 100644 index 00000000..89863f20 --- /dev/null +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreator.java @@ -0,0 +1,125 @@ +package kieker.analysis.dev.dependencygraphs; + +import java.util.Collection; +import java.util.EnumSet; +import java.util.Set; + +import kieker.analysis.domain.systemdependency.Component; +import kieker.analysis.domain.systemdependency.Container; +import kieker.analysis.domain.systemdependency.Dependency; +import kieker.analysis.domain.systemdependency.Operation; +import kieker.analysis.domain.systemdependency.SoftwareSystem; +import kieker.analysis.util.graph.Edge; +import kieker.analysis.util.graph.Graph; +import kieker.analysis.util.graph.Vertex; +import kieker.analysis.util.graph.impl.GraphImpl; + +public class AssemblyDependencyGraphCreator { + + private final AssemblyDependencyGraphLevel depth; + private final Set<AssemblyDependencyGraphLevel> relations; + + public AssemblyDependencyGraphCreator(final AssemblyDependencyGraphLevel depth) { + this.depth = depth; + this.relations = EnumSet.of(depth); + } + + public AssemblyDependencyGraphCreator(final AssemblyDependencyGraphLevel depth, final Collection<AssemblyDependencyGraphLevel> relations) { + this.depth = depth; + this.relations = EnumSet.copyOf(relations); + } + + public Graph create(final SoftwareSystem softwareSystem) { + + Graph graph = new GraphImpl(); + switch (this.depth) { + case COMPONENT: + graph.setName("DeploymentComponentsDependencyGraph"); + break; + case OPERATION: + graph.setName("DeploymentOperationsDependencyGraph"); + break; + } + + for (Container container : softwareSystem.getContainers()) { + + // This should only be one (DEFAULT) + + if (this.depth.compareTo(AssemblyDependencyGraphLevel.COMPONENT) <= 0) { + + for (Component component : container.getComponents()) { + + Vertex componentVertex = graph.addVertex(component.getIdentifier()); + componentVertex.setProperty("Name", component.getName()); + componentVertex.setProperty("Type", "Component"); + componentVertex.setProperty("MaxDuration", component.getMaxDuration()); + componentVertex.setProperty("MinDuration", component.getMinDuration()); + componentVertex.setProperty("MeanDuration", component.getMeanDuration()); + componentVertex.setProperty("MedianDuration", component.getMedianDuration()); + componentVertex.setProperty("TotalDuration", component.getTotalDuration()); + + if (this.depth.compareTo(AssemblyDependencyGraphLevel.OPERATION) <= 0) { + Graph operationsGraph = componentVertex.addChildGraph(); + + for (Operation operation : component.getOperations()) { + Vertex operationVertex = operationsGraph.addVertex(operation.getIdentifier()); + operationVertex.setProperty("Name", operation.getName()); + operationVertex.setProperty("Type", "Operation"); + operationVertex.setProperty("MaxDuration", operation.getMaxDuration()); + operationVertex.setProperty("MinDuration", operation.getMinDuration()); + operationVertex.setProperty("MeanDuration", operation.getMeanDuration()); + operationVertex.setProperty("MedianDuration", operation.getMedianDuration()); + operationVertex.setProperty("TotalDuration", operation.getTotalDuration()); + } + + } + } + + } + } + + if (this.relations.contains(AssemblyDependencyGraphLevel.COMPONENT)) { + for (Dependency<Component> dependency : softwareSystem.getComponentDependencies()) { + + String callerContainerIdentifier = dependency.getCaller().getContainer().getIdentifier(); + String callerComponentIdentifier = dependency.getCaller().getIdentifier(); + + String calleeContainerIdentifier = dependency.getCallee().getContainer().getIdentifier(); + String calleeComponentIdentifier = dependency.getCallee().getIdentifier(); + + Vertex callerVertex = graph.getVertex(callerContainerIdentifier).getChildGraph().getVertex(callerComponentIdentifier); + Vertex calleeVertex = graph.getVertex(calleeContainerIdentifier).getChildGraph().getVertex(calleeComponentIdentifier); + + Edge dependencyEdge = graph.addEdge(null, callerVertex, calleeVertex); + dependencyEdge.setProperty("calls", dependency.getCalls()); + dependencyEdge.setProperty("failuredCalls", dependency.getFailuredCalls()); + } + } + + if (this.relations.contains(AssemblyDependencyGraphLevel.OPERATION)) { + for (Dependency<Operation> dependency : softwareSystem.getOperationDependencies()) { + + String callerContainerIdentifier = dependency.getCaller().getComponent().getContainer().getIdentifier(); + String callerComponentIdentifier = dependency.getCaller().getComponent().getIdentifier(); + String callerOperationIdentifier = dependency.getCaller().getIdentifier(); + + String calleeContainerIdentifier = dependency.getCallee().getComponent().getContainer().getIdentifier(); + String calleeComponentIdentifier = dependency.getCallee().getComponent().getIdentifier(); + String calleeOperationIdentifier = dependency.getCallee().getIdentifier(); + + Vertex callerVertex = graph.getVertex(callerContainerIdentifier).getChildGraph().getVertex(callerComponentIdentifier).getChildGraph() + .getVertex(callerOperationIdentifier); + Vertex calleeVertex = graph.getVertex(calleeContainerIdentifier).getChildGraph().getVertex(calleeComponentIdentifier).getChildGraph() + .getVertex(calleeOperationIdentifier); + + Edge dependencyEdge = graph.addEdge(null, callerVertex, calleeVertex); + dependencyEdge.setProperty("calls", dependency.getCalls()); + dependencyEdge.setProperty("failuredCalls", dependency.getFailuredCalls()); + } + } + + return graph; + + } + +} diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreatorStage.java b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreatorStage.java new file mode 100644 index 00000000..5ea6bcb9 --- /dev/null +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphCreatorStage.java @@ -0,0 +1,28 @@ +package kieker.analysis.dev.dependencygraphs; + +import java.util.Collection; + +import kieker.analysis.domain.systemdependency.SoftwareSystem; +import kieker.analysis.util.graph.Graph; + +import teetime.stage.basic.AbstractTransformation; + +public class AssemblyDependencyGraphCreatorStage extends AbstractTransformation<SoftwareSystem, Graph> { + + private final AssemblyDependencyGraphCreator graphCreator; + + public AssemblyDependencyGraphCreatorStage(final AssemblyDependencyGraphLevel depth) { + this.graphCreator = new AssemblyDependencyGraphCreator(depth); + } + + public AssemblyDependencyGraphCreatorStage(final AssemblyDependencyGraphLevel depth, final Collection<AssemblyDependencyGraphLevel> relations) { + this.graphCreator = new AssemblyDependencyGraphCreator(depth, relations); + } + + @Override + protected void execute(final SoftwareSystem softwareSystem) { + final Graph graph = graphCreator.create(softwareSystem); + this.outputPort.send(graph); + } + +} diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphLevel.java b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphLevel.java new file mode 100644 index 00000000..1beadaed --- /dev/null +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/AssemblyDependencyGraphLevel.java @@ -0,0 +1,7 @@ +package kieker.analysis.dev.dependencygraphs; + +public enum AssemblyDependencyGraphLevel { + + OPERATION, COMPONENT; + +} diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/DotDependencyGraphConfigurationFactory.java b/src/main/java/kieker/analysis/dev/dependencygraphs/DotDependencyGraphConfigurationFactory.java new file mode 100644 index 00000000..1428e27f --- /dev/null +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/DotDependencyGraphConfigurationFactory.java @@ -0,0 +1,48 @@ +package kieker.analysis.dev.dependencygraphs; + +import kieker.analysis.util.graph.export.dot.DotExportConfiguration; +import kieker.analysis.util.graph.util.dot.attributes.DotGraphAttribute; + +public class DotDependencyGraphConfigurationFactory { + + public DotExportConfiguration getAssemblyComponentConfiguration() { + DotExportConfiguration configuration = new DotExportConfiguration(); + + configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); + + return configuration; + } + + public DotExportConfiguration getAssemblyOperationConfiguration() { + DotExportConfiguration configuration = new DotExportConfiguration(); + + configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); + + return configuration; + } + + public DotExportConfiguration getDeploymentContainerConfiguration() { + DotExportConfiguration configuration = new DotExportConfiguration(); + + configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); + + return configuration; + } + + public DotExportConfiguration getDeploymentComponentConfiguration() { + DotExportConfiguration configuration = new DotExportConfiguration(); + + configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); + + return configuration; + } + + public DotExportConfiguration getDeploymentOperationConfiguration() { + DotExportConfiguration configuration = new DotExportConfiguration(); + + configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); + + return configuration; + } + +} -- GitLab