Merge branch 'master'
authorFrancois Chouinard <fchouinard@gmail.com>
Mon, 14 May 2012 20:28:41 +0000 (16:28 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Mon, 14 May 2012 20:28:41 +0000 (16:28 -0400)
78 files changed:
org.eclipse.linuxtools.ctf.core.tests/.gitignore
org.eclipse.linuxtools.ctf.core.tests/traces/.gitignore
org.eclipse.linuxtools.lttng.core.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/LttngTestPreparation.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngExperimentTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java
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/control/LttngSyntheticEventProvider.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/LTTngTextTrace.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeManagerTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfSimpleTimestampTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimeRangeTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/AllTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentCheckpointIndexTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java [deleted file]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfLocationTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperimentContext.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperimentLocation.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfLegacyExperiment.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfLocationArray.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfCheckpoint.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfContext.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfLocation.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTraceIndexer.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpoint.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfContext.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfLocation.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
org.eclipse.linuxtools.tmf.ui.tests/plugin.xml
org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramRequest.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java

index 8d94ef8debe45a7bc3866f985fdc60d41c12822f..e98343d9d0ab125b3e3ddc921cc7656937600144 100644 (file)
@@ -3,3 +3,4 @@ bin
 javaCompiler...args
 build.xml
 target
+Tests/*
index 6c4dbbfdaa606e233d18397e660eb5dd16aa9b6d..d5f79d55d4dd58b9588ddc7d3e8b01f0568ae188 100644 (file)
@@ -1,2 +1,5 @@
+*.bz2
 /kernel
 /trace2
+*.ht
+
index df97ffa2d9a161f894dbef3f146763e38aad641f..b867c78bbfd7250b47013eeec85e869626883ce0 100644 (file)
@@ -7,7 +7,6 @@ Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.linuxtools.lttng.core.tests
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.eclipse.linuxtools.lttng.jni
 Fragment-Host: org.eclipse.linuxtools.lttng.core
 Require-Bundle: org.junit;bundle-version="3.8.2",
  org.eclipse.core.runtime;bundle-version="3.7.0",
index aa5d574c54e82e13c88d2af608d2198c0a9e5fb7..15ca47654283ab608d30369a760eb21156abac45 100644 (file)
@@ -77,10 +77,8 @@ public abstract class LttngTestPreparation extends TestCase {
             final ITmfTrace<LttngEvent> trace = prepareStreamToTest();
             traces[0] = trace;
 
-            // create experiment and associate traces
             fTestExperiment = new TmfExperiment<LttngEvent>(LttngEvent.class,
                     expId, traces, TmfTimestamp.ZERO, TmfExperiment.DEFAULT_BLOCK_SIZE, true);
-            // fTestExperiment.indexExperiment(waitForCompletion);
 
             // Set the current selected experiment as the test experiment
             final TmfExperimentSelectedSignal<LttngEvent> signal = new TmfExperimentSelectedSignal<LttngEvent>(
index 529df0d212d799132ae790b81884d0837e1df949..19cb11ebfc6f8d0d0b5a974d4aaa0b273e5712bd 100644 (file)
@@ -86,7 +86,7 @@ public class LttngEventContentTest extends TestCase {
         try {
             testStream = null;
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpEventContent = (LttngEventContent)tmpStream.readNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent();
+            tmpEventContent = (LttngEventContent)tmpStream.getNext( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent();
         }
         catch (final Exception e) {
             fail("ERROR : Failed to get content!");
@@ -148,7 +148,7 @@ public class LttngEventContentTest extends TestCase {
         // Require an event
         tmpStream = initializeEventStream();
         tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-        tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.getNext(tmpContext);
         testContent = prepareToTest();
         // getFieldS()
         assertNotSame("getFields() returned null!", null, testContent.getFields() );
@@ -177,10 +177,10 @@ public class LttngEventContentTest extends TestCase {
         // Skip first events and seek to event pass metadata
         tmpContext= tmpStream.seekEvent(new LttngTimestamp(timestampAfterMetadata) );
         // Skip first one
-        tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.getNext(tmpContext);
 
         // Second event past metadata should have more fields
-        tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.getNext(tmpContext);
         // Get the content
         testContent = tmpEvent.getContent();
 
@@ -211,7 +211,7 @@ public class LttngEventContentTest extends TestCase {
         // Require an event
         tmpStream = initializeEventStream();
         tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-        tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.getNext(tmpContext);
 
         final LttngEventContent tmpContent = prepareToTest();
         try {
@@ -240,7 +240,7 @@ public class LttngEventContentTest extends TestCase {
         // Require an event
         tmpStream = initializeEventStream();
         tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-        tmpEvent = (LttngEvent)tmpStream.readNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.getNext(tmpContext);
         // Get the content
         testContent = tmpEvent.getContent();
         // Get all the fields to make sure there is something in the HashMap
index f92f395e7222cf8e57e8106d8da4ae22766f1880..879b47f48adb0bf5780743734294f97a1477757a 100644 (file)
@@ -56,7 +56,7 @@ public class LttngEventFieldTest extends TestCase {
         // This trace should be valid
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpField = (LttngEventField)tmpStream.readNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
+            tmpField = (LttngEventField)tmpStream.getNext( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
         }
         catch (final Exception e) {
             fail("ERROR : Failed to get field!");
@@ -94,7 +94,7 @@ public class LttngEventFieldTest extends TestCase {
 
         LttngEventField testField = null;
         //        try {
-        testField = (LttngEventField) tmpStream.readNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
+        testField = (LttngEventField) tmpStream.getNext( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
         //        } catch (TmfNoSuchFieldException e) {
         //            e.printStackTrace();
         //        }
index f81a634ccec2d5b3fc94fdf4d8e56b44dc5b218e..a99f824248699029f02b2449c25a5cad339ff8c4 100644 (file)
@@ -77,7 +77,7 @@ public class LttngEventTest extends TestCase {
 
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpEvent = (LttngEvent)tmpStream.readNextEvent(new TmfContext(new TmfLocation<Long>(0L), 0) );
+            tmpEvent = (LttngEvent)tmpStream.getNext(new TmfContext(new TmfLocation<Long>(0L), 0) );
         }
         catch (final Exception e) {
             System.out.println("ERROR : Could not open " + tracepath1);
index bc5ade03a15eee046a24a1439d6d7e3ad9174297..7c4ebf9c0ab4a184f95c608315ffa252e860244a 100644 (file)
@@ -59,7 +59,7 @@ public class LttngEventTypeTest extends TestCase {
         // This trace should be valid
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpEventType = (LttngEventType)tmpStream.readNextEvent( new TmfContext(null, 0) ).getType();
+            tmpEventType = (LttngEventType)tmpStream.getNext( new TmfContext(null, 0) ).getType();
         }
         catch (final Exception e) {
             fail("ERROR : Failed to get reference!");
index b2257c15f39df135a26380f50072e1a0c496b621..e5dcf34959c6d94ede39a14b0f3d1ea822fffa8e 100644 (file)
@@ -58,7 +58,7 @@ public class LttngTimestampTest extends TestCase {
         // This trace should be valid
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpTime = (LttngTimestamp) tmpStream.readNextEvent(new TmfContext(null, 0)).getTimestamp();
+            tmpTime = (LttngTimestamp) tmpStream.getNext(new TmfContext(null, 0)).getTimestamp();
         } catch (final Exception e) {
             fail("ERROR : Failed to get reference!");
         }
index d91049446aa7c0acaeb1dfda079e5413bbc4b742..e46d1de7b2af9f75346ea9c1e1abab244dd20190 100644 (file)
@@ -67,10 +67,10 @@ public class LttngTraceTest {
 
                 // Seek to the beginning of the trace
                 tmpContext = tmptrace.seekEvent( tmpTime  );
-                tmpevent = (LttngEvent)tmptrace.readNextEvent(tmpContext);
+                tmpevent = (LttngEvent)tmptrace.getNext(tmpContext);
 
                 while ( tmpevent != null ) {
-                    tmpevent = (LttngEvent)tmptrace.readNextEvent(tmpContext);
+                    tmpevent = (LttngEvent)tmptrace.getNext(tmpContext);
 
                     // Parse the events if it was asked
                     if ( (tmpevent != null) && (PARSE_EVENTS) )
index 456a9a67ee86e9982209d5e597c933a417c01424..e0167f73696dddcda123fce872199a043a5eb68d 100644 (file)
@@ -22,10 +22,11 @@ import junit.framework.TestCase;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
+import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
 import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfLegacyExperiment;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.osgi.framework.FrameworkUtil;
 
@@ -43,11 +44,11 @@ public class LTTngExperimentTest extends TestCase {
     private static int          NB_EVENTS   = 15316;
 
     // Note: Start/end times are for the LTTng *trace*, not the actual events
-    private static final TmfTimestamp  fStartTime = new TmfTimestamp(13589759412128L, (byte) -9);
-    private static final TmfTimestamp  fEndTime   = new TmfTimestamp(13589907059242L, (byte) -9);
+    private static final TmfTimestamp  fStartTime = new LttngTimestamp(13589759412128L);
+    private static final TmfTimestamp  fEndTime   = new LttngTimestamp(13589906758692L);
 
-    private static ITmfTrace<LttngEvent>[] fTraces;
-    private static TmfExperiment<LttngEvent> fExperiment;
+    private static ITmfTrace<LttngEvent>[] fTestTraces;
+    private static TmfLegacyExperiment<LttngEvent> fExperiment;
 
     // ------------------------------------------------------------------------
     // Housekeeping
@@ -55,13 +56,13 @@ public class LTTngExperimentTest extends TestCase {
 
     @SuppressWarnings("unchecked")
     private synchronized static ITmfTrace<LttngEvent>[] setupTrace(final String path) {
-        if (fTraces == null) {
-            fTraces = new ITmfTrace[1];
+        if (fTestTraces == null) {
+            fTestTraces = new ITmfTrace[1];
             try {
                 final URL location = FileLocator.find(FrameworkUtil.getBundle(LTTngExperimentTest.class), new Path(path), null);
                 final File testfile = new File(FileLocator.toFileURL(location).toURI());
-                final LTTngTrace trace = new LTTngTrace(null, testfile.getPath(), false);
-                fTraces[0] = trace;
+                final LTTngTrace trace = new LTTngTrace(null, testfile.getPath(), true);
+                fTestTraces[0] = trace;
             } catch (final URISyntaxException e) {
                 e.printStackTrace();
             } catch (final IOException e) {
@@ -70,12 +71,13 @@ public class LTTngExperimentTest extends TestCase {
                 e.printStackTrace();
             }
         }
-        return fTraces;
+        return fTestTraces;
     }
 
     private synchronized static void setupExperiment() {
-        if (fExperiment == null)
-            fExperiment = new TmfExperiment<LttngEvent>(LttngEvent.class, EXPERIMENT, fTraces, TmfTimestamp.ZERO, 1000, true);
+        if (fExperiment == null) {
+            fExperiment = new TmfLegacyExperiment<LttngEvent>(LttngEvent.class, EXPERIMENT, fTestTraces, TmfTimestamp.ZERO, 1000, true);
+        }
     }
 
     public LTTngExperimentTest(final String name) throws Exception {
@@ -101,15 +103,14 @@ public class LTTngExperimentTest extends TestCase {
     public void testBasicTmfExperimentConstructor() {
 
         assertEquals("GetId", EXPERIMENT, fExperiment.getName());
-        assertEquals("GetEpoch", TmfTimestamp.ZERO, fExperiment.getEpoch());
         assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
 
         final long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
         assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
 
         final TmfTimeRange timeRange = fExperiment.getTimeRange();
-        assertTrue("getStartTime", fStartTime.equals(timeRange.getStartTime()));
-        assertTrue("getEndTime",   fEndTime.equals(timeRange.getEndTime()));
+        assertEquals("getStartTime", fStartTime, timeRange.getStartTime());
+        assertEquals("getEndTime", fEndTime, timeRange.getEndTime());
     }
 
 }
\ No newline at end of file
index 9023ef78316720f2e1de1894a2eb833d7551cde7..1fdaab28c6af776ff82eb8a27cf05e7625c21ec9 100644 (file)
@@ -116,12 +116,12 @@ public class LTTngTextTraceTest extends TestCase {
         final TmfContext tmpContext = new TmfContext(null, 0);
         // We should be at the beginning of the trace, so we will just read the
         // first event now
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpEvent is null after first getNextEvent()", null, tmpEvent);
         assertEquals("tmpEvent has wrong timestamp after first getNextEvent()", firstEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Read the next event as well
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpEvent is null after second getNextEvent()", null, tmpEvent);
         assertEquals("tmpEvent has wrong timestamp after second getNextEvent()", secondEventTimestamp, tmpEvent.getTimestamp().getValue());
     }
@@ -151,7 +151,7 @@ public class LTTngTextTraceTest extends TestCase {
         // We should be at the beginning of the trace, we will seek at a certain
         // timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent);
@@ -159,7 +159,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after seekEvent() to last", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after seekEvent() to last", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent);
@@ -167,7 +167,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent);
         assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference()));
         assertNotSame("tmpContext is null after seekEvent() to first", null, tmpContext);
@@ -182,7 +182,7 @@ public class LTTngTextTraceTest extends TestCase {
         // We should be at the beginning of the trace, we will seek at a certain
         // timestamp
         tmpContext = testStream1.seekEvent(indexToSeekTest1);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent);
@@ -190,7 +190,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(indexToSeekLast);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent);
@@ -198,7 +198,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(indexToSeekFirst);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent);
@@ -213,7 +213,7 @@ public class LTTngTextTraceTest extends TestCase {
         // We should be at the beginning of the trace, we will seek at a certain
         // timestamp
         tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekTest1));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after first seekLocation()", null, tmpEvent);
@@ -221,7 +221,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekLast));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekLocation() to last ", null, tmpEvent);
@@ -229,7 +229,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekFirst));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekLocation() to start ", null, tmpEvent);
index 83f4dbb39845834efa43324fc965b3b88dc97ee5..a3628bd8e9bf226cf2add32c7ea6ea93b3eea9bc 100644 (file)
@@ -11,6 +11,7 @@ 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.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.osgi.framework.FrameworkUtil;
 
@@ -116,12 +117,12 @@ public class LTTngTraceTest extends TestCase {
 
         final TmfContext tmpContext = new TmfContext(null, 0);
         // We should be at the beginning of the trace, so we will just read the first event now
-        tmpEvent = testStream1.readNextEvent(tmpContext );
+        tmpEvent = testStream1.getNext(tmpContext );
         assertNotSame("tmpEvent is null after first getNextEvent()",null,tmpEvent );
         assertEquals("tmpEvent has wrong timestamp after first getNextEvent()",firstEventTimestamp,tmpEvent.getTimestamp().getValue() );
 
         // Read the next event as well
-        tmpEvent = testStream1.readNextEvent( tmpContext);
+        tmpEvent = testStream1.getNext( tmpContext);
         assertNotSame("tmpEvent is null after second getNextEvent()",null,tmpEvent );
         assertEquals("tmpEvent has wrong timestamp after second getNextEvent()",secondEventTimestamp,tmpEvent.getTimestamp().getValue() );
     }
@@ -144,12 +145,12 @@ public class LTTngTraceTest extends TestCase {
 
     public void testSeekEventTimestamp() {
         TmfEvent tmpEvent = null;
-        TmfContext tmpContext = new TmfContext(null, 0);
+        ITmfContext tmpContext = new TmfContext(null, 0);
         final LTTngTrace testStream1 = prepareStreamToTest();
 
         // We should be at the beginning of the trace, we will seek at a certain timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent );
@@ -157,7 +158,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after seekEvent() to last",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after seekEvent() to last",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent );
@@ -165,7 +166,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent );
         assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference()));
         assertNotSame("tmpContext is null after seekEvent() to first",null,tmpContext );
@@ -174,12 +175,12 @@ public class LTTngTraceTest extends TestCase {
 
     public void testSeekEventIndex() {
         TmfEvent tmpEvent = null;
-        TmfContext tmpContext = new TmfContext(null, 0);
+        ITmfContext tmpContext = new TmfContext(null, 0);
         final LTTngTrace testStream1 = prepareStreamToTest();
 
         // We should be at the beginning of the trace, we will seek at a certain timestamp
         tmpContext = testStream1.seekEvent(indexToSeekTest1);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent );
@@ -187,7 +188,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(indexToSeekLast);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent );
@@ -195,7 +196,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(indexToSeekFirst);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent );
@@ -204,12 +205,12 @@ public class LTTngTraceTest extends TestCase {
 
     public void testSeekLocation() {
         TmfEvent tmpEvent = null;
-        TmfContext tmpContext = new TmfContext(null, 0);
+        ITmfContext tmpContext = new TmfContext(null, 0);
         final LTTngTrace testStream1 = prepareStreamToTest();
 
         // We should be at the beginning of the trace, we will seek at a certain timestamp
         tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekTest1));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent );
@@ -217,7 +218,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekLast));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent );
@@ -225,7 +226,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekFirst));
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent );
@@ -234,7 +235,7 @@ public class LTTngTraceTest extends TestCase {
 
     public void testLocationOperations() {
         TmfEvent tmpEvent = null;
-        TmfContext tmpContext = new TmfContext(null, 0);
+        ITmfContext tmpContext = new TmfContext(null, 0);
         final LTTngTrace testStream1 = prepareStreamToTest();
 
         // Test LttngLocation after a seek
@@ -243,7 +244,7 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationSeek());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
 
@@ -255,19 +256,19 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
@@ -281,27 +282,27 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext and getNext
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext and parse
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
@@ -309,7 +310,7 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
@@ -317,13 +318,13 @@ public class LTTngTraceTest extends TestCase {
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
@@ -331,7 +332,7 @@ public class LTTngTraceTest extends TestCase {
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
@@ -339,7 +340,7 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
@@ -347,21 +348,21 @@ public class LTTngTraceTest extends TestCase {
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext, parse and parse
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
@@ -371,31 +372,31 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext, parse and getNext
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext, getNext and parse
         tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.readNextEvent(tmpContext);
+        tmpEvent = testStream.getNext(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
@@ -403,7 +404,7 @@ public class LTTngTraceTest extends TestCase {
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextnextEventTimestamp, location.getOperationTimeValue());
         tmpContext = testStream1.seekEvent(location);
-        tmpEvent = testStream1.readNextEvent(tmpContext);
+        tmpEvent = testStream1.getNext(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
     }
index ac4a3d5185e47ea120aef99e3b0e1a232d706d1d..8691e072b4dbd06a1e87f19b78ba4df9093a36e6 100644 (file)
@@ -23,8 +23,8 @@ import org.eclipse.linuxtools.internal.lttng.core.TraceDebug;
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEventType;
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngSyntheticEvent;
-import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngSyntheticEvent.SequenceInd;
+import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
 import org.eclipse.linuxtools.internal.lttng.core.model.LTTngTreeNode;
 import org.eclipse.linuxtools.internal.lttng.core.request.LttngBaseEventRequest;
 import org.eclipse.linuxtools.internal.lttng.core.state.evProcessor.ITransEventProcessor;
index 4d693bfc423aadaac377c216b3189a98796951ae..08bfcafbb431b989dcc84e100aa8f1132b31a93d 100644 (file)
@@ -41,26 +41,8 @@ public class LttngLocation implements ITmfLocation<LttngTimestamp>, Comparable<L
 
     @Override
     public LttngLocation clone() {
-
-        LttngLocation newLocation = null;
-
-        try {
-            newLocation = (LttngLocation)super.clone();
-
-            // *** IMPORTANT ***
-            // Basic type in java are immutable!
-            // Thus, using assignation ("=") on basic type is VALID.
-            newLocation.isLastOperationParse = this.isLastOperationParse;
-            newLocation.isLastOperationReadNext = this.isLastOperationReadNext;
-            newLocation.isLastOperationSeek = this.isLastOperationSeek;
-
-            // For other type, we need to create a new timestamp
-            newLocation.operationTime  = new LttngTimestamp( this.operationTime );
-        }
-        catch (final CloneNotSupportedException e) {
-            System.out.println("Cloning failed with : " + e.getMessage()); //$NON-NLS-1$
-        }
-
+        LttngLocation newLocation = new LttngLocation(this);
+        newLocation.operationTime  = new LttngTimestamp( this.operationTime );
         return newLocation;
     }
 
index 0fc81a174c024fe024ade9197206dcbc5241b35a..9517564a2cad0b19186dbe5c93906511d5785096 100644 (file)
@@ -76,23 +76,15 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> implements ITmfEventPar
         if ( positionToFirstEvent() == false )
             throw new IOException("Fail to position to the beginning of the trace"); //$NON-NLS-1$
         else {
-//            fCacheSize = 1000;
-
-            // Skip indexing if asked
-            //         if ( skipIndexing == true ) {
-//            fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L), new TmfLocation<Long>(0L)));
+            setCacheSize(1000);
             ITmfContext context = new TmfContext(new TmfLocation<Long>(0L), 0);
-            fIndexer.updateIndex(context, new LttngTimestamp(0L));
-            fParser = (ITmfEventParser<LttngEvent>) this;
-            //         }
-            //         else {
-            //                 indexTrace(true);
-            //         }
+            getIndexer().updateIndex(context, new LttngTimestamp(0L));
+            setParser((ITmfEventParser<LttngEvent>) this);
 
             final Long endTime = currentLttngEvent.getTimestamp().getValue();
             positionToFirstEvent();
 
-            readNextEvent(new TmfContext(null, 0));
+            getNext(new TmfContext(null, 0));
             final Long starTime = currentLttngEvent.getTimestamp().getValue();
             positionToFirstEvent();
 
index 842f7cc3f06cb862f820c773d20675029e179811..ad725da3e8d21edc648081990b53eea5a18eb03a 100644 (file)
@@ -121,7 +121,6 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
         initialize(resource, path, eventType);
     }
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
     protected synchronized void initialize(final IResource resource, final String path, final Class<LttngEvent> eventType)
             throws TmfTraceException {
@@ -153,8 +152,8 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
         // Set the currentEvent to the eventContent
         eventContent.setEvent(currentLttngEvent);
 
-        fParser = (ITmfEventParser<LttngEvent>) this;
-        fCacheSize = CHECKPOINT_PAGE_SIZE;
+        setParser((ITmfEventParser<LttngEvent>) this);
+        setCacheSize(CHECKPOINT_PAGE_SIZE);
  
         // // Bypass indexing if asked
         // if ( bypassIndexing == false ) {
@@ -173,8 +172,8 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
         if (jniTrace == null
                 || (!jniTrace.isLiveTraceSupported() || !LiveTraceManager.isLiveTrace(jniTrace.getTracepath()))) {
             // Set the time range of the trace
-            final TmfContext context = seekEvent(0);
-            final LttngEvent event = readNextEvent(context);
+            final ITmfContext context = seekEvent(0);
+            final LttngEvent event = getNext(context);
             final LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp());
             final LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime());
             setTimeRange(new TmfTimeRange(startTime, endTime));
@@ -184,11 +183,11 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
         }
 
         // Set the time range of the trace
-        final TmfContext context = seekEvent(0);
-        final LttngEvent event = readNextEvent(context);
+        final ITmfContext context = seekEvent(0);
+        final LttngEvent event = getNext(context);
         setEndTime(TmfTimestamp.BIG_BANG);
         final long startTime = event != null ? event.getTimestamp().getValue() : TmfTimestamp.BIG_BANG.getValue();
-        fStreamingInterval = LTTNG_STREAMING_INTERVAL;
+        setStreamingInterval(LTTNG_STREAMING_INTERVAL);
 
         final Thread thread = new Thread("Streaming Monitor for trace " + getName()) { //$NON-NLS-1$
 
@@ -445,35 +444,28 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
      * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext
      */
     @Override
-    public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {
-
-        // // [lmcfrch]
-        // lastTime = 0;
+    public synchronized ITmfContext seekEvent(final ITmfLocation<?> location) {
 
         if (PRINT_DEBUG)
             System.out.println("seekLocation(location) location -> " + location); //$NON-NLS-1$
 
         // If the location in context is null, create a new one
-        LttngLocation curLocation = null;
         if (location == null) {
-            curLocation = new LttngLocation();
-            final TmfContext context = seekEvent(curLocation.getOperationTime());
+            LttngLocation curLocation = new LttngLocation();
+            final ITmfContext context = seekEvent(curLocation.getOperationTime());
             context.setRank(0);
             return context;
-        } else
-            curLocation = (LttngLocation) location;
-
-        // *** NOTE :
-        // Update to location should (and will) be done in SeekEvent.
-
+        }
+        
         // The only seek valid in LTTng is with the time, we call
         // seekEvent(timestamp)
-        final TmfContext context = seekEvent(curLocation.getOperationTime());
+        LttngLocation curLocation = (LttngLocation) location;
+        final ITmfContext context = 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(context);
+            getNext(context);
 
         return context;
     }
@@ -543,14 +535,14 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
 //            timestamp = getStartTime();
 
         // Position the trace at the checkpoint
-        final ITmfContext checkpointContext = fIndexer.seekIndex(rank);
+        final ITmfContext checkpointContext = getIndexer().seekIndex(rank);
         LttngLocation location = (LttngLocation) checkpointContext.getLocation();
         ITmfTimestamp timestamp = location.getLocation();
         long index = rank / getCacheSize();
 
         // Seek to the found time
         final TmfContext tmpContext = seekEvent(timestamp);
-        tmpContext.setRank((index + 1) * fCacheSize);
+        tmpContext.setRank((index + 1) * getCacheSize());
         previousLocation = (LttngLocation) tmpContext.getLocation();
 
         // Ajust the index of the event we found at this check point position
@@ -618,7 +610,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<
     public int nbEventsRead = 0;
 
     @Override
-    public synchronized LttngEvent readNextEvent(final ITmfContext context) {
+    public synchronized LttngEvent getNext(final ITmfContext context) {
 
         if (PRINT_DEBUG)
             System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$
index 3c55153ab2cbb0023d84126b46113299f646d3d5..26548d801a74063078ff3cae02fb2a50a290d90e 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
@@ -55,7 +56,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> implements ITmfEventPar
      * @throws FileNotFoundException
      */
     public LTTngTraceStub(final IResource resource) throws TmfTraceException {
-        this(resource, DEFAULT_TRACE_CACHE_SIZE);
+        this(resource, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE);
     }
 
     /**
@@ -76,7 +77,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> implements ITmfEventPar
     }
 
     public void indexTrace() {
-        fIndexer.buildIndex(true);
+        getIndexer().buildIndex(true);
     }
 
     // ========================================================================
index ceaca0ded222a56624891da3c1b07f81af0e589e..ae11c98b667cc57f1b67969000c0673fc0ec91c2 100644 (file)
@@ -767,7 +767,7 @@ public class CtfTmfTraceTest {
         CtfTmfTrace fixture = initTrace();
         ITmfContext context = fixture.seekEvent(0);
 
-        CtfTmfEvent result = fixture.readNextEvent(context);
+        CtfTmfEvent result = fixture.getNext(context);
 
         // add additional test code here
         // An unexpected exception was thrown in user code while executing this test:
index f26e5ddc1e5b95546412f1d823c7084f7f8b4002..a0b94e09b39e3d32af646aa888ad4cd4a28d9e38 100644 (file)
@@ -19,8 +19,7 @@ import junit.framework.TestSuite;
 import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin;
 
 /**
- * <b><u>AllTests</u></b>
- * <p>
+ * Test suite for org.eclipse.linuxtools.tmf.core.event
  */
 @SuppressWarnings("nls")
 public class AllTests {
index dcfc605113d763c73c4b93a6f5a05a03ecf1044b..c710ee881c522eb6ddb02eab8d04640444eb69c2 100644 (file)
@@ -19,8 +19,6 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 
 /**
- * <b><u>TmfEventFieldTest</u></b>
- * <p>
  * Test suite for the TmfEventField class.
  */
 @SuppressWarnings("nls")
index 3ae06dac223e1aa0efacb2b469308bbe58c95bc2..a87beae1393f9c976437da1a4788760260cee992 100644 (file)
@@ -37,8 +37,6 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 /**
- * <b><u>TmfEventTest</u></b>
- * <p>
  * Test suite for the TmfEvent class.
  */
 @SuppressWarnings("nls")
index 5216666c7e7dac0eb404f131f27719b815d5196c..4ef3ba445ad39e8f2549334ead8eed37932f11a8 100644 (file)
@@ -22,10 +22,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager;
 
 /**
- * <b><u>TmfEventTypeManagerTest</u></b>
- * <p>
  * Test suite for the TmfEventTypeManager class.
- * <p>
  */
 @SuppressWarnings("nls")
 public class TmfEventTypeManagerTest extends TestCase {
index 76238f741ccf165fa2301382bfb9a829f911b532..ddd7889ffc3d5e5f3bedb14434625503bbc7fa73 100644 (file)
@@ -20,8 +20,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 
 /**
- * <b><u>TmfEventTypeTest</u></b>
- * <p>
  * Test suite for the TmfEventType class.
  */
 @SuppressWarnings("nls")
index 1bfd3f630f55a8f000e460d8406a424888ec2ffd..bb198b56502cfa0de389a41b12beb97a751eca76 100644 (file)
@@ -19,8 +19,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfSimpleTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 
 /**
- * <b><u>TmfSimpleTimestampTest</u></b>
- * <p>
  * Test suite for the TmfSimpleTimestampTest class.
  */
 @SuppressWarnings("nls")
index 216677e2590a27599a067b72b209f3fdd2595f4f..a3e3e390cb196d78ec2a991ffa353b741ffaaea2 100644 (file)
@@ -20,8 +20,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 
 /**
- * <b><u>TmfTimeRangeTest</u></b>
- * <p>
  * Test suite for the TmfTimeRange class.
  */
 @SuppressWarnings("nls")
index e60b94c3b518958f86a749c6c6622c553c820949..95e1136ee22e7cd8234f4f2f041c21366b0dae5a 100644 (file)
@@ -19,8 +19,6 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 
 /**
- * <b><u>TmfTimestampTest</u></b>
- * <p>
  * Test suite for the TmfTimestamp class.
  */
 @SuppressWarnings("nls")
index 21c10605e2ae9c07c72f5c922a41292693b896d1..1192d6a14ff7d803c6f45bb8a64ed33c6d3312e4 100644 (file)
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Adjusted for new Trace Model
+ *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.core.tests.experiment;
 
 import junit.framework.Test;
@@ -5,13 +18,17 @@ import junit.framework.TestSuite;
 
 import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin;
 
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.experiment
+ */
 @SuppressWarnings("nls")
 public class AllTests {
 
        public static Test suite() {
                TestSuite suite = new TestSuite("Test suite for " + TmfCorePlugin.PLUGIN_ID + ".experiment"); //$NON-NLS-1$);
                //$JUnit-BEGIN$
-               suite.addTestSuite(TmfExperimentTest.class);
+               suite.addTestSuite(TmfExperimentCheckpointIndexTest.class);
+        suite.addTestSuite(TmfExperimentTest.class);
                suite.addTestSuite(TmfMultiTraceExperimentTest.class);
                //$JUnit-END$
                return suite;
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentCheckpointIndexTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentCheckpointIndexTest.java
new file mode 100644 (file)
index 0000000..d847c9a
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.experiment;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentLocation;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfLocationArray;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
+import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+
+/**
+ * Test suite for the TmfCheckpointIndexTest class.
+ */
+@SuppressWarnings("nls")
+public class TmfExperimentCheckpointIndexTest extends TestCase {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    private static final String DIRECTORY    = "testfiles";
+    private static final String TEST_STREAM1 = "O-Test-10K";
+    private static final String TEST_STREAM2 = "E-Test-10K";
+    private static final String EXPERIMENT   = "MyExperiment";
+    private static int          NB_EVENTS    = 20000;
+    private static int          BLOCK_SIZE   = 1000;
+
+    private static ITmfTrace<?>[] fTestTraces;
+    private static TestExperiment fExperiment;
+
+    // ------------------------------------------------------------------------
+    // Helper classes
+    // ------------------------------------------------------------------------
+
+    private class TestIndexer extends TmfCheckpointIndexer<ITmfTrace<ITmfEvent>> {
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        public TestIndexer(TestExperiment testExperiment) {
+            super((ITmfTrace) testExperiment, BLOCK_SIZE);
+        }
+        public List<TmfCheckpoint> getCheckpoints() {
+            return getTraceIndex();
+        }
+    }
+
+    private class TestExperiment extends TmfExperiment<ITmfEvent> {
+        @SuppressWarnings("unchecked")
+        public TestExperiment() {
+            super(ITmfEvent.class, EXPERIMENT, (ITmfTrace<ITmfEvent>[]) fTestTraces, TmfTimestamp.ZERO, BLOCK_SIZE, false);
+            setIndexer(new TestIndexer(this));
+            getIndexer().buildIndex(true);
+        }
+        @Override
+        public TestIndexer getIndexer() {
+            return (TestIndexer) super.getIndexer();
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Housekeeping
+    // ------------------------------------------------------------------------
+
+    public TmfExperimentCheckpointIndexTest(final String name) throws Exception {
+        super(name);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        setupTrace(DIRECTORY + File.separator + TEST_STREAM1, DIRECTORY + File.separator + TEST_STREAM2);
+        if (fExperiment == null) {
+            fExperiment = new TestExperiment();
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        fExperiment.dispose();
+        fExperiment = null;
+    }
+
+    private static ITmfTrace<?>[] setupTrace(final String path1, final String path2) {
+        if (fTestTraces == null) {
+            fTestTraces = new ITmfTrace[2];
+            try {
+                URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
+                File test = new File(FileLocator.toFileURL(location).toURI());
+                final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
+                fTestTraces[0] = trace1;
+                location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
+                test = new File(FileLocator.toFileURL(location).toURI());
+                final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
+                fTestTraces[1] = trace2;
+            } catch (final TmfTraceException e) {
+                e.printStackTrace();
+            } catch (final URISyntaxException e) {
+                e.printStackTrace();
+            } catch (final IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return fTestTraces;
+    }
+
+    // ------------------------------------------------------------------------
+    // Verify checkpoints
+    // ------------------------------------------------------------------------
+
+    public void testTmfTraceIndexing() throws Exception {
+        assertEquals("getCacheSize",   BLOCK_SIZE, fExperiment.getCacheSize());
+        assertEquals("getTraceSize",   NB_EVENTS,  fExperiment.getNbEvents());
+        assertEquals("getRange-start", 1,          fExperiment.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end",   NB_EVENTS,  fExperiment.getTimeRange().getEndTime().getValue());
+        assertEquals("getStartTime",   1,          fExperiment.getStartTime().getValue());
+        assertEquals("getEndTime",     NB_EVENTS,  fExperiment.getEndTime().getValue());
+
+        List<TmfCheckpoint> checkpoints = fExperiment.getIndexer().getCheckpoints();
+        int pageSize = fExperiment.getCacheSize();
+        assertTrue("Checkpoints exist",  checkpoints != null);
+        assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+
+        // Validate that each checkpoint points to the right event
+        for (int i = 0; i < checkpoints.size(); i++) {
+            TmfCheckpoint checkpoint = checkpoints.get(i);
+            TmfExperimentLocation expLocation = (TmfExperimentLocation) checkpoint.getLocation();
+            TmfLocationArray locations = expLocation.getLocation();
+            ITmfContext[] trcContexts = new ITmfContext[2];
+            trcContexts[0] = new TmfContext(locations.getLocations()[0], (i * pageSize) / 2);
+            trcContexts[1] = new TmfContext(locations.getLocations()[1], (i * pageSize) / 2);
+            TmfExperimentContext expContext = new TmfExperimentContext(trcContexts);
+            expContext.getEvents()[0] = fTestTraces[0].getNext(fTestTraces[0].seekEvent((i * pageSize) / 2));
+            expContext.getEvents()[1] = fTestTraces[1].getNext(fTestTraces[1].seekEvent((i * pageSize) / 2));
+            ITmfEvent event = fExperiment.parseEvent(expContext);
+            assertTrue(expContext.getRank() == i * pageSize);
+            assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+        }
+    }
+
+}
\ No newline at end of file
index c6d259726f6452514ca4670ea75527e8f79bdc39..9a693b99efadbdd1890f8006c2b54da1432c6b9f 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  * 
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,6 +8,7 @@
  * 
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Adjusted for new Trace Model
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.experiment;
@@ -28,28 +29,28 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext;
 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 /**
- * <b><u>TmfExperimentTest</u></b>
- * <p>
- * TODO: Implement me. Please.
+ * Test suite for the TmfExperiment class (single trace).
  */
 @SuppressWarnings("nls")
 public class TmfExperimentTest extends TestCase {
 
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
     private static final String DIRECTORY   = "testfiles";
     private static final String TEST_STREAM = "A-Test-10K";
     private static final String EXPERIMENT  = "MyExperiment";
     private static int          NB_EVENTS   = 10000;
-    private static int    fDefaultBlockSize = 1000;
+    private static int          BLOCK_SIZE  = 1000;
 
     private static ITmfTrace<?>[] fTraces;
     private static TmfExperiment<TmfEvent> fExperiment;
@@ -109,9 +110,11 @@ public class TmfExperimentTest extends TestCase {
     public void testBasicTmfExperimentConstructor() {
 
         assertEquals("GetId", EXPERIMENT, fExperiment.getName());
-        assertEquals("GetEpoch", TmfTimestamp.ZERO, fExperiment.getEpoch());
         assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
 
+        final long nbExperimentEvents = fExperiment.getNbEvents();
+        assertEquals("GetNbEvents", NB_EVENTS, nbExperimentEvents);
+
         final long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
         assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
 
@@ -121,437 +124,284 @@ public class TmfExperimentTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // Verify checkpoints
+    // seekEvent on rank
     // ------------------------------------------------------------------------
 
-    public void testValidateCheckpoints() throws Exception {
-
-        final Vector<TmfCheckpoint> checkpoints = fExperiment.getCheckpoints();
-        final int pageSize = fExperiment.getCacheSize();
-        assertTrue("Checkpoints exist", checkpoints != null);
-
-        // Validate that each checkpoint points to the right event
-        for (int i = 0; i < checkpoints.size(); i++) {
-            final TmfCheckpoint checkpoint = checkpoints.get(i);
-            final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
-            final ITmfEvent event = fExperiment.parseEvent(context);
-            assertEquals("Event rank", i * pageSize, context.getRank());
-            assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // seekLocation
-    // ------------------------------------------------------------------------
+    public void testSeekRankOnCacheBoundary() throws Exception {
 
-    public void testSeekLocationOnCacheBoundary() throws Exception {
+        long cacheSize = fExperiment.getCacheSize();
 
-        // Position trace at event rank 0
-        TmfContext context = fExperiment.seekEvent(0);
-        assertEquals("Event rank", 0, context.getRank());
+        // On lower bound, returns the first event (TS = 1)
+        ITmfContext context = fExperiment.seekEvent(0);
+        assertEquals("Context rank", 0, context.getRank());
 
-        ITmfEvent event = fExperiment.parseEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
+        assertEquals("Context rank", 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 2, context.getRank());
+        // Position trace at event rank [cacheSize]
+        context = fExperiment.seekEvent(cacheSize);
+        assertEquals("Context rank", cacheSize, context.getRank());
 
-        // Position trace at event rank 1000
-        TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 1000, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize + 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
+        // Position trace at event rank [4 * cacheSize]
+        context = fExperiment.seekEvent(4 * cacheSize);
+        assertEquals("Context rank", 4 * cacheSize, context.getRank());
 
-        // Position trace at event rank 4000
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 4000, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4002, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
     }
 
-    public void testSeekLocationNotOnCacheBoundary() throws Exception {
+    public void testSeekRankNotOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 9
-        TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 9, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
+        // Position trace at event rank 9
+        ITmfContext context = fExperiment.seekEvent(9);
+        assertEquals("Context rank", 9, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
-
-        // Position trace at event rank 999
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 999, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
+        assertEquals("Context rank", 10, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        // Position trace at event rank [cacheSize - 1]
+        context = fExperiment.seekEvent(cacheSize - 1);
+        assertEquals("Context rank", cacheSize - 1, context.getRank());
 
-        // Position trace at event rank 1001
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 1001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize, context.getRank());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        // Position trace at event rank [cacheSize + 1]
+        context = fExperiment.seekEvent(cacheSize + 1);
+        assertEquals("Context rank", cacheSize + 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize + 2, context.getRank());
 
         // Position trace at event rank 4500
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 4500, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
+        context = fExperiment.seekEvent(4500);
+        assertEquals("Context rank", 4500, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
+        assertEquals("Context rank", 4501, context.getRank());
     }
 
-    public void testSeekLocationOutOfScope() throws Exception {
+    public void testSeekRankOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext tmpContext = fExperiment.seekEvent(0);
-        final TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
+        ITmfContext context = fExperiment.seekEvent(-1);
         assertEquals("Event rank", 0, context.getRank());
 
-        ITmfEvent event = fExperiment.parseEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        assertEquals("Context rank", 1, context.getRank());
 
         // Position trace at event passed the end
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event location", null, tmpContext.getLocation());
-        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, tmpContext.getRank());
+        context = fExperiment.seekEvent(NB_EVENTS);
+        assertEquals("Context rank", NB_EVENTS, context.getRank());
+
+        event = fExperiment.getNext(context);
+        assertNull("Event", event);
+        assertEquals("Context rank", NB_EVENTS, context.getRank());
     }
 
     // ------------------------------------------------------------------------
     // seekEvent on timestamp
     // ------------------------------------------------------------------------
 
-    public void testSeekEventOnTimestampOnCacheBoundary() throws Exception {
+    public void testSeekTimestampOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 0
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
-        assertEquals("Event rank", 0, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
+        // Position trace at event rank 0
+        ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
+        assertEquals("Context rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event rank 1000
-        context = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        assertEquals("Event rank", 1000, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        assertEquals("Context rank", 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        // Position trace at event rank [cacheSize]
+        context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE, 0));
+        assertEquals("Event rank", cacheSize, context.getRank());
 
-        // Position trace at event rank 4000
-        context = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        assertEquals("Event rank", 4000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize + 1, context.getRank());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
+        // Position trace at event rank [4 * cacheSize]
+        context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE, 0));
+        assertEquals("Context rank", 4 * cacheSize, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
     }
 
-    public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception {
+    public void testSeekTimestampNotOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 1
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
-        assertEquals("Event rank", 1, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        // Position trace at event rank 1 (TS = 2)
+        ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
+        assertEquals("Context rank", 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 2, context.getRank());
+        assertEquals("Context rank", 2, context.getRank());
 
-        // Position trace at event rank 9
+        // Position trace at event rank 9 (TS = 10)
         context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        assertEquals("Event rank", 9, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
+        assertEquals("Context rank", 9, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
+        assertEquals("Context rank", 10, context.getRank());
 
-        // Position trace at event rank 999
+        // Position trace at event rank 999 (TS = 1000)
         context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        assertEquals("Event rank", 999, context.getRank());
+        assertEquals("Context rank", 999, context.getRank());
 
-        event = fExperiment.parseEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
+        assertEquals("Context rank", 1000, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
-
-        // Position trace at event rank 1001
+        // Position trace at event rank 1001 (TS = 1002)
         context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        assertEquals("Event rank", 1001, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        assertEquals("Context rank", 1001, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
+        assertEquals("Context rank", 1002, context.getRank());
 
-        // Position trace at event rank 4500
+        // Position trace at event rank 4500 (TS = 4501)
         context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        assertEquals("Event rank", 4500, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
+        assertEquals("Context rank", 4500, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
+        assertEquals("Context rank", 4501, context.getRank());
     }
 
-    public void testSeekEventOnTimestampoutOfScope() throws Exception {
+    public void testSeekTimestampOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
-        assertEquals("Event rank", 0, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
         // Position trace at event passed the end
         context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event location", null, context.getLocation());
+        event = fExperiment.getNext(context);
+        assertNull("Event location", event);
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
     }
 
     // ------------------------------------------------------------------------
-    // seekEvent on rank
+    // seekEvent by location (context rank is undefined)
     // ------------------------------------------------------------------------
 
-    public void testSeekOnRankOnCacheBoundary() throws Exception {
+    public void testSeekLocationOnCacheBoundary() throws Exception {
+        
+        long cacheSize = fExperiment.getCacheSize();
 
-        // On lower bound, returns the first event (ts = 1)
-        TmfContext context = fExperiment.seekEvent(0);
-        assertEquals("Event rank", 0, context.getRank());
+        // Position trace at event rank 0
+        ITmfContext tmpContext = fExperiment.seekEvent(0);
+        ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        ITmfEvent event = fExperiment.parseEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
 
-        // Position trace at event rank 1000
-        context = fExperiment.seekEvent(1000);
-        assertEquals("Event rank", 1000, context.getRank());
+        // Position trace at event rank 'cacheSize'
+        tmpContext = fExperiment.seekEvent(cacheSize);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
 
-        // Position trace at event rank 4000
-        context = fExperiment.seekEvent(4000);
-        assertEquals("Event rank", 4000, context.getRank());
+        // Position trace at event rank 4 * 'cacheSize'
+        tmpContext = fExperiment.seekEvent(4 * cacheSize);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue());
     }
 
-    public void testSeekOnRankNotOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 9
-        TmfContext context = fExperiment.seekEvent(9);
-        assertEquals("Event rank", 9, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
+    public void testSeekLocationNotOnCacheBoundary() throws Exception {
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        // Position trace at event rank 999
-        context = fExperiment.seekEvent(999);
-        assertEquals("Event rank", 999, context.getRank());
+        // Position trace at event 'cacheSize' - 1
+        ITmfContext tmpContext = fExperiment.seekEvent(cacheSize - 1);
+        ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
+        ITmfEvent event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
 
-        // Position trace at event rank 1001
-        context = fExperiment.seekEvent(1001);
-        assertEquals("Event rank", 1001, context.getRank());
+        // Position trace at event rank 2 * 'cacheSize' - 1
+        tmpContext = fExperiment.seekEvent(2 * cacheSize - 1);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
+        context = fExperiment.seekEvent(2 * cacheSize - 1);
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 2 * cacheSize, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 2 * cacheSize + 1, event.getTimestamp().getValue());
 
         // Position trace at event rank 4500
-        context = fExperiment.seekEvent(4500);
-        assertEquals("Event rank", 4500, context.getRank());
+        tmpContext = fExperiment.seekEvent(4500);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4502, event.getTimestamp().getValue());
     }
 
-    public void testSeekEventOnRankOutOfScope() throws Exception {
+    public void testSeekLocationOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext context = fExperiment.seekEvent(-1);
-        assertEquals("Event rank", 0, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
+        ITmfContext context = fExperiment.seekEvent((ITmfLocation<?>) null);
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event passed the end
-        context = fExperiment.seekEvent(NB_EVENTS);
-        assertEquals("Event location", null, context.getLocation());
-        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
     }
 
     // ------------------------------------------------------------------------
-    // parseEvent - make sure parseEvent doesn't update the context
-    // Note: This test is essentially the same as the one from TmfTraceTest
+    // readtNextEvent - updates the context
     // ------------------------------------------------------------------------
 
-    public void testParseEvent() throws Exception {
-
-        final int NB_READS = 20;
-
-        // On lower bound, returns the first event (ts = 1)
-        final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-
-        // Read NB_EVENTS
-        ITmfEvent event = null;;
-        for (int i = 0; i < NB_READS; i++) {
-            event = fExperiment.readNextEvent(context);
-            assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
-            assertEquals("Event rank", i + 1, context.getRank());
-        }
-
-        // Make sure we stay positioned
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", NB_READS, context.getRank());
-    }
-
-    // ------------------------------------------------------------------------
-    // getNextEvent - updates the context
-    // ------------------------------------------------------------------------
-
-    public void testGetNextEvent() throws Exception {
+    public void testReadNextEvent() throws Exception {
 
         // On lower bound, returns the first event (ts = 0)
-        final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-        ITmfEvent event = fExperiment.readNextEvent(context);
+        final ITmfContext context = fExperiment.seekEvent(0);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
 
         for (int i = 2; i < 20; i++) {
-            event = fExperiment.readNextEvent(context);
+            event = fExperiment.getNext(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
     }
@@ -652,7 +502,7 @@ public class TmfExperimentTest extends TestCase {
     public void testCancel() throws Exception {
 
         final int nbEvents  = NB_EVENTS;
-        final int blockSize = fDefaultBlockSize;
+        final int blockSize = BLOCK_SIZE;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
         final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
@@ -681,21 +531,6 @@ public class TmfExperimentTest extends TestCase {
         assertTrue("isCancelled", request.isCancelled());
     }
 
-    // ------------------------------------------------------------------------
-    // getRank
-    // ------------------------------------------------------------------------
-
-    //    public void testGetRank() throws Exception {
-    //
-    //         assertEquals("getRank",    0, fExperiment.getRank(new TmfTimestamp()));
-    //        assertEquals("getRank",    0, fExperiment.getRank(new TmfTimestamp(   1, (byte) -3)));
-    //        assertEquals("getRank",   10, fExperiment.getRank(new TmfTimestamp(  11, (byte) -3)));
-    //        assertEquals("getRank",  100, fExperiment.getRank(new TmfTimestamp( 101, (byte) -3)));
-    //        assertEquals("getRank", 1000, fExperiment.getRank(new TmfTimestamp(1001, (byte) -3)));
-    //        assertEquals("getRank", 2000, fExperiment.getRank(new TmfTimestamp(2001, (byte) -3)));
-    //        assertEquals("getRank", 2500, fExperiment.getRank(new TmfTimestamp(2501, (byte) -3)));
-    //    }
-
     // ------------------------------------------------------------------------
     // getTimestamp
     // ------------------------------------------------------------------------
index bd274776112a54ec6b44af2fb29debfc7a144b38..0787c42222831b67767e2ee237c3de20546f2534 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  * 
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,6 +8,7 @@
  * 
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Adjusted for new Trace Model
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.experiment;
@@ -28,23 +29,23 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext;
 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 /**
- * <b><u>TmfExperimentTest</u></b>
- * <p>
- * TODO: Implement me. Please.
+ * Test suite for the TmfExperiment class (multiple traces).
  */
 @SuppressWarnings("nls")
 public class TmfMultiTraceExperimentTest extends TestCase {
 
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
     private static final String DIRECTORY    = "testfiles";
     private static final String TEST_STREAM1 = "O-Test-10K";
     private static final String TEST_STREAM2 = "E-Test-10K";
@@ -84,24 +85,18 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         return fTraces;
     }
 
-    @SuppressWarnings("unchecked")
-    private synchronized static void setupExperiment() {
-        synchronized (TmfMultiTraceExperimentTest.class) {
-            if (fExperiment == null) {
-                fExperiment = new TmfExperiment<TmfEvent>(TmfEvent.class, EXPERIMENT, (ITmfTrace<TmfEvent>[]) fTraces, TmfTimestamp.ZERO, BLOCK_SIZE, true);
-            }
-        }
-    }
-
     public TmfMultiTraceExperimentTest(final String name) throws Exception {
         super(name);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         setupTrace(DIRECTORY + File.separator + TEST_STREAM1, DIRECTORY + File.separator + TEST_STREAM2);
-        setupExperiment();
+        if (fExperiment == null) {
+            fExperiment = new TmfExperiment<TmfEvent>(TmfEvent.class, EXPERIMENT, (ITmfTrace<TmfEvent>[]) fTraces, TmfTimestamp.ZERO, BLOCK_SIZE, true);
+        }
     }
 
     @Override
@@ -116,7 +111,6 @@ public class TmfMultiTraceExperimentTest extends TestCase {
     public void testBasicTmfExperimentConstructor() {
 
         assertEquals("GetId", EXPERIMENT, fExperiment.getName());
-        assertEquals("GetEpoch", TmfTimestamp.ZERO, fExperiment.getEpoch());
         assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
 
         final TmfTimeRange timeRange = fExperiment.getTimeRange();
@@ -125,437 +119,284 @@ public class TmfMultiTraceExperimentTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // Verify checkpoints
-    // ------------------------------------------------------------------------
-
-    public void testValidateCheckpoints() throws Exception {
-
-        final Vector<TmfCheckpoint> checkpoints = fExperiment.getCheckpoints();
-        final int pageSize = fExperiment.getCacheSize();
-        assertTrue("Checkpoints exist", checkpoints != null);
-
-        // Validate that each checkpoint points to the right event
-        for (int i = 0; i < checkpoints.size(); i++) {
-            final TmfCheckpoint checkpoint = checkpoints.get(i);
-            final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
-            final ITmfEvent event = fExperiment.parseEvent(context);
-            assertEquals("Event rank", context.getRank(), i * pageSize);
-            assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // seekLocation
+    // seekEvent on rank
     // ------------------------------------------------------------------------
 
-    public void testSeekLocationOnCacheBoundary() throws Exception {
+    public void testSeekRankOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 0
-        TmfContext context = fExperiment.seekEvent(0);
-        assertEquals("Event rank", 0, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
+        // On lower bound, returns the first event (TS = 1)
+        ITmfContext context = fExperiment.seekEvent(0);
+        assertEquals("Context rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        assertEquals("Context rank", 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 2, context.getRank());
-
-        // Position trace at event rank 1000
-        TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 1000, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        // Position trace at event rank [cacheSize]
+        context = fExperiment.seekEvent(cacheSize);
+        assertEquals("Context rank", cacheSize, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
-
-        // Position trace at event rank 4000
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 4000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize + 1, context.getRank());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
+        // Position trace at event rank [4 * cacheSize]
+        context = fExperiment.seekEvent(4 * cacheSize);
+        assertEquals("Context rank", 4 * cacheSize, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
-
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4002, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
     }
 
-    public void testSeekLocationNotOnCacheBoundary() throws Exception {
+    public void testSeekRankNotOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 9
-        TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 9, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
+        // Position trace at event rank 9
+        ITmfContext context = fExperiment.seekEvent(9);
+        assertEquals("Context rank", 9, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
-
-        // Position trace at event rank 999
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 999, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
+        assertEquals("Context rank", 10, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        // Position trace at event rank [cacheSize - 1]
+        context = fExperiment.seekEvent(cacheSize - 1);
+        assertEquals("Context rank", cacheSize - 1, context.getRank());
 
-        // Position trace at event rank 1001
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 1001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize, context.getRank());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        // Position trace at event rank [cacheSize + 1]
+        context = fExperiment.seekEvent(cacheSize + 1);
+        assertEquals("Context rank", cacheSize + 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize + 2, context.getRank());
 
         // Position trace at event rank 4500
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 4500, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
+        context = fExperiment.seekEvent(4500);
+        assertEquals("Context rank", 4500, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
+        assertEquals("Context rank", 4501, context.getRank());
     }
 
-    public void testSeekLocationOutOfScope() throws Exception {
+    public void testSeekRankOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext tmpContext = fExperiment.seekEvent(0);
-        final TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", 0, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        ITmfContext context = fExperiment.seekEvent(-1);
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        assertEquals("Context rank", 1, context.getRank());
 
         // Position trace at event passed the end
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event location", null, tmpContext.getLocation());
-        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, tmpContext.getRank());
+        context = fExperiment.seekEvent(NB_EVENTS);
+        assertEquals("Context rank", NB_EVENTS, context.getRank());
+
+        event = fExperiment.getNext(context);
+        assertNull("Event", event);
+        assertEquals("Context rank", NB_EVENTS, context.getRank());
     }
 
     // ------------------------------------------------------------------------
     // seekEvent on timestamp
     // ------------------------------------------------------------------------
 
-    public void testSeekEventOnTimestampOnCacheBoundary() throws Exception {
+    public void testSeekTimestampOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 0
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
-        assertEquals("Event rank", 0, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
+        // Position trace at event rank 0
+        ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
+        assertEquals("Context rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event rank 1000
-        context = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        assertEquals("Event rank", 1000, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        assertEquals("Context rank", 1, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        // Position trace at event rank [cacheSize]
+        context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE, 0));
+        assertEquals("Event rank", cacheSize, context.getRank());
 
-        // Position trace at event rank 4000
-        context = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        assertEquals("Event rank", 4000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", cacheSize + 1, context.getRank());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
+        // Position trace at event rank [4 * cacheSize]
+        context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE, 0));
+        assertEquals("Context rank", 4 * cacheSize, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
+        assertEquals("Context rank", 4 * cacheSize + 1, context.getRank());
     }
 
-    public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception {
+    public void testSeekTimestampNotOnCacheBoundary() throws Exception {
 
-        // Position trace at event rank 1
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
-        assertEquals("Event rank", 1, context.getRank());
+        // Position trace at event rank 1 (TS = 2)
+        ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
+        assertEquals("Context rank", 1, context.getRank());
 
-        ITmfEvent event = fExperiment.parseEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        assertEquals("Context rank", 2, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 2, context.getRank());
-
-        // Position trace at event rank 9
+        // Position trace at event rank 9 (TS = 10)
         context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        assertEquals("Event rank", 9, context.getRank());
+        assertEquals("Context rank", 9, context.getRank());
 
-        event = fExperiment.parseEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
+        assertEquals("Context rank", 10, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
-
-        // Position trace at event rank 999
+        // Position trace at event rank 999 (TS = 1000)
         context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        assertEquals("Event rank", 999, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
+        assertEquals("Context rank", 999, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        assertEquals("Context rank", 1000, context.getRank());
 
-        // Position trace at event rank 1001
+        // Position trace at event rank 1001 (TS = 1002)
         context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        assertEquals("Event rank", 1001, context.getRank());
+        assertEquals("Context rank", 1001, context.getRank());
 
-        event = fExperiment.parseEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        assertEquals("Context rank", 1002, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
-
-        // Position trace at event rank 4500
+        // Position trace at event rank 4500 (TS = 4501)
         context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        assertEquals("Event rank", 4500, context.getRank());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
+        assertEquals("Context rank", 4500, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
+        assertEquals("Context rank", 4501, context.getRank());
     }
 
-    public void testSeekEventOnTimestampOutOfScope() throws Exception {
+    public void testSeekTimestampOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
-        assertEquals("Event rank", 0, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
         // Position trace at event passed the end
         context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event location", null, context.getLocation());
+        event = fExperiment.getNext(context);
+        assertNull("Event location", event);
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
     }
 
     // ------------------------------------------------------------------------
-    // seekEvent on rank
+    // seekEvent by location (context rank is undefined)
     // ------------------------------------------------------------------------
 
-    public void testSeekOnRankOnCacheBoundary() throws Exception {
+    public void testSeekLocationOnCacheBoundary() throws Exception {
+        
+        long cacheSize = fExperiment.getCacheSize();
 
-        // On lower bound, returns the first event (ts = 1)
-        TmfContext context = fExperiment.seekEvent(0);
-        assertEquals("Event rank", 0, context.getRank());
+        // Position trace at event rank 0
+        ITmfContext tmpContext = fExperiment.seekEvent(0);
+        ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        ITmfEvent event = fExperiment.parseEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
 
-        // Position trace at event rank 1000
-        context = fExperiment.seekEvent(1000);
-        assertEquals("Event rank", 1000, context.getRank());
+        // Position trace at event rank 'cacheSize'
+        tmpContext = fExperiment.seekEvent(cacheSize);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 2, event.getTimestamp().getValue());
 
-        // Position trace at event rank 4000
-        context = fExperiment.seekEvent(4000);
-        assertEquals("Event rank", 4000, context.getRank());
+        // Position trace at event rank 4 * 'cacheSize'
+        tmpContext = fExperiment.seekEvent(4 * cacheSize);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 1, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4 * cacheSize + 2, event.getTimestamp().getValue());
     }
 
-    public void testSeekOnRankNotOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 9
-        TmfContext context = fExperiment.seekEvent(9);
-        assertEquals("Event rank", 9, context.getRank());
+    public void testSeekLocationNotOnCacheBoundary() throws Exception {
 
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
+        long cacheSize = fExperiment.getCacheSize();
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
+        // Position trace at event 'cacheSize' - 1
+        ITmfContext tmpContext = fExperiment.seekEvent(cacheSize - 1);
+        ITmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        // Position trace at event rank 999
-        context = fExperiment.seekEvent(999);
-        assertEquals("Event rank", 999, context.getRank());
+        ITmfEvent event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize, event.getTimestamp().getValue());
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", cacheSize + 1, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
-
-        // Position trace at event rank 1001
-        context = fExperiment.seekEvent(1001);
-        assertEquals("Event rank", 1001, context.getRank());
+        // Position trace at event rank 2 * 'cacheSize' - 1
+        tmpContext = fExperiment.seekEvent(2 * cacheSize - 1);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
+        context = fExperiment.seekEvent(2 * cacheSize - 1);
 
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 2 * cacheSize, event.getTimestamp().getValue());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 2 * cacheSize + 1, event.getTimestamp().getValue());
 
         // Position trace at event rank 4500
-        context = fExperiment.seekEvent(4500);
-        assertEquals("Event rank", 4500, context.getRank());
+        tmpContext = fExperiment.seekEvent(4500);
+        context = fExperiment.seekEvent(tmpContext.getLocation());
 
-        event = fExperiment.parseEvent(context);
+        event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
+        event = fExperiment.getNext(context);
+        assertEquals("Event timestamp", 4502, event.getTimestamp().getValue());
     }
 
-    public void testSeekEventOnRankOutOfScope() throws Exception {
+    public void testSeekLocationOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext context = fExperiment.seekEvent(-1);
-        assertEquals("Event rank", 0, context.getRank());
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
+        ITmfContext context = fExperiment.seekEvent((ITmfLocation<?>) null);
 
-        event = fExperiment.readNextEvent(context);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event passed the end
-        context = fExperiment.seekEvent(NB_EVENTS);
-        assertEquals("Event location", null, context.getLocation());
-        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-    }
-
-    // ------------------------------------------------------------------------
-    // parseEvent - make sure parseEvent doesn't update the context
-    // Note: This test is essentially the same as the one from TmfTraceTest
-    // ------------------------------------------------------------------------
-
-    public void testParseEvent() throws Exception {
-
-        final int NB_READS = 20;
-
-        // On lower bound, returns the first event (ts = 1)
-        final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-
-        // Read NB_EVENTS
-        ITmfEvent event = null;;
-        for (int i = 0; i < NB_READS; i++) {
-            event = fExperiment.readNextEvent(context);
-            assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
-            assertEquals("Event rank", i + 1, context.getRank());
-        }
-
-        // Make sure we stay positioned
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", NB_READS, context.getRank());
     }
 
     // ------------------------------------------------------------------------
-    // getNextEvent - updates the context
+    // readtNextEvent - updates the context
     // ------------------------------------------------------------------------
 
-    public void testGetNextEvent() throws Exception {
+    public void testReadNextEvent() throws Exception {
 
         // On lower bound, returns the first event (ts = 0)
-        final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-        ITmfEvent event = fExperiment.readNextEvent(context);
+        final ITmfContext context = fExperiment.seekEvent(0);
+        ITmfEvent event = fExperiment.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
 
         for (int i = 2; i < 20; i++) {
-            event = fExperiment.readNextEvent(context);
+            event = fExperiment.getNext(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
     }
@@ -685,21 +526,6 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertTrue("isCancelled", request.isCancelled());
     }
 
-    // ------------------------------------------------------------------------
-    // getRank
-    // ------------------------------------------------------------------------
-
-    //    public void testGetRank() throws Exception {
-    //
-    //         assertEquals("getRank",    0, fExperiment.getRank(new TmfTimestamp()));
-    //        assertEquals("getRank",    0, fExperiment.getRank(new TmfTimestamp(   1, (byte) -3)));
-    //        assertEquals("getRank",   10, fExperiment.getRank(new TmfTimestamp(  11, (byte) -3)));
-    //        assertEquals("getRank",  100, fExperiment.getRank(new TmfTimestamp( 101, (byte) -3)));
-    //        assertEquals("getRank", 1000, fExperiment.getRank(new TmfTimestamp(1001, (byte) -3)));
-    //        assertEquals("getRank", 2000, fExperiment.getRank(new TmfTimestamp(2001, (byte) -3)));
-    //        assertEquals("getRank", 2500, fExperiment.getRank(new TmfTimestamp(2501, (byte) -3)));
-    //    }
-
     // ------------------------------------------------------------------------
     // getTimestamp
     // ------------------------------------------------------------------------
index e5d304222d82db2e34be50e08f03d816e9f844d6..167d55a405db4d209413430f1cd849e549d09c91 100644 (file)
@@ -19,8 +19,7 @@ import junit.framework.TestSuite;
 import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin;
 
 /**
- * <b><u>AllTests</u></b>
- * <p>
+ * Test suite for org.eclipse.linuxtools.tmf.core.trace
  */
 @SuppressWarnings("nls")
 public class AllTests {
index f61a8a9590a151ebcc21c0a78e551b4ddd5746b7..3255dc29df6f0c60446b0d89cfb3f567c896ae38 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 20112 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -17,7 +17,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.Vector;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -33,9 +33,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 /**
- * <b><u>TmfTraceTest</u></b>
- * <p>
- * Test suite for the TmfTrace class.
+ * Test suite for the TmfCheckpointIndexTest class.
  */
 @SuppressWarnings("nls")
 public class TmfCheckpointIndexTest extends TestCase {
@@ -46,7 +44,7 @@ public class TmfCheckpointIndexTest extends TestCase {
 
     private static final String DIRECTORY   = "testfiles";
     private static final String TEST_STREAM = "A-Test-10K";
-    private static final int    BLOCK_SIZE  = 500;
+    private static final int    BLOCK_SIZE  = 100;
     private static final int    NB_EVENTS   = 10000;
     private static TestTrace    fTrace      = null;
 
@@ -78,20 +76,21 @@ public class TmfCheckpointIndexTest extends TestCase {
     private class TestIndexer extends TmfCheckpointIndexer<ITmfTrace<ITmfEvent>> {
         @SuppressWarnings({ "unchecked", "rawtypes" })
         public TestIndexer(TestTrace testTrace) {
-            super((ITmfTrace) testTrace);
+            super((ITmfTrace) testTrace, BLOCK_SIZE);
         }
-        public Vector<TmfCheckpoint> getCheckpoints() {
-            return fTraceIndex;
+        public List<TmfCheckpoint> getCheckpoints() {
+            return getTraceIndex();
         }
     }
 
     private class TestTrace extends TmfTraceStub {
         public TestTrace(String path, int blockSize) throws TmfTraceException {
             super(path, blockSize);
-            fIndexer = new TestIndexer(this);
+            setIndexer(new TestIndexer(this));
         }
+        @Override
         public TestIndexer getIndexer() {
-            return (TestIndexer) fIndexer;
+            return (TestIndexer) super.getIndexer();
         }
     }
 
@@ -129,9 +128,10 @@ public class TmfCheckpointIndexTest extends TestCase {
         assertEquals("getStartTime",   1,          fTrace.getStartTime().getValue());
         assertEquals("getEndTime",     NB_EVENTS,  fTrace.getEndTime().getValue());
 
-        Vector<TmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
+        List<TmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
         int pageSize = fTrace.getCacheSize();
         assertTrue("Checkpoints exist",  checkpoints != null);
+        assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
 
         // Validate that each checkpoint points to the right event
         for (int i = 0; i < checkpoints.size(); i++) {
index d9d32d3f10377c66c026423eb1ede20595f948eb..55e373b86f3e683a3b43ecb0757997b618eb02ae 100644 (file)
@@ -8,6 +8,7 @@
  * 
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Adapted for TMF Trace Model 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.trace;
@@ -20,8 +21,6 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 
 /**
- * <b><u>TmfCheckpointTest</u></b>
- * <p>
  * Test suite for the TmfCheckpoint class.
  */
 @SuppressWarnings("nls")
index 9eb3db9115c96930128d2e0509ab38eeedeb9ec6..6dd13f119276386cea57a92a703fff99b85e559d 100644 (file)
@@ -8,6 +8,7 @@
  * 
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Adapted for TMF Trace Model 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.trace;
@@ -21,8 +22,6 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 
 /**
- * <b><u>TmfContextTest</u></b>
- * <p>
  * Test suite for the TmfContext class.
  */
 @SuppressWarnings("nls")
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java
deleted file mode 100644 (file)
index 2deb9e5..0000000
+++ /dev/null
@@ -1,652 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
- * 
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.experiment.TmfExperimentContext;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-
-/**
- * <b><u>TmfExperimentTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@SuppressWarnings("nls")
-public class TmfExperimentTest extends TestCase {
-
-    private static final String DIRECTORY   = "testfiles";
-    private static final String TEST_STREAM = "A-Test-10K";
-    private static final String EXPERIMENT  = "MyExperiment";
-    private static int          NB_EVENTS   = 10000;
-    private static int    fDefaultBlockSize = 1000;
-
-    private static ITmfTrace<?>[] fTraces;
-    private static TmfExperiment<TmfEvent> fExperiment;
-
-    private static byte SCALE = (byte) -3;
-
-    // ------------------------------------------------------------------------
-    // Housekeeping
-    // ------------------------------------------------------------------------
-
-    private synchronized ITmfTrace<?>[] setupTrace(final String path) {
-        if (fTraces == null) {
-            fTraces = new ITmfTrace[1];
-            try {
-                final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
-                final File test = new File(FileLocator.toFileURL(location).toURI());
-                final TmfTraceStub trace = new TmfTraceStub(test.getPath(), true);
-                fTraces[0] = trace;
-            } catch (final TmfTraceException e) {
-                e.printStackTrace();
-            } catch (final URISyntaxException e) {
-                e.printStackTrace();
-            } catch (final IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return fTraces;
-    }
-
-    @SuppressWarnings("unchecked")
-    private synchronized void setupExperiment() {
-        if (fExperiment == null)
-            fExperiment = new TmfExperiment<TmfEvent>(TmfEvent.class, EXPERIMENT, (ITmfTrace<TmfEvent>[]) fTraces);
-        //            fExperiment.indexExperiment();
-    }
-
-    public TmfExperimentTest(final String name) throws Exception {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        setupTrace(DIRECTORY + File.separator + TEST_STREAM);
-        setupExperiment();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructor
-    // ------------------------------------------------------------------------
-
-    public void testBasicTmfExperimentConstructor() {
-        assertEquals("GetId", EXPERIMENT, fExperiment.getName());
-        assertEquals("GetEpoch", TmfTimestamp.ZERO, fExperiment.getEpoch());
-        assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
-
-        final TmfTimeRange timeRange = fExperiment.getTimeRange();
-        assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
-        assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
-    }
-
-    // ------------------------------------------------------------------------
-    // Verify checkpoints
-    // Note: seekLocation() does not reliably set the rank
-    // ------------------------------------------------------------------------
-
-    public void testValidateCheckpoints() throws Exception {
-
-        final Vector<TmfCheckpoint> checkpoints = fExperiment.getCheckpoints();
-        //     int pageSize = fExperiment.getCacheSize();
-        assertTrue("Checkpoints exist",  checkpoints != null);
-
-        // Validate that each checkpoint points to the right event
-        for (int i = 0; i < checkpoints.size(); i++) {
-            final TmfCheckpoint checkpoint = checkpoints.get(i);
-            final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
-            final ITmfEvent event = fExperiment.parseEvent(context);
-            //                 assertEquals("Event rank", context.getRank(), i * pageSize);
-            assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // parseEvent - make sure parseEvent doesn't update the context
-    // ------------------------------------------------------------------------
-
-    public void testParseEvent() throws Exception {
-
-        // On lower bound, returns the first event (ts = 0)
-        final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        for (int i = 1; i < 20; i++) {
-            event = fExperiment.readNextEvent(context);
-            assertEquals("Event timestamp", i, event.getTimestamp().getValue());
-        }
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
-
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
-    }
-
-    // ------------------------------------------------------------------------
-    // getNextEvent - updates the context
-    // ------------------------------------------------------------------------
-
-    public void testGetNextEvent() throws Exception {
-
-        // On lower bound, returns the first event (ts = 0)
-        final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-        ITmfEvent event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        for (int i = 2; i < 20; i++) {
-            event = fExperiment.readNextEvent(context);
-            assertEquals("Event timestamp", i, event.getTimestamp().getValue());
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // seekLocation
-    // Note: seekLocation() does not reliably set the rank
-    // ------------------------------------------------------------------------
-
-    public void testSeekLocationOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 0
-        TmfContext context = fExperiment.seekEvent(0);
-        //        assertEquals("Event rank", 0, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event rank 1000
-        TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1001, context.getRank());
-
-        // Position trace at event rank 4000
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 4001, context.getRank());
-    }
-
-    public void testSeekLocationNotOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 9
-        TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 9, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 10, context.getRank());
-
-        // Position trace at event rank 999
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1000, context.getRank());
-
-        // Position trace at event rank 1001
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1002, context.getRank());
-
-        // Position trace at event rank 4500
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 4501, context.getRank());
-    }
-
-    public void testSeekLocationOutOfScope() throws Exception {
-
-        // Position trace at beginning
-        TmfContext tmpContext = fExperiment.seekEvent(0);
-        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", 0, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        //        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event passed the end
-        tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
-        //        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", null, event);
-        //        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", null, event);
-        //        assertEquals("Event rank", NB_EVENTS, context.getRank());
-    }
-
-    // ------------------------------------------------------------------------
-    // seekEvent on timestamp
-    // ------------------------------------------------------------------------
-
-    public void testSeekEventOnTimestampOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 0
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
-        assertEquals("Event rank", 0, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event rank 1000
-        context = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
-
-        // Position trace at event rank 4000
-        context = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
-    }
-
-    public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 1
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
-        assertEquals("Event rank", 1, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
-        assertEquals("Event rank", 2, context.getRank());
-
-        // Position trace at event rank 9
-        context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
-
-        // Position trace at event rank 999
-        context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
-
-        // Position trace at event rank 1001
-        context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
-
-        // Position trace at event rank 4500
-        context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
-    }
-
-    public void testSeekEventOnTimestampoutOfScope() throws Exception {
-
-        // Position trace at beginning
-        TmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
-        assertEquals("Event rank", 0, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event passed the end
-        context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
-    }
-
-    // ------------------------------------------------------------------------
-    // seekEvent on rank
-    // ------------------------------------------------------------------------
-
-    public void testSeekOnRankOnCacheBoundary() throws Exception {
-
-        // On lower bound, returns the first event (ts = 1)
-        TmfContext context = fExperiment.seekEvent(0);
-        assertEquals("Event rank", 0, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event rank 1000
-        context = fExperiment.seekEvent(1000);
-        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
-
-        // Position trace at event rank 4000
-        context = fExperiment.seekEvent(4000);
-        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4001, context.getRank());
-    }
-
-    public void testSeekOnRankNotOnCacheBoundary() throws Exception {
-
-        // Position trace at event rank 9
-        TmfContext context = fExperiment.seekEvent(9);
-        assertEquals("Event rank", 9, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-        assertEquals("Event rank", 10, context.getRank());
-
-        // Position trace at event rank 999
-        context = fExperiment.seekEvent(999);
-        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1000, context.getRank());
-
-        // Position trace at event rank 1001
-        context = fExperiment.seekEvent(1001);
-        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1002, context.getRank());
-
-        // Position trace at event rank 4500
-        context = fExperiment.seekEvent(4500);
-        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-        assertEquals("Event rank", 4501, context.getRank());
-    }
-
-    public void testSeekEventOnRankOfScope() throws Exception {
-
-        // Position trace at beginning
-        TmfContext context = fExperiment.seekEvent(-1);
-        assertEquals("Event rank", 0, context.getRank());
-        ITmfEvent event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-        assertEquals("Event rank", 1, context.getRank());
-
-        // Position trace at event passed the end
-        context = fExperiment.seekEvent(NB_EVENTS);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.parseEvent(context);
-        assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.readNextEvent(context);
-        assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
-    }
-
-    // ------------------------------------------------------------------------
-    // processRequest
-    // ------------------------------------------------------------------------
-
-    public void testProcessRequestForNbEvents() throws Exception {
-        final int blockSize = 100;
-        final int nbEvents  = 1000;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-        final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
-            @Override
-            public void handleData(final TmfEvent event) {
-                super.handleData(event);
-                requestedEvents.add(event);
-            }
-        };
-        fExperiment.sendRequest(request);
-        request.waitForCompletion();
-
-        assertEquals("nbEvents", nbEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub!
-        for (int i = 0; i < nbEvents; i++)
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-    }
-
-    public void testProcessRequestForNbEvents2() throws Exception {
-        final int blockSize = 2 * NB_EVENTS;
-        final int nbEvents = 1000;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-        final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
-            @Override
-            public void handleData(final TmfEvent event) {
-                super.handleData(event);
-                requestedEvents.add(event);
-            }
-        };
-        fExperiment.sendRequest(request);
-        request.waitForCompletion();
-
-        assertEquals("nbEvents", nbEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub!
-        for (int i = 0; i < nbEvents; i++)
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-    }
-
-    public void testProcessRequestForAllEvents() throws Exception {
-        final int nbEvents  = TmfEventRequest.ALL_DATA;
-        final int blockSize =  1;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        final long nbExpectedEvents = fExperiment.getNbEvents();
-
-        final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-        final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
-            @Override
-            public void handleData(final TmfEvent event) {
-                super.handleData(event);
-                requestedEvents.add(event);
-            }
-        };
-        fExperiment.sendRequest(request);
-        request.waitForCompletion();
-
-        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub!
-        for (int i = 0; i < nbExpectedEvents; i++)
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-    }
-
-    // ------------------------------------------------------------------------
-    // cancel
-    // ------------------------------------------------------------------------
-
-    public void testCancel() throws Exception {
-        final int nbEvents  = NB_EVENTS;
-        final int blockSize =  fDefaultBlockSize;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
-        final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
-            int nbRead = 0;
-            @Override
-            public void handleData(final TmfEvent event) {
-                super.handleData(event);
-                requestedEvents.add(event);
-                if (++nbRead == blockSize)
-                    cancel();
-            }
-        };
-        fExperiment.sendRequest(request);
-        request.waitForCompletion();
-
-        assertEquals("nbEvents",  blockSize, requestedEvents.size());
-        assertTrue("isCompleted", request.isCompleted());
-        assertTrue("isCancelled", request.isCancelled());
-    }
-
-    // ------------------------------------------------------------------------
-    // getRank
-    // ------------------------------------------------------------------------
-
-    //    public void testGetRank() throws Exception {
-    //        assertEquals("getRank",    0, fExperiment.getRank(new TmfTimestamp()));
-    //        assertEquals("getRank",    0, fExperiment.getRank(new TmfTimestamp(   1, (byte) -3)));
-    //        assertEquals("getRank",   10, fExperiment.getRank(new TmfTimestamp(  11, (byte) -3)));
-    //        assertEquals("getRank",  100, fExperiment.getRank(new TmfTimestamp( 101, (byte) -3)));
-    //        assertEquals("getRank", 1000, fExperiment.getRank(new TmfTimestamp(1001, (byte) -3)));
-    //        assertEquals("getRank", 2000, fExperiment.getRank(new TmfTimestamp(2001, (byte) -3)));
-    //        assertEquals("getRank", 2500, fExperiment.getRank(new TmfTimestamp(2501, (byte) -3)));
-    //    }
-
-    // ------------------------------------------------------------------------
-    // getTimestamp
-    // ------------------------------------------------------------------------
-
-    public void testGetTimestamp() throws Exception {
-        assertTrue("getTimestamp", fExperiment.getTimestamp(   0).equals(new TmfTimestamp(   1, (byte) -3)));
-        assertTrue("getTimestamp", fExperiment.getTimestamp(  10).equals(new TmfTimestamp(  11, (byte) -3)));
-        assertTrue("getTimestamp", fExperiment.getTimestamp( 100).equals(new TmfTimestamp( 101, (byte) -3)));
-        assertTrue("getTimestamp", fExperiment.getTimestamp(1000).equals(new TmfTimestamp(1001, (byte) -3)));
-        assertTrue("getTimestamp", fExperiment.getTimestamp(2000).equals(new TmfTimestamp(2001, (byte) -3)));
-        assertTrue("getTimestamp", fExperiment.getTimestamp(2500).equals(new TmfTimestamp(2501, (byte) -3)));
-    }
-
-}
\ No newline at end of file
index af7c07797e1326b39693d84345433a3e8c9dafd0..a0cf96e77763bca77974e6f97d7c100240850ae4 100644 (file)
@@ -19,8 +19,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 
 /**
- * <b><u>TmfLocationTest</u></b>
- * <p>
  * Test suite for the TmfLocation class.
  */
 @SuppressWarnings("nls")
index a6d63b90b49ecadbdfb4fed1c1c2f63ddee173de..40986df9b3fad126042a388c7efc5c0044db9cb0 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 20112 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -35,14 +35,12 @@ import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 /**
- * <b><u>TmfTraceTest</u></b>
- * <p>
  * Test suite for the TmfTrace class.
  */
 @SuppressWarnings("nls")
@@ -125,7 +123,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("getType",  TmfEvent.class, trace.getType());
         assertNull  ("getResource", trace.getResource());
         assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
-        assertEquals("getCacheSize", TmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
+        assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
         assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
         assertEquals("getName", TEST_STREAM, trace.getName());
 
@@ -154,7 +152,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("getType",  TmfEvent.class, trace.getType());
         assertNull  ("getResource", trace.getResource());
         assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
-        assertEquals("getCacheSize", TmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
+        assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
         assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
         assertEquals("getName", TEST_STREAM, trace.getName());
 
@@ -327,7 +325,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("getType", TmfEvent.class, trace.getType());
         assertNull  ("getResource", trace.getResource());
         assertEquals("getPath", path, trace.getPath());
-        assertEquals("getCacheSize", TmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
+        assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
         assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
         assertEquals("getName", path, trace.getName());
 
@@ -356,7 +354,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("getType", TmfEvent.class, trace.getType());
         assertNull  ("getResource", trace.getResource());
         assertEquals("getPath", path, trace.getPath());
-        assertEquals("getCacheSize", TmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
+        assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
         assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
         assertEquals("getName", name, trace.getName());
 
@@ -375,7 +373,7 @@ public class TmfTraceTest extends TestCase {
         assertFalse ("Open trace", trace == null);
         assertNull  ("getType",  trace.getType());
         assertNull  ("getResource", trace.getResource());
-        assertEquals("getCacheSize", TmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
+        assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
         assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
         assertEquals("getName", "", trace.getName());
 
@@ -392,6 +390,7 @@ public class TmfTraceTest extends TestCase {
 
         // InitTrace and wait for indexing completion...
         trace.initTrace(null, testfile.getPath(), TmfEvent.class);
+        trace.indexTrace();
         int nbSecs = 0;
         while (trace.getNbEvents() < NB_EVENTS && nbSecs < 10) {
             Thread.sleep(1000);
@@ -404,7 +403,7 @@ public class TmfTraceTest extends TestCase {
         assertFalse ("Open trace", trace == null);
         assertEquals("getType",  TmfEvent.class, trace.getType());
         assertNull  ("getResource", trace.getResource());
-        assertEquals("getCacheSize", TmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
+        assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
         assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
         assertEquals("getName", TEST_STREAM, trace.getName());
 
@@ -517,7 +516,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
@@ -530,7 +529,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
@@ -543,7 +542,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
     }
@@ -559,7 +558,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
@@ -572,7 +571,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
@@ -585,7 +584,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
@@ -598,7 +597,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
     }
@@ -614,22 +613,17 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
         // Position trace at event passed the end
-        tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        context = fTrace.seekEvent(tmpContext.getLocation());
-        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-
-        event = fTrace.parseEvent(context);
-        assertEquals("Event timestamp", null, event);
+        context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
+        assertNull("Event timestamp", context.getLocation());
         assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
-        assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+        event = fTrace.getNext(context);
+        assertNull("Event", event);
     }
 
     // ------------------------------------------------------------------------
@@ -657,7 +651,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -669,7 +663,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -681,7 +675,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -696,7 +690,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
@@ -708,7 +702,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -720,7 +714,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -732,7 +726,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -744,7 +738,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -759,21 +753,21 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
         // Position trace at event passed the end
         context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
         event = fTrace.parseEvent(context);
         assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", null, event);
-        assertEquals("Event rank", NB_EVENTS, context.getRank());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
     }
 
     // ------------------------------------------------------------------------
@@ -801,7 +795,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -813,7 +807,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -825,7 +819,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -840,7 +834,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -852,7 +846,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -864,7 +858,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -876,12 +870,12 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
 
-    public void testSeekEventOnRankOfScope() throws Exception {
+    public void testSeekEventOnRankOutOfScope() throws Exception {
 
         // Position trace at beginning
         ITmfContext context = fTrace.seekEvent(-1);
@@ -891,7 +885,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.readNextEvent(context);
+        event = fTrace.getNext(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -900,11 +894,11 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event rank", NB_EVENTS, context.getRank());
 
         event = fTrace.parseEvent(context);
-        assertEquals("Event timestamp", null, event);
+        assertNull("Event", event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
 
-        event = fTrace.readNextEvent(context);
-        assertEquals("Event timestamp", null, event);
+        event = fTrace.getNext(context);
+        assertNull("Event", event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
     }
 
@@ -937,7 +931,7 @@ public class TmfTraceTest extends TestCase {
 
         // Position the trace at event NB_READS
         for (int i = 1; i < NB_READS; i++) {
-            event = fTrace.readNextEvent(context);
+            event = fTrace.getNext(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
 
@@ -967,7 +961,7 @@ public class TmfTraceTest extends TestCase {
         // Read NB_EVENTS
         ITmfEvent event;
         for (int i = 0; i < NB_READS; i++) {
-            event = fTrace.readNextEvent(context);
+            event = fTrace.getNext(context);
             assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
             assertEquals("Event rank", i + 1, context.getRank());
         }
index 47f64a6f8e1ff8b5517c3775f1a1d1a6a1a0fa2c..44b51f891373e817d78501654bc8c6d1bacaf1db 100644 (file)
@@ -82,35 +82,35 @@ public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
         // no need to use synchronized since it's already cover by the calling method
 
         long location = 0;
-        if (context != null)
+        if (context != null && context.getLocation() != null) {
             location = ((TmfLocation<Long>) (context.getLocation())).getLocation();
-
-        try {
-            stream.seek(location);
-
-            final long ts        = stream.readLong();
-            final String source  = stream.readUTF();
-            final String type    = stream.readUTF();
-            final Integer reference  = stream.readInt();
-            final int typeIndex  = Integer.parseInt(type.substring(typePrefix.length()));
-            final String[] fields = new String[typeIndex];
-            for (int i = 0; i < typeIndex; i++)
-                fields[i] = stream.readUTF();
-
-            final StringBuffer content = new StringBuffer("[");
-            if (typeIndex > 0)
-                content.append(fields[0]);
-            for (int i = 1; i < typeIndex; i++)
-                content.append(", ").append(fields[i]);
-            content.append("]");
-
-            final TmfEventField root = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString());
-            final TmfEvent event = new TmfEvent(fEventStream,
-                    new TmfTimestamp(ts, -3, 0),     // millisecs
-                    source, fTypes[typeIndex], root, reference.toString());
-            return event;
-        } catch (final EOFException e) {
-        } catch (final IOException e) {
+            try {
+                stream.seek(location);
+
+                final long ts        = stream.readLong();
+                final String source  = stream.readUTF();
+                final String type    = stream.readUTF();
+                final Integer reference  = stream.readInt();
+                final int typeIndex  = Integer.parseInt(type.substring(typePrefix.length()));
+                final String[] fields = new String[typeIndex];
+                for (int i = 0; i < typeIndex; i++)
+                    fields[i] = stream.readUTF();
+
+                final StringBuffer content = new StringBuffer("[");
+                if (typeIndex > 0)
+                    content.append(fields[0]);
+                for (int i = 1; i < typeIndex; i++)
+                    content.append(", ").append(fields[i]);
+                content.append("]");
+
+                final TmfEventField root = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString());
+                final TmfEvent event = new TmfEvent(fEventStream,
+                        new TmfTimestamp(ts, -3, 0),     // millisecs
+                        source, fTypes[typeIndex], root, reference.toString());
+                return event;
+            } catch (final EOFException e) {
+            } catch (final IOException e) {
+            }
         }
         return null;
     }
index b12336831060337bca8bb5d7c42be01705cc450b..e005b39855bc3146aad96cd008241b4282128532 100644 (file)
@@ -26,6 +26,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
@@ -62,7 +63,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
      */
     public TmfTraceStub() {
         super();
-        fParser = new TmfEventParserStub(this);
+        setParser(new TmfEventParserStub(this));
     }
 
     /**
@@ -70,7 +71,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
      * @throws FileNotFoundException
      */
     public TmfTraceStub(final String path) throws TmfTraceException {
-        this(path, DEFAULT_TRACE_CACHE_SIZE, false);
+        this(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false);
     }
 
     /**
@@ -94,7 +95,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         } catch (FileNotFoundException e) {
             throw new TmfTraceException(e.getMessage());
         }
-        fParser = new TmfEventParserStub(this);
+        setParser(new TmfEventParserStub(this));
     }
 
     /**
@@ -112,7 +113,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
      * @throws FileNotFoundException
      */
     public TmfTraceStub(final String path, final boolean waitForCompletion) throws TmfTraceException {
-        this(path, DEFAULT_TRACE_CACHE_SIZE, waitForCompletion);
+        this(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, waitForCompletion);
     }
 
     /**
@@ -128,7 +129,10 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         } catch (FileNotFoundException e) {
             throw new TmfTraceException(e.getMessage());
         }
-        fParser = new TmfEventParserStub(this);
+        setParser(new TmfEventParserStub(this));
+        if (waitForCompletion) {
+            indexTrace();
+        }
     }
 
     /**
@@ -144,7 +148,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         } catch (FileNotFoundException e) {
             throw new TmfTraceException(e.getMessage());
         }
-        fParser = new TmfEventParserStub(this);
+        setParser(new TmfEventParserStub(this));
     }
 
     /**
@@ -162,7 +166,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         } catch (FileNotFoundException e) {
             throw new TmfTraceException(e.getMessage());
         }
-        fParser = (parser != null) ? parser : new TmfEventParserStub(this);
+        setParser((parser != null) ? parser : new TmfEventParserStub(this));
     }
 
     /**
@@ -175,11 +179,11 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         } catch (FileNotFoundException e) {
             throw new TmfTraceException(e.getMessage());
         }
-        fParser = new TmfEventParserStub(this);
+        setParser(new TmfEventParserStub(this));
     }
 
     public void indexTrace() {
-        fIndexer.buildIndex(true);
+        indexTrace(true);
     }
 
     @Override
@@ -189,7 +193,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         } catch (FileNotFoundException e) {
             throw new TmfTraceException(e.getMessage());
         }
-        fParser = new TmfEventParserStub(this);
+        setParser(new TmfEventParserStub(this));
         super.initTrace(resource, path, type);
     }
 
@@ -299,13 +303,10 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<
         fLock.lock();
         try {
             // parseNextEvent will update the context
-            if (fTrace != null) {
-                final TmfEvent event = fParser.parseEvent(context.clone());
+            if (fTrace != null && getParser() != null && context != null) {
+                final TmfEvent event = getParser().parseEvent(context.clone());
                 return event;
             }
-//        }
-//        catch (final IOException e) {
-//            e.printStackTrace();
         } finally {
             fLock.unlock();
         }
index f8c49ae1dc874136b1ddd38801f03ac3a758206f..5f387127f8c7042a10627f11fc5f3b48ed5de4b0 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.tmf.core.component;
 
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 
 /**
  * <b><u>ITmfDataRequest</u></b>
@@ -32,4 +33,13 @@ public interface ITmfDataProvider<T extends ITmfEvent> extends ITmfComponent {
     public void sendRequest(ITmfDataRequest<T> request);
     public void fireRequest();
     public void notifyPendingRequest(boolean isIncrement);
+
+    /**
+     * Return the next event based on the context supplied. The context
+     * will be updated for the subsequent read.
+     * 
+     * @param context the trace read context (updated)
+     * @return the event referred to by context
+     */
+    public T getNext(ITmfContext context);
 }
index de628fdd5a003ac37475957b2267ebbd89f8732a..a4ed0bde1941fdabaadd9de1477dd4fba33848c2 100644 (file)
@@ -384,14 +384,14 @@ public abstract class TmfDataProvider<T extends ITmfEvent> extends TmfComponent
      */
     public abstract ITmfContext armRequest(ITmfDataRequest<T> request);
 
-    /**
-     * Return the next event based on the context supplied. The context
-     * will be updated for the subsequent read.
-     * 
-     * @param context the trace read context (updated)
-     * @return the event referred to by context
-     */
-    public abstract T getNext(ITmfContext context);
+//    /**
+//     * Return the next event based on the context supplied. The context
+//     * will be updated for the subsequent read.
+//     * 
+//     * @param context the trace read context (updated)
+//     * @return the event referred to by context
+//     */
+//    public abstract T getNext(ITmfContext context);
 
     /**
      * Checks if the data meets the request completion criteria.
index 389170423e4a2d191d6abce96d6b535d3ad1da95..27acd6ae7768fc3f9a37c0d3e7d6068af79ef5f3 100644 (file)
@@ -341,22 +341,22 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements ITmfTr
         return seekEvent(request.getIndex());
     }
 
-    /**
-     * The trace reader keeps its own iterator: the "context" parameter here
-     * will be ignored.
-     *
-     * If you wish to specify a new context, instantiate a new CtfIterator and
-     * seek() it to where you want, and use that to read events.
-     *
-     * FIXME merge with getNextEvent below once they both use the same parameter
-     * type.
-     * @param context ITmfContext
-     * @return CtfTmfEvent
-     */
-    @Override
-    public CtfTmfEvent getNext(final ITmfContext context) {
-        return readNextEvent(context);
-    }
+//    /**
+//     * The trace reader keeps its own iterator: the "context" parameter here
+//     * will be ignored.
+//     *
+//     * If you wish to specify a new context, instantiate a new CtfIterator and
+//     * seek() it to where you want, and use that to read events.
+//     *
+//     * FIXME merge with getNextEvent below once they both use the same parameter
+//     * type.
+//     * @param context ITmfContext
+//     * @return CtfTmfEvent
+//     */
+//    @Override
+//    public CtfTmfEvent getNext(final ITmfContext context) {
+//        return readNextEvent(context);
+//    }
 
     // ------------------------------------------------------------------------
     // ITmfTrace
@@ -452,10 +452,10 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements ITmfTr
      * Method readNextEvent.
      * @param context ITmfContext
      * @return CtfTmfEvent
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(ITmfContext)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNext(ITmfContext)
      */
     @Override
-    public CtfTmfEvent readNextEvent(final ITmfContext context) {
+    public CtfTmfEvent getNext(final ITmfContext context) {
         CtfTmfEvent event = null;
         if (context instanceof CtfIterator) {
             CtfIterator ctfIterator = (CtfIterator) context;
index a3ffdcacff13da529c5e06703d838056144abd16..eac36207e4f37c49033b410f7bfcedfc977476d1 100644 (file)
@@ -28,7 +28,6 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
  * used as e.g. a location marker (filename:lineno) to indicate where the event
  * was generated.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
@@ -37,7 +36,7 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
  * @see ITmfEventField
  * @see TmfEvent
  */
-public interface ITmfEvent extends Cloneable {
+public interface ITmfEvent {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -107,10 +106,6 @@ public interface ITmfEvent extends Cloneable {
      */
     public String getReference();
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
     /**
      * @return a clone of the event
      */
index 0168e5fd76b7284ea917d2ceb20a64756551500e..7efb44dfaf485a69b4f57cbe1a1b896a42251c27 100644 (file)
@@ -16,14 +16,13 @@ package org.eclipse.linuxtools.tmf.core.event;
  * The generic event payload in TMF. Each field can be either a terminal or
  * further decomposed into subfields.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
  * @see ITmfEvent
  * @see ITmfEventType
  */
-public interface ITmfEventField extends Cloneable {
+public interface ITmfEventField {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -73,10 +72,6 @@ public interface ITmfEventField extends Cloneable {
      */
     public ITmfEventField getField(int index);
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
     /**
      * @return a clone of the event field
      */
index e653471e3c1716f5bd2b693b18bcee6de4786937..d3e8e690a99a0bd4d763e34bbfa9ae9603c69e7f 100644 (file)
@@ -18,14 +18,13 @@ package org.eclipse.linuxtools.tmf.core.event;
  * <p>
  * Types are unique within their context space.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
  * @see ITmfEvent
  * @see ITmfEventField
  */
-public interface ITmfEventType extends Cloneable {
+public interface ITmfEventType {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -71,10 +70,6 @@ public interface ITmfEventType extends Cloneable {
      */
     public String getFieldName(int index);
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
     /**
      * @return a clone of the event type
      */
index a5804edfd1c6f6f01e407df145073bdce91b09b4..d51fd590302e84d80fcf6f0a95f617324e673d34 100644 (file)
@@ -28,14 +28,13 @@ package org.eclipse.linuxtools.tmf.core.event;
  * timestamps in different scales). Default: 0.
  * </ul>
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
  * @see ITmfEvent
  * @see TmfTimeRange
  */
-public interface ITmfTimestamp extends Cloneable, Comparable<ITmfTimestamp> {
+public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
 
     // ------------------------------------------------------------------------
     // Getters
@@ -86,10 +85,6 @@ public interface ITmfTimestamp extends Cloneable, Comparable<ITmfTimestamp> {
      */
     public ITmfTimestamp getDelta(ITmfTimestamp ts);
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
     /**
      * @return a clone of the timestamp
      */
index 6e6ac3bb2b43fa14ffedb6d7261076de679efbef..c5d8299fd2be90a7ec5808f37ac2b489b22aafb7 100644 (file)
@@ -23,7 +23,6 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
  * copy of the event is needed, use the copy constructor. Otherwise (deep copy)
  * use clone().
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
@@ -32,7 +31,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
  * @see ITmfEventField
  * @see ITmfTrace
 */
-public class TmfEvent implements ITmfEvent {
+public class TmfEvent implements ITmfEvent, Cloneable {
 
     // ------------------------------------------------------------------------
     // Attributes
index 6d1ed598248271b80bb214d2782cbb258be7f901..100e5ae4782f4d7d0a309fba97be789f1c40a074 100644 (file)
@@ -23,14 +23,13 @@ import java.util.Map;
  * Non-value fields are structural (i.e. used to represent the event structure
  * including optional fields) while the valued fields are actual event fields.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
  * @see ITmfEvent
  * @see ITmfEventType
  */
-public class TmfEventField implements ITmfEventField {
+public class TmfEventField implements ITmfEventField, Cloneable {
 
     // ------------------------------------------------------------------------
     // Attributes
index 48577ab2dd013c7030d9829e599aa9b375873c08..14cff763c60c8b51415f9f3cc47cd9b9fab8964c 100644 (file)
@@ -16,14 +16,13 @@ package org.eclipse.linuxtools.tmf.core.event;
 /**
  * A basic implementation of ITmfEventType.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
  * @see ITmfEvent
  * @see ITmfEventField
  */
-public class TmfEventType implements ITmfEventType {
+public class TmfEventType implements ITmfEventType, Cloneable {
 
     // ------------------------------------------------------------------------
     // Attributes
index 8daf10b1481848ca978cfc3e23304997dbc9cc47..5f170c7f9ae9886886a407f0638e36157910fac5 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Map;
  * A central repository for the available event types. Types are managed by
  * context space.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
index e99b7797587f036fc34a06d55e06d3ef41ffee9d..6ec7f3c428b2a1a04383dc9379e5e38cf6fef04a 100644 (file)
@@ -15,11 +15,10 @@ package org.eclipse.linuxtools.tmf.core.event;
 /**
  * A simplified timestamp where scale and precision are set to 0.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  */
-public class TmfSimpleTimestamp extends TmfTimestamp {
+public class TmfSimpleTimestamp extends TmfTimestamp implements Cloneable {
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -61,7 +60,7 @@ public class TmfSimpleTimestamp extends TmfTimestamp {
      * @see org.eclipse.linuxtools.tmf.core.event.TmfTimestamp#normalize(long, int)
      */
     @Override
-    public ITmfTimestamp normalize(final long offset, final int scale) throws ArithmeticException {
+    public ITmfTimestamp normalize(final long offset, final int scale) {
         if (scale == 0) {
             return new TmfSimpleTimestamp(getValue() + offset);
         }
index 794d3746a1a0615e0b2d8fd67ab256ea4f0688bb..47a5f9dffc705617a37916ad3c21b439b27ba3a4 100644 (file)
@@ -16,7 +16,6 @@ package org.eclipse.linuxtools.tmf.core.event;
 /**
  * A utility class to define and manage time ranges.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  * 
@@ -38,7 +37,7 @@ public final class TmfTimeRange implements Cloneable {
      * The null time range
      */
     public static final TmfTimeRange NULL_RANGE =
-            new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_BANG);
+            new TmfTimeRange(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_BANG);
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -163,7 +162,7 @@ public final class TmfTimeRange implements Cloneable {
      * @see java.lang.Object#clone()
      */
     @Override
-    public TmfTimeRange clone() {
+    public TmfTimeRange clone() throws CloneNotSupportedException {
         TmfTimeRange clone = null;
         try {
             clone = (TmfTimeRange) super.clone();
index 7264468d2a93580dba7f51de04f60e639d008efb..601ac3f82993b5024c11235dd76d90dfd6c7fb83 100644 (file)
 
 package org.eclipse.linuxtools.tmf.core.event;
 
+
 /**
  * A generic timestamp implementation. The timestamp is represented by the
  * tuple { value, scale, precision }.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  */
@@ -186,7 +186,7 @@ public class TmfTimestamp implements ITmfTimestamp, Cloneable {
      * @see org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp#normalize(long, int)
      */
     @Override
-    public ITmfTimestamp normalize(final long offset, final int scale) throws ArithmeticException {
+    public ITmfTimestamp normalize(final long offset, final int scale) {
 
         long value = fValue;
         int precision = fPrecision;
index 7565efb2311f541bd159c126095c6cd248eddddc..f6fa5d8f0cdc9679e010214351a647cedde8535a 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,29 +8,21 @@
  *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Updated as per TMF Trace Model 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.experiment;
 
-import java.util.Collections;
-import java.util.Vector;
-
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
@@ -39,19 +31,24 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
 
 /**
- * <b><u>TmfExperiment</u></b>
- * <p>
  * TmfExperiment presents a time-ordered, unified view of a set of TmfTraces
  * that are part of a tracing experiment.
- * <p>
  */
-public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> implements ITmfTrace<T> {
+public class TmfExperiment<T extends ITmfEvent> extends TmfTrace<T> implements ITmfEventParser<T> {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    // The index page size
+    private static final int DEFAULT_INDEX_PAGE_SIZE = 5000;
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -63,47 +60,33 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
     // The set of traces that constitute the experiment
     protected ITmfTrace<T>[] fTraces;
 
-    // The total number of events
-    protected long fNbEvents;
-
-    // The experiment time range
-    protected TmfTimeRange fTimeRange;
-
-    // The experiment reference timestamp (default: ZERO)
-    protected ITmfTimestamp fEpoch;
-
-    // The experiment index
-    protected Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
-
-    // The current experiment context
-    protected TmfExperimentContext fExperimentContext;
-
     // Flag to initialize only once
-    private boolean fInitialized = false;
+    protected boolean fInitialized = false;
 
     // The experiment bookmarks file
-    private IFile fBookmarksFile;
+    protected IFile fBookmarksFile;
 
-    // The properties resource
-    private IResource fResource;
+//    // The properties resource
+//    private IResource fResource;
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
-    @Override
-    public TmfExperiment<T> clone() throws CloneNotSupportedException {
-        throw new CloneNotSupportedException();
-    }
-
     @Override
     public boolean validate(final IProject project, final String path) {
         return true;
     }
 
     @Override
-    public void initTrace(final IResource resource, final String path, final Class<T> eventType) {
-        fResource = resource;
+    public void initTrace(final IResource resource, final String path, final Class<T> type) {
+//        fResource = resource;
+        try {
+            super.initTrace(resource, path, type);
+        } catch (TmfTraceException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
     }
 
     /**
@@ -112,35 +95,41 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
      * @param traces
      * @param epoch
      * @param indexPageSize
+     * @throws TmfTraceException 
      */
     public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
-            final int indexPageSize) {
+            final int indexPageSize)
+    {
         this(type, id, traces, TmfTimestamp.ZERO, indexPageSize, false);
     }
 
-    public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
-            final int indexPageSize, final boolean preIndexExperiment) {
-        super(id, type);
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public TmfExperiment(final Class<T> type, final String path, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
+            final int indexPageSize, final boolean preIndexExperiment)
+    {
+        setCacheSize(indexPageSize);
+        setStreamingInterval(0);
+        setIndexer(new TmfCheckpointIndexer(this, indexPageSize));
+        setParser(this);
+        try {
+            super.initialize(null, path, type);
+        } catch (TmfTraceException e) {
+            e.printStackTrace();
+        }
 
         fTraces = traces;
-        fEpoch = epoch;
-        fIndexPageSize = indexPageSize;
-        fTimeRange = TmfTimeRange.NULL_RANGE;
+        setTimeRange(TmfTimeRange.NULL_RANGE);
 
         if (preIndexExperiment) {
-            indexExperiment(true, 0, TmfTimeRange.ETERNITY);
-            updateTimeRange();
+            getIndexer().buildIndex(true);
         }
     }
 
-    protected TmfExperiment(final String id, final Class<T> type) {
-        super(id, type);
-    }
-
     /**
      * @param type
      * @param id
      * @param traces
+     * @throws TmfTraceException 
      */
     public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces) {
         this(type, id, traces, TmfTimestamp.ZERO, DEFAULT_INDEX_PAGE_SIZE);
@@ -151,6 +140,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
      * @param id
      * @param traces
      * @param indexPageSize
+     * @throws TmfTraceException 
      */
     public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final int indexPageSize) {
         this(type, id, traces, TmfTimestamp.ZERO, indexPageSize);
@@ -173,49 +163,9 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
                 trace.dispose();
             fTraces = null;
         }
-        if (fCheckpoints != null)
-            fCheckpoints.clear();
         super.dispose();
     }
 
-    // ------------------------------------------------------------------------
-    // ITmfTrace
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Class<T> getEventType() {
-        return fType;
-    }
-
-    @Override
-    public long getNbEvents() {
-        return fNbEvents;
-    }
-
-    @Override
-    public int getCacheSize() {
-        return fIndexPageSize;
-    }
-
-    @Override
-    public TmfTimeRange getTimeRange() {
-        return fTimeRange;
-    }
-
-    @Override
-    public ITmfTimestamp getStartTime() {
-        return fTimeRange.getStartTime();
-    }
-
-    @Override
-    public ITmfTimestamp getEndTime() {
-        return fTimeRange.getEndTime();
-    }
-
-    public Vector<TmfCheckpoint> getCheckpoints() {
-        return fCheckpoints;
-    }
-
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
@@ -230,10 +180,6 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
         return fCurrentExperiment;
     }
 
-    public ITmfTimestamp getEpoch() {
-        return fEpoch;
-    }
-
     public ITmfTrace<T>[] getTraces() {
         return fTraces;
     }
@@ -246,64 +192,31 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
      * @return the corresponding event timestamp
      */
     public ITmfTimestamp getTimestamp(final int index) {
-        final TmfExperimentContext context = seekEvent(index);
-        final ITmfEvent event = readNextEvent(context);
+        final ITmfContext context = seekEvent(index);
+        final ITmfEvent event = getNext(context);
         return (event != null) ? event.getTimestamp() : null;
     }
 
-    // ------------------------------------------------------------------------
-    // Operators
-    // ------------------------------------------------------------------------
-
-    /**
-     * Update the global time range
-     */
-    protected void updateTimeRange() {
-        ITmfTimestamp startTime = fTimeRange != TmfTimeRange.NULL_RANGE ? fTimeRange.getStartTime() : TmfTimestamp.BIG_CRUNCH;
-        ITmfTimestamp endTime = fTimeRange != TmfTimeRange.NULL_RANGE ? fTimeRange.getEndTime() : TmfTimestamp.BIG_BANG;
-
-        for (final ITmfTrace<T> trace : fTraces) {
-            final ITmfTimestamp traceStartTime = trace.getStartTime();
-            if (traceStartTime.compareTo(startTime, true) < 0)
-                startTime = traceStartTime;
-            final ITmfTimestamp traceEndTime = trace.getEndTime();
-            if (traceEndTime.compareTo(endTime, true) > 0)
-                endTime = traceEndTime;
-        }
-        fTimeRange = new TmfTimeRange(startTime, endTime);
-    }
-
     // ------------------------------------------------------------------------
     // TmfProvider
     // ------------------------------------------------------------------------
 
     @Override
     public ITmfContext armRequest(final ITmfDataRequest<T> request) {
-        //             Tracer.trace("Ctx: Arming request - start");
         ITmfTimestamp timestamp = (request instanceof ITmfEventRequest<?>) ? ((ITmfEventRequest<T>) request).getRange().getStartTime() : null;
-        if (TmfTimestamp.BIG_BANG.equals(timestamp) || request.getIndex() > 0)
-            timestamp = null; // use request index
-        TmfExperimentContext context = null;
-        if (timestamp != null) {
-            // seek by timestamp
+        if (TmfTimestamp.BIG_BANG.equals(timestamp) || request.getIndex() > 0) {
+            timestamp = null;
+        }
+
+        ITmfContext context = null;
+        if (timestamp != null) { // Seek by timestamp
             context = seekEvent(timestamp);
             ((ITmfEventRequest<T>) request).setStartIndex((int) context.getRank());
-        } else // Seek by rank
-            if ((fExperimentContext != null) && fExperimentContext.getRank() == request.getIndex())
-                // We are already at the right context -> no need to seek
-                context = fExperimentContext;
-            else
-                context = seekEvent(request.getIndex());
-        // Tracer.trace("Ctx: Arming request - done");
-        return context;
-    }
+        } else { // Seek by rank
+            context = seekEvent(request.getIndex());
+        }
 
-    @Override
-    @SuppressWarnings("unchecked")
-    public T getNext(final ITmfContext context) {
-        if (context instanceof TmfExperimentContext)
-            return (T) readNextEvent(context);
-        return null;
+        return context;
     }
 
     // ------------------------------------------------------------------------
@@ -323,136 +236,29 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
 
         // Instantiate the location
         final TmfExperimentLocation expLocation = (location == null) ? new TmfExperimentLocation(new TmfLocationArray(
-                new ITmfLocation<?>[fTraces.length]), new long[fTraces.length]) : (TmfExperimentLocation) location.clone();
+                new ITmfLocation<?>[fTraces.length])) : (TmfExperimentLocation) location.clone();
 
         // Create and populate the context's traces contexts
-        final TmfExperimentContext context = new TmfExperimentContext(fTraces, new ITmfContext[fTraces.length]);
-        // Tracer.trace("Ctx: SeekLocation - start");
+        final TmfExperimentContext context = new TmfExperimentContext(new ITmfContext[fTraces.length]);
 
-        long rank = 0;
         for (int i = 0; i < fTraces.length; i++) {
             // Get the relevant trace attributes
-            final ITmfLocation<?> traceLocation = expLocation.getLocation().locations[i];
-            final long traceRank = expLocation.getRanks()[i];
-
-            // Set the corresponding sub-context
+            final ITmfLocation<?> traceLocation = expLocation.getLocation().getLocations()[i];
             context.getContexts()[i] = fTraces[i].seekEvent(traceLocation);
-            context.getContexts()[i].setRank(traceRank);
-            rank += traceRank;
-
-            // Set the trace location and read the corresponding event
-            /*
-             * The (TmfContext) cast should be safe since we created 'context'
-             * ourselves higher up.
-             */
-            expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone();
-            context.getEvents()[i] = fTraces[i].readNextEvent(context.getContexts()[i]);
+            expLocation.getLocation().getLocations()[i] = context.getContexts()[i].getLocation().clone();
+            context.getEvents()[i] = fTraces[i].getNext(context.getContexts()[i]);
         }
 
-        // Tracer.trace("Ctx: SeekLocation - done");
-
         // Finalize context
         context.setLocation(expLocation);
         context.setLastTrace(TmfExperimentContext.NO_TRACE);
-        context.setRank(rank);
-
-        fExperimentContext = context;
-
+        context.setRank(ITmfContext.UNKNOWN_RANK);
         return context;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools .tmf.event.TmfTimestamp)
-     */
     @Override
-    public synchronized TmfExperimentContext seekEvent(ITmfTimestamp timestamp) {
-
-        //             Tracer.trace("Ctx: seekEvent(TS) - start");
-
-        if (timestamp == null)
-            timestamp = TmfTimestamp.BIG_BANG;
-
-        // First, find the right checkpoint
-        int index = Collections.binarySearch(fCheckpoints, new TmfCheckpoint(timestamp, null));
-
-        // In the very likely case that the checkpoint was not found, bsearch
-        // returns its negated would-be location (not an offset...). From that
-        // index, we can then position the stream and get the event.
-        if (index < 0)
-            index = Math.max(0, -(index + 2));
-
-        // Position the experiment at the checkpoint
-        ITmfLocation<?> location;
-        synchronized (fCheckpoints) {
-            if (fCheckpoints.size() > 0) {
-                if (index >= fCheckpoints.size())
-                    index = fCheckpoints.size() - 1;
-                location = fCheckpoints.elementAt(index).getLocation();
-            } else
-                location = null;
-        }
-
-        final TmfExperimentContext context = seekEvent(location);
-        context.setRank((long) index * fIndexPageSize);
-
-        // And locate the event
-        ITmfEvent event = parseEvent(context);
-        while ((event != null) && (event.getTimestamp().compareTo(timestamp, false) < 0)) {
-            readNextEvent(context);
-            event = parseEvent(context);
-        }
-
-        if (event == null) {
-            context.setLocation(null);
-            context.setRank(ITmfContext.UNKNOWN_RANK);
-        }
-
-        return context;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(long)
-     */
-    @Override
-    public synchronized TmfExperimentContext seekEvent(final long rank) {
-
-        //             Tracer.trace("Ctx: seekEvent(rank) - start");
-
-        // Position the stream at the previous checkpoint
-        int index = (int) rank / fIndexPageSize;
-        ITmfLocation<?> location;
-        synchronized (fCheckpoints) {
-            if (fCheckpoints.size() == 0)
-                location = null;
-            else {
-                if (index >= fCheckpoints.size())
-                    index = fCheckpoints.size() - 1;
-                location = fCheckpoints.elementAt(index).getLocation();
-            }
-        }
-
-        final TmfExperimentContext context = seekEvent(location);
-        context.setRank((long) index * fIndexPageSize);
-
-        // And locate the event
-        ITmfEvent event = parseEvent(context);
-        long pos = context.getRank();
-        while ((event != null) && (pos++ < rank)) {
-            readNextEvent(context);
-            event = parseEvent(context);
-        }
-
-        if (event == null) {
-            context.setLocation(null);
-            context.setRank(ITmfContext.UNKNOWN_RANK);
-        }
-
-        return context;
-    }
-
-    @Override
-    public TmfContext seekEvent(final double ratio) {
-        final TmfContext context = seekEvent((long) (ratio * getNbEvents()));
+    public ITmfContext seekEvent(final double ratio) {
+        final ITmfContext context = seekEvent((long) (ratio * getNbEvents()));
         return context;
     }
 
@@ -465,152 +271,61 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
 
     @Override
     public ITmfLocation<?> getCurrentLocation() {
-        if (fExperimentContext != null)
-            return fExperimentContext.getLocation();
-        return null;
+        ITmfLocation<?>[] locations = new ITmfLocation<?>[fTraces.length];
+        for (int i = 0; i < fTraces.length; i++) {
+            locations[i] = fTraces[i].getCurrentLocation();
+        }
+        return new TmfExperimentLocation(new TmfLocationArray(locations));
     }
 
-    // private void dumpContext(TmfExperimentContext context, boolean isBefore) {
-    //         TmfContext context0 = context.getContexts()[0];
-    //         TmfEvent   event0   = context.getEvents()[0];
-    //         TmfExperimentLocation location0 = (TmfExperimentLocation) context.getLocation();
-    //         long       rank0    = context.getRank();
-    //         int        trace    = context.getLastTrace();
-    //
-    //         StringBuffer result = new StringBuffer("Ctx: " + (isBefore ? "B " : "A "));
-    //
-    //         result.append("[Ctx: fLoc= " + context0.getLocation().toString() + ", fRnk= " + context0.getRank() + "] ");
-    //         result.append("[Evt: " + event0.getTimestamp().toString() + "] ");
-    //         result.append("[Loc: fLoc= " + location0.getLocation()[0].toString() + ", fRnk= " + location0.getRanks()[0] + "] ");
-    //         result.append("[Rnk: " + rank0 + "], [Trc: " + trace + "]");
-    //         Tracer.trace(result.toString());
-    // }
-
-    /**
-     * Scan the next events from all traces and return the next one in
-     * chronological order.
-     * 
-     * @param context the trace context
-     * @return the next event
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
      */
     @Override
-    public synchronized ITmfEvent readNextEvent(final ITmfContext context) {
-
-        // Validate the context
-        if (!(context instanceof TmfExperimentContext))
-            return null; // Throw an exception?
-
-        if (!context.equals(fExperimentContext))
-            // Tracer.trace("Ctx: Restoring context");
-            fExperimentContext = seekEvent(context.getLocation());
-
-        final TmfExperimentContext expContext = (TmfExperimentContext) context;
-
-        //             dumpContext(expContext, true);
-
-        // If an event was consumed previously, get the next one from that trace
-        final int lastTrace = expContext.getLastTrace();
-        if (lastTrace != TmfExperimentContext.NO_TRACE) {
-            final ITmfContext traceContext = expContext.getContexts()[lastTrace];
-            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readNextEvent(traceContext);
-            expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
-        }
-
-        // Scan the candidate events and identify the "next" trace to read from
-        final ITmfEvent eventArray[] = expContext.getEvents();
-        if (eventArray == null)
-            return null;
-        int trace = TmfExperimentContext.NO_TRACE;
-        ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
-        if (eventArray.length == 1) {
-            if (eventArray[0] != null) {
-                timestamp = eventArray[0].getTimestamp();
-                trace = 0;
-            }
-        } else
-            for (int i = 0; i < eventArray.length; i++) {
-                final ITmfEvent event = eventArray[i];
-                if (event != null && event.getTimestamp() != null) {
-                    final ITmfTimestamp otherTS = event.getTimestamp();
-                    if (otherTS.compareTo(timestamp, true) < 0) {
-                        trace = i;
-                        timestamp = otherTS;
-                    }
-                }
+    public synchronized T getNext(final ITmfContext context) {
+        final ITmfContext previousContext = (TmfExperimentContext) context.clone();
+        final T event = parseEvent(context);
+        if (event != null) {
+            updateAttributes(previousContext, event.getTimestamp());
+
+            TmfExperimentContext expContext = (TmfExperimentContext) context;
+            int trace = expContext.getLastTrace();
+            if (trace != TmfExperimentContext.NO_TRACE) {
+                TmfExperimentLocation location = (TmfExperimentLocation) expContext.getLocation();
+                location.getLocation().getLocations()[trace] = expContext.getContexts()[trace].getLocation();
             }
-        // Update the experiment context and set the "next" event
-        ITmfEvent event = null;
-        if (trace != TmfExperimentContext.NO_TRACE) {
-            updateIndex(expContext, timestamp);
-
-            final ITmfContext traceContext = expContext.getContexts()[trace];
-            final TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
-            //         expLocation.getLocation()[trace] = traceContext.getLocation().clone();
-            expLocation.getLocation().locations[trace] = traceContext.getLocation().clone();
-
-            //         updateIndex(expContext, timestamp);
-
-            expLocation.getRanks()[trace] = traceContext.getRank();
-            expContext.setLastTrace(trace);
-            expContext.increaseRank();
-            event = expContext.getEvents()[trace];
-            fExperimentContext = expContext;
+            
+            context.increaseRank();
+            processEvent(event);
         }
-
-        //             if (event != null) {
-        //             Tracer.trace("Exp: " + (expContext.getRank() - 1) + ": " + event.getTimestamp().toString());
-        //             dumpContext(expContext, false);
-        //             Tracer.trace("Ctx: Event returned= " + event.getTimestamp().toString());
-        //             }
-
         return event;
     }
 
-    public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
-        // Build the index as we go along
-        final long rank = context.getRank();
-        if (context.hasValidRank() && (rank % fIndexPageSize) == 0) {
-            // Determine the table position
-            final long position = rank / fIndexPageSize;
-            // Add new entry at proper location (if empty)
-            if (fCheckpoints.size() == position) {
-                final ITmfLocation<?> location = context.getLocation().clone();
-                fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location));
-                //                System.out.println(this + "[" + (fCheckpoints.size() - 1) + "] " + timestamp + ", "
-                //                        + location.toString());
-            }
-        }
-    }
-
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
      */
-//    @Override
-    public ITmfEvent parseEvent(final ITmfContext context) {
+    @SuppressWarnings("unchecked")
+    @Override
+    public T parseEvent(ITmfContext context) {
 
         // Validate the context
         if (!(context instanceof TmfExperimentContext))
             return null; // Throw an exception?
 
-        if (!context.equals(fExperimentContext))
-            // Tracer.trace("Ctx: Restoring context");
-            seekEvent(context.getLocation());
+        TmfExperimentContext expContext = (TmfExperimentContext) context;
 
-        final TmfExperimentContext expContext = (TmfExperimentContext) context;
-
-        // If an event was consumed previously, get the next one from that trace
+        // If an event was consumed previously, first get the next one from that trace
         final int lastTrace = expContext.getLastTrace();
         if (lastTrace != TmfExperimentContext.NO_TRACE) {
             final ITmfContext traceContext = expContext.getContexts()[lastTrace];
-            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readNextEvent(traceContext);
+            expContext.getEvents()[lastTrace] = fTraces[lastTrace].getNext(traceContext);
             expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
-            fExperimentContext = (TmfExperimentContext) context;
         }
 
         // Scan the candidate events and identify the "next" trace to read from
         int trace = TmfExperimentContext.NO_TRACE;
         ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
-        for (int i = 0; i < expContext.getTraces().length; i++) {
+        for (int i = 0; i < fTraces.length; i++) {
             final ITmfEvent event = expContext.getEvents()[i];
             if (event != null && event.getTimestamp() != null) {
                 final ITmfTimestamp otherTS = event.getTimestamp();
@@ -621,10 +336,12 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
             }
         }
 
-        ITmfEvent event = null;
-        if (trace != TmfExperimentContext.NO_TRACE)
-            event = expContext.getEvents()[trace];
+        T event = null;
+        if (trace != TmfExperimentContext.NO_TRACE) {
+            event = (T) expContext.getEvents()[trace];
+        }
 
+        expContext.setLastTrace(trace);
         return event;
     }
 
@@ -647,7 +364,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
         fInitialized = true;
 
         if (getStreamingInterval() == 0) {
-            final TmfContext context = seekEvent(0);
+            final ITmfContext context = seekEvent(0);
             final ITmfEvent event = getNext(context);
             if (event == null)
                 return;
@@ -725,154 +442,32 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
      * event).
      */
 
-    // The index page size
-    private static final int DEFAULT_INDEX_PAGE_SIZE = 5000;
-    protected int fIndexPageSize;
+//    protected int fIndexPageSize;
     protected boolean fIndexing = false;
-    protected TmfTimeRange fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
+//    protected TmfTimeRange fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
 
     private Integer fEndSynchReference;
 
-    // private static BufferedWriter fEventLog = null;
-    // private static BufferedWriter openLogFile(String filename) {
-    //         BufferedWriter outfile = null;
-    //         try {
-    //                 outfile = new BufferedWriter(new FileWriter(filename));
-    //         } catch (IOException e) {
-    //                 e.printStackTrace();
-    //         }
-    //         return outfile;
-    // }
-
     protected boolean isIndexingBusy() {
-        synchronized (fCheckpoints) {
-            return fIndexing;
-        }
+        return fIndexing;
     }
 
-    @SuppressWarnings("unchecked")
-    private void indexExperiment(final boolean waitForCompletion, final int index, final TmfTimeRange timeRange) {
-
-        synchronized (fCheckpoints) {
-            if (fIndexing)
-                return;
-            fIndexing = true;
-        }
-
-        final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
-
-            @Override
-            protected IStatus run(final IProgressMonitor monitor) {
-                while (!monitor.isCanceled())
-                    try {
-                        Thread.sleep(100);
-                    } catch (final InterruptedException e) {
-                        return Status.OK_STATUS;
-                    }
-                monitor.done();
-                return Status.OK_STATUS;
-            }
-        };
-        job.schedule();
-
-        //             fEventLog = openLogFile("TraceEvent.log");
-        //        System.out.println(System.currentTimeMillis() + ": Experiment indexing started");
-
-        final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, timeRange, index,
-                TmfDataRequest.ALL_DATA,
-                fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) { // PATA
-            // FOREGROUND
-
-            //            long indexingStart = System.nanoTime();
-
-            ITmfTimestamp startTime = (fTimeRange == TmfTimeRange.NULL_RANGE) ? null : fTimeRange.getStartTime();
-            ITmfTimestamp lastTime = (fTimeRange == TmfTimeRange.NULL_RANGE) ? null : fTimeRange.getEndTime();
-            long initialNbEvents = fNbEvents;
-
-            @Override
-            public void handleStarted() {
-                super.handleStarted();
-            }
-
-            @Override
-            public void handleData(final ITmfEvent event) {
-                super.handleData(event);
-                if (event != null) {
-                    final ITmfTimestamp ts = event.getTimestamp();
-                    if (startTime == null)
-                        startTime = ts.clone();
-                    lastTime = ts.clone();
-                }
-                if ((getNbRead() % fIndexPageSize) == 1 && getNbRead() != 1)
-                    updateExperiment();
-            }
-
-            @Override
-            public void handleSuccess() {
-                //                long indexingEnd = System.nanoTime();
-
-                // if the end time is a real value then it is the streaming safe
-                // time stamp
-                // set the last time to the safe time stamp to prevent
-                // unnecessary indexing requests
-                if (getRange().getEndTime() != TmfTimestamp.BIG_CRUNCH)
-                    lastTime = getRange().getEndTime();
-                updateExperiment();
-                //                System.out.println(System.currentTimeMillis() + ": Experiment indexing completed");
-
-                //                long average = (indexingEnd - indexingStart) / fNbEvents;
-                //                System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed="
-                //                        + (indexingEnd * 1.0 - indexingStart) / 1000000000);
-                //                System.out.println(getName() + ": nbEvents=" + fNbEvents + " (" + (average / 1000) + "."
-                //                        + (average % 1000) + " us/evt)");
-                super.handleSuccess();
-            }
-
-            @Override
-            public void handleCompleted() {
-                job.cancel();
-                super.handleCompleted();
-                synchronized (fCheckpoints) {
-                    fIndexing = false;
-                    if (fIndexingPendingRange != TmfTimeRange.NULL_RANGE) {
-                        indexExperiment(false, (int) fNbEvents, fIndexingPendingRange);
-                        fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
-                    }
-                }
-            }
-
-            private void updateExperiment() {
-                final int nbRead = getNbRead();
-                if (startTime != null)
-                    fTimeRange = new TmfTimeRange(startTime, lastTime.clone());
-                if (nbRead != 0) {
-                    //                                 updateTimeRange();
-                    //                                 updateNbEvents();
-                    fNbEvents = initialNbEvents + nbRead;
-                    notifyListeners();
-                }
-            }
-        };
 
-        sendRequest((ITmfDataRequest<T>) request);
-        if (waitForCompletion)
-            try {
-                request.waitForCompletion();
-            } catch (final InterruptedException e) {
-                e.printStackTrace();
-            }
-    }
-
-    protected void notifyListeners() {
-        broadcast(new TmfExperimentUpdatedSignal(this, this)); // , null));
-        // broadcast(new TmfExperimentRangeUpdatedSignal(this, this,
-        // fTimeRange)); // , null));
-    }
+//    protected void notifyListeners() {
+//        broadcast(new TmfExperimentUpdatedSignal(this, this));
+//    }
 
     // ------------------------------------------------------------------------
     // Signal handlers
     // ------------------------------------------------------------------------
 
+    @TmfSignalHandler
+    public void traceUpdated(final TmfTraceUpdatedSignal signal) {
+        if (signal.getTrace() == this) {
+            broadcast(new TmfExperimentUpdatedSignal(this, this));
+        }
+    }
+
     @TmfSignalHandler
     public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
         final TmfExperiment<?> experiment = signal.getExperiment();
@@ -896,33 +491,9 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
 
     @TmfSignalHandler
     public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
-        if (signal.getExperiment() == this)
-            indexExperiment(false, (int) fNbEvents, signal.getRange());
-    }
-
-    @TmfSignalHandler
-    public void traceUpdated(final TmfTraceUpdatedSignal signal) {
-        for (final ITmfTrace<T> trace : fTraces)
-            if (trace == signal.getTrace()) {
-                synchronized (fCheckpoints) {
-                    if (fIndexing) {
-                        if (fIndexingPendingRange == TmfTimeRange.NULL_RANGE)
-                            fIndexingPendingRange = signal.getRange();
-                        else {
-                            ITmfTimestamp startTime = fIndexingPendingRange.getStartTime();
-                            ITmfTimestamp endTime = fIndexingPendingRange.getEndTime();
-                            if (signal.getRange().getStartTime().compareTo(startTime) < 0)
-                                startTime = signal.getRange().getStartTime();
-                            if (signal.getRange().getEndTime().compareTo(endTime) > 0)
-                                endTime = signal.getRange().getEndTime();
-                            fIndexingPendingRange = new TmfTimeRange(startTime, endTime);
-                        }
-                        return;
-                    }
-                }
-                indexExperiment(false, (int) fNbEvents, signal.getRange());
-                return;
-            }
+        if (signal.getExperiment() == this) {
+            getIndexer().buildIndex(false);
+        }
     }
 
     @Override
@@ -949,13 +520,976 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
         return fBookmarksFile;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
-     */
-    @Override
-    public IResource getResource() {
-        return fResource;
-    }
+//    /*
+//     * (non-Javadoc)
+//     * 
+//     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
+//     */
+//    @Override
+//    public IResource getResource() {
+//        return fResource;
+//    }
 }
+
+
+///*******************************************************************************
+// * Copyright (c) 2009, 2010 Ericsson
+// *
+// * All rights reserved. This program and the accompanying materials are
+// * made available under the terms of the Eclipse Public License v1.0 which
+// * accompanies this distribution, and is available at
+// * http://www.eclipse.org/legal/epl-v10.html
+// *
+// * Contributors:
+// *   Francois Chouinard - Initial API and implementation
+// *******************************************************************************/
+//
+//package org.eclipse.linuxtools.tmf.core.experiment;
+//
+//import java.util.Collections;
+//import java.util.Vector;
+//
+//import org.eclipse.core.resources.IFile;
+//import org.eclipse.core.resources.IProject;
+//import org.eclipse.core.resources.IResource;
+//import org.eclipse.core.runtime.IProgressMonitor;
+//import org.eclipse.core.runtime.IStatus;
+//import org.eclipse.core.runtime.Status;
+//import org.eclipse.core.runtime.jobs.Job;
+//import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
+//import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+//import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+//import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+//import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+//import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+//import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+//import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+//import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+//import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+//import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+//import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+//import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+//import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
+//import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+//
+///**
+// * <b><u>TmfExperiment</u></b>
+// * <p>
+// * TmfExperiment presents a time-ordered, unified view of a set of TmfTraces
+// * that are part of a tracing experiment.
+// * <p>
+// */
+//public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> implements ITmfTrace<T> {
+//
+//    // ------------------------------------------------------------------------
+//    // Attributes
+//    // ------------------------------------------------------------------------
+//
+//    // The currently selected experiment
+//    protected static TmfExperiment<?> fCurrentExperiment = null;
+//
+//    // The set of traces that constitute the experiment
+//    protected ITmfTrace<T>[] fTraces;
+//
+//    // The total number of events
+//    protected long fNbEvents;
+//
+//    // The experiment time range
+//    protected TmfTimeRange fTimeRange;
+//
+//    // The experiment reference timestamp (default: ZERO)
+//    protected ITmfTimestamp fEpoch;
+//
+//    // The experiment index
+//    protected Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
+//
+//    // The current experiment context
+//    protected TmfExperimentContext fExperimentContext;
+//
+//    // Flag to initialize only once
+//    private boolean fInitialized = false;
+//
+//    // The experiment bookmarks file
+//    private IFile fBookmarksFile;
+//
+//    // The properties resource
+//    private IResource fResource;
+//
+//    // ------------------------------------------------------------------------
+//    // Constructors
+//    // ------------------------------------------------------------------------
+//
+//    @Override
+//    public TmfExperiment<T> clone() throws CloneNotSupportedException {
+//        throw new CloneNotSupportedException();
+//    }
+//
+//    @Override
+//    public boolean validate(final IProject project, final String path) {
+//        return true;
+//    }
+//
+//    @Override
+//    public void initTrace(final IResource resource, final String path, final Class<T> eventType) {
+//        fResource = resource;
+//    }
+//
+//    /**
+//     * @param type
+//     * @param id
+//     * @param traces
+//     * @param epoch
+//     * @param indexPageSize
+//     */
+//    public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
+//            final int indexPageSize) {
+//        this(type, id, traces, TmfTimestamp.ZERO, indexPageSize, false);
+//    }
+//
+//    public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
+//            final int indexPageSize, final boolean preIndexExperiment) {
+//        super(id, type);
+//
+//        fTraces = traces;
+//        fEpoch = epoch;
+//        fIndexPageSize = indexPageSize;
+//        fTimeRange = TmfTimeRange.NULL_RANGE;
+//
+//        if (preIndexExperiment) {
+//            indexExperiment(true, 0, TmfTimeRange.ETERNITY);
+//            updateTimeRange();
+//        }
+//    }
+//
+//    protected TmfExperiment(final String id, final Class<T> type) {
+//        super(id, type);
+//    }
+//
+//    /**
+//     * @param type
+//     * @param id
+//     * @param traces
+//     */
+//    public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces) {
+//        this(type, id, traces, TmfTimestamp.ZERO, DEFAULT_INDEX_PAGE_SIZE);
+//    }
+//
+//    /**
+//     * @param type
+//     * @param id
+//     * @param traces
+//     * @param indexPageSize
+//     */
+//    public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final int indexPageSize) {
+//        this(type, id, traces, TmfTimestamp.ZERO, indexPageSize);
+//    }
+//
+//    /**
+//     * Clears the experiment
+//     */
+//    @Override
+//    @SuppressWarnings("rawtypes")
+//    public synchronized void dispose() {
+//
+//        final TmfExperimentDisposedSignal<T> signal = new TmfExperimentDisposedSignal<T>(this, this);
+//        broadcast(signal);
+//        if (fCurrentExperiment == this)
+//            fCurrentExperiment = null;
+//
+//        if (fTraces != null) {
+//            for (final ITmfTrace trace : fTraces)
+//                trace.dispose();
+//            fTraces = null;
+//        }
+//        if (fCheckpoints != null)
+//            fCheckpoints.clear();
+//        super.dispose();
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // ITmfTrace
+//    // ------------------------------------------------------------------------
+//
+//    @Override
+//    public Class<T> getEventType() {
+//        return fType;
+//    }
+//
+//    @Override
+//    public long getNbEvents() {
+//        return fNbEvents;
+//    }
+//
+//    @Override
+//    public int getCacheSize() {
+//        return fIndexPageSize;
+//    }
+//
+//    @Override
+//    public TmfTimeRange getTimeRange() {
+//        return fTimeRange;
+//    }
+//
+//    @Override
+//    public ITmfTimestamp getStartTime() {
+//        return fTimeRange.getStartTime();
+//    }
+//
+//    @Override
+//    public ITmfTimestamp getEndTime() {
+//        return fTimeRange.getEndTime();
+//    }
+//
+//    public Vector<TmfCheckpoint> getCheckpoints() {
+//        return fCheckpoints;
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // Accessors
+//    // ------------------------------------------------------------------------
+//
+//    public static void setCurrentExperiment(final TmfExperiment<?> experiment) {
+//        if (fCurrentExperiment != null && fCurrentExperiment != experiment)
+//            fCurrentExperiment.dispose();
+//        fCurrentExperiment = experiment;
+//    }
+//
+//    public static TmfExperiment<?> getCurrentExperiment() {
+//        return fCurrentExperiment;
+//    }
+//
+//    public ITmfTimestamp getEpoch() {
+//        return fEpoch;
+//    }
+//
+//    public ITmfTrace<T>[] getTraces() {
+//        return fTraces;
+//    }
+//
+//    /**
+//     * Returns the timestamp of the event at the requested index. If none,
+//     * returns null.
+//     * 
+//     * @param index the event index (rank)
+//     * @return the corresponding event timestamp
+//     */
+//    public ITmfTimestamp getTimestamp(final int index) {
+//        final TmfExperimentContext context = seekEvent(index);
+//        final ITmfEvent event = readNextEvent(context);
+//        return (event != null) ? event.getTimestamp() : null;
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // Operators
+//    // ------------------------------------------------------------------------
+//
+//    /**
+//     * Update the global time range
+//     */
+//    protected void updateTimeRange() {
+//        ITmfTimestamp startTime = fTimeRange != TmfTimeRange.NULL_RANGE ? fTimeRange.getStartTime() : TmfTimestamp.BIG_CRUNCH;
+//        ITmfTimestamp endTime = fTimeRange != TmfTimeRange.NULL_RANGE ? fTimeRange.getEndTime() : TmfTimestamp.BIG_BANG;
+//
+//        for (final ITmfTrace<T> trace : fTraces) {
+//            final ITmfTimestamp traceStartTime = trace.getStartTime();
+//            if (traceStartTime.compareTo(startTime, true) < 0)
+//                startTime = traceStartTime;
+//            final ITmfTimestamp traceEndTime = trace.getEndTime();
+//            if (traceEndTime.compareTo(endTime, true) > 0)
+//                endTime = traceEndTime;
+//        }
+//        fTimeRange = new TmfTimeRange(startTime, endTime);
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // TmfProvider
+//    // ------------------------------------------------------------------------
+//
+//    @Override
+//    public ITmfContext armRequest(final ITmfDataRequest<T> request) {
+//        //      Tracer.trace("Ctx: Arming request - start");
+//        ITmfTimestamp timestamp = (request instanceof ITmfEventRequest<?>) ? ((ITmfEventRequest<T>) request).getRange().getStartTime() : null;
+//        if (TmfTimestamp.BIG_BANG.equals(timestamp) || request.getIndex() > 0)
+//            timestamp = null; // use request index
+//        TmfExperimentContext context = null;
+//        if (timestamp != null) {
+//            // seek by timestamp
+//            context = seekEvent(timestamp);
+//            ((ITmfEventRequest<T>) request).setStartIndex((int) context.getRank());
+//        } else // Seek by rank
+//            if ((fExperimentContext != null) && fExperimentContext.getRank() == request.getIndex())
+//                // We are already at the right context -> no need to seek
+//                context = fExperimentContext;
+//            else
+//                context = seekEvent(request.getIndex());
+//        // Tracer.trace("Ctx: Arming request - done");
+//        return context;
+//    }
+//
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public T getNext(final ITmfContext context) {
+//        if (context instanceof TmfExperimentContext)
+//            return (T) readNextEvent(context);
+//        return null;
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // ITmfTrace trace positioning
+//    // ------------------------------------------------------------------------
+//
+//    // Returns a brand new context based on the location provided
+//    // and initializes the event queues
+//    @Override
+//    public synchronized TmfExperimentContext seekEvent(final ITmfLocation<?> location) {
+//        // Validate the location
+//        if (location != null && !(location instanceof TmfExperimentLocation))
+//            return null; // Throw an exception?
+//
+//        if (fTraces == null)
+//            return null;
+//
+//        // Instantiate the location
+//        final TmfExperimentLocation expLocation = (location == null) ? new TmfExperimentLocation(new TmfLocationArray(
+//                new ITmfLocation<?>[fTraces.length]), new long[fTraces.length]) : (TmfExperimentLocation) location.clone();
+//
+//        // Create and populate the context's traces contexts
+//        final TmfExperimentContext context = new TmfExperimentContext(fTraces, new ITmfContext[fTraces.length]);
+//        // Tracer.trace("Ctx: SeekLocation - start");
+//
+//        long rank = 0;
+//        for (int i = 0; i < fTraces.length; i++) {
+//            // Get the relevant trace attributes
+//            final ITmfLocation<?> traceLocation = expLocation.getLocation().locations[i];
+//            final long traceRank = expLocation.getRanks()[i];
+//
+//            // Set the corresponding sub-context
+//            context.getContexts()[i] = fTraces[i].seekEvent(traceLocation);
+//            context.getContexts()[i].setRank(traceRank);
+//            rank += traceRank;
+//
+//            // Set the trace location and read the corresponding event
+//            /*
+//             * The (TmfContext) cast should be safe since we created 'context'
+//             * ourselves higher up.
+//             */
+//            expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone();
+//            context.getEvents()[i] = fTraces[i].readNextEvent(context.getContexts()[i]);
+//        }
+//
+//        // Tracer.trace("Ctx: SeekLocation - done");
+//
+//        // Finalize context
+//        context.setLocation(expLocation);
+//        context.setLastTrace(TmfExperimentContext.NO_TRACE);
+//        context.setRank(rank);
+//
+//        fExperimentContext = context;
+//
+//        return context;
+//    }
+//
+//    /* (non-Javadoc)
+//     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools .tmf.event.TmfTimestamp)
+//     */
+//    @Override
+//    public synchronized TmfExperimentContext seekEvent(ITmfTimestamp timestamp) {
+//
+//        //      Tracer.trace("Ctx: seekEvent(TS) - start");
+//
+//        if (timestamp == null)
+//            timestamp = TmfTimestamp.BIG_BANG;
+//
+//        // First, find the right checkpoint
+//        int index = Collections.binarySearch(fCheckpoints, new TmfCheckpoint(timestamp, null));
+//
+//        // In the very likely case that the checkpoint was not found, bsearch
+//        // returns its negated would-be location (not an offset...). From that
+//        // index, we can then position the stream and get the event.
+//        if (index < 0)
+//            index = Math.max(0, -(index + 2));
+//
+//        // Position the experiment at the checkpoint
+//        ITmfLocation<?> location;
+//        synchronized (fCheckpoints) {
+//            if (fCheckpoints.size() > 0) {
+//                if (index >= fCheckpoints.size())
+//                    index = fCheckpoints.size() - 1;
+//                location = fCheckpoints.elementAt(index).getLocation();
+//            } else
+//                location = null;
+//        }
+//
+//        final TmfExperimentContext context = seekEvent(location);
+//        context.setRank((long) index * fIndexPageSize);
+//
+//        // And locate the event
+//        ITmfEvent event = parseEvent(context);
+//        while ((event != null) && (event.getTimestamp().compareTo(timestamp, false) < 0)) {
+//            readNextEvent(context);
+//            event = parseEvent(context);
+//        }
+//
+//        if (event == null) {
+//            context.setLocation(null);
+//            context.setRank(ITmfContext.UNKNOWN_RANK);
+//        }
+//
+//        return context;
+//    }
+//
+//    /* (non-Javadoc)
+//     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(long)
+//     */
+//    @Override
+//    public synchronized TmfExperimentContext seekEvent(final long rank) {
+//
+//        //      Tracer.trace("Ctx: seekEvent(rank) - start");
+//
+//        // Position the stream at the previous checkpoint
+//        int index = (int) rank / fIndexPageSize;
+//        ITmfLocation<?> location;
+//        synchronized (fCheckpoints) {
+//            if (fCheckpoints.size() == 0)
+//                location = null;
+//            else {
+//                if (index >= fCheckpoints.size())
+//                    index = fCheckpoints.size() - 1;
+//                location = fCheckpoints.elementAt(index).getLocation();
+//            }
+//        }
+//
+//        final TmfExperimentContext context = seekEvent(location);
+//        context.setRank((long) index * fIndexPageSize);
+//
+//        // And locate the event
+//        ITmfEvent event = parseEvent(context);
+//        long pos = context.getRank();
+//        while ((event != null) && (pos++ < rank)) {
+//            readNextEvent(context);
+//            event = parseEvent(context);
+//        }
+//
+//        if (event == null) {
+//            context.setLocation(null);
+//            context.setRank(ITmfContext.UNKNOWN_RANK);
+//        }
+//
+//        return context;
+//    }
+//
+//    @Override
+//    public TmfContext seekEvent(final double ratio) {
+//        final TmfContext context = seekEvent((long) (ratio * getNbEvents()));
+//        return context;
+//    }
+//
+//    @Override
+//    public double getLocationRatio(final ITmfLocation<?> location) {
+//        if (location instanceof TmfExperimentLocation)
+//            return (double) seekEvent(location).getRank() / getNbEvents();
+//        return 0;
+//    }
+//
+//    @Override
+//    public ITmfLocation<?> getCurrentLocation() {
+//        if (fExperimentContext != null)
+//            return fExperimentContext.getLocation();
+//        return null;
+//    }
+//
+//    //  private void dumpContext(TmfExperimentContext context, boolean isBefore) {
+//    //      TmfContext context0 = context.getContexts()[0];
+//    //      TmfEvent   event0   = context.getEvents()[0];
+//    //      TmfExperimentLocation location0 = (TmfExperimentLocation) context.getLocation();
+//    //      long       rank0    = context.getRank();
+//    //      int        trace    = context.getLastTrace();
+//    //
+//    //      StringBuffer result = new StringBuffer("Ctx: " + (isBefore ? "B " : "A "));
+//    //
+//    //      result.append("[Ctx: fLoc= " + context0.getLocation().toString() + ", fRnk= " + context0.getRank() + "] ");
+//    //      result.append("[Evt: " + event0.getTimestamp().toString() + "] ");
+//    //      result.append("[Loc: fLoc= " + location0.getLocation()[0].toString() + ", fRnk= " + location0.getRanks()[0] + "] ");
+//    //      result.append("[Rnk: " + rank0 + "], [Trc: " + trace + "]");
+//    //      Tracer.trace(result.toString());
+//    //  }
+//
+//    /**
+//     * Scan the next events from all traces and return the next one in
+//     * chronological order.
+//     * 
+//     * @param context the trace context
+//     * @return the next event
+//     */
+//    @Override
+//    public synchronized ITmfEvent readNextEvent(final ITmfContext context) {
+//
+//        // Validate the context
+//        if (!(context instanceof TmfExperimentContext))
+//            return null; // Throw an exception?
+//
+//        if (!context.equals(fExperimentContext))
+//            // Tracer.trace("Ctx: Restoring context");
+//            fExperimentContext = seekEvent(context.getLocation());
+//
+//        final TmfExperimentContext expContext = (TmfExperimentContext) context;
+//
+//        //      dumpContext(expContext, true);
+//
+//        // If an event was consumed previously, get the next one from that trace
+//        final int lastTrace = expContext.getLastTrace();
+//        if (lastTrace != TmfExperimentContext.NO_TRACE) {
+//            final ITmfContext traceContext = expContext.getContexts()[lastTrace];
+//            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readNextEvent(traceContext);
+//            expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+//        }
+//
+//        // Scan the candidate events and identify the "next" trace to read from
+//        final ITmfEvent eventArray[] = expContext.getEvents();
+//        if (eventArray == null)
+//            return null;
+//        int trace = TmfExperimentContext.NO_TRACE;
+//        ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
+//        if (eventArray.length == 1) {
+//            if (eventArray[0] != null) {
+//                timestamp = eventArray[0].getTimestamp();
+//                trace = 0;
+//            }
+//        } else
+//            for (int i = 0; i < eventArray.length; i++) {
+//                final ITmfEvent event = eventArray[i];
+//                if (event != null && event.getTimestamp() != null) {
+//                    final ITmfTimestamp otherTS = event.getTimestamp();
+//                    if (otherTS.compareTo(timestamp, true) < 0) {
+//                        trace = i;
+//                        timestamp = otherTS;
+//                    }
+//                }
+//            }
+//        // Update the experiment context and set the "next" event
+//        ITmfEvent event = null;
+//        if (trace != TmfExperimentContext.NO_TRACE) {
+//            updateIndex(expContext, timestamp);
+//
+//            final ITmfContext traceContext = expContext.getContexts()[trace];
+//            final TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
+//            //          expLocation.getLocation()[trace] = traceContext.getLocation().clone();
+//            expLocation.getLocation().locations[trace] = traceContext.getLocation().clone();
+//
+//            //          updateIndex(expContext, timestamp);
+//
+//            expLocation.getRanks()[trace] = traceContext.getRank();
+//            expContext.setLastTrace(trace);
+//            expContext.increaseRank();
+//            event = expContext.getEvents()[trace];
+//            fExperimentContext = expContext;
+//        }
+//
+//        //      if (event != null) {
+//        //          Tracer.trace("Exp: " + (expContext.getRank() - 1) + ": " + event.getTimestamp().toString());
+//        //          dumpContext(expContext, false);
+//        //          Tracer.trace("Ctx: Event returned= " + event.getTimestamp().toString());
+//        //      }
+//
+//        return event;
+//    }
+//
+//    public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
+//        // Build the index as we go along
+//        final long rank = context.getRank();
+//        if (context.hasValidRank() && (rank % fIndexPageSize) == 0) {
+//            // Determine the table position
+//            final long position = rank / fIndexPageSize;
+//            // Add new entry at proper location (if empty)
+//            if (fCheckpoints.size() == position) {
+//                final ITmfLocation<?> location = context.getLocation().clone();
+//                fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location));
+//                //                System.out.println(this + "[" + (fCheckpoints.size() - 1) + "] " + timestamp + ", "
+//                //                        + location.toString());
+//            }
+//        }
+//    }
+//
+//    /* (non-Javadoc)
+//     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
+//     */
+////    @Override
+//    public ITmfEvent parseEvent(final ITmfContext context) {
+//
+//        // Validate the context
+//        if (!(context instanceof TmfExperimentContext))
+//            return null; // Throw an exception?
+//
+//        if (!context.equals(fExperimentContext))
+//            // Tracer.trace("Ctx: Restoring context");
+//            seekEvent(context.getLocation());
+//
+//        final TmfExperimentContext expContext = (TmfExperimentContext) context;
+//
+//        // If an event was consumed previously, get the next one from that trace
+//        final int lastTrace = expContext.getLastTrace();
+//        if (lastTrace != TmfExperimentContext.NO_TRACE) {
+//            final ITmfContext traceContext = expContext.getContexts()[lastTrace];
+//            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readNextEvent(traceContext);
+//            expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+//            fExperimentContext = (TmfExperimentContext) context;
+//        }
+//
+//        // Scan the candidate events and identify the "next" trace to read from
+//        int trace = TmfExperimentContext.NO_TRACE;
+//        ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
+//        for (int i = 0; i < expContext.getTraces().length; i++) {
+//            final ITmfEvent event = expContext.getEvents()[i];
+//            if (event != null && event.getTimestamp() != null) {
+//                final ITmfTimestamp otherTS = event.getTimestamp();
+//                if (otherTS.compareTo(timestamp, true) < 0) {
+//                    trace = i;
+//                    timestamp = otherTS;
+//                }
+//            }
+//        }
+//
+//        ITmfEvent event = null;
+//        if (trace != TmfExperimentContext.NO_TRACE)
+//            event = expContext.getEvents()[trace];
+//
+//        return event;
+//    }
+//
+//    /* (non-Javadoc)
+//     * @see java.lang.Object#toString()
+//     */
+//    @Override
+//    @SuppressWarnings("nls")
+//    public String toString() {
+//        return "[TmfExperiment (" + getName() + ")]";
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // Indexing
+//    // ------------------------------------------------------------------------
+//
+//    private synchronized void initializeStreamingMonitor() {
+//        if (fInitialized)
+//            return;
+//        fInitialized = true;
+//
+//        if (getStreamingInterval() == 0) {
+//            final TmfContext context = seekEvent(0);
+//            final ITmfEvent event = getNext(context);
+//            if (event == null)
+//                return;
+//            final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
+//            final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
+//
+//            // Broadcast in separate thread to prevent deadlock
+//            new Thread() {
+//                @Override
+//                public void run() {
+//                    broadcast(signal);
+//                }
+//            }.start();
+//            return;
+//        }
+//
+//        final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { ////$NON-NLS-1$
+//            private ITmfTimestamp safeTimestamp = null;
+//            private TmfTimeRange timeRange = null;
+//
+//            @Override
+//            public void run() {
+//                while (!fExecutor.isShutdown()) {
+//                    if (!isIndexingBusy()) {
+//                        ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
+//                        ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
+//                        for (final ITmfTrace<T> trace : fTraces) {
+//                            if (trace.getStartTime().compareTo(startTimestamp) < 0)
+//                                startTimestamp = trace.getStartTime();
+//                            if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0)
+//                                endTimestamp = trace.getEndTime();
+//                        }
+//                        if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0)
+//                            timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
+//                        else
+//                            timeRange = null;
+//                        safeTimestamp = endTimestamp;
+//                        if (timeRange != null) {
+//                            final TmfExperimentRangeUpdatedSignal signal =
+//                                    new TmfExperimentRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange);
+//                            broadcast(signal);
+//                        }
+//                    }
+//                    try {
+//                        Thread.sleep(getStreamingInterval());
+//                    } catch (final InterruptedException e) {
+//                        e.printStackTrace();
+//                    }
+//                }
+//            }
+//        };
+//        thread.start();
+//    }
+//
+//    /*
+//     * (non-Javadoc)
+//     * 
+//     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getStreamingInterval()
+//     */
+//    @Override
+//    public long getStreamingInterval() {
+//        long interval = 0;
+//        for (final ITmfTrace<T> trace : fTraces)
+//            interval = Math.max(interval, trace.getStreamingInterval());
+//        return interval;
+//    }
+//
+//    /*
+//     * The experiment holds the globally ordered events of its set of traces. It
+//     * is expected to provide access to each individual event by index i.e. it
+//     * must be possible to request the Nth event of the experiment.
+//     * 
+//     * The purpose of the index is to keep the information needed to rapidly
+//     * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE
+//     * event).
+//     */
+//
+//    // The index page size
+//    private static final int DEFAULT_INDEX_PAGE_SIZE = 5000;
+//    protected int fIndexPageSize;
+//    protected boolean fIndexing = false;
+//    protected TmfTimeRange fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
+//
+//    private Integer fEndSynchReference;
+//
+//    //  private static BufferedWriter fEventLog = null;
+//    //  private static BufferedWriter openLogFile(String filename) {
+//    //      BufferedWriter outfile = null;
+//    //      try {
+//    //          outfile = new BufferedWriter(new FileWriter(filename));
+//    //      } catch (IOException e) {
+//    //          e.printStackTrace();
+//    //      }
+//    //      return outfile;
+//    //  }
+//
+//    protected boolean isIndexingBusy() {
+//        synchronized (fCheckpoints) {
+//            return fIndexing;
+//        }
+//    }
+//
+//    @SuppressWarnings("unchecked")
+//    private void indexExperiment(final boolean waitForCompletion, final int index, final TmfTimeRange timeRange) {
+//
+//        synchronized (fCheckpoints) {
+//            if (fIndexing)
+//                return;
+//            fIndexing = true;
+//        }
+//
+//        final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
+//
+//            @Override
+//            protected IStatus run(final IProgressMonitor monitor) {
+//                while (!monitor.isCanceled())
+//                    try {
+//                        Thread.sleep(100);
+//                    } catch (final InterruptedException e) {
+//                        return Status.OK_STATUS;
+//                    }
+//                monitor.done();
+//                return Status.OK_STATUS;
+//            }
+//        };
+//        job.schedule();
+//
+//        //      fEventLog = openLogFile("TraceEvent.log");
+//        //        System.out.println(System.currentTimeMillis() + ": Experiment indexing started");
+//
+//        final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, timeRange, index,
+//                TmfDataRequest.ALL_DATA,
+//                fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) { // PATA
+//            // FOREGROUND
+//
+//            //            long indexingStart = System.nanoTime();
+//
+//            ITmfTimestamp startTime = (fTimeRange == TmfTimeRange.NULL_RANGE) ? null : fTimeRange.getStartTime();
+//            ITmfTimestamp lastTime = (fTimeRange == TmfTimeRange.NULL_RANGE) ? null : fTimeRange.getEndTime();
+//            long initialNbEvents = fNbEvents;
+//
+//            @Override
+//            public void handleStarted() {
+//                super.handleStarted();
+//            }
+//
+//            @Override
+//            public void handleData(final ITmfEvent event) {
+//                super.handleData(event);
+//                if (event != null) {
+//                    final ITmfTimestamp ts = event.getTimestamp();
+//                    if (startTime == null)
+//                        startTime = ts.clone();
+//                    lastTime = ts.clone();
+//                }
+//                if ((getNbRead() % fIndexPageSize) == 1 && getNbRead() != 1)
+//                    updateExperiment();
+//            }
+//
+//            @Override
+//            public void handleSuccess() {
+//                //                long indexingEnd = System.nanoTime();
+//
+//                // if the end time is a real value then it is the streaming safe
+//                // time stamp
+//                // set the last time to the safe time stamp to prevent
+//                // unnecessary indexing requests
+//                if (getRange().getEndTime() != TmfTimestamp.BIG_CRUNCH)
+//                    lastTime = getRange().getEndTime();
+//                updateExperiment();
+//                //                System.out.println(System.currentTimeMillis() + ": Experiment indexing completed");
+//
+//                //                long average = (indexingEnd - indexingStart) / fNbEvents;
+//                //                System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed="
+//                //                        + (indexingEnd * 1.0 - indexingStart) / 1000000000);
+//                //                System.out.println(getName() + ": nbEvents=" + fNbEvents + " (" + (average / 1000) + "."
+//                //                        + (average % 1000) + " us/evt)");
+//                super.handleSuccess();
+//            }
+//
+//            @Override
+//            public void handleCompleted() {
+//                job.cancel();
+//                super.handleCompleted();
+//                synchronized (fCheckpoints) {
+//                    fIndexing = false;
+//                    if (fIndexingPendingRange != TmfTimeRange.NULL_RANGE) {
+//                        indexExperiment(false, (int) fNbEvents, fIndexingPendingRange);
+//                        fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
+//                    }
+//                }
+//            }
+//
+//            private void updateExperiment() {
+//                final int nbRead = getNbRead();
+//                if (startTime != null)
+//                    fTimeRange = new TmfTimeRange(startTime, lastTime.clone());
+//                if (nbRead != 0) {
+//                    //                  updateTimeRange();
+//                    //                  updateNbEvents();
+//                    fNbEvents = initialNbEvents + nbRead;
+//                    notifyListeners();
+//                }
+//            }
+//        };
+//
+//        sendRequest((ITmfDataRequest<T>) request);
+//        if (waitForCompletion)
+//            try {
+//                request.waitForCompletion();
+//            } catch (final InterruptedException e) {
+//                e.printStackTrace();
+//            }
+//    }
+//
+//    protected void notifyListeners() {
+//        broadcast(new TmfExperimentUpdatedSignal(this, this)); // , null));
+//        // broadcast(new TmfExperimentRangeUpdatedSignal(this, this,
+//        // fTimeRange)); // , null));
+//    }
+//
+//    // ------------------------------------------------------------------------
+//    // Signal handlers
+//    // ------------------------------------------------------------------------
+//
+//    @TmfSignalHandler
+//    public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
+//        final TmfExperiment<?> experiment = signal.getExperiment();
+//        if (experiment == this) {
+//            setCurrentExperiment(experiment);
+//            fEndSynchReference = Integer.valueOf(signal.getReference());
+//        }
+//    }
+//
+//    @TmfSignalHandler
+//    public void endSync(final TmfEndSynchSignal signal) {
+//        if (fEndSynchReference != null && fEndSynchReference.intValue() == signal.getReference()) {
+//            fEndSynchReference = null;
+//            initializeStreamingMonitor();
+//        }
+//    }
+//
+//    @TmfSignalHandler
+//    public void experimentUpdated(final TmfExperimentUpdatedSignal signal) {
+//    }
+//
+//    @TmfSignalHandler
+//    public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
+//        if (signal.getExperiment() == this)
+//            indexExperiment(false, (int) fNbEvents, signal.getRange());
+//    }
+//
+//    @TmfSignalHandler
+//    public void traceUpdated(final TmfTraceUpdatedSignal signal) {
+//        for (final ITmfTrace<T> trace : fTraces)
+//            if (trace == signal.getTrace()) {
+//                synchronized (fCheckpoints) {
+//                    if (fIndexing) {
+//                        if (fIndexingPendingRange == TmfTimeRange.NULL_RANGE)
+//                            fIndexingPendingRange = signal.getRange();
+//                        else {
+//                            ITmfTimestamp startTime = fIndexingPendingRange.getStartTime();
+//                            ITmfTimestamp endTime = fIndexingPendingRange.getEndTime();
+//                            if (signal.getRange().getStartTime().compareTo(startTime) < 0)
+//                                startTime = signal.getRange().getStartTime();
+//                            if (signal.getRange().getEndTime().compareTo(endTime) > 0)
+//                                endTime = signal.getRange().getEndTime();
+//                            fIndexingPendingRange = new TmfTimeRange(startTime, endTime);
+//                        }
+//                        return;
+//                    }
+//                }
+//                indexExperiment(false, (int) fNbEvents, signal.getRange());
+//                return;
+//            }
+//    }
+//
+//    @Override
+//    public String getPath() {
+//        // TODO Auto-generated method stub
+//        return null;
+//    }
+//
+//    /**
+//     * Set the file to be used for bookmarks on this experiment
+//     * 
+//     * @param file the bookmarks file
+//     */
+//    public void setBookmarksFile(final IFile file) {
+//        fBookmarksFile = file;
+//    }
+//
+//    /**
+//     * Get the file used for bookmarks on this experiment
+//     * 
+//     * @return the bookmarks file or null if none is set
+//     */
+//    public IFile getBookmarksFile() {
+//        return fBookmarksFile;
+//    }
+//
+//    /*
+//     * (non-Javadoc)
+//     * 
+//     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
+//     */
+//    @Override
+//    public IResource getResource() {
+//        return fResource;
+//    }
+//}
index e1d2b5afd6475ecddf8f97e609076ceaa427308e..5c41718434aba19fb6248a663f413f45d66c8764 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Put in shape for 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.experiment;
@@ -15,19 +16,18 @@ package org.eclipse.linuxtools.tmf.core.experiment;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 
 /**
- * <b><u>TmfExperimentContext</u></b>
+ * The experiment context in TMF.
  * <p>
  * The experiment keeps track of the next event from each of its traces so it
  * can pick the next one in chronological order.
  * <p>
  * This implies that the "next" event from each trace has already been
  * read and that we at least know its timestamp. This doesn't imply that a
- * full parse of the event content was performed (read: LTTng works like
- * this).
+ * full parse of the event content was performed (read: the legacy LTTng works
+ * like this...).
  * <p>
  * The last trace refers to the trace from which the last event was "consumed"
  * at the experiment level.
@@ -38,13 +38,16 @@ public class TmfExperimentContext extends TmfContext {
     // Constants
     // ------------------------------------------------------------------------
 
-    public static final int NO_TRACE = -1;
+    /**
+     * No last trace read indicator
+     */
+    static final int NO_TRACE = -1;
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
 
-    private ITmfTrace<?>[] fTraces = new ITmfTrace[0];
+//    private ITmfTrace<?>[] fTraces = new ITmfTrace[0];
     private final ITmfContext[] fContexts;
     private ITmfEvent[] fEvents;
     private int lastTraceRead;
@@ -53,28 +56,28 @@ public class TmfExperimentContext extends TmfContext {
     // Constructors
     // ------------------------------------------------------------------------
 
-    public TmfExperimentContext(final ITmfTrace<?>[] traces, final ITmfContext[] contexts) {
+    public TmfExperimentContext(final ITmfContext[] contexts) {
         super();
-        fTraces = traces;
+//        fTraces = traces;
         fContexts = contexts;
-        fEvents = new ITmfEvent[fTraces.length];
-        final ITmfLocation<?>[] locations = new ITmfLocation[fTraces.length];
-        final long[] ranks = new long[fTraces.length];
+        fEvents = new ITmfEvent[fContexts.length];
+        final ITmfLocation<?>[] locations = new ITmfLocation[fContexts.length];
+        final long[] ranks = new long[fContexts.length];
         long rank = 0;
-        for (int i = 0; i < fTraces.length; i++)
+        for (int i = 0; i < fContexts.length; i++)
             if (contexts[i] != null) {
                 locations[i] = contexts[i].getLocation();
                 ranks[i] = contexts[i].getRank();
                 rank += contexts[i].getRank();
             }
 
-        setLocation(new TmfExperimentLocation(new TmfLocationArray(locations), ranks));
+        setLocation(new TmfExperimentLocation(new TmfLocationArray(locations)));
         setRank(rank);
         lastTraceRead = NO_TRACE;
     }
 
     public TmfExperimentContext(final TmfExperimentContext other) {
-        this(other.fTraces, other.cloneContexts());
+        this(other.cloneContexts());
         fEvents = other.fEvents;
         if (other.getLocation() != null)
             setLocation(other.getLocation().clone());
@@ -82,9 +85,9 @@ public class TmfExperimentContext extends TmfContext {
         setLastTrace(other.lastTraceRead);
     }
 
-    public TmfExperimentContext(final ITmfTrace<?>[] traces) {
-        this(traces, new TmfContext[traces.length]);
-    }
+//    public TmfExperimentContext(final ITmfTrace<?>[] traces) {
+//        this(traces, new TmfContext[traces.length]);
+//    }
 
     private ITmfContext[] cloneContexts() {
         final ITmfContext[] contexts = new ITmfContext[fContexts.length];
@@ -114,9 +117,9 @@ public class TmfExperimentContext extends TmfContext {
     // Accessors
     // ------------------------------------------------------------------------
 
-    public ITmfTrace<?>[] getTraces() {
-        return fTraces;
-    }
+//    public ITmfTrace<?>[] getTraces() {
+//        return fTraces;
+//    }
 
     public ITmfContext[] getContexts() {
         return fContexts;
@@ -141,8 +144,8 @@ public class TmfExperimentContext extends TmfContext {
     @Override
     public int hashCode() {
         int result = 17;
-        for (int i = 0; i < fTraces.length; i++) {
-            result = 37 * result + fTraces[i].hashCode();
+        for (int i = 0; i < fContexts.length; i++) {
+//            result = 37 * result + fTraces[i].hashCode();
             result = 37 * result + fContexts[i].hashCode();
         }
         return result;
@@ -159,8 +162,8 @@ public class TmfExperimentContext extends TmfContext {
         final TmfExperimentContext o = (TmfExperimentContext) other;
         boolean isEqual = true;
         int i = 0;
-        while (isEqual && (i < fTraces.length)) {
-            isEqual &= fTraces[i].equals(o.fTraces[i]);
+        while (isEqual && (i < fContexts.length)) {
+//            isEqual &= fTraces[i].equals(o.fTraces[i]);
             isEqual &= fContexts[i].equals(o.fContexts[i]);
             i++;
         }
index f3bd092c0d8ea212a2399172805bc71e1976569e..57ca5d48bb848e26bec2746a65c77b1189da385b 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  * 
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.experiment;
 
-import java.util.Arrays;
-
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 
 /**
- * <b><u>TmfExperimentLocation</u></b>
+ * The experiment location in TMF.
+ * <p>
+ * An experiment location is actually the set of locations of the traces it
+ * contains. By setting the individual traces to their corresponding locations,
+ * the experiment can be positioned to read the next chronological event.
  * <p>
- * The experiment location is the set of its traces' locations.
+ * It is the responsibility of the user the individual trace locations are valid
+ * and that they are matched to the correct trace.
+ * 
+ * @version 1.0
+ * @author Francois Chouinard
+ * 
+ * @see TmfLocationArray
  */
-public class TmfExperimentLocation extends TmfLocation<TmfLocationArray> {
+public class TmfExperimentLocation extends TmfLocation<TmfLocationArray> implements Cloneable {
 
-    private long[] fRanks;
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
 
-       public TmfExperimentLocation(TmfLocationArray locations, long[] ranks) {
-               super(locations);
-               fRanks = ranks;
-       }
+    /**
+     * The standard constructor
+     * 
+     * @param locations the set of trace locations
+     */
+    public TmfExperimentLocation(TmfLocationArray locations) {
+        super(locations);
+    }
 
-       @Override
-       public TmfExperimentLocation clone() {
-               super.clone();  // To keep FindBugs happy
-               TmfLocationArray array = (TmfLocationArray) getLocation();
-               TmfLocationArray clones = array.clone();
-               return new TmfExperimentLocation(clones, fRanks.clone());
-       }
+    /**
+     * The copy constructor
+     * 
+     * @param location the other experiment location
+     */
+    public TmfExperimentLocation(TmfExperimentLocation location) {
+        this(location.getLocation());
+    }
 
-       @Override
-    @SuppressWarnings("nls")
-       public String toString() {
-               StringBuilder result = new StringBuilder("[TmfExperimentLocation");
-               TmfLocationArray array = (TmfLocationArray) getLocation();
-               for (int i = 0; i < array.locations.length; i++) {
-                       result.append("[" + array.locations[i].toString() + "," + fRanks[i] + "]");
-               }
-               result.append("]");
-               return result.toString();
-       }
+    // ------------------------------------------------------------------------
+    // Cloneable
+    // ------------------------------------------------------------------------
 
-       public long[] getRanks() {
-        return fRanks;
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#clone()
+     */
+    @Override
+    public TmfExperimentLocation clone() {
+//        super.clone(); // To keep FindBugs happy
+        TmfLocationArray array = (TmfLocationArray) getLocation();
+        TmfLocationArray clones = array.clone();
+        return new TmfExperimentLocation(clones);
     }
 
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#toString()
+     */
+    @Override
+    @SuppressWarnings("nls")
+    public String toString() {
+        StringBuilder result = new StringBuilder("[TmfExperimentLocation");
+        ITmfLocation<? extends Comparable<?>>[] locations = ((TmfLocationArray) getLocation()).getLocations();
+        for (ITmfLocation<?> location : locations) {
+            result.append("[" + location.toString() + "]");
+        }
+        result.append("]");
+        return result.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#hashCode()
+     */
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + Arrays.hashCode(fRanks);
-        return result;
+        return super.hashCode();
     }
 
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#equals(java.lang.Object)
+     */
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (!super.equals(obj))
-            return false;
-        if (getClass() != obj.getClass())
+        }
+        if (!super.equals(obj)) {
             return false;
-        TmfExperimentLocation other = (TmfExperimentLocation) obj;
-        if (!Arrays.equals(fRanks, other.fRanks))
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         return true;
     }
 
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfLegacyExperiment.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfLegacyExperiment.java
new file mode 100644 (file)
index 0000000..2de95e3
--- /dev/null
@@ -0,0 +1,960 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.experiment;
+
+import java.util.Collections;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+
+/**
+ * <b><u>TmfLegacyExperiment</u></b>
+ * <p>
+ * TmfExperiment presents a time-ordered, unified view of a set of TmfTraces
+ * that are part of a tracing experiment.
+ * <p>
+ */
+public class TmfLegacyExperiment<T extends ITmfEvent> extends TmfExperiment<T> {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+//    // The currently selected experiment
+//    protected static TmfExperiment<?> fCurrentExperiment = null;
+//
+//    // The set of traces that constitute the experiment
+//    protected ITmfTrace<T>[] fTraces;
+
+//    // The total number of events
+//    protected long fNbEvents;
+
+//    // The experiment time range
+//    protected TmfTimeRange fTimeRange;
+
+    // The experiment reference timestamp (default: ZERO)
+    protected ITmfTimestamp fEpoch;
+
+    // The experiment index
+    protected Vector<TmfCheckpoint> fCheckpoints;
+
+    // The current experiment context
+    protected TmfExperimentContext fExperimentContext;
+
+//    // Flag to initialize only once
+//    private boolean fInitialized = false;
+
+//    // The experiment bookmarks file
+//    private IFile fBookmarksFile;
+
+    // The properties resource
+    private IResource fResource;
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
+    @Override
+    public TmfLegacyExperiment<T> clone() throws CloneNotSupportedException {
+        throw new CloneNotSupportedException();
+    }
+
+    @Override
+    public boolean validate(final IProject project, final String path) {
+        return true;
+    }
+
+    /**
+     * @param type
+     * @param id
+     * @param traces
+     * @param epoch
+     * @param indexPageSize
+     */
+    public TmfLegacyExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
+            final int indexPageSize)
+    {
+        this(type, id, traces, TmfTimestamp.ZERO, indexPageSize, false);
+    }
+
+    public TmfLegacyExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
+            final int indexPageSize, final boolean preIndexExperiment)
+    {
+        super(type, id, traces, epoch, indexPageSize, false);
+//        fNbEvents = 0;
+        setTimeRange(TmfTimeRange.NULL_RANGE);
+        fEpoch = epoch;
+        fCheckpoints = new Vector<TmfCheckpoint>();
+        if (preIndexExperiment) {
+            indexExperiment(true, 0, TmfTimeRange.ETERNITY);
+        }
+    }
+
+//    protected TmfLegacyExperiment(final String id, final Class<T> type) {
+//        super(id, type);
+//    }
+
+    /**
+     * @param type
+     * @param id
+     * @param traces
+     */
+    public TmfLegacyExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces) {
+        this(type, id, traces, TmfTimestamp.ZERO, DEFAULT_INDEX_PAGE_SIZE);
+    }
+
+    /**
+     * @param type
+     * @param id
+     * @param traces
+     * @param indexPageSize
+     */
+    public TmfLegacyExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final int indexPageSize) {
+        this(type, id, traces, TmfTimestamp.ZERO, indexPageSize);
+    }
+
+    /**
+     * Clears the experiment
+     */
+    @Override
+    @SuppressWarnings( "rawtypes" )
+    public synchronized void dispose() {
+
+        final TmfExperimentDisposedSignal<T> signal = new TmfExperimentDisposedSignal<T>(this, this);
+        broadcast(signal);
+        if (fCurrentExperiment == this)
+            fCurrentExperiment = null;
+
+        if (fTraces != null) {
+            for (final ITmfTrace trace : fTraces)
+                trace.dispose();
+            fTraces = null;
+        }
+        if (fCheckpoints != null)
+            fCheckpoints.clear();
+        super.dispose();
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfTrace
+    // ------------------------------------------------------------------------
+
+//    @Override
+//    public Class<T> getEventType() {
+//        return fType;
+//    }
+//
+//    @Override
+//    public long getNbEvents() {
+//        return fNbEvents;
+//    }
+//
+//    @Override
+//    public int getCacheSize() {
+//        return fIndexPageSize;
+//    }
+//
+//    @Override
+//    public TmfTimeRange getTimeRange() {
+//        return fTimeRange;
+//    }
+//
+//    @Override
+//    public ITmfTimestamp getStartTime() {
+//        return fTimeRange.getStartTime();
+//    }
+//
+//    @Override
+//    public ITmfTimestamp getEndTime() {
+//        return fTimeRange.getEndTime();
+//    }
+
+//    public Vector<TmfCheckpoint> getCheckpoints() {
+//        return fCheckpoints;
+//    }
+
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
+//    public static void setCurrentExperiment(final TmfExperiment<?> experiment) {
+//        if (fCurrentExperiment != null && fCurrentExperiment != experiment)
+//            fCurrentExperiment.dispose();
+//        fCurrentExperiment = experiment;
+//    }
+//
+//    public static TmfExperiment<?> getCurrentExperiment() {
+//        return fCurrentExperiment;
+//    }
+
+    public ITmfTimestamp getEpoch() {
+        return fEpoch;
+    }
+
+    @Override
+    public ITmfTrace<T>[] getTraces() {
+        return fTraces;
+    }
+
+    /**
+     * Returns the timestamp of the event at the requested index. If none,
+     * returns null.
+     * 
+     * @param index the event index (rank)
+     * @return the corresponding event timestamp
+     */
+    @Override
+    public ITmfTimestamp getTimestamp(final int index) {
+        final TmfExperimentContext context = seekEvent(index);
+        final ITmfEvent event = getNext(context);
+        return (event != null) ? event.getTimestamp() : null;
+    }
+
+    // ------------------------------------------------------------------------
+    // Operators
+    // ------------------------------------------------------------------------
+
+    /**
+     * Update the global time range
+     */
+    protected void updateTimeRange() {
+        ITmfTimestamp startTime = getStartTime();
+        ITmfTimestamp endTime = getEndTime();
+
+        for (final ITmfTrace<T> trace : fTraces) {
+            final ITmfTimestamp traceStartTime = trace.getStartTime();
+            if (traceStartTime.compareTo(startTime, true) < 0)
+                startTime = traceStartTime;
+            final ITmfTimestamp traceEndTime = trace.getEndTime();
+            if (traceEndTime.compareTo(endTime, true) > 0)
+                endTime = traceEndTime;
+        }
+        setTimeRange(new TmfTimeRange(startTime, endTime));
+    }
+
+    // ------------------------------------------------------------------------
+    // TmfProvider
+    // ------------------------------------------------------------------------
+
+    @Override
+    public ITmfContext armRequest(final ITmfDataRequest<T> request) {
+        //             Tracer.trace("Ctx: Arming request - start");
+        ITmfTimestamp timestamp = (request instanceof ITmfEventRequest<?>) ? ((ITmfEventRequest<T>) request).getRange().getStartTime() : null;
+        if (TmfTimestamp.BIG_BANG.equals(timestamp) || request.getIndex() > 0)
+            timestamp = null; // use request index
+        TmfExperimentContext context = null;
+        if (timestamp != null) {
+            // seek by timestamp
+            context = seekEvent(timestamp);
+            ((ITmfEventRequest<T>) request).setStartIndex((int) context.getRank());
+        } else // Seek by rank
+            if ((fExperimentContext != null) && fExperimentContext.getRank() == request.getIndex())
+                // We are already at the right context -> no need to seek
+                context = fExperimentContext;
+            else
+                context = seekEvent(request.getIndex());
+        // Tracer.trace("Ctx: Arming request - done");
+        return context;
+    }
+
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public T getNext(final ITmfContext context) {
+//        if (context instanceof TmfExperimentContext)
+//            return (T) readNextEvent(context);
+//        return null;
+//    }
+
+    // ------------------------------------------------------------------------
+    // ITmfTrace trace positioning
+    // ------------------------------------------------------------------------
+
+    // Returns a brand new context based on the location provided
+    // and initializes the event queues
+    @Override
+    public synchronized TmfExperimentContext seekEvent(final ITmfLocation<?> location) {
+        // Validate the location
+        if (location != null && !(location instanceof TmfExperimentLocation))
+            return null; // Throw an exception?
+
+        if (fTraces == null)
+            return null;
+
+        // Instantiate the location
+        final TmfExperimentLocation expLocation = (location == null) ? new TmfExperimentLocation(new TmfLocationArray(
+                new ITmfLocation<?>[fTraces.length])) : (TmfExperimentLocation) location.clone();
+
+        // Create and populate the context's traces contexts
+        final TmfExperimentContext context = new TmfExperimentContext(new ITmfContext[fTraces.length]);
+        // Tracer.trace("Ctx: SeekLocation - start");
+
+//        long rank = 0;
+        for (int i = 0; i < fTraces.length; i++) {
+            // Get the relevant trace attributes
+            final ITmfLocation<?> traceLocation = expLocation.getLocation().getLocations()[i];
+//            final long traceRank = expLocation.getRanks()[i];
+
+            // Set the corresponding sub-context
+            context.getContexts()[i] = fTraces[i].seekEvent(traceLocation);
+//            context.getContexts()[i].setRank(traceRank);
+//            rank += traceRank;
+
+            // Set the trace location and read the corresponding event
+            /*
+             * The (TmfContext) cast should be safe since we created 'context'
+             * ourselves higher up.
+             */
+            expLocation.getLocation().getLocations()[i] = context.getContexts()[i].getLocation().clone();
+            context.getEvents()[i] = fTraces[i].getNext(context.getContexts()[i]);
+        }
+
+        // Tracer.trace("Ctx: SeekLocation - done");
+
+        // Finalize context
+        context.setLocation(expLocation);
+        context.setLastTrace(TmfExperimentContext.NO_TRACE);
+//        context.setRank(rank);
+        context.setRank(ITmfContext.UNKNOWN_RANK);
+
+        fExperimentContext = context;
+
+        return context;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools .tmf.event.TmfTimestamp)
+     */
+    @Override
+    public synchronized TmfExperimentContext seekEvent(ITmfTimestamp timestamp) {
+
+        //             Tracer.trace("Ctx: seekEvent(TS) - start");
+
+        if (timestamp == null)
+            timestamp = TmfTimestamp.BIG_BANG;
+
+        // First, find the right checkpoint
+        int index = Collections.binarySearch(fCheckpoints, new TmfCheckpoint(timestamp, null));
+
+        // In the very likely case that the checkpoint was not found, bsearch
+        // returns its negated would-be location (not an offset...). From that
+        // index, we can then position the stream and get the event.
+        if (index < 0)
+            index = Math.max(0, -(index + 2));
+
+        // Position the experiment at the checkpoint
+        ITmfLocation<?> location;
+        synchronized (fCheckpoints) {
+            if (fCheckpoints.size() > 0) {
+                if (index >= fCheckpoints.size())
+                    index = fCheckpoints.size() - 1;
+                location = fCheckpoints.elementAt(index).getLocation();
+            } else
+                location = null;
+        }
+
+        final TmfExperimentContext context = seekEvent(location);
+        context.setRank((long) index * getCacheSize());
+
+        // And locate the event
+        ITmfEvent event = parseEvent(context);
+        while ((event != null) && (event.getTimestamp().compareTo(timestamp, false) < 0)) {
+            getNext(context);
+            event = parseEvent(context);
+        }
+
+        if (event == null) {
+            context.setLocation(null);
+            context.setRank(ITmfContext.UNKNOWN_RANK);
+        }
+
+        return context;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(long)
+     */
+    @Override
+    public synchronized TmfExperimentContext seekEvent(final long rank) {
+
+        //             Tracer.trace("Ctx: seekEvent(rank) - start");
+
+        // Position the stream at the previous checkpoint
+        int fIndexPageSize = getCacheSize();
+        int index = (int) rank / fIndexPageSize;
+        ITmfLocation<?> location;
+        synchronized (fCheckpoints) {
+            if (fCheckpoints.size() == 0)
+                location = null;
+            else {
+                if (index >= fCheckpoints.size())
+                    index = fCheckpoints.size() - 1;
+                location = fCheckpoints.elementAt(index).getLocation();
+            }
+        }
+
+        final TmfExperimentContext context = seekEvent(location);
+        context.setRank((long) index * fIndexPageSize);
+
+        // And locate the event
+        ITmfEvent event = parseEvent(context);
+        long pos = context.getRank();
+        while ((event != null) && (pos++ < rank)) {
+            getNext(context);
+            event = parseEvent(context);
+        }
+
+        if (event == null) {
+            context.setLocation(null);
+            context.setRank(ITmfContext.UNKNOWN_RANK);
+        }
+
+        return context;
+    }
+
+    @Override
+    public TmfContext seekEvent(final double ratio) {
+        final TmfContext context = seekEvent((long) (ratio * getNbEvents()));
+        return context;
+    }
+
+    @Override
+    public double getLocationRatio(final ITmfLocation<?> location) {
+        if (location instanceof TmfExperimentLocation)
+            return (double) seekEvent(location).getRank() / getNbEvents();
+        return 0;
+    }
+
+    @Override
+    public ITmfLocation<?> getCurrentLocation() {
+        if (fExperimentContext != null)
+            return fExperimentContext.getLocation();
+        return null;
+    }
+
+    // private void dumpContext(TmfExperimentContext context, boolean isBefore) {
+    //         TmfContext context0 = context.getContexts()[0];
+    //         TmfEvent   event0   = context.getEvents()[0];
+    //         TmfExperimentLocation location0 = (TmfExperimentLocation) context.getLocation();
+    //         long       rank0    = context.getRank();
+    //         int        trace    = context.getLastTrace();
+    //
+    //         StringBuffer result = new StringBuffer("Ctx: " + (isBefore ? "B " : "A "));
+    //
+    //         result.append("[Ctx: fLoc= " + context0.getLocation().toString() + ", fRnk= " + context0.getRank() + "] ");
+    //         result.append("[Evt: " + event0.getTimestamp().toString() + "] ");
+    //         result.append("[Loc: fLoc= " + location0.getLocation()[0].toString() + ", fRnk= " + location0.getRanks()[0] + "] ");
+    //         result.append("[Rnk: " + rank0 + "], [Trc: " + trace + "]");
+    //         Tracer.trace(result.toString());
+    // }
+
+    /**
+     * Scan the next events from all traces and return the next one in
+     * chronological order.
+     * 
+     * @param context the trace context
+     * @return the next event
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public synchronized T getNext(final ITmfContext context) {
+
+        // Validate the context
+        if (!(context instanceof TmfExperimentContext))
+            return null; // Throw an exception?
+
+        if (!context.equals(fExperimentContext))
+            // Tracer.trace("Ctx: Restoring context");
+            fExperimentContext = seekEvent(context.getLocation());
+
+        final TmfExperimentContext expContext = (TmfExperimentContext) context;
+
+        //             dumpContext(expContext, true);
+
+        // If an event was consumed previously, get the next one from that trace
+        final int lastTrace = expContext.getLastTrace();
+        if (lastTrace != TmfExperimentContext.NO_TRACE) {
+            final ITmfContext traceContext = expContext.getContexts()[lastTrace];
+            expContext.getEvents()[lastTrace] = fTraces[lastTrace].getNext(traceContext);
+            expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+        }
+
+        // Scan the candidate events and identify the "next" trace to read from
+        final ITmfEvent eventArray[] = expContext.getEvents();
+        if (eventArray == null)
+            return null;
+        int trace = TmfExperimentContext.NO_TRACE;
+        ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
+        if (eventArray.length == 1) {
+            if (eventArray[0] != null) {
+                timestamp = eventArray[0].getTimestamp();
+                trace = 0;
+            }
+        } else
+            for (int i = 0; i < eventArray.length; i++) {
+                final ITmfEvent event = eventArray[i];
+                if (event != null && event.getTimestamp() != null) {
+                    final ITmfTimestamp otherTS = event.getTimestamp();
+                    if (otherTS.compareTo(timestamp, true) < 0) {
+                        trace = i;
+                        timestamp = otherTS;
+                    }
+                }
+            }
+        // Update the experiment context and set the "next" event
+        T event = null;
+        if (trace != TmfExperimentContext.NO_TRACE) {
+            updateIndex(expContext, timestamp);
+
+            final ITmfContext traceContext = expContext.getContexts()[trace];
+            final TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
+            //         expLocation.getLocation()[trace] = traceContext.getLocation().clone();
+            expLocation.getLocation().getLocations()[trace] = traceContext.getLocation().clone();
+
+            //         updateIndex(expContext, timestamp);
+
+//            expLocation.getRanks()[trace] = traceContext.getRank();
+            expContext.setLastTrace(trace);
+            expContext.increaseRank();
+            event = (T) expContext.getEvents()[trace];
+            fExperimentContext = expContext;
+        }
+
+        //             if (event != null) {
+        //             Tracer.trace("Exp: " + (expContext.getRank() - 1) + ": " + event.getTimestamp().toString());
+        //             dumpContext(expContext, false);
+        //             Tracer.trace("Ctx: Event returned= " + event.getTimestamp().toString());
+        //             }
+
+        return event;
+    }
+
+    public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
+        // Build the index as we go along
+        final long rank = context.getRank();
+        if (context.hasValidRank() && (rank % getCacheSize()) == 0) {
+            // Determine the table position
+            final long position = rank / getCacheSize();
+            // Add new entry at proper location (if empty)
+            if (fCheckpoints.size() == position) {
+                final ITmfLocation<?> location = context.getLocation().clone();
+                fCheckpoints.add(new TmfCheckpoint(timestamp.clone(), location));
+                //                System.out.println(this + "[" + (fCheckpoints.size() - 1) + "] " + timestamp + ", "
+                //                        + location.toString());
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public T parseEvent(final ITmfContext context) {
+
+        // Validate the context
+        if (!(context instanceof TmfExperimentContext))
+            return null; // Throw an exception?
+
+        if (!context.equals(fExperimentContext))
+            // Tracer.trace("Ctx: Restoring context");
+            seekEvent(context.getLocation());
+
+        final TmfExperimentContext expContext = (TmfExperimentContext) context;
+
+        // If an event was consumed previously, get the next one from that trace
+        final int lastTrace = expContext.getLastTrace();
+        if (lastTrace != TmfExperimentContext.NO_TRACE) {
+            final ITmfContext traceContext = expContext.getContexts()[lastTrace];
+            expContext.getEvents()[lastTrace] = fTraces[lastTrace].getNext(traceContext);
+            expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+            fExperimentContext = (TmfExperimentContext) context;
+        }
+
+        // Scan the candidate events and identify the "next" trace to read from
+        int trace = TmfExperimentContext.NO_TRACE;
+        ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH;
+        for (int i = 0; i < fTraces.length; i++) {
+            final ITmfEvent event = expContext.getEvents()[i];
+            if (event != null && event.getTimestamp() != null) {
+                final ITmfTimestamp otherTS = event.getTimestamp();
+                if (otherTS.compareTo(timestamp, true) < 0) {
+                    trace = i;
+                    timestamp = otherTS;
+                }
+            }
+        }
+
+        T event = null;
+        if (trace != TmfExperimentContext.NO_TRACE)
+            event = (T) expContext.getEvents()[trace];
+
+        return event;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    @SuppressWarnings("nls")
+    public String toString() {
+        return "[TmfExperiment (" + getName() + ")]";
+    }
+
+    // ------------------------------------------------------------------------
+    // Indexing
+    // ------------------------------------------------------------------------
+
+//    private synchronized void initializeStreamingMonitor() {
+//        if (fInitialized)
+//            return;
+//        fInitialized = true;
+//
+//        if (getStreamingInterval() == 0) {
+//            final TmfContext context = seekEvent(0);
+//            final ITmfEvent event = getNext(context);
+//            if (event == null)
+//                return;
+//            final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
+//            final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
+//
+//            // Broadcast in separate thread to prevent deadlock
+//            new Thread() {
+//                @Override
+//                public void run() {
+//                    broadcast(signal);
+//                }
+//            }.start();
+//            return;
+//        }
+//
+//        final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { ////$NON-NLS-1$
+//            private ITmfTimestamp safeTimestamp = null;
+//            private TmfTimeRange timeRange = null;
+//
+//            @Override
+//            public void run() {
+//                while (!fExecutor.isShutdown()) {
+//                    if (!isIndexingBusy()) {
+//                        ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
+//                        ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
+//                        for (final ITmfTrace<T> trace : fTraces) {
+//                            if (trace.getStartTime().compareTo(startTimestamp) < 0)
+//                                startTimestamp = trace.getStartTime();
+//                            if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0)
+//                                endTimestamp = trace.getEndTime();
+//                        }
+//                        if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0)
+//                            timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
+//                        else
+//                            timeRange = null;
+//                        safeTimestamp = endTimestamp;
+//                        if (timeRange != null) {
+//                            final TmfExperimentRangeUpdatedSignal signal =
+//                                    new TmfExperimentRangeUpdatedSignal(TmfLegacyExperiment.this, TmfLegacyExperiment.this, timeRange);
+//                            broadcast(signal);
+//                        }
+//                    }
+//                    try {
+//                        Thread.sleep(getStreamingInterval());
+//                    } catch (final InterruptedException e) {
+//                        e.printStackTrace();
+//                    }
+//                }
+//            }
+//        };
+//        thread.start();
+//    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getStreamingInterval()
+     */
+    @Override
+    public long getStreamingInterval() {
+        long interval = 0;
+        for (final ITmfTrace<T> trace : fTraces)
+            interval = Math.max(interval, trace.getStreamingInterval());
+        return interval;
+    }
+
+    /*
+     * The experiment holds the globally ordered events of its set of traces. It
+     * is expected to provide access to each individual event by index i.e. it
+     * must be possible to request the Nth event of the experiment.
+     * 
+     * The purpose of the index is to keep the information needed to rapidly
+     * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE
+     * event).
+     */
+
+    // The index page size
+    private static final int DEFAULT_INDEX_PAGE_SIZE = 5000;
+//    protected int fIndexPageSize;
+    protected boolean fIndexing = false;
+    protected TmfTimeRange fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
+
+//    private Integer fEndSynchReference;
+
+    // private static BufferedWriter fEventLog = null;
+    // private static BufferedWriter openLogFile(String filename) {
+    //         BufferedWriter outfile = null;
+    //         try {
+    //                 outfile = new BufferedWriter(new FileWriter(filename));
+    //         } catch (IOException e) {
+    //                 e.printStackTrace();
+    //         }
+    //         return outfile;
+    // }
+
+//    protected boolean isIndexingBusy() {
+//        synchronized (fCheckpoints) {
+//            return fIndexing;
+//        }
+//    }
+
+    @SuppressWarnings("unchecked")
+    private void indexExperiment(final boolean waitForCompletion, final int index, final TmfTimeRange timeRange) {
+
+        synchronized (fCheckpoints) {
+            if (fIndexing)
+                return;
+            fIndexing = true;
+        }
+
+        final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
+
+            @Override
+            protected IStatus run(final IProgressMonitor monitor) {
+                while (!monitor.isCanceled())
+                    try {
+                        Thread.sleep(100);
+                    } catch (final InterruptedException e) {
+                        return Status.OK_STATUS;
+                    }
+                monitor.done();
+                return Status.OK_STATUS;
+            }
+        };
+        job.schedule();
+
+        //             fEventLog = openLogFile("TraceEvent.log");
+        //        System.out.println(System.currentTimeMillis() + ": Experiment indexing started");
+
+        final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, timeRange, index,
+                TmfDataRequest.ALL_DATA,
+                getCacheSize(), ITmfDataRequest.ExecutionType.BACKGROUND) { // PATA
+            // FOREGROUND
+
+            //            long indexingStart = System.nanoTime();
+
+            ITmfTimestamp startTime = (getTimeRange().equals(TmfTimeRange.NULL_RANGE)) ? null : getStartTime();
+            ITmfTimestamp lastTime = (getTimeRange().equals(TmfTimeRange.NULL_RANGE)) ? null : getEndTime();
+            long initialNbEvents = getNbEvents();
+
+            @Override
+            public void handleStarted() {
+                super.handleStarted();
+            }
+
+            @Override
+            public void handleData(final ITmfEvent event) {
+                super.handleData(event);
+                if (event != null) {
+                    final ITmfTimestamp ts = event.getTimestamp();
+                    if (startTime == null)
+                        startTime = ts.clone();
+                    lastTime = ts.clone();
+                }
+                if ((getNbRead() % getCacheSize()) == 1 && getNbRead() != 1)
+                    updateExperiment();
+            }
+
+            @Override
+            public void handleSuccess() {
+                //                long indexingEnd = System.nanoTime();
+
+                // if the end time is a real value then it is the streaming safe
+                // time stamp
+                // set the last time to the safe time stamp to prevent
+                // unnecessary indexing requests
+                if (getRange().getEndTime() != TmfTimestamp.BIG_CRUNCH)
+                    lastTime = getRange().getEndTime();
+                updateExperiment();
+                //                System.out.println(System.currentTimeMillis() + ": Experiment indexing completed");
+
+                //                long average = (indexingEnd - indexingStart) / fNbEvents;
+                //                System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed="
+                //                        + (indexingEnd * 1.0 - indexingStart) / 1000000000);
+                //                System.out.println(getName() + ": nbEvents=" + fNbEvents + " (" + (average / 1000) + "."
+                //                        + (average % 1000) + " us/evt)");
+                super.handleSuccess();
+            }
+
+            @Override
+            public void handleCompleted() {
+                job.cancel();
+                super.handleCompleted();
+                synchronized (fCheckpoints) {
+                    fIndexing = false;
+                    if (!(fIndexingPendingRange.equals(TmfTimeRange.NULL_RANGE))) {
+                        indexExperiment(false, (int) getNbEvents(), fIndexingPendingRange);
+                        fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
+                    }
+                }
+            }
+
+            private void updateExperiment() {
+                final int nbRead = getNbRead();
+                if (startTime != null) {
+                    setTimeRange(new TmfTimeRange(startTime, lastTime.clone()));
+                }
+                if (nbRead != 0) {
+                    //                                 updateTimeRange();
+                    //                                 updateNbEvents();
+                    setNbEvents(initialNbEvents + nbRead);
+                    notifyListeners();
+                }
+            }
+        };
+
+        sendRequest((ITmfDataRequest<T>) request);
+        if (waitForCompletion)
+            try {
+                request.waitForCompletion();
+            } catch (final InterruptedException e) {
+                e.printStackTrace();
+            }
+    }
+
+    protected void notifyListeners() {
+        broadcast(new TmfExperimentUpdatedSignal(this, this)); // , null));
+        // broadcast(new TmfExperimentRangeUpdatedSignal(this, this,
+        // fTimeRange)); // , null));
+    }
+
+    // ------------------------------------------------------------------------
+    // Signal handlers
+    // ------------------------------------------------------------------------
+
+//    @TmfSignalHandler
+//    public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
+//        final TmfExperiment<?> experiment = signal.getExperiment();
+//        if (experiment == this) {
+//            setCurrentExperiment(experiment);
+//            fEndSynchReference = Integer.valueOf(signal.getReference());
+//        }
+//    }
+//
+//    @TmfSignalHandler
+//    public void endSync(final TmfEndSynchSignal signal) {
+//        if (fEndSynchReference != null && fEndSynchReference.intValue() == signal.getReference()) {
+//            fEndSynchReference = null;
+//            initializeStreamingMonitor();
+//        }
+//    }
+//
+//    @TmfSignalHandler
+//    public void experimentUpdated(final TmfExperimentUpdatedSignal signal) {
+//    }
+//
+    @Override
+    @TmfSignalHandler
+    public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
+        if (signal.getExperiment() == this)
+            indexExperiment(false, (int) getNbEvents(), signal.getRange());
+    }
+
+    @Override
+    @TmfSignalHandler
+    public void traceUpdated(final TmfTraceUpdatedSignal signal) {
+        for (final ITmfTrace<T> trace : fTraces)
+            if (trace == signal.getTrace()) {
+                synchronized (fCheckpoints) {
+                    if (fIndexing) {
+                        if (fIndexingPendingRange.equals(TmfTimeRange.NULL_RANGE))
+                            fIndexingPendingRange = signal.getRange();
+                        else {
+                            ITmfTimestamp startTime = fIndexingPendingRange.getStartTime();
+                            ITmfTimestamp endTime = fIndexingPendingRange.getEndTime();
+                            if (signal.getRange().getStartTime().compareTo(startTime) < 0)
+                                startTime = signal.getRange().getStartTime();
+                            if (signal.getRange().getEndTime().compareTo(endTime) > 0)
+                                endTime = signal.getRange().getEndTime();
+                            fIndexingPendingRange = new TmfTimeRange(startTime, endTime);
+                        }
+                        return;
+                    }
+                }
+                indexExperiment(false, (int) getNbEvents(), signal.getRange());
+                return;
+            }
+    }
+
+    @Override
+    public String getPath() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+//    /**
+//     * Set the file to be used for bookmarks on this experiment
+//     * 
+//     * @param file the bookmarks file
+//     */
+//    public void setBookmarksFile(final IFile file) {
+//        fBookmarksFile = file;
+//    }
+//
+//    /**
+//     * Get the file used for bookmarks on this experiment
+//     * 
+//     * @return the bookmarks file or null if none is set
+//     */
+//    public IFile getBookmarksFile() {
+//        return fBookmarksFile;
+//    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
+     */
+    @Override
+    public IResource getResource() {
+        return fResource;
+    }
+}
index 605be73409e037131da4e350e6f70e39d10908c7..f01b56ca357e71a83448aa913d26d46657a1b774 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 2012 Ericsson
  * 
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -7,7 +7,8 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Patrick Tasse - Initial API and implementation
+ * Patrick Tasse - Initial API and implementation
+ * Francois Chouinard - Put in shape for 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.experiment;
@@ -16,60 +17,124 @@ import java.util.Arrays;
 
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 
+/**
+ * A convenience class to store trace location arrays. The main purpose is to
+ * provide a Comparable implementation for TmfExperimentLocation.
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
 public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable {
-       public ITmfLocation<? extends Comparable<?>>[] locations;
-       
-       public TmfLocationArray(ITmfLocation<? extends Comparable<?>>[] locations) {
-               this.locations = locations;
-       }
-       
-       @SuppressWarnings({ "unchecked", "rawtypes" })
-       @Override
-       public int compareTo(TmfLocationArray o) {
-               for (int i = 0; i < locations.length; i++) {
-                       ITmfLocation<? extends Comparable> l1 = (ITmfLocation<? extends Comparable>) locations[i].getLocation();
-                       ITmfLocation<? extends Comparable> l2 = (ITmfLocation<? extends Comparable>) o.locations[i].getLocation();
-                       int result = l1.getLocation().compareTo(l2.getLocation());
-                       if (result != 0) {
-                               return result;
-                       }
-               }
-               return 0;
-       }
-
-       /* (non-Javadoc)
-        * @see java.lang.Object#clone()
-        */
-       @Override
-       protected TmfLocationArray clone() {
-               ITmfLocation<? extends Comparable<?>>[] clones = (ITmfLocation<? extends Comparable<?>>[]) new ITmfLocation<?>[locations.length];
-               for (int i = 0; i < locations.length; i++) {
-                       clones[i] = locations[i].clone();
-               }
-               return new TmfLocationArray(clones);
-       }
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    private ITmfLocation<? extends Comparable<?>>[] fLocations;
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
+    /**
+     * The standard constructor
+     * 
+     * @param locations the locations
+     */
+    public TmfLocationArray(ITmfLocation<? extends Comparable<?>>[] locations) {
+        fLocations = locations;
+    }
+
+    // ------------------------------------------------------------------------
+    // Getters
+    // ------------------------------------------------------------------------
+
+    /**
+     * The standard constructor
+     * 
+     * @param locations the locations
+     */
+    public ITmfLocation<? extends Comparable<?>>[] getLocations() {
+        return fLocations;
+    }
+
+    // ------------------------------------------------------------------------
+    // Cloneable
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#clone()
+     */
+    @Override
+    public TmfLocationArray clone() {
+        ITmfLocation<? extends Comparable<?>>[] clones = (ITmfLocation<? extends Comparable<?>>[]) new ITmfLocation<?>[fLocations.length];
+        for (int i = 0; i < fLocations.length; i++) {
+            clones[i] = fLocations[i].clone();
+        }
+        return new TmfLocationArray(clones);
+    }
+
+    // ------------------------------------------------------------------------
+    // Comparable
+    // ------------------------------------------------------------------------
 
+    @Override
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public int compareTo(TmfLocationArray o) {
+        for (int i = 0; i < fLocations.length; i++) {
+            ITmfLocation<? extends Comparable> l1 = (ITmfLocation<? extends Comparable>) fLocations[i].getLocation();
+            ITmfLocation<? extends Comparable> l2 = (ITmfLocation<? extends Comparable>) o.fLocations[i].getLocation();
+            int result = l1.getLocation().compareTo(l2.getLocation());
+            if (result != 0) {
+                return result;
+            }
+        }
+        return 0;
+    }
+
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + Arrays.hashCode(locations);
+        result = prime * result + Arrays.hashCode(fLocations);
         return result;
     }
 
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         TmfLocationArray other = (TmfLocationArray) obj;
-        if (!Arrays.equals(locations, other.locations))
+        if (!Arrays.equals(fLocations, other.fLocations)) {
             return false;
+        }
         return true;
     }
 
-}
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    @SuppressWarnings("nls")
+    public String toString() {
+        return "TmfLocationArray [locations=" + Arrays.toString(fLocations) + "]";
+    }
 
+}
index e36626b14b42a09c994786396762d3a6e613ad98..796b144eac2bdb2c3aa6cb4f348126fc80920633 100644 (file)
@@ -18,15 +18,13 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
  * The basic trace checkpoint structure in TMF. The purpose of the checkpoint is
  * to associate a trace location to an event timestamp.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
- * @see TmfCheckpoint
  * @see ITmfTimestamp
  * @see ITmfLocation
  */
-public interface ITmfCheckpoint extends Cloneable, Comparable<ITmfCheckpoint> {
+public interface ITmfCheckpoint extends Comparable<ITmfCheckpoint> {
 
     // ------------------------------------------------------------------------
     // Getters
@@ -42,10 +40,6 @@ public interface ITmfCheckpoint extends Cloneable, Comparable<ITmfCheckpoint> {
      */
     public ITmfLocation<? extends Comparable<?>> getLocation();
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
     /**
      * @return a clone of the checkpoint
      */
index 4ba1ec14d9fa2d353e4bcf35160d0d1924be900c..cfee4087b570ca957267148f9de9128332cb8b90 100644 (file)
@@ -15,18 +15,18 @@ package org.eclipse.linuxtools.tmf.core.trace;
 
 /**
  * The basic trace context structure in TMF. The purpose of the context is to
- * associate a trace location to an event of a specific rank (order).
+ * associate a trace location to an event at a specific rank (order).
  * <p>
  * The context should be sufficient to allow the trace to position itself so
- * that performing a trace read operation will yield the corresponding event.
+ * that performing a trace read operation will yield the corresponding 'nth'
+ * event.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
  * @see ITmfLocation
  */
-public interface ITmfContext extends Cloneable {
+public interface ITmfContext {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -42,12 +42,12 @@ public interface ITmfContext extends Cloneable {
     // ------------------------------------------------------------------------
 
     /**
-     * @return the rank of the event referred to by the context
+     * @return the rank of the event at the context location
      */
     public long getRank();
 
     /**
-     * @return the location of the event referred to by the context
+     * @return the location of the event at the context rank
      */
     public ITmfLocation<? extends Comparable<?>> getLocation();
 
@@ -80,10 +80,6 @@ public interface ITmfContext extends Cloneable {
      */
     public void dispose();
 
-    // ------------------------------------------------------------------------
-    // Cloneable
-    // ------------------------------------------------------------------------
-
     /**
      * @return a clone of the context
      */
index fd2526231f893698256144cf8e3da1d1152d575a..1b7920ba5283ff86cf2241cc85656a5aa356e7fd 100644 (file)
@@ -18,7 +18,6 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 /**
  * The generic trace parser in TMF.
  *  
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
index 5ec399f77da29fbbf2c04ae01d9675dbbbae6141..708ff96562a9c4ac3fd91775985d021e54c0e1e9 100644 (file)
@@ -23,13 +23,10 @@ package org.eclipse.linuxtools.tmf.core.trace;
  * <p>
  * This location is trace-specific and must be comparable.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
- *
- * @see TmfLocation
  */
-public interface ITmfLocation<L extends Comparable<?>> extends Cloneable {
+public interface ITmfLocation<L extends Comparable<?>> {
 
     // ------------------------------------------------------------------------
     // Getters
@@ -41,7 +38,7 @@ public interface ITmfLocation<L extends Comparable<?>> extends Cloneable {
     public L getLocation();
 
     // ------------------------------------------------------------------------
-    // Cloneable
+    // Operations
     // ------------------------------------------------------------------------
 
     /**
index 9f877ba7b0ca967f32e70064c91b9b148b796886..79dcf55a6afc13f1e2a9f74f65242e7f76e5e57a 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
 
 /**
  * The event stream structure in TMF. In its basic form, a trace has:
@@ -47,21 +46,21 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * <b>Example 1</b>: Process a whole trace
  * <pre>
  * ITmfContext context = trace.seekEvent(0);
- * ITmfEvent event = trace.readEvent(context);
+ * ITmfEvent event = trace.getNext(context);
  * while (event != null) {
  *     processEvent(event);
- *     event = trace.readNextEvent(context);
+ *     event = trace.getNext(context);
  * }
  * </pre>
  * <b>Example 2</b>: Process 50 events starting from the 1000th event
  * <pre>
  * int nbEventsRead = 0;
  * ITmfContext context = trace.seekEvent(1000);
- * ITmfEvent event = trace.readNextEvent(context);
+ * ITmfEvent event = trace.getNext(context);
  * while (event != null && nbEventsRead < 50) {
  *     nbEventsRead++;
  *     processEvent(event);
- *     event = trace.readNextEvent(context);
+ *     event = trace.getNext(context);
  * }
  * </pre>
  * <b>Example 3</b>: Process the events between 2 timestamps (inclusive)
@@ -69,10 +68,10 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * ITmfTimestamp startTime = ...;
  * ITmfTimestamp endTime = ...;
  * ITmfContext context = trace.seekEvent(startTime);
- * ITmfEvent event = trace.readNextEvent(context);
+ * ITmfEvent event = trace.getNext(context);
  * while (event != null && event.getTimestamp().compareTo(endTime) <= 0) {
  *     processEvent(event);
- *     event = trace.readNextEvent(context);
+ *     event = trace.getNext(context);
  * }
  * </pre>
  * A trace is also an event provider so it can process event requests
@@ -100,17 +99,25 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * } 
  * </pre>
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
- *
+ * 
+ * @see ITmfContext
  * @see ITmfEvent
- * @see ITmfDataProvider
- * @see ITmfEventRequest
- * @see TmfTrace
+ * @see ITmfTraceIndexer
+ * @see ITmfEventParser
  */
 public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
 
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    /**
+     * The default trace cache size
+     */
+    public static final int DEFAULT_TRACE_CACHE_SIZE = 1000;
+
     // ------------------------------------------------------------------------
     // Initializers
     // ------------------------------------------------------------------------
@@ -271,17 +278,4 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      */
     public ITmfContext seekEvent(double ratio);
 
-    // ------------------------------------------------------------------------
-    // Read operations (returning an actual event)
-    // ------------------------------------------------------------------------
-
-    /**
-     * Return the event pointed by the supplied context (or null if no event
-     * left) and updates the context to point the next event.
-     * 
-     * @param context the read context (will be updated)
-     * @return the event pointed to by the context
-     */
-    public ITmfEvent readNextEvent(ITmfContext context);
-
 }
index 76d878a82ee7efb15f69fad1fc8fb6b2c04bc914..1f16da37bf07576fa0ff243d6e331007b673b937 100644 (file)
@@ -18,7 +18,6 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 /**
  * The generic trace indexer in TMF.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
index 967aecaa84b864e0bf2a23c2f4387391080480c8..76eca5e37dff25560d7fbdd7df941844c5dfd1d8 100644 (file)
@@ -19,15 +19,13 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
  * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
  * to a generic location.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
- * @see ITmfCheckpoint
  * @see ITmfLocation
  * @see ITmfTimestamp
  */
-public class TmfCheckpoint implements ITmfCheckpoint {
+public class TmfCheckpoint implements ITmfCheckpoint, Cloneable {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -67,8 +65,9 @@ public class TmfCheckpoint implements ITmfCheckpoint {
      * @param other the other checkpoint
      */
     public TmfCheckpoint(final TmfCheckpoint other) {
-        if (other == null)
+        if (other == null) {
             throw new IllegalArgumentException();
+        }
         fTimestamp = other.fTimestamp;
         fLocation = other.fLocation;
     }
@@ -154,23 +153,30 @@ public class TmfCheckpoint implements ITmfCheckpoint {
      */
     @Override
     public boolean equals(final Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (!(obj instanceof TmfCheckpoint))
+        }
+        if (!(obj instanceof TmfCheckpoint)) {
             return false;
+        }
         final TmfCheckpoint other = (TmfCheckpoint) obj;
         if (fLocation == null) {
-            if (other.fLocation != null)
+            if (other.fLocation != null) {
                 return false;
-        } else if (!fLocation.equals(other.fLocation))
+            }
+        } else if (!fLocation.equals(other.fLocation)) {
             return false;
+        }
         if (fTimestamp == null) {
-            if (other.fTimestamp != null)
+            if (other.fTimestamp != null) {
                 return false;
-        } else if (!fTimestamp.equals(other.fTimestamp))
+            }
+        } else if (!fTimestamp.equals(other.fTimestamp)) {
             return false;
+        }
         return true;
     }
 
index aaedb788d0d67bd6677015214aa221e0d716b16f..6df55ddab814e8144e657feccbee8ae6d8c2f2a0 100644 (file)
@@ -12,8 +12,9 @@
 
 package org.eclipse.linuxtools.tmf.core.trace;
 
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Vector;
+import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -41,11 +42,9 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
  * Locating a specific checkpoint is trivial for both rank (rank % interval) and
  * timestamp (bsearch in the array).
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
- * @see ITmfTraceIndexer
  * @see ITmfTrace
  * @see ITmfEvent
  */
@@ -55,21 +54,17 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
     // Attributes
     // ------------------------------------------------------------------------
 
-    /**
-     * The event trace to index
-     */
+    // The event trace to index
     private final ITmfTrace<ITmfEvent> fTrace;
 
-    /**
-     * The interval between checkpoints
-     */
-    protected final int fCheckpointInterval;
+    // The interval between checkpoints
+    private final int fCheckpointInterval;
 
     /**
      * The trace index. It is composed of checkpoints taken at intervals of
      * fCheckpointInterval events.
      */
-    protected final Vector<TmfCheckpoint> fTraceIndex;
+    private final List<TmfCheckpoint> fTraceIndex;
 
     // ------------------------------------------------------------------------
     // Construction
@@ -94,7 +89,7 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
     public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace, final int interval) {
         fTrace = trace;
         fCheckpointInterval = interval;
-        fTraceIndex = new Vector<TmfCheckpoint>();
+        fTraceIndex = new ArrayList<TmfCheckpoint>();
     }
 
     // ------------------------------------------------------------------------
@@ -134,12 +129,12 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
         fTraceIndex.clear();
 
         // Build a background request for all the trace data. The index is
-        // updated as we go by getNextEvent().
+        // updated as we go by readNextEvent().
         final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, TmfTimeRange.ETERNITY,
                 TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
         {
-            ITmfTimestamp startTime = null;
-            ITmfTimestamp lastTime = null;
+            private ITmfTimestamp startTime = null;
+            private ITmfTimestamp lastTime = null;
 
             @Override
             public void handleData(final ITmfEvent event) {
@@ -228,8 +223,9 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
     public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
 
         // A null timestamp indicates to seek the first event
-        if (timestamp == null)
+        if (timestamp == null) {
             return fTrace.seekEvent(0);
+        }
 
         // Find the checkpoint at or before the requested timestamp.
         // In the very likely event that the timestamp is not at a checkpoint
@@ -251,8 +247,9 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
     public ITmfContext seekIndex(final long rank) {
 
       // A rank < 0 indicates to seek the first event
-      if (rank < 0)
+      if (rank < 0) {
           return fTrace.seekEvent(0);
+      }
 
       // Find the checkpoint at or before the requested rank.
       final int index = (int) rank / fCheckpointInterval;
@@ -264,20 +261,18 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
     /**
      * Position the trace at the given checkpoint
      * 
-     * @param index
-     *            the checkpoint index
+     * @param checkpoint the checkpoint index
      * @return the corresponding context
      */
-    private ITmfContext seekCheckpoint(int index) {
-        ITmfLocation<?> location;
+    private ITmfContext seekCheckpoint(final int checkpoint) {
+        ITmfLocation<?> location = null;
+        int index = checkpoint;
         synchronized (fTraceIndex) {
             if (!fTraceIndex.isEmpty()) {
                 if (index >= fTraceIndex.size()) {
                     index = fTraceIndex.size() - 1;
                 }
-                location = fTraceIndex.elementAt(index).getLocation();
-            } else {
-                location = null;
+                location = fTraceIndex.get(index).getLocation();
             }
         }
         final ITmfContext context = fTrace.seekEvent(location);
@@ -285,4 +280,14 @@ public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITm
         return context;
     }
 
+    // ------------------------------------------------------------------------
+    // Getters
+    // ------------------------------------------------------------------------
+
+    /**
+     * @return the trace index
+     */
+    protected List<TmfCheckpoint> getTraceIndex() {
+        return fTraceIndex;
+    }
 }
index dfba34f7bcf374919a84b715166b8a6dc4301491..add489ddcc916a984780c8e6d42044e972c4f2b0 100644 (file)
@@ -19,7 +19,6 @@ package org.eclipse.linuxtools.tmf.core.trace;
  * It ties a trace location to an event rank. The context should be enough to
  * restore the trace state so the corresponding event can be read.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
@@ -74,8 +73,9 @@ public class TmfContext implements ITmfContext, Cloneable {
      * @param context the other context
      */
     public TmfContext(final TmfContext context) {
-        if (context == null)
+        if (context == null) {
             throw new IllegalArgumentException();
+        }
         fLocation = context.fLocation;
         fRank = context.fRank;
     }
@@ -140,8 +140,9 @@ public class TmfContext implements ITmfContext, Cloneable {
      */
     @Override
     public void increaseRank() {
-        if (hasValidRank())
+        if (hasValidRank()) {
             fRank++;
+        }
     }
 
     /* (non-Javadoc)
@@ -180,20 +181,26 @@ public class TmfContext implements ITmfContext, Cloneable {
      */
     @Override
     public boolean equals(final Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         final TmfContext other = (TmfContext) obj;
         if (fLocation == null) {
-            if (other.fLocation != null)
+            if (other.fLocation != null) {
                 return false;
-        } else if (!fLocation.equals(other.fLocation))
+            }
+        } else if (!fLocation.equals(other.fLocation)) {
             return false;
-        if (fRank != other.fRank)
+        }
+        if (fRank != other.fRank) {
             return false;
+        }
         return true;
     }
 
index 2ffb6c701c3b909f84903946057c565d34701387..8a438dc62283e6b6f9eea6f00a0c4bc2e22dc060 100644 (file)
@@ -19,11 +19,10 @@ import java.lang.reflect.Method;
  * A convenience implementation on of ITmfLocation. The generic class (L) must
  * be comparable.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  */
-public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
+public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L>, Cloneable {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -40,7 +39,6 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
      */
     @SuppressWarnings("unused")
     private TmfLocation() {
-        fLocation = null;
     }
 
     /**
@@ -91,8 +89,9 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
                 final Method method = clazz.getMethod("clone", new Class[0]); //$NON-NLS-1$
                 final Object copy = method.invoke(this.fLocation, new Object[0]);
                 clone.fLocation = (L) copy;
-            } else
+            } else {
                 clone.fLocation = null;
+            }
         } catch (final CloneNotSupportedException e) {
         } catch (final NoSuchMethodException e) {
         } catch (final Exception e) {
@@ -122,18 +121,23 @@ public class TmfLocation<L extends Comparable<L>> implements ITmfLocation<L> {
     @Override
     @SuppressWarnings("unchecked")
     public boolean equals(final Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         final TmfLocation<L> other = (TmfLocation<L>) obj;
         if (fLocation == null) {
-            if (other.fLocation != null)
+            if (other.fLocation != null) {
                 return false;
-        } else if (!fLocation.equals(other.fLocation))
+            }
+        } else if (!fLocation.equals(other.fLocation)) {
             return false;
+        }
         return true;
     }
 
index e0c5fc726eefcc35b1cfc8c669c9f1fb2637ed7c..9b1ec6397bbaecae3d0fe64c02ced22427e25e49 100644 (file)
@@ -14,7 +14,6 @@
 package org.eclipse.linuxtools.tmf.core.trace;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.Path;
@@ -47,7 +46,6 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * TmfCheckpointIndexer (default). In this case, the trace cache size will be
  * used as checkpoint interval.
  * 
- * @since 1.0
  * @version 1.0
  * @author Francois Chouinard
  *
@@ -57,15 +55,6 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  */
 public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T> implements ITmfTrace<T> {
 
-    // ------------------------------------------------------------------------
-    // Constants
-    // ------------------------------------------------------------------------
-
-    /**
-     * The default trace cache size
-     */
-    public static final int DEFAULT_TRACE_CACHE_SIZE = 10000;
-
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -76,34 +65,24 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     // The trace path
     private String fPath;
 
-    /**
-     * The trace cache page size
-     */
-    protected int fCacheSize = DEFAULT_TRACE_CACHE_SIZE;
+    // The trace cache page size
+    private int fCacheSize = ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
 
-    /**
-     * The number of events collected (so far)
-     */
-    protected long fNbEvents = 0;
+    // The number of events collected (so far)
+    private long fNbEvents = 0;
 
     // The time span of the event stream
     private ITmfTimestamp fStartTime = TmfTimestamp.BIG_CRUNCH;
     private ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG;
 
-    /**
-     * The trace streaming interval (0 = no streaming)
-     */
-    protected long fStreamingInterval = 0;
+    // The trace streaming interval (0 = no streaming)
+    private long fStreamingInterval = 0;
 
-    /**
-     * The trace indexer
-     */
-    protected ITmfTraceIndexer<ITmfTrace<ITmfEvent>> fIndexer;
+    // The trace indexer
+    private ITmfTraceIndexer<ITmfTrace<ITmfEvent>> fIndexer;
 
-    /**
-     * The trace parser
-     */
-    protected ITmfEventParser<T> fParser;
+    // The trace parser
+    private ITmfEventParser<T> fParser;
 
     // ------------------------------------------------------------------------
     // Construction
@@ -160,7 +139,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
      */
     protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize,
             final long interval, final ITmfTraceIndexer<?> indexer) throws TmfTraceException {
-        this(resource, type, path, cacheSize, interval, null, null);
+        this(resource, type, path, cacheSize, interval, indexer, null);
     }
 
     /**
@@ -178,7 +157,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize,
             final long interval, final ITmfTraceIndexer<?> indexer, final ITmfEventParser<T> parser) throws TmfTraceException {
         super();
-        fCacheSize = (cacheSize > 0) ? cacheSize : DEFAULT_TRACE_CACHE_SIZE;
+        fCacheSize = (cacheSize > 0) ? cacheSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
         fStreamingInterval = interval;
         fIndexer = (indexer != null) ? indexer : new TmfCheckpointIndexer(this, fCacheSize);
         fParser = parser;
@@ -193,8 +172,9 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public TmfTrace(final TmfTrace<T> trace) throws TmfTraceException {
         super();
-        if (trace == null)
+        if (trace == null) {
             throw new IllegalArgumentException();
+        }
         fCacheSize = trace.getCacheSize();
         fStreamingInterval = trace.getStreamingInterval();
         fIndexer = new TmfCheckpointIndexer(this);
@@ -212,7 +192,6 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     @Override
     public void initTrace(final IResource resource, final String path, final Class<T> type) throws TmfTraceException {
         initialize(resource, path, type);
-        fIndexer.buildIndex(false);
     }
 
     /**
@@ -222,12 +201,13 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
      * @param path the trace path
      * @param type the trace event type
      * 
-     * @throws FileNotFoundException
+     * @throws TmfTraceException
      */
     @SuppressWarnings("unchecked")
     protected void initialize(final IResource resource, final String path, final Class<T> type) throws TmfTraceException {
-        if (path == null)
+        if (path == null) {
             throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
+        }
         fPath = path;
         fResource = resource;
         String traceName = (resource != null) ? resource.getName() : null;
@@ -257,6 +237,15 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         return file.exists();
     }
 
+    /**
+     * Index the trace
+     * 
+     * @param waitForCompletion index synchronously (true) or not (false)
+     */
+    protected void indexTrace(boolean waitForCompletion) {
+        getIndexer().buildIndex(waitForCompletion);
+    }
+
     // ------------------------------------------------------------------------
     // ITmfTrace - Basic getters
     // ------------------------------------------------------------------------
@@ -302,6 +291,20 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         return fStreamingInterval;
     }
 
+    /**
+     * @return the trace indexer
+     */
+    protected ITmfTraceIndexer<ITmfTrace<ITmfEvent>> getIndexer() {
+        return fIndexer;
+    }
+
+    /**
+     * @return the trace parser
+     */
+    protected ITmfEventParser<T> getParser() {
+        return fParser;
+    }
+
     // ------------------------------------------------------------------------
     // ITmfTrace - Trace characteristics getters
     // ------------------------------------------------------------------------
@@ -339,9 +342,28 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     }
 
     // ------------------------------------------------------------------------
-    // Convenience setters
+    // Convenience setters/getters
     // ------------------------------------------------------------------------
 
+    /**
+     * Set the trace cache size. Must be done at initialization time.
+     * 
+     * @param cacheSize The trace cache size
+     */
+    protected void setCacheSize(final int cacheSize) {
+        fCacheSize = cacheSize;
+    }
+
+    /**
+     * Set the trace known number of events. This can be quite dynamic
+     * during indexing or for live traces.
+     * 
+     * @param nbEvents The number of events
+     */
+    protected synchronized void setNbEvents(final long nbEvents) {
+        fNbEvents = (nbEvents > 0) ? nbEvents : 0;
+    }
+
     /**
      * Update the trace events time range
      * 
@@ -371,7 +393,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     }
 
     /**
-     * Update the trace streaming interval
+     * Set the polling interval for live traces (default = 0 = no streaming).
      * 
      * @param interval the new trace streaming interval
      */
@@ -379,6 +401,24 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         fStreamingInterval = (interval > 0) ? interval : 0;
     }
 
+    /**
+     * Set the trace indexer. Must be done at initialization time.
+     * 
+     * @param indexer the trace indexer
+     */
+    protected void setIndexer(final ITmfTraceIndexer<ITmfTrace<ITmfEvent>> indexer) {
+        fIndexer = indexer;
+    }
+
+    /**
+     * Set the trace parser. Must be done at initialization time.
+     * 
+     * @param parser the new trace parser
+     */
+    protected void setParser(final ITmfEventParser<T> parser) {
+        fParser = parser;
+    }
+
     // ------------------------------------------------------------------------
     // ITmfTrace - SeekEvent operations (returning a trace context)
     // ------------------------------------------------------------------------
@@ -402,9 +442,9 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         // And locate the requested event context
         long pos = context.getRank();
         if (pos < rank) {
-            ITmfEvent event = readNextEvent(context);
+            ITmfEvent event = getNext(context);
             while (event != null && ++pos < rank) {
-                event = readNextEvent(context);
+                event = getNext(context);
             }
         }
         return context;
@@ -428,11 +468,15 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
 
         // And locate the requested event context
         final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
-        ITmfEvent event = readNextEvent(nextEventContext);
+        ITmfEvent event = getNext(nextEventContext);
         while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
             context.setLocation(nextEventContext.getLocation().clone());
             context.increaseRank();
-            event = readNextEvent(nextEventContext);
+            event = getNext(nextEventContext);
+        }
+        if (event == null) {
+            context.setLocation(null);
+            context.setRank(ITmfContext.UNKNOWN_RANK);
         }
         return context;
     }
@@ -445,9 +489,9 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
      * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
      */
     @Override
-    public synchronized ITmfEvent readNextEvent(final ITmfContext context) {
+    public synchronized T getNext(final ITmfContext context) {
         // parseEvent() does not update the context
-        final ITmfEvent event = fParser.parseEvent(context);
+        final T event = fParser.parseEvent(context);
         if (event != null) {
             updateAttributes(context, event.getTimestamp());
             context.setLocation(getCurrentLocation());
@@ -499,8 +543,9 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     @Override
     public ITmfContext armRequest(final ITmfDataRequest<T> request) {
         if (request instanceof ITmfEventRequest<?>
-        && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<T>) request).getRange().getStartTime())
-        && request.getIndex() == 0) {
+            && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<T>) request).getRange().getStartTime())
+            && request.getIndex() == 0)
+        {
             final ITmfContext context = seekEvent(((ITmfEventRequest<T>) request).getRange().getStartTime());
             ((ITmfEventRequest<T>) request).setStartIndex((int) context.getRank());
             return context;
@@ -509,16 +554,17 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         return seekEvent(request.getIndex());
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.component.TmfDataProvider#getNext(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
-     */
-    @Override
-    @SuppressWarnings("unchecked")
-    public T getNext(final ITmfContext context) {
-        if (context instanceof TmfContext)
-            return (T) readNextEvent(context);
-        return null;
-    }
+//    /* (non-Javadoc)
+//     * @see org.eclipse.linuxtools.tmf.core.component.TmfDataProvider#getNext(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
+//     */
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public T getNext(final ITmfContext context) {
+//        if (context instanceof TmfContext) {
+//            return (T) readNextEvent(context);
+//        }
+//        return null;
+//    }
 
 
     // ------------------------------------------------------------------------
index 73084a37dbfe125e685e5ba37430af9b5a7219c3..3b939e7dd3253658cee7e6d1cbc6352e2cca0931 100644 (file)
     </uml2SDLoader>
  </extension>
 
+   <extension
+         point="org.eclipse.linuxtools.tmf.ui.tracetype">
+      <category
+            id="org.eclipse.linuxtools.tmf.tests.category.tracetype"
+            name="Test trace">
+      </category>
+      <type
+            category="org.eclipse.linuxtools.tmf.tests.category.tracetype"
+            event_type="org.eclipse.linuxtools.tmf.core.event.TmfEvent"
+            id="org.eclipse.linuxtools.tmf.tests.tracetype"
+            name="TMF Tests"
+            trace_type="org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub">
+         <eventsTableType
+               class="org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable">
+         </eventsTableType>
+      </type>
+   </extension>
+
 </plugin>
index 3d1d33b354add97395195b9c42df0a00c1d41d4c..6d37bbb8554cde9ebc8b45c368af28dfd0c9a87b 100644 (file)
@@ -8,16 +8,24 @@ Bundle-SymbolicName: org.eclipse.linuxtools.tmf.ui;singleton:=true
 Bundle-Activator: org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.ui.ide;bundle-version="3.7.0",
- org.eclipse.core.resources;bundle-version="3.7.100",
+Require-Bundle: org.eclipse.core.expressions,
  org.eclipse.core.filesystem;bundle-version="1.3.100",
+ org.eclipse.core.resources;bundle-version="3.7.100",
  org.eclipse.core.runtime;bundle-version="3.7.0",
  org.eclipse.linuxtools.tmf.core;bundle-version="0.5.0",
+ org.eclipse.ui;bundle-version="3.7.0",
+ org.eclipse.ui.ide;bundle-version="3.7.0",
  org.eclipse.ui.navigator;bundle-version="3.5.100",
- org.eclipse.ui.navigator.resources;bundle-version="3.4.300",
- org.eclipse.core.expressions
+ org.eclipse.ui.navigator.resources;bundle-version="3.4.300"
 Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.linuxtools.tmf.ui.tests",
+ org.eclipse.linuxtools.internal.tmf.ui.commands;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.dialogs;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.editors.handlers;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.preferences;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.project.handlers;x-internal:=true,
+ org.eclipse.linuxtools.internal.tmf.ui.signal;x-internal:=true,
  org.eclipse.linuxtools.tmf.ui.editors,
  org.eclipse.linuxtools.tmf.ui.project.model,
  org.eclipse.linuxtools.tmf.ui.project.wizards,
index 059622a5d4133ff4332f79c625b616adc75023a3..88cd06b390cbfceea6dd6e41cf28fdaa6328a975 100644 (file)
@@ -24,7 +24,6 @@ import java.util.regex.Matcher;
 import org.eclipse.core.resources.IProject;\r
 import org.eclipse.core.resources.IResource;\r
 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
 import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
@@ -168,9 +167,9 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> implements ITmfEven
     }\r
 \r
     @Override\r
-    public synchronized TmfEvent readNextEvent(final ITmfContext context) {\r
+    public synchronized CustomTxtEvent getNext(final ITmfContext context) {\r
         final ITmfContext savedContext = context.clone();\r
-        final TmfEvent event = parseEvent(context);\r
+        final CustomTxtEvent event = parseEvent(context);\r
         if (event != null) {\r
             updateAttributes(savedContext, event.getTimestamp());\r
             context.increaseRank();\r
index bc5ff987a4d0f488351be6a8cb4f659bf47ceafd..00b77f6e9d3e64e5d4f810db65f0cc1f9a4c9675 100644 (file)
@@ -26,7 +26,6 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;\r
 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;\r
 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
 import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
@@ -170,9 +169,9 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> implements ITmfEven
     }\r
 \r
     @Override\r
-    public synchronized TmfEvent readNextEvent(final ITmfContext context) {\r
+    public synchronized CustomXmlEvent getNext(final ITmfContext context) {\r
         final ITmfContext savedContext = context.clone();\r
-        final TmfEvent event = parseEvent(context);\r
+        final CustomXmlEvent event = parseEvent(context);\r
         if (event != null) {\r
             updateAttributes(savedContext, event.getTimestamp());\r
             context.increaseRank();\r
index 0398916fb7de2d2a3c0d957cbb84cdad9f6b23dd..fd53cdcfbbbc6ebca5c865bff9377b2d7937f27d 100644 (file)
@@ -384,14 +384,16 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
                             return;
                         fDataModel.setCurrentEvent(fCurrentEventTime);
                         fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, HISTOGRAM_BAR_WIDTH);
-                        if (fScaledData != null) {
-                            fCanvas.redraw();
-                            // Display histogram and update X-,Y-axis labels
-                            fTimeRangeStartText.setText(HistogramUtils.nanosecondsToString(fDataModel.getFirstBucketTime()));
-                            fTimeRangeEndText.setText(HistogramUtils.nanosecondsToString(fDataModel.getEndTime()));
-                            fMaxNbEventsText.setText(Long.toString(fScaledData.fMaxValue));
-                            // The Y-axis area might need to be re-sized
-                            fMaxNbEventsText.getParent().layout();
+                        synchronized(fScaledData) {
+                            if (fScaledData != null) {
+                                fCanvas.redraw();
+                                // Display histogram and update X-,Y-axis labels
+                                fTimeRangeStartText.setText(HistogramUtils.nanosecondsToString(fDataModel.getFirstBucketTime()));
+                                fTimeRangeEndText.setText(HistogramUtils.nanosecondsToString(fDataModel.getEndTime()));
+                                fMaxNbEventsText.setText(Long.toString(fScaledData.fMaxValue));
+                                // The Y-axis area might need to be re-sized
+                                fMaxNbEventsText.getParent().layout();
+                            }
                         }
                     }
                 }
index b386e4f7b1624d8203026a5060df7741bc3f475b..7cc41e51d041d5db8fc7026c71c5a7c5ca91c99d 100644 (file)
@@ -19,7 +19,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 
 /**
  * <b><u>HistogramRequest</u></b>
@@ -38,7 +38,7 @@ public class HistogramRequest extends TmfEventRequest<ITmfEvent> {
     // ------------------------------------------------------------------------
 
     public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range, int rank, int nbEvents, ITmfDataRequest.ExecutionType execType) {
-        super(ITmfEvent.class, range, rank, nbEvents, TmfTrace.DEFAULT_TRACE_CACHE_SIZE, execType);
+        super(ITmfEvent.class, range, rank, nbEvents, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, execType);
         fHistogram = histogram;
     }
 
index 77d7f0b1f1133ccdf0e3af908f49ac58a184bddc..adff191523809269eaf2c793199ada5ed60e56c0 100644 (file)
@@ -170,7 +170,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
                 }\r
                 while (true) {\r
                     long rank = context.getRank();\r
-                    ITmfEvent event = trace.readNextEvent(context);\r
+                    ITmfEvent event = trace.getNext(context);\r
                     if (event == null) {\r
                         done = true;\r
                         break;\r
@@ -435,7 +435,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
                         if (interrupted)\r
                             return;\r
                         long rank = fContext.getRank();\r
-                        ITmfEvent event = trace.readNextEvent(fContext);\r
+                        ITmfEvent event = trace.getNext(fContext);\r
                         if (event == null) {\r
                             break;\r
                         }\r
index 218ee91e69132b9817a7dc61dda67db3dc37ed50..9c3d76d5469ff89e026854d3dac2457783bfb772 100644 (file)
@@ -388,7 +388,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                     long rank = 0;\r
                     while (!context.getLocation().equals(endLocation)) {\r
                         location = context.getLocation().clone();\r
-                        ITmfEvent event = fTrace.readNextEvent(context);\r
+                        ITmfEvent event = fTrace.getNext(context);\r
                         if (event == null) {\r
                                break;\r
                         }\r
@@ -428,7 +428,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                    } else {\r
                     //fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1);\r
                        fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location);\r
-                       fTrace.readNextEvent(fBottomContext);\r
+                       fTrace.getNext(fBottomContext);\r
                    }\r
                    if (fBottomContext == null) {\r
                        break;\r
@@ -436,7 +436,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                }\r
             long rank = fBottomContext.getRank();\r
             ITmfLocation<?> location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;\r
-            ITmfEvent event = fTrace.readNextEvent(fBottomContext);\r
+            ITmfEvent event = fTrace.getNext(fBottomContext);\r
             if (event == null) {\r
                 break;\r
             }\r
This page took 0.154478 seconds and 5 git commands to generate.