Fix for bug 382667: Legacy LTTng trace concurrency problems.
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 14 Jun 2012 19:26:44 +0000 (15:26 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 14 Jun 2012 19:27:45 +0000 (15:27 -0400)
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngLocation.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java

index a3628bd8e9bf226cf2add32c7ea6ea93b3eea9bc..6a2e2f975295171d13e523ac1825e1c71a680a67 100644 (file)
@@ -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();
index c19f4aae8731d66edd3978fa0ca23064ad4329a5..8869483b72e5cc535821f27e572316621414177c 100644 (file)
@@ -36,7 +36,7 @@ public class LttngLocation implements ITmfLocation<LttngTimestamp>, Comparable<L
         this.isLastOperationParse = oldLocation.isLastOperationParse;
         this.isLastOperationReadNext = oldLocation.isLastOperationReadNext;
         this.isLastOperationSeek = oldLocation.isLastOperationSeek;
-        this.operationTime = oldLocation.operationTime;
+        this.operationTime = oldLocation.operationTime.clone();
     }
 
     @Override
index f18d4c6de6bc957dee1174c3f8ff03ba5fe3a0d8..b7ccb1cbbcd1cfd324aea1933a6b2bb0e8fb6e44 100644 (file)
@@ -582,6 +582,12 @@ public class LTTngTrace extends TmfTrace<LttngEvent> 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.
This page took 0.028626 seconds and 5 git commands to generate.