@Override public String toString() { final StringBuilder strBuild = new StringBuilder(512); synchronized (this) { strBuild.append("SessionId ").append(this.getSessionId()); strBuild.append(" (startTime=").append(this.getStartTimestamp()); strBuild.append(" (").append(LoggingTimestampConverter.convertLoggingTimestampToUTCString(this.getStartTimestamp())); strBuild.append("); endTime=").append(this.getEndTimestamp()); strBuild.append(" (").append(LoggingTimestampConverter.convertLoggingTimestampToUTCString(this.getEndTimestamp())); strBuild.append("):\n"); for (final ExecutionTrace t : this.getStateContainedTraces()) { strBuild.append('{'); strBuild.append(t.toString()).append("}\n"); } } return strBuild.toString(); }
/** * Processes an incoming execution. * * @param executionTrace * The execution trace to process. */ @InputPort(name = INPUT_PORT_NAME_EXECUTION_TRACES, description = "Receives execution traces", eventTypes = { ExecutionTrace.class }) public void processExecutionTrace(final ExecutionTrace executionTrace) { synchronized (this) { // Purge timed-out sessions before processing the next trace final long currentTimestamp = executionTrace.getStartTimestamp(); this.processTimeouts(currentTimestamp, OUTPUT_PORT_NAME_EXECUTION_TRACE_SESSIONS, this.executionSessionTimeoutQueue, this.openExecutionBasedSessions); // Add the trace to the appropriate session and create it if necessary boolean existingSession = true; final String sessionId = executionTrace.getSessionId(); ExecutionTraceBasedSession session = this.openExecutionBasedSessions.get(sessionId); if (session == null) { session = new ExecutionTraceBasedSession(sessionId); final ExecutionTraceBasedSession previousSession = this.openExecutionBasedSessions.putIfAbsent(sessionId, session); existingSession = previousSession != null; } session.addTrace(executionTrace); // Update the changed session's position in the timeout queue if (existingSession) { this.executionSessionTimeoutQueue.remove(session); } this.executionSessionTimeoutQueue.add(session); } }
/** * Tests a simple trace constellation with two traces which are put into two different sessions because * the maximum think time is exceeded. * * @throws AnalysisConfigurationException * If a configuration error occurs */ @Test public void testExecutionTraceSessionSplit() throws AnalysisConfigurationException { final List<OperationExecutionRecord> records = TestSessionReconstructionFilter.createSplitSessionExecutionTrace(); final SessionReconstructionTestSetup<ExecutionTraceBasedSession> setup = SessionReconstructionTestUtil.createSetup(records, MAX_THINK_TIME_MILLIS); setup.run(); final List<ExecutionTraceBasedSession> sessions = setup.getResult(); Assert.assertEquals(2, sessions.size()); final ExecutionTraceBasedSession session1 = sessions.get(0); Assert.assertEquals(1, session1.getStateContainedTraces().size()); final ExecutionTraceBasedSession session2 = sessions.get(1); Assert.assertEquals(1, session2.getStateContainedTraces().size()); }
/** * Tests a trace constellation with two traces which carry different session IDs. * * @throws AnalysisConfigurationException * If a configuration error occurs */ @Test public void testExecutionTraceTwoSessions() throws AnalysisConfigurationException { final List<OperationExecutionRecord> records = TestSessionReconstructionFilter.createTwoSessionsExecutionTrace(); final SessionReconstructionTestSetup<ExecutionTraceBasedSession> setup = SessionReconstructionTestUtil.createSetup(records, MAX_THINK_TIME_MILLIS); setup.run(); final List<ExecutionTraceBasedSession> sessions = setup.getResult(); Assert.assertEquals(2, sessions.size()); final ExecutionTraceBasedSession session1 = sessions.get(0); Assert.assertEquals(1, session1.getStateContainedTraces().size()); final ExecutionTraceBasedSession session2 = sessions.get(1); Assert.assertEquals(1, session2.getStateContainedTraces().size()); } }
/** * Tests a simple trace constellation with two traces which get assigned to the same session. * * @throws AnalysisConfigurationException * If a configuration error occurs */ @Test public void testSimpleExecutionTraceSession() throws AnalysisConfigurationException { final List<OperationExecutionRecord> records = TestSessionReconstructionFilter.createSimpleExecutionTrace(); final SessionReconstructionTestSetup<ExecutionTraceBasedSession> setup = SessionReconstructionTestUtil.createSetup(records, MAX_THINK_TIME_MILLIS); setup.run(); final List<ExecutionTraceBasedSession> sessions = setup.getResult(); Assert.assertEquals(1, sessions.size()); final ExecutionTraceBasedSession session = sessions.get(0); Assert.assertEquals(2, session.getStateContainedTraces().size()); }