From bcf8b0f31d7d49e92095e82c6b31d0c826799824 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Thu, 14 Jun 2012 15:26:44 -0400 Subject: [PATCH] Fix for bug 382667: Legacy LTTng trace concurrency problems. --- .../core/tests/trace/LTTngTraceTest.java | 108 ++++++++++++++++++ .../lttng/core/event/LttngLocation.java | 2 +- .../internal/lttng/core/trace/LTTngTrace.java | 6 + 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java index a3628bd8e9..6a2e2f9752 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java @@ -9,6 +9,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.lttng.core.event.LttngLocation; import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace; +import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; @@ -409,6 +410,113 @@ public class LTTngTraceTest extends TestCase { assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); } + public void testConcurrentOperations() { + final LTTngTrace testStream = prepareStreamToTest(); + ITmfEvent event1 = null; + ITmfEvent event2 = null; + ITmfContext context1; + ITmfContext context2; + + // Test concurrent interference (seek) after a seek + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (parseEvent) after a seek + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event2 = testStream.parseEvent(context2); + assertTrue("event is null after parseEvent()", event2 != null); + assertEquals("event has wrong timestamp", timestampToSeekLast, event2.getTimestamp().getValue()); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (getNext) after a seek + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event2 = testStream.getNext(context2); + assertTrue("event is null after getNext()", event2 != null); + assertEquals("event has wrong timestamp", timestampToSeekLast, event2.getTimestamp().getValue()); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (seek) after a parseEvent + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event1 = testStream.parseEvent(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (parseEvent) after a parseEvent + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event1 = testStream.parseEvent(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + event2 = testStream.parseEvent(context2); + assertTrue("event is null after parseEvent()", event2 != null); + assertEquals("event has wrong timestamp", timestampToSeekLast, event2.getTimestamp().getValue()); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (getNext) after a parseEvent + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event1 = testStream.parseEvent(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + event2 = testStream.getNext(context2); + assertTrue("event is null after getNext()", event2 != null); + assertEquals("event has wrong timestamp", timestampToSeekLast, event2.getTimestamp().getValue()); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (seek) after a getNext + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", nextEventTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (parseEvent) after a getNext + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + event2 = testStream.parseEvent(context2); + assertTrue("event is null after parseEvent()", event2 != null); + assertEquals("event has wrong timestamp", timestampToSeekLast, event2.getTimestamp().getValue()); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", nextEventTimestamp, event1.getTimestamp().getValue()); + + // Test concurrent interference (getNext) after a getNext + context2 = testStream.seekEvent(new LttngLocation(timestampToSeekLast)); + context1 = testStream.seekEvent(new LttngLocation(seekTimestamp)); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", seekTimestamp, event1.getTimestamp().getValue()); + event2 = testStream.getNext(context2); + assertTrue("event is null after getNext()", event2 != null); + assertEquals("event has wrong timestamp", timestampToSeekLast, event2.getTimestamp().getValue()); + event1 = testStream.getNext(context1); + assertTrue("event is null after getNext()", event1 != null); + assertEquals("event has wrong timestamp", nextEventTimestamp, event1.getTimestamp().getValue()); + } + public void testGetter() { TmfEvent tmpEvent = null; final LTTngTrace testStream1 = prepareStreamToTest(); diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngLocation.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngLocation.java index c19f4aae87..8869483b72 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngLocation.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngLocation.java @@ -36,7 +36,7 @@ public class LttngLocation implements ITmfLocation, Comparable implements ITmfEventParser< + previousLocation.getOperationTimeValue() + " CurrentTime" //$NON-NLS-1$ + curLocation.getOperationTimeValue() + " ]"); //$NON-NLS-1$ seekEvent(curLocation.getOperationTime()); + + // If the location is marked with the read next flag + // then it is pointing to the next event following the operation time + if (curLocation.isLastOperationReadNext()) { + readNextEvent(curLocation); + } } // Read the next event from the trace. The last one will NO LONGER // BE VALID. -- 2.34.1