/** * This method can be used to debug the {@link java.util.Comparator} provided by {@link ExecutionTrace#createExecutionTraceComparator()}. */ @Test public void testTreeSet() { final SortedSet<Execution> s0 = new TreeSet<>(ExecutionTrace.createExecutionTraceComparator()); final SortedSet<Execution> s1 = new TreeSet<>(ExecutionTrace.createExecutionTraceComparator()); final Execution execFromTrace0 = this.exec0_0__bookstore_searchBook; final Execution long1 = new Execution(execFromTrace0.getOperation(), execFromTrace0.getAllocationComponent(), execFromTrace0.getTraceId(), execFromTrace0.getSessionId(), execFromTrace0.getEoi(), execFromTrace0.getEss(), execFromTrace0.getTin(), execFromTrace0.getTout(), execFromTrace0.isAssumed()); s0.add(execFromTrace0); s1.add(long1); Assert.assertEquals("Expected sets to be equal", s0, s1); }
if (e1.equals(e2)) { return 0; if (e1.getTraceId() < e2.getTraceId()) { return -1; } else if (e1.getTraceId() > e2.getTraceId()) { return 1; if (e1.getEoi() < e2.getEoi()) { return -1; if (e1.getEoi() > e2.getEoi()) { return 1; if (e1.getEss() < e2.getEss()) { return -1; if (e1.getEss() > e2.getEss()) { return 1; if (e1.getTin() < e2.getTin()) { return -1; if (e1.getTin() > e2.getTin()) { return 1; if (e1.getTout() < e2.getTout()) { return -1;
/** * Registers a given execution for the decorated vertex. * * @param execution * The execution to register */ public void registerExecution(final Execution execution) { final long responseTime = this.displayTimeunit.convert(execution.getTout() - execution.getTin(), this.executionTimeunit); this.responseTimeSum = this.responseTimeSum + responseTime; this.executionCount++; if (responseTime < this.minimalResponseTime) { this.minimalResponseTime = responseTime; } if (responseTime > this.maximalResponseTime) { this.maximalResponseTime = responseTime; } }
private SynchronousCallMessage createCallMessage(final Execution rootExecution, final Execution prevE, final Execution curE) throws InvalidTraceException { final SynchronousCallMessage message; if (prevE.equals(rootExecution)) { // initial execution callMessage message = new SynchronousCallMessage(curE.getTin(), rootExecution, curE); } else if ((prevE.getEss() + 1) == curE.getEss()) { // usual callMessage with senderComponentName and // receiverComponentName message = new SynchronousCallMessage(curE.getTin(), prevE, curE); } else if (prevE.getEss() < curE.getEss()) { // detect ess incrementation by > 1 final InvalidTraceException ex = new InvalidTraceException( "Ess are only allowed to increment by 1 --" + "but found sequence <" + prevE.getEss() + "," + curE.getEss() + ">" + "(Execution: " + curE + ")"); // don't log and throw // LOG.error("Found invalid trace:" + ex.getMessage()); // don't need the stack trace here throw ex; } else { final String errorMessage = "Unexpected trace: " + prevE + " and " + curE; throw new IllegalStateException(errorMessage); } return message; }
/** * Checks whether the given executions are equal or not. * * @param r1 * The first execution object. * @param r2 * The second execution object. * * @return true if and only if the executions have the same values. */ private boolean executionsEqual(final Execution r1, final Execution r2) { if (r1 == r2) { // NOPMD (no equals) return true; } if ((r1 == null) || (r2 == null)) { return false; } return (r1.getAllocationComponent().getId() == r2.getAllocationComponent().getId()) && (r1.getOperation().getId() == r2.getOperation().getId()) && (r1.getEoi() == r2.getEoi()) && (r1.getEss() == r2.getEss()); }
if (this.getTraceId() != execution.getTraceId()) { throw new InvalidTraceException("TraceId of new record (" + execution.getTraceId() + ") differs from Id of this trace (" + this.getTraceId() + ")"); if ((this.minTin < 0) || (execution.getTin() < this.minTin)) { this.minTin = execution.getTin(); if ((this.maxTout < 0) || (execution.getTout() > this.maxTout)) { this.maxTout = execution.getTout(); if ((this.minEoi < 0) || (execution.getEoi() < this.minEoi)) { this.minEoi = execution.getEoi(); if ((this.maxEoi < 0) || (execution.getEoi() > this.maxEoi)) { this.maxEoi = execution.getEoi(); if (execution.getEss() > this.maxEss) { this.maxEss = execution.getEss();
final long traceId = execution.getTraceId(); this.minTin = ((this.minTin < 0) || (execution.getTin() < this.minTin)) ? execution.getTin() : this.minTin; // NOCS this.maxTout = execution.getTout() > this.maxTout ? execution.getTout() : this.maxTout; // NOCS executionTrace = new ExecutionTrace(traceId, execution.getSessionId()); this.pendingTraces.put(traceId, executionTrace);
while (eSeqIt.hasNext()) { final Execution curE = eSeqIt.next(); if (expectingEntryCall && (curE.getEss() != 0)) { final InvalidTraceException ex = new InvalidTraceException("First execution must have ess " + "0 (found " + curE.getEss() + ")\n Causing execution: " + curE); if (prevEoi != (curE.getEoi() - 1)) { final InvalidTraceException ex = new InvalidTraceException( "Eois must increment by 1 --" + "but found sequence <" + prevEoi + "," + curE.getEoi() + ">" + "(Execution: " + curE + ")"); prevEoi = curE.getEoi(); if ((!prevE.equals(rootExecution)) && (prevE.getEss() >= curE.getEss())) { while (curStack.size() > curE.getEss()) { final AbstractMessage poppedCall = curStack.pop(); prevE = poppedCall.getReceivingExecution(); curReturnReceiver = poppedCall.getSendingExecution(); final AbstractMessage m = new SynchronousReplyMessage(prevE.getTout(), prevE, curReturnReceiver); mSeq.add(m); prevE = poppedCall.getReceivingExecution(); curReturnReceiver = poppedCall.getSendingExecution(); final AbstractMessage m = new SynchronousReplyMessage(prevE.getTout(), prevE, curReturnReceiver); mSeq.add(m);
@Before public void setUp() throws Exception { final SystemModelRepository systemEntityFactory = new SystemModelRepository(new Configuration(), new AnalysisController()); this.eFactory = new ExecutionFactory(systemEntityFactory); int myNumExecutions = 0; // Manually create Executions for a trace myNumExecutions++; this.exec0_0__bookstore_searchBook = this.eFactory.genExecution("Bookstore", "bookstore", "searchBook", TestExecutionTraceBookstore.TRACE_ID, TestExecutionTraceBookstore.SESSION_ID, 1, 10, 0, 0); this.minTin = this.exec0_0__bookstore_searchBook.getTin(); this.maxTout = this.exec0_0__bookstore_searchBook.getTout(); myNumExecutions++; this.exec1_1__catalog_getBook = this.eFactory.genExecution("Catalog", "catalog", "getBook", TestExecutionTraceBookstore.TRACE_ID, TestExecutionTraceBookstore.SESSION_ID, 2, 4, 1, 1); myNumExecutions++; this.exec2_1__crm_getOrders = this.eFactory.genExecution("CRM", "crm", "getOrders", TestExecutionTraceBookstore.TRACE_ID, TestExecutionTraceBookstore.SESSION_ID, 5, 8, 2, 1); myNumExecutions++; this.exec3_2__catalog_getBook = this.eFactory.genExecution("Catalog", "catalog", "getBook", TestExecutionTraceBookstore.TRACE_ID, TestExecutionTraceBookstore.SESSION_ID, 6, 7, 3, 2); // Just some basic checks to make sure that the trace has been set up properly (we've had some trouble here) Assert.assertNotSame(this.exec3_2__catalog_getBook.getOperation(), this.exec2_1__crm_getOrders.getOperation()); Assert.assertNotSame(this.exec0_0__bookstore_searchBook.getAllocationComponent(), this.exec1_1__catalog_getBook.getAllocationComponent()); this.numExecutions = myNumExecutions; }
continue; final AssemblyComponent senderComponent = m.getSendingExecution().getAllocationComponent().getAssemblyComponent(); final AssemblyComponent receiverComponent = m.getReceivingExecution().getAllocationComponent().getAssemblyComponent(); final int rootOperationId = OperationRepository.ROOT_OPERATION.getId(); final Operation senderOperation = m.getSendingExecution().getOperation(); final Operation receiverOperation = m.getReceivingExecution().getOperation(); this.getOriginRetentionPolicy()); if (m.getSendingExecution().isAssumed()) { senderNode.setAssumed(); this.getOriginRetentionPolicy()); if (m.getReceivingExecution().isAssumed()) { receiverNode.setAssumed();
/** * {@inheritDoc} */ @Override protected AssemblyComponentOperationPair concreteCreatePair(final SynchronousCallMessage callMsg) { final Execution execution = callMsg.getReceivingExecution(); final AssemblyComponent assemblyComponent = execution.getAllocationComponent().getAssemblyComponent(); final Operation op = execution.getOperation(); return this.getSystemEntityFactory().getAssemblyPairFactory().getPairInstanceByPair(assemblyComponent, op); } }
/** Order traces by tins */ @Override public int compare(final ExecutionTrace t1, final ExecutionTrace t2) { if (t1 == t2) { // NOPMD (no equals) return 0; } final long t1LowestTin = t1.getTraceAsSortedExecutionSet().first().getTin(); final long t2LowestTin = t2.getTraceAsSortedExecutionSet().first().getTin(); // Multiple traces may have an equal tin timestamp value. In order to provide an absolute ordering of the keys, we take the traceId as a second ordering // key. if (t1LowestTin != t2LowestTin) { return t1LowestTin < t2LowestTin ? -1 : 1; // NOCS } return t1.getTraceId() < t2.getTraceId() ? -1 : 1; // NOCS } });
continue; final AllocationComponent senderComponent = m.getSendingExecution().getAllocationComponent(); final AllocationComponent receiverComponent = m.getReceivingExecution().getAllocationComponent(); DependencyGraphNode<AllocationComponent> senderNode = this.getGraph().getNode(senderComponent.getId()); DependencyGraphNode<AllocationComponent> receiverNode = this.getGraph().getNode(receiverComponent.getId()); this.getOriginRetentionPolicy()); if (m.getSendingExecution().isAssumed()) { senderNode.setAssumed(); this.getOriginRetentionPolicy()); if (m.getReceivingExecution().isAssumed()) { receiverNode.setAssumed();
@Override public boolean equals(final Object obj) { if (!(obj instanceof SynchronousCallMessage)) { return false; } if (this == obj) { return true; } final SynchronousCallMessage other = (SynchronousCallMessage) obj; return (this.getTimestamp() == other.getTimestamp()) && this.getSendingExecution().equals(other.getSendingExecution()) && this.getReceivingExecution().equals(other.getReceivingExecution()); }
return new Execution(op, allocInst, traceId, sessionId, eoi, ess, tin, tout, assumed);
@Override public String toString() { final StringBuilder strBuild = new StringBuilder(); strBuild.append(this.timestamp) .append(' '); if (this.getSendingExecution().getOperation().getId() == Operation.ROOT_OPERATION_ID) { strBuild.append(SystemModelRepository.ROOT_NODE_LABEL); } else { strBuild.append(this.getSendingExecution()); } strBuild.append(" --> "); if (this.getReceivingExecution().getOperation().getId() == Operation.ROOT_OPERATION_ID) { strBuild.append(SystemModelRepository.ROOT_NODE_LABEL); } else { strBuild.append(this.getReceivingExecution()); } return strBuild.toString(); }
continue; final AllocationComponent senderComponent = m.getSendingExecution().getAllocationComponent(); final AllocationComponent receiverComponent = m.getReceivingExecution().getAllocationComponent(); final ExecutionContainer senderContainer = senderComponent.getExecutionContainer(); final ExecutionContainer receiverContainer = receiverComponent.getExecutionContainer();
Assert.assertTrue("Test invalid (traceIds not matching)", this.exec0_0__bookstore_searchBook.getTraceId() == completingExecutionTrace.getTraceId()); completingExecutionTrace.add(this.exec0_0__bookstore_searchBook);
/** * Creates a new instance of this class using the given parameters. * * @param t * The execution trace to be stored in this container. */ public ExecutionTraceHashContainerAllocationEquivalence(final ExecutionTrace t) { super(t); final int prime = 31; int result = 1; for (final Execution r : t.getTraceAsSortedExecutionSet()) { result = (prime * result) + r.getOperation().getId(); result = (prime * result) + r.getAllocationComponent().getId(); result = (prime * result) + r.getEoi(); result = (prime * result) + r.getEss(); } // this.hashcodeBuffer = result; }
continue; final AllocationComponent senderComponent = m.getSendingExecution().getAllocationComponent(); final AllocationComponent receiverComponent = m.getReceivingExecution().getAllocationComponent(); final int rootOperationId = OperationRepository.ROOT_OPERATION.getId(); final Operation senderOperation = m.getSendingExecution().getOperation(); final Operation receiverOperation = m.getReceivingExecution().getOperation(); this.getOriginRetentionPolicy()); if (m.getSendingExecution().isAssumed()) { senderNode.setAssumed(); this.getOriginRetentionPolicy()); if (m.getReceivingExecution().isAssumed()) { receiverNode.setAssumed();