@Override public String getIdentifier() { return this.getEntity().getIdentifier(); }
/** * Creates a new dependency graph with the given root entity. * * @param rootEntity * The entity from which the root node originates */ public AbstractDependencyGraph(final T rootEntity) { this.rootNode = new DependencyGraphNode<T>(DependencyGraphNode.ROOT_NODE_ID, rootEntity, null, NoOriginRetentionPolicy.createInstance()); this.nodes.put(DependencyGraphNode.ROOT_NODE_ID, this.rootNode); }
@Override public void processMessage(final AbstractMessage message, final DependencyGraphNode<?> sourceNode, final DependencyGraphNode<?> targetNode, final TimeUnit timeunit) { // Ignore internal executions if (sourceNode.equals(targetNode)) { return; } ResponseTimeDecoration timeDecoration = targetNode.getDecoration(ResponseTimeDecoration.class); if (timeDecoration == null) { timeDecoration = new ResponseTimeDecoration(timeunit, this.displayTimeunit); targetNode.addDecoration(timeDecoration); } timeDecoration.registerExecution(message.getReceivingExecution()); }
@Override public Collection<WeightedBidirectionalDependencyGraphEdge<T>> getOutgoingEdges() { final Collection<WeightedBidirectionalDependencyGraphEdge<T>> edges = new ArrayList<WeightedBidirectionalDependencyGraphEdge<T>>(); edges.addAll(this.getOutgoingDependencies()); edges.addAll(this.getAssumedOutgoingDependencies()); return edges; } }
senderNode = new DependencyGraphNode<>(senderComponent.getId(), senderComponent, t.getTraceInformation(), this.getOriginRetentionPolicy()); senderNode.setAssumed(); this.getGraph().addNode(senderNode.getId(), senderNode); } else { this.handleOrigin(senderNode, t.getTraceInformation()); receiverNode = new DependencyGraphNode<>(receiverComponent.getId(), receiverComponent, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.setAssumed(); this.getGraph().addNode(receiverNode.getId(), receiverNode); } else { this.handleOrigin(receiverNode, t.getTraceInformation()); senderNode.addOutgoingDependency(receiverNode, assumed, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.addIncomingDependency(senderNode, assumed, t.getTraceInformation(), this.getOriginRetentionPolicy());
@Override public void visitVertex(final DependencyGraphNode<ExecutionContainer> vertex) { final ExecutionContainer container = vertex.getEntity(); AbstractGraphFormatter.getDotRepresentation(vertex.getColor()), // framecolor vertex.getDescription())); // tooltip
DotFactory.DOT_SHAPE_BOX, AbstractGraphFormatter.getDotRepresentation(node.getColor()), // framecolor node.getDescription())); // tooltip
final AllocationComponent allocationComponent1 = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_1).getEntity(); final AllocationComponent allocationComponent2 = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_2).getEntity(); Assert.assertNotNull(allocationComponent1); Assert.assertNotNull(allocationComponent2); Assert.assertEquals(2, rootNode.getOutgoingEdges().size()); Assert.assertTrue(DependencyGraphTestUtil.dependencyEdgeExists(rootNode, 1, type1Node)); Assert.assertTrue(DependencyGraphTestUtil.dependencyEdgeExists(rootNode, 1, type2Node)); Assert.assertEquals(1, type1Node.getOutgoingEdges().size()); Assert.assertTrue(DependencyGraphTestUtil.dependencyEdgeExists(type1Node, 1, type2Node)); Assert.assertEquals(0, type2Node.getOutgoingEdges().size());
senderNode = new DependencyGraphNode<>(senderContainer.getId(), senderContainer, t.getTraceInformation(), this.getOriginRetentionPolicy()); this.getGraph().addNode(senderContainer.getId(), senderNode); receiverNode = new DependencyGraphNode<>(receiverContainer.getId(), receiverContainer, t.getTraceInformation(), this.getOriginRetentionPolicy()); this.getGraph().addNode(receiverContainer.getId(), receiverNode); senderNode.addOutgoingDependency(receiverNode, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.addIncomingDependency(senderNode, t.getTraceInformation(), this.getOriginRetentionPolicy());
/** * This method tests whether the trace coloring works or not. It uses the nodes resulting from the test setup and checks them against the expected colors. * * @throws AnalysisConfigurationException * If the assembled test setup is somehow invalid. */ @Test public void testTraceColoring() throws AnalysisConfigurationException { testSetup.run(); final GraphReceiverPlugin graphReceiver = testSetup.getResultCollectionPlugin(); // Check number of produced graphs Assert.assertEquals(1, graphReceiver.getNumberOfReceivedGraphs()); // Prepare the produced graph final ComponentAllocationDependencyGraph graph = graphReceiver.<ComponentAllocationDependencyGraph>getFirstGraph(); // NOCS (generic) final ConcurrentMap<String, DependencyGraphNode<AllocationComponent>> nodeMap = DependencyGraphTestUtil.createNodeLookupTable(graph); final DependencyGraphNode<AllocationComponent> component1Node = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_1); final DependencyGraphNode<AllocationComponent> component2Node = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_2); final DependencyGraphNode<AllocationComponent> component3Node = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_3); // Check the node colors Assert.assertEquals(HIGHLIGHT_COLOR, component1Node.getColor()); Assert.assertEquals(COLLISION_COLOR, component2Node.getColor()); Assert.assertEquals(DEFAULT_COLOR, component3Node.getColor()); } }
@Test public void testDescriptionDecorator() throws AnalysisConfigurationException { testSetup.run(); final GraphReceiverPlugin graphReceiver = testSetup.getResultCollectionPlugin(); // Check number of produced graphs Assert.assertEquals(1, graphReceiver.getNumberOfReceivedGraphs()); // Prepare the produced graph final ComponentAllocationDependencyGraph graph = graphReceiver.<ComponentAllocationDependencyGraph>getFirstGraph(); // NOCS (generic) final ConcurrentMap<String, DependencyGraphNode<AllocationComponent>> nodeMap = DependencyGraphTestUtil.createNodeLookupTable(graph); final DependencyGraphNode<AllocationComponent> component1Node = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_1); final DependencyGraphNode<AllocationComponent> component2Node = nodeMap.get(EXPECTED_ALLOCATION_COMPONENT_NAME_2); // Check the decorations Assert.assertEquals(DESCRIPTION_1, component1Node.getDescription()); Assert.assertEquals(DESCRIPTION_2, component2Node.getDescription()); }
/** * Adds an outgoing dependency to this node. The dependency will be marked as not assumed. * * @param destination * The destination of the dependency. * @param origin * The origin of the destination. * @param originPolicy * The origin policy of the destination. */ public void addOutgoingDependency(final DependencyGraphNode<T> destination, final TraceInformation origin, final IOriginRetentionPolicy originPolicy) { this.addOutgoingDependency(destination, false, origin, originPolicy); }
/** * Adds an incoming dependency to this node. The dependency will be marked as not assumed. * * @param source * The source of the dependency. * @param origin * The origin of the destination. * @param originPolicy * The origin policy of the destination. */ public void addIncomingDependency(final DependencyGraphNode<T> source, final TraceInformation origin, final IOriginRetentionPolicy originPolicy) { this.addIncomingDependency(source, false, origin, originPolicy); }
public String getFormattedDecorations() { synchronized (this) { final StringBuilder builder = new StringBuilder(); final Iterator<AbstractVertexDecoration> decorationsIter = this.getDecorations().iterator(); while (decorationsIter.hasNext()) { final String currentDecorationText = decorationsIter.next().createFormattedOutput(); if ((currentDecorationText == null) || (currentDecorationText.length() == 0)) { continue; } builder.append(currentDecorationText); if (decorationsIter.hasNext()) { builder.append("\\n"); } } return builder.toString(); } }
DependencyGraphNode<AssemblyComponent> receiverNode = this.getGraph().getNode(receiverComponent.getId()); if (senderNode == null) { senderNode = new DependencyGraphNode<>(senderComponent.getId(), senderComponent, t.getTraceInformation(), this.getOriginRetentionPolicy()); senderNode.setAssumed(); this.getGraph().addNode(senderNode.getId(), senderNode); } else { this.handleOrigin(senderNode, t.getTraceInformation()); receiverNode = new DependencyGraphNode<>(receiverComponent.getId(), receiverComponent, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.setAssumed(); this.getGraph().addNode(receiverNode.getId(), receiverNode); } else { this.handleOrigin(receiverNode, t.getTraceInformation()); senderNode.addOutgoingDependency(receiverNode, assumed, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.addIncomingDependency(senderNode, assumed, t.getTraceInformation(), this.getOriginRetentionPolicy());
@Override public void visitVertex(final DependencyGraphNode<AssemblyComponent> vertex) { final AssemblyComponent component = vertex.getEntity(); AbstractGraphFormatter.getDotRepresentation(vertex.getColor()), // framecolor vertex.getDescription())); // tooltip
senderPair = this.getGraph().getRootNode().getEntity(); } else { senderPair = pairFactory.getPairInstanceByPair(senderComponent, senderOperation); receiverPair = this.getGraph().getRootNode().getEntity(); } else { receiverPair = pairFactory.getPairInstanceByPair(receiverComponent, receiverOperation); DependencyGraphNode<AllocationComponentOperationPair> receiverNode = this.getGraph().getNode(receiverPair.getId()); if (senderNode == null) { senderNode = new DependencyGraphNode<>(senderPair.getId(), senderPair, t.getTraceInformation(), this.getOriginRetentionPolicy()); senderNode.setAssumed(); this.getGraph().addNode(senderNode.getId(), senderNode); } else { this.handleOrigin(senderNode, t.getTraceInformation()); receiverNode = new DependencyGraphNode<>(receiverPair.getId(), receiverPair, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.setAssumed(); this.getGraph().addNode(receiverNode.getId(), receiverNode); } else { this.handleOrigin(receiverNode, t.getTraceInformation()); senderNode.addOutgoingDependency(receiverNode, assumed, t.getTraceInformation(), this.getOriginRetentionPolicy());
final Operation operation = node.getEntity().getOperation(); DotFactory.DOT_SHAPE_OVAL, AbstractGraphFormatter.getDotRepresentation(node.getColor()), // framecolor node.getDescription())); // tooltip
private static ConcurrentMap<ExecutionContainer, List<DependencyGraphNode<AllocationComponent>>> groupNodesByComponent( final ComponentAllocationDependencyGraph graph) { final ConcurrentMap<ExecutionContainer, List<DependencyGraphNode<AllocationComponent>>> nodeMap = new ConcurrentHashMap<>(); for (final DependencyGraphNode<AllocationComponent> node : graph.getNodes()) { final ExecutionContainer container = node.getEntity().getExecutionContainer(); List<DependencyGraphNode<AllocationComponent>> nodes = nodeMap.get(container); if (nodes == null) { nodes = new ArrayList<>(); nodeMap.put(container, nodes); } nodes.add(node); } return nodeMap; }
senderPair = this.getGraph().getRootNode().getEntity(); } else { senderPair = pairFactory.getPairInstanceByPair(senderComponent, senderOperation); receiverPair = this.getGraph().getRootNode().getEntity(); } else { receiverPair = pairFactory.getPairInstanceByPair(receiverComponent, receiverOperation); DependencyGraphNode<AssemblyComponentOperationPair> receiverNode = this.getGraph().getNode(receiverPair.getId()); if (senderNode == null) { senderNode = new DependencyGraphNode<>(senderPair.getId(), senderPair, t.getTraceInformation(), this.getOriginRetentionPolicy()); senderNode.setAssumed(); this.getGraph().addNode(senderNode.getId(), senderNode); } else { this.handleOrigin(senderNode, t.getTraceInformation()); receiverNode = new DependencyGraphNode<>(receiverPair.getId(), receiverPair, t.getTraceInformation(), this.getOriginRetentionPolicy()); receiverNode.setAssumed(); this.getGraph().addNode(receiverNode.getId(), receiverNode); } else { this.handleOrigin(receiverNode, t.getTraceInformation()); senderNode.addOutgoingDependency(receiverNode, assumed, t.getTraceInformation(), this.getOriginRetentionPolicy());