diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/DeploymentDependencyGraphCreator.java b/src/main/java/kieker/analysis/dev/dependencygraphs/DeploymentDependencyGraphCreator.java new file mode 100644 index 0000000000000000000000000000000000000000..c4fada31a15e33c74363a708166d8ce1c90d8db1 --- /dev/null +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/DeploymentDependencyGraphCreator.java @@ -0,0 +1,141 @@ +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 DeploymentDependencyGraphCreator { + + private final DeploymentDependencyGraphLevel depth; + private final Set<DeploymentDependencyGraphLevel> relations; + + public DeploymentDependencyGraphCreator(final DeploymentDependencyGraphLevel depth) { + this.depth = depth; + this.relations = EnumSet.of(depth); + } + + public DeploymentDependencyGraphCreator(final DeploymentDependencyGraphLevel depth, final Collection<DeploymentDependencyGraphLevel> relations) { + this.depth = depth; + this.relations = EnumSet.copyOf(relations); + } + + public Graph create(final SoftwareSystem softwareSystem) { + + Graph graph = new GraphImpl(); + graph.setName("OperationsDependencyGraph"); // TODO + + for (Container container : softwareSystem.getContainers()) { + + Vertex containerVertex = graph.addVertex(container.getIdentifier()); + containerVertex.setProperty("Name", container.getName()); + containerVertex.setProperty("Type", "Container"); + containerVertex.setProperty("MaxDuration", container.getMaxDuration()); + containerVertex.setProperty("MinDuration", container.getMinDuration()); + containerVertex.setProperty("MeanDuration", container.getMeanDuration()); + containerVertex.setProperty("MedianDuration", container.getMedianDuration()); + containerVertex.setProperty("TotalDuration", container.getTotalDuration()); + Graph componentGraph = containerVertex.addChildGraph(); + + if (this.depth.compareTo(DeploymentDependencyGraphLevel.COMPONENT) <= 0) { + + for (Component component : container.getComponents()) { + + Vertex componentVertex = componentGraph.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()); + Graph operationsGraph = componentVertex.addChildGraph(); + + if (this.depth.compareTo(DeploymentDependencyGraphLevel.OPERATION) <= 0) { + + 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(DeploymentDependencyGraphLevel.CONTAINER)) { + for (Dependency<Container> dependency : softwareSystem.getContainerDependencies()) { + + String callerContainerIdentifier = dependency.getCaller().getIdentifier(); + String calleeContainerIdentifier = dependency.getCallee().getIdentifier(); + + Vertex callerVertex = graph.getVertex(callerContainerIdentifier); + Vertex calleeVertex = graph.getVertex(calleeContainerIdentifier); + + Edge dependencyEdge = graph.addEdge(null, callerVertex, calleeVertex); + dependencyEdge.setProperty("calls", dependency.getCalls()); + dependencyEdge.setProperty("failuredCalls", dependency.getFailuredCalls()); + } + } + + if (this.relations.contains(DeploymentDependencyGraphLevel.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(DeploymentDependencyGraphLevel.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/DeploymentDependencyGraphLevel.java b/src/main/java/kieker/analysis/dev/dependencygraphs/DeploymentDependencyGraphLevel.java new file mode 100644 index 0000000000000000000000000000000000000000..ffbb0a3fd47d5234ffc6d329a493753448e38b29 --- /dev/null +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/DeploymentDependencyGraphLevel.java @@ -0,0 +1,7 @@ +package kieker.analysis.dev.dependencygraphs; + +public enum DeploymentDependencyGraphLevel { + + OPERATION, COMPONENT, CONTAINER; + +} diff --git a/src/main/java/kieker/analysis/dev/dependencygraphs/OperationsDependencyGraphCreatorStage.java b/src/main/java/kieker/analysis/dev/dependencygraphs/OperationsDependencyGraphCreatorStage.java index f0de5f85bf5c589737d353e3addff3ae37099dfd..2d33c135140bc793460f6f742262fb4898c22c31 100644 --- a/src/main/java/kieker/analysis/dev/dependencygraphs/OperationsDependencyGraphCreatorStage.java +++ b/src/main/java/kieker/analysis/dev/dependencygraphs/OperationsDependencyGraphCreatorStage.java @@ -1,116 +1,22 @@ package kieker.analysis.dev.dependencygraphs; -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; import teetime.stage.basic.AbstractTransformation; public class OperationsDependencyGraphCreatorStage extends AbstractTransformation<SoftwareSystem, Graph> { - @Override - protected void execute(final SoftwareSystem softwareSystem) { - - Graph graph = new GraphImpl(); - - for (Container container : softwareSystem.getContainers()) { - - Vertex containerVertex = graph.addVertex(container.getIdentifier()); - containerVertex.setProperty("Name", container.getName()); - containerVertex.setProperty("Type", "Container"); - containerVertex.setProperty("MaxDuration", container.getMaxDuration()); - containerVertex.setProperty("MinDuration", container.getMinDuration()); - containerVertex.setProperty("MeanDuration", container.getMeanDuration()); - containerVertex.setProperty("MedianDuration", container.getMedianDuration()); - containerVertex.setProperty("TotalDuration", container.getTotalDuration()); - Graph componentGraph = containerVertex.addChildGraph(); - - for (Component component : container.getComponents()) { - - Vertex componentVertex = componentGraph.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()); - 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()); - - } - } - } + private final DeploymentDependencyGraphCreator graphCreator; - /* - * for (Dependency<Container> dependency : softwareSystem.getContainerDependencies()) { - * - * String callerContainerIdentifier = dependency.getCaller().getIdentifier(); - * String calleeContainerIdentifier = dependency.getCallee().getIdentifier(); - * - * Vertex callerVertex = graph.getVertex(callerContainerIdentifier); - * Vertex calleeVertex = graph.getVertex(calleeContainerIdentifier); - * - * Edge dependencyEdge = graph.addEdge(null, callerVertex, calleeVertex); - * dependencyEdge.setProperty("calls", dependency.getCalls()); - * dependencyEdge.setProperty("failuredCalls", dependency.getFailuredCalls()); - * } - * - * 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()); - * } - */ - - 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()); - } + public OperationsDependencyGraphCreatorStage() { + this.graphCreator = new DeploymentDependencyGraphCreator(DeploymentDependencyGraphLevel.OPERATION); + } + @Override + protected void execute(final SoftwareSystem softwareSystem) { + final Graph graph = graphCreator.create(softwareSystem); this.outputPort.send(graph); - } }