@Override public String getIdentifier() { return this.getAssemblyComponent().getName(); } }
private static final String allocationComponentOperationPairNodeLabel( final AbstractCallTreeNode<AllocationComponentOperationPair> node, final boolean shortLabels) { final AllocationComponentOperationPair p = node.getEntity(); final AllocationComponent component = p.getAllocationComponent(); final Operation operation = p.getOperation(); final String resourceContainerName = component.getExecutionContainer().getName(); final String assemblyComponentName = component.getAssemblyComponent().getName(); final String componentTypePackagePrefx = component.getAssemblyComponent().getType().getPackageName(); final String componentTypeIdentifier = component.getAssemblyComponent().getType().getTypeName(); final StringBuilder strBuild = new StringBuilder(resourceContainerName).append("::\\n") .append(assemblyComponentName).append(":"); if (!shortLabels) { strBuild.append(componentTypePackagePrefx).append('.'); } else { strBuild.append(".."); } strBuild.append(componentTypeIdentifier).append("\\n."); final Signature sig = operation.getSignature(); final StringBuilder opLabel = new StringBuilder(sig.getName()); opLabel.append('('); final String[] paramList = sig.getParamTypeList(); if (paramList.length > 0) { opLabel.append(".."); } opLabel.append(')'); strBuild.append(opLabel.toString()); return strBuild.toString(); }
public final AllocationComponent createAndRegisterAllocationComponentInstance(final String namedIdentifier, final AssemblyComponent assemblyComponentInstance, final ExecutionContainer executionContainer) { if (this.allocationComponentInstancesByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final AllocationComponent newInst = new AllocationComponent(id, assemblyComponentInstance, executionContainer); this.allocationComponentInstancesById.put(id, newInst); this.allocationComponentInstancesByName.put(namedIdentifier, newInst); return newInst; }
final String rootDotId = "O" + rootAllocationComponent.getId(); ps.print("actor(O" + rootAllocationComponent.getId() + ",\"\");" + "\n"); plottedComponentIds.add(rootAllocationComponent.getId()); final AllocationComponent senderComponent = me.getSendingExecution().getAllocationComponent(); final AllocationComponent receiverComponent = me.getReceivingExecution().getAllocationComponent(); if (!plottedComponentIds.contains(senderComponent.getId())) { ps.print("object(O" + senderComponent.getId() + ",\"" + senderComponent.getExecutionContainer().getName() + "::\",\"" + SequenceDiagramFilter.allocationComponentLabel(senderComponent, shortLabels) + "\");" + "\n"); plottedComponentIds.add(senderComponent.getId()); if (!plottedComponentIds.contains(receiverComponent.getId())) { ps.print("object(O" + receiverComponent.getId() + ",\"" + receiverComponent.getExecutionContainer().getName() + "::\",\"" + SequenceDiagramFilter.allocationComponentLabel(receiverComponent, shortLabels) + "\");" + "\n"); plottedComponentIds.add(receiverComponent.getId()); final AssemblyComponent senderComponent = me.getSendingExecution().getAllocationComponent().getAssemblyComponent(); final AssemblyComponent receiverComponent = me.getReceivingExecution().getAllocationComponent().getAssemblyComponent(); if (!plottedComponentIds.contains(senderComponent.getId())) { ps.print("object(O" + senderComponent.getId() + ",\"\",\"" + SequenceDiagramFilter.assemblyComponentLabel(senderComponent, shortLabels) + "\");" final AllocationComponent senderComponent = me.getSendingExecution().getAllocationComponent(); final AllocationComponent receiverComponent = me.getReceivingExecution().getAllocationComponent(); senderDotId = "O" + senderComponent.getId(); receiverDotId = "O" + receiverComponent.getId(); } else if (sdMode == SDModes.ASSEMBLY) { final AssemblyComponent senderComponent = me.getSendingExecution().getAllocationComponent().getAssemblyComponent(); final AssemblyComponent receiverComponent = me.getReceivingExecution().getAllocationComponent().getAssemblyComponent(); senderDotId = "O" + senderComponent.getId();
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; }
/** * Utility function to create a textual container ID for an allocation component. * * @param component * The allocation component to create the ID for * @return The created ID */ protected static String createAllocationComponentId(final AllocationComponent component) { return COMPONENT_NODE_ID_PREFIX + component.getId(); }
@Override public String getIdentifier() { return this.getAllocationComponent().getIdentifier(); } }
@Override public int hashCode() { int hash = 3; hash = (43 * hash) + (this.operation != null ? this.operation.hashCode() : 0); // NOCS (inline ?) hash = (43 * hash) + (this.allocationComponent != null ? this.allocationComponent.hashCode() : 0); // NOCS (inline ?) hash = (43 * hash) + (int) (this.traceId ^ (this.traceId >>> 32)); hash = (43 * hash) + (this.sessionId != null ? this.sessionId.hashCode() : 0); // NOCS (inline ?) hash = (43 * hash) + this.eoi; hash = (43 * hash) + this.ess; hash = (43 * hash) + (int) (this.tin ^ (this.tin >>> 32)); hash = (43 * hash) + (int) (this.tout ^ (this.tout >>> 32)); hash = (43 * hash) + (this.assumed ? 5643 : 5648); // NOCS (inline ?) return hash; }
@Override public String toString() { final StringBuilder strBuild = new StringBuilder(128); strBuild.append(this.traceId) .append('[').append(this.eoi).append(',').append(this.ess).append("] ") .append(this.tin).append('-').append(this.tout).append(' ') .append(this.allocationComponent.toString()).append('.') .append(this.operation.getSignature().getName()).append(' ') .append((this.sessionId != null) ? this.sessionId : NO_SESSION_ID); // NOCS if (this.assumed) { strBuild.append(" (assumed)"); } return strBuild.toString(); } }
/** * Compares this {@link Execution} with the given object with respect to type and fields. All * fields but the {@link #isAssumed()} are considered for comparison. * * @param obj * The object to be compared with this instance. * * @return true if and only if the current object and the given object have equal values. */ @Override public boolean equals(final Object obj) { if (!(obj instanceof Execution)) { return false; } if (this == obj) { return true; } final Execution other = (Execution) obj; return this.allocationComponent.equals(other.allocationComponent) && this.operation.equals(other.operation) && this.sessionId.equals(other.sessionId) && (this.traceId == other.traceId) && (this.eoi == other.eoi) && (this.ess == other.ess) && (this.tin == other.tin) && (this.tout == other.tout) && (this.assumed == other.assumed); }
for (final AllocationComponent allocationComponent : allocationComponentInstances) { final String[] cells = new String[] { this.htmlEntityLabel(allocationComponent.getId(), Integer.toString(allocationComponent.getId()), EntityType.ALLOCATION_COMPONENT), this.htmlEntityRef(allocationComponent.getAssemblyComponent().getId(), SystemModelRepository.simpleHTMLEscape(allocationComponent.getAssemblyComponent().toString()), EntityType.ALLOCATION_COMPONENT), this.htmlEntityRef(allocationComponent.getExecutionContainer().getId(), SystemModelRepository.simpleHTMLEscape(allocationComponent.getExecutionContainer().getName()), EntityType.EXECUTION_CONTAINER), }; this.printHtmlTableRow(ps, cells);
private ElementGrouping groupElements(final OperationAllocationDependencyGraph graph) { final ConcurrentMap<ExecutionContainer, Set<AllocationComponent>> allocationComponentGrouping = new ConcurrentHashMap<>(); final ConcurrentMap<AllocationComponent, Set<DependencyGraphNode<AllocationComponentOperationPair>>> operationGrouping = new ConcurrentHashMap<>(); for (final DependencyGraphNode<AllocationComponentOperationPair> vertex : graph.getVertices()) { final AllocationComponent allocationComponent = vertex.getEntity().getAllocationComponent(); final ExecutionContainer executionContainer = allocationComponent.getExecutionContainer(); // Update map execution container -> allocation components Set<AllocationComponent> allocationComponents = allocationComponentGrouping.get(executionContainer); if (allocationComponents == null) { allocationComponents = new HashSet<>(); allocationComponentGrouping.put(executionContainer, allocationComponents); } allocationComponents.add(allocationComponent); // Update map allocation component -> operations Set<DependencyGraphNode<AllocationComponentOperationPair>> operations = operationGrouping.get(allocationComponent); if (operations == null) { operations = new HashSet<>(); operationGrouping.put(allocationComponent, operations); } operations.add(vertex); } return new ElementGrouping(allocationComponentGrouping, operationGrouping); }
@Override public String toString() { return +this.allocationComponent.getId() + ":" + this.operation.getId() + "@" + this.id; }
private static String createAllocationComponentNodeLabel(final AllocationComponent component, final boolean useShortLabels) { final StringBuilder builder = new StringBuilder(); builder.append(AbstractDependencyGraphFormatter.STEREOTYPE_ALLOCATION_COMPONENT).append("\\n") .append(component.getAssemblyComponent().getName()).append(':'); if (useShortLabels) { builder.append(".."); } else { builder.append(component.getAssemblyComponent().getType().getPackageName()).append('.'); } builder.append(component.getAssemblyComponent().getType().getTypeName()); return builder.toString(); }
Assert.assertEquals("eoi's differ", opExec.getEoi(), exec.getEoi()); Assert.assertEquals("ess's differ", opExec.getEss(), exec.getEss()); Assert.assertEquals("Hostnames differ", opExec.getHostname(), exec.getAllocationComponent().getExecutionContainer().getName()); Assert.assertEquals("Session ID's differ", opExec.getSessionId(), exec.getSessionId()); Assert.assertEquals("Trace ID's differ", opExec.getTraceId(), exec.getTraceId()); ClassOperationSignaturePair.splitOperationSignatureStr(opExec.getOperationSignature()); Assert.assertEquals("Class/Component type names differ", opExecClassOperationSignature.getFqClassname(), exec.getAllocationComponent().getAssemblyComponent().getType().getFullQualifiedName()); Assert.assertEquals("Signatures differ", opExecClassOperationSignature.getSignature(), exec.getOperation().getSignature());
final ExecutionContainer senderContainer = senderComponent.getExecutionContainer(); final ExecutionContainer receiverContainer = receiverComponent.getExecutionContainer(); DependencyGraphNode<ExecutionContainer> senderNode = this.getGraph().getNode(senderContainer.getId()); DependencyGraphNode<ExecutionContainer> receiverNode = this.getGraph().getNode(receiverContainer.getId());
/** * Creates a new pair using both elements and registers it was well. * * @param operation * The second element of the pair (the operation). * @param allocationComponent * The first element of the pair (the allocation component). * * @return The newly created pair. */ private final AllocationComponentOperationPair createAndRegisterPair(final Operation operation, final AllocationComponent allocationComponent) { return this.createAndRegisterPair(allocationComponent.getId() + "-" + operation.getId(), operation, allocationComponent); }
private static String allocationComponentLabel(final AllocationComponent component, final boolean shortLabels) { final String assemblyComponentName = component.getAssemblyComponent().getName(); final String componentTypePackagePrefx = component.getAssemblyComponent().getType().getPackageName(); final String componentTypeIdentifier = component.getAssemblyComponent().getType().getTypeName(); final StringBuilder strBuild = new StringBuilder(assemblyComponentName).append(':'); if (!shortLabels) { strBuild.append(componentTypePackagePrefx).append('.'); } else { strBuild.append(".."); } strBuild.append(componentTypeIdentifier); return strBuild.toString(); }
/** * Returns a corresponding pair instance (existing or newly created). * * @param allocationComponent * The first element of the pair (the allocation component). * @param operation * The second element of the pair (the operation). * * @return A (possible new) pair containing both elements. */ public final AllocationComponentOperationPair getPairInstanceByPair(final AllocationComponent allocationComponent, final Operation operation) { final AllocationComponentOperationPair inst = this.getPairByNamedIdentifier(allocationComponent.getId() + "-" + operation.getId()); if (inst == null) { return this.createAndRegisterPair(operation, allocationComponent); } return inst; }
/** * Utility function to create a label for component nodes. * * @param node * The component node to create the label for * @param useShortLabels * Indicates whether short labels (i.e. without package names) should be used * @param stereotype * The stereotype to use in the label * @return A formatted component node label */ protected static String createComponentNodeLabel(final DependencyGraphNode<AllocationComponent> node, final boolean useShortLabels, final String stereotype) { final StringBuilder builder = new StringBuilder(); final AllocationComponent component = node.getEntity(); builder.append(stereotype).append("\\n") .append(component.getAssemblyComponent().getName()).append(':'); if (useShortLabels) { builder.append(".."); } else { builder.append(component.getAssemblyComponent().getType().getPackageName()).append('.'); } builder.append(component.getAssemblyComponent().getType().getTypeName()); AbstractGraphFormatter.formatDecorations(builder, node); return builder.toString(); } }