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

worked on assembly dependency graphs

parent 232b0043
No related branches found
No related tags found
No related merge requests found
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;
}
}
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);
}
}
package kieker.analysis.dev.dependencygraphs;
public enum AssemblyDependencyGraphLevel {
OPERATION, COMPONENT;
}
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;
}
}
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