From 7e6347b04485ecd18554c99405bfa6bf84a9e70e Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Tue, 24 Apr 2012 07:40:31 -0400 Subject: [PATCH] Refactor TmfTrace and dependencies - move parseEvent to ITmfEventParser --- .../tests/event/LttngEventContentTest.java | 12 +- .../core/tests/event/LttngEventFieldTest.java | 4 +- .../core/tests/event/LttngEventTest.java | 2 +- .../core/tests/event/LttngEventTypeTest.java | 2 +- .../core/tests/event/LttngTimestampTest.java | 2 +- .../core/tests/headless/LttngTraceTest.java | 4 +- .../core/tests/trace/LTTngTextTraceTest.java | 28 +- .../core/tests/trace/LTTngTraceTest.java | 126 ++--- .../lttng/core/trace/LTTngTextTrace.java | 12 +- .../internal/lttng/core/trace/LTTngTrace.java | 21 +- .../lttng/stubs/LTTngEventParserStub.java | 6 +- .../internal/lttng/stubs/LTTngTraceStub.java | 22 +- .../tests/experiment/TmfExperimentTest.java | 82 ++-- .../TmfMultiTraceExperimentTest.java | 82 ++-- .../tmf/core/tests/trace/AllTests.java | 20 +- .../core/tests/trace/TmfExperimentTest.java | 84 ++-- .../tmf/core/tests/trace/TmfTraceTest.java | 451 ++++++++++-------- .../tests/stubs/trace/TmfEventParserStub.java | 20 +- .../tmf/tests/stubs/trace/TmfTraceStub.java | 37 +- .../META-INF/MANIFEST.MF | 1 - .../tmf/core/ctfadaptor/CtfTmfTrace.java | 14 +- .../tmf/core/experiment/TmfExperiment.java | 36 +- .../tmf/core/request/TmfEventRequest.java | 14 + .../{parser => trace}/ITmfEventParser.java | 20 +- .../linuxtools/tmf/core/trace/ITmfTrace.java | 96 ++-- ...Indexer.java => TmfCheckpointIndexer.java} | 26 +- .../linuxtools/tmf/core/trace/TmfTrace.java | 116 +++-- .../views/uml2sd/impl/Uml2SDTestFacility.java | 7 +- .../uml2sd/trace/TmfUml2SDTestTrace.java | 29 +- .../tmf/ui/parsers/custom/CustomTxtTrace.java | 11 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 11 +- .../tmf/ui/views/timechart/TimeChartView.java | 4 +- .../tmf/ui/widgets/TmfRawEventViewer.java | 12 +- 33 files changed, 768 insertions(+), 646 deletions(-) rename org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/{parser => trace}/ITmfEventParser.java (61%) rename org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/{TmfTraceIndexer.java => TmfCheckpointIndexer.java} (92%) diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java index 4a2f5e4eb6..a11b8c4336 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java @@ -86,7 +86,7 @@ public class LttngEventContentTest extends TestCase { try { testStream = null; final LTTngTextTrace tmpStream = initializeEventStream(); - tmpEventContent = (LttngEventContent)tmpStream.getNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent(); + tmpEventContent = (LttngEventContent)tmpStream.readEvent( new TmfContext(new TmfLocation(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(0L), 0); - tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readEvent(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.getNextEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); // Second event past metadata should have more fields - tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readEvent(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(0L), 0); - tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readEvent(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(0L), 0); - tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); + tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext); // Get the content testContent = tmpEvent.getContent(); // Get all the fields to make sure there is something in the HashMap diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java index ac542bdfd8..1801b1a966 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java @@ -56,7 +56,7 @@ public class LttngEventFieldTest extends TestCase { // This trace should be valid try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpField = (LttngEventField)tmpStream.getNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); + tmpField = (LttngEventField)tmpStream.readEvent( new TmfContext(new TmfLocation(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.getNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); + testField = (LttngEventField) tmpStream.readEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); // } catch (TmfNoSuchFieldException e) { // e.printStackTrace(); // } diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java index 713949d33b..9843ae4df5 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java @@ -77,7 +77,7 @@ public class LttngEventTest extends TestCase { try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpEvent = (LttngEvent)tmpStream.getNextEvent(new TmfContext(new TmfLocation(0L), 0) ); + tmpEvent = (LttngEvent)tmpStream.readEvent(new TmfContext(new TmfLocation(0L), 0) ); } catch (final Exception e) { System.out.println("ERROR : Could not open " + tracepath1); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java index a877c7434e..515efa5df0 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java @@ -59,7 +59,7 @@ public class LttngEventTypeTest extends TestCase { // This trace should be valid try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpEventType = (LttngEventType)tmpStream.getNextEvent( new TmfContext(null, 0) ).getType(); + tmpEventType = (LttngEventType)tmpStream.readEvent( new TmfContext(null, 0) ).getType(); } catch (final Exception e) { fail("ERROR : Failed to get reference!"); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java index 37800c7e8d..c5db31ce83 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java @@ -58,7 +58,7 @@ public class LttngTimestampTest extends TestCase { // This trace should be valid try { final LTTngTextTrace tmpStream = initializeEventStream(); - tmpTime = (LttngTimestamp) tmpStream.getNextEvent(new TmfContext(null, 0)).getTimestamp(); + tmpTime = (LttngTimestamp) tmpStream.readEvent(new TmfContext(null, 0)).getTimestamp(); } catch (final Exception e) { fail("ERROR : Failed to get reference!"); } diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java index cb034a9053..6cf8f48dfe 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java @@ -67,10 +67,10 @@ public class LttngTraceTest { // Seek to the beginning of the trace tmpContext = tmptrace.seekEvent( tmpTime ); - tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext); + tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext); while ( tmpevent != null ) { - tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext); + tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext); // Parse the events if it was asked if ( (tmpevent != null) && (PARSE_EVENTS) ) diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java index 8a3281e4df..f9e939e225 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java @@ -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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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); @@ -212,24 +212,24 @@ public class LTTngTextTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain // timestamp - tmpContext = testStream1.seekLocation(new TmfLocation(locationToSeekTest1)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new TmfLocation(locationToSeekTest1)); + tmpEvent = testStream1.readEvent(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); assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference.contains(tmpEvent.getReference())); // Seek to the last timestamp - tmpContext = testStream1.seekLocation(new TmfLocation(locationToSeekLast)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new TmfLocation(locationToSeekLast)); + tmpEvent = testStream1.readEvent(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); assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference.contains(tmpEvent.getReference())); // Seek to the first timestamp (startTime) - tmpContext = testStream1.seekLocation(new TmfLocation(locationToSeekFirst)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new TmfLocation(locationToSeekFirst)); + tmpEvent = testStream1.readEvent(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); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java index 471863b456..0982407c91 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java @@ -116,12 +116,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.getNextEvent(tmpContext ); + tmpEvent = testStream1.readEvent(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.getNextEvent( tmpContext); + tmpEvent = testStream1.readEvent( tmpContext); assertNotSame("tmpEvent is null after second getNextEvent()",null,tmpEvent ); assertEquals("tmpEvent has wrong timestamp after second getNextEvent()",secondEventTimestamp,tmpEvent.getTimestamp().getValue() ); } @@ -149,7 +149,7 @@ public class LTTngTraceTest 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.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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 +157,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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 +165,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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 ); @@ -179,7 +179,7 @@ public class LTTngTraceTest extends TestCase { // We should be at the beginning of the trace, we will seek at a certain timestamp tmpContext = testStream1.seekEvent(indexToSeekTest1); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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 +187,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the last timestamp tmpContext = testStream1.seekEvent(indexToSeekLast); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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 +195,7 @@ public class LTTngTraceTest extends TestCase { // Seek to the first timestamp (startTime) tmpContext = testStream1.seekEvent(indexToSeekFirst); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpEvent = testStream1.readEvent(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 ); @@ -208,24 +208,24 @@ public class LTTngTraceTest extends TestCase { final LTTngTrace testStream1 = prepareStreamToTest(); // We should be at the beginning of the trace, we will seek at a certain timestamp - tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekTest1)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekTest1)); + tmpEvent = testStream1.readEvent(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 ); assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference.contains(tmpEvent.getReference())); // Seek to the last timestamp - tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekLast)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekLast)); + tmpEvent = testStream1.readEvent(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 ); assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference.contains(tmpEvent.getReference())); // Seek to the first timestamp (startTime) - tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekFirst)); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekFirst)); + tmpEvent = testStream1.readEvent(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 ); @@ -238,41 +238,41 @@ public class LTTngTraceTest extends TestCase { final LTTngTrace testStream1 = prepareStreamToTest(); // Test LttngLocation after a seek - tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp)); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); LttngLocation location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationSeek()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a parse - tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp)); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(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.seekLocation(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); + tmpEvent = testStream.readEvent(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.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a parse and parse - tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp)); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); @@ -280,88 +280,88 @@ public class LTTngTraceTest extends TestCase { location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(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.seekLocation(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(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.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(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.seekLocation(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a parse and getNext - tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp)); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(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.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a parse, getNext and parse - tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp)); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); // Test LttngLocation after a parse, getNext and getNext - tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp)); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(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.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(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.seekLocation(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); @@ -370,40 +370,40 @@ public class LTTngTraceTest extends TestCase { location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(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.seekLocation(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); + tmpEvent = testStream.readEvent(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.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(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.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(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.seekLocation(new LttngLocation(seekTimestamp)); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp)); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue()); - tmpEvent = testStream.getNextEvent(tmpContext); + tmpEvent = testStream.readEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue()); tmpEvent = testStream.parseEvent(tmpContext); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); location = (LttngLocation) tmpContext.getLocation().clone(); assertTrue("location has wrong flag", location.isLastOperationParse()); assertEquals("location has wrong operation time", nextnextEventTimestamp, location.getOperationTimeValue()); - tmpContext = testStream1.seekLocation(location); - tmpEvent = testStream1.getNextEvent(tmpContext); + tmpContext = testStream1.seekEvent(location); + tmpEvent = testStream1.readEvent(tmpContext); assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null); assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue()); } diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java index c757bc783e..085dc358f7 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java @@ -26,12 +26,13 @@ import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp; import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; 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.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; -public class LTTngTextTrace extends TmfTrace { +public class LTTngTextTrace extends TmfTrace implements ITmfEventParser { private LttngTimestamp eventTimestamp = null; private String eventSource = null; private LttngEventType eventType = null; @@ -81,6 +82,7 @@ public class LTTngTextTrace extends TmfTrace { // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L), new TmfLocation(0L))); ITmfContext context = new TmfContext(new TmfLocation(0L), 0); fIndexer.updateIndex(context, new LttngTimestamp(0L)); + fParser = (ITmfEventParser) this; // } // else { // indexTrace(true); @@ -89,7 +91,7 @@ public class LTTngTextTrace extends TmfTrace { final Long endTime = currentLttngEvent.getTimestamp().getValue(); positionToFirstEvent(); - getNextEvent(new TmfContext(null, 0)); + readEvent(new TmfContext(null, 0)); final Long starTime = currentLttngEvent.getTimestamp().getValue(); positionToFirstEvent(); @@ -160,7 +162,7 @@ public class LTTngTextTrace extends TmfTrace { @Override @SuppressWarnings("unchecked") - public TmfContext seekLocation(ITmfLocation location) { + public TmfContext seekEvent(ITmfLocation location) { if (location == null) location = new TmfLocation(0L); @@ -173,7 +175,7 @@ public class LTTngTextTrace extends TmfTrace { } @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { // TODO Auto-generated method stub return null; } @@ -407,7 +409,7 @@ public class LTTngTextTrace extends TmfTrace { @Override public LttngEvent parseEvent(ITmfContext context) { - context = seekLocation(context.getLocation()); + context = seekEvent(context.getLocation()); return parseMyNextEvent(context); } diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java index cc65e7ae9b..dfaf4c9088 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java @@ -43,6 +43,7 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; 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.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; @@ -63,7 +64,7 @@ class LTTngTraceException extends LttngException { * LTTng trace implementation. It accesses the C trace handling library * (seeking, reading and parsing) through the JNI component. */ -public class LTTngTrace extends TmfTrace { +public class LTTngTrace extends TmfTrace implements ITmfEventParser { public final static boolean PRINT_DEBUG = false; public final static boolean UNIQUE_EVENT = true; @@ -151,6 +152,8 @@ public class LTTngTrace extends TmfTrace { // Set the currentEvent to the eventContent eventContent.setEvent(currentLttngEvent); + fParser = (ITmfEventParser) this; + // // Bypass indexing if asked // if ( bypassIndexing == false ) { // indexTrace(true); @@ -168,8 +171,8 @@ public class LTTngTrace extends TmfTrace { if (jniTrace == null || (!jniTrace.isLiveTraceSupported() || !LiveTraceManager.isLiveTrace(jniTrace.getTracepath()))) { // Set the time range of the trace - final TmfContext context = seekLocation(null); - final LttngEvent event = getNextEvent(context); + final TmfContext context = seekEvent(0); + final LttngEvent event = readEvent(context); final LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp()); final LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime()); setTimeRange(new TmfTimeRange(startTime, endTime)); @@ -179,8 +182,8 @@ public class LTTngTrace extends TmfTrace { } // Set the time range of the trace - final TmfContext context = seekLocation(null); - final LttngEvent event = getNextEvent(context); + final TmfContext context = seekEvent(0); + final LttngEvent event = readEvent(context); setEndTime(TmfTimestamp.BIG_BANG); final long startTime = event != null ? event.getTimestamp().getValue() : TmfTimestamp.BIG_BANG.getValue(); fStreamingInterval = LTTNG_STREAMING_INTERVAL; @@ -440,7 +443,7 @@ public class LTTngTrace extends TmfTrace { * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext */ @Override - public synchronized TmfContext seekLocation(final ITmfLocation location) { + public synchronized TmfContext seekEvent(final ITmfLocation location) { // // [lmcfrch] // lastTime = 0; @@ -468,7 +471,7 @@ public class LTTngTrace extends TmfTrace { // 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()) - getNextEvent(context); + readEvent(context); return context; } @@ -584,7 +587,7 @@ public class LTTngTrace extends TmfTrace { } @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { // TODO Auto-generated method stub return null; } @@ -613,7 +616,7 @@ public class LTTngTrace extends TmfTrace { public int nbEventsRead = 0; @Override - public synchronized LttngEvent getNextEvent(final ITmfContext context) { + public synchronized LttngEvent readEvent(final ITmfContext context) { if (PRINT_DEBUG) System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngEventParserStub.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngEventParserStub.java index d5e0979ad7..6a3415b685 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngEventParserStub.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngEventParserStub.java @@ -16,9 +16,8 @@ import java.io.IOException; import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; -import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; -import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; /** * TmfEventParserStub @@ -31,8 +30,7 @@ public class LTTngEventParserStub implements ITmfEventParser { * @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext) */ @Override - public ITmfEvent parseNextEvent(ITmfTrace stream, ITmfContext context) - throws IOException { + public ITmfEvent parseEvent(ITmfContext context) { // TODO Auto-generated method stub return null; } diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java index e88fa9d96f..4c3d4dadf7 100644 --- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java +++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java @@ -19,8 +19,8 @@ import java.io.RandomAccessFile; import org.eclipse.core.resources.IResource; import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; -import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; 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.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; @@ -32,7 +32,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; * Dummy test trace. Use in conjunction with LTTngEventParserStub. */ @SuppressWarnings("nls") -public class LTTngTraceStub extends TmfTrace { +public class LTTngTraceStub extends TmfTrace implements ITmfEventParser { // ======================================================================== // Attributes @@ -91,7 +91,7 @@ public class LTTngTraceStub extends TmfTrace { */ @Override @SuppressWarnings("unchecked") - public TmfContext seekLocation(final ITmfLocation location) { + public TmfContext seekEvent(final ITmfLocation location) { TmfContext context = null; try { synchronized(fTrace) { @@ -109,7 +109,7 @@ public class LTTngTraceStub extends TmfTrace { } @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { // TODO Auto-generated method stub return null; } @@ -139,18 +139,18 @@ public class LTTngTraceStub extends TmfTrace { */ @Override public ITmfEvent parseEvent(final ITmfContext context) { - try { +// try { // paserNextEvent updates the context - final LttngEvent event = (LttngEvent) fParser.parseNextEvent(this, context); + final LttngEvent event = (LttngEvent) fParser.parseEvent(context); // if (event != null) { // context.setTimestamp(event.getTimestamp()); // } return event; - } - catch (final IOException e) { - e.printStackTrace(); - } - return null; +// } +// catch (final IOException e) { +// e.printStackTrace(); +// } +// return null; } /* (non-Javadoc) diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java index f80d2c704e..ea72941947 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java @@ -130,7 +130,7 @@ public class TmfExperimentTest extends TestCase { // 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.seekLocation(checkpoint.getLocation()); + 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)); @@ -144,52 +144,52 @@ public class TmfExperimentTest extends TestCase { public void testSeekLocationOnCacheBoundary() throws Exception { // Position trace at event rank 0 - TmfContext context = fExperiment.seekLocation(null); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4002, event.getTimestamp().getValue()); assertEquals("Event rank", 4002, context.getRank()); } @@ -198,53 +198,53 @@ public class TmfExperimentTest extends TestCase { // Position trace at event rank 9 TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0)); - TmfContext context = fExperiment.seekLocation(tmpContext.getLocation()); + TmfContext context = fExperiment.seekEvent(tmpContext.getLocation()); 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + context = fExperiment.seekEvent(tmpContext.getLocation()); 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -252,15 +252,15 @@ public class TmfExperimentTest extends TestCase { public void testSeekLocationOutOfScope() throws Exception { // Position trace at beginning - TmfContext tmpContext = fExperiment.seekLocation(null); - final TmfContext context = fExperiment.seekLocation(tmpContext.getLocation()); + 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()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -284,7 +284,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -296,7 +296,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -308,7 +308,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -323,7 +323,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -335,7 +335,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -347,7 +347,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -359,7 +359,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -371,7 +371,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -386,7 +386,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -410,7 +410,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -422,7 +422,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -434,7 +434,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -449,7 +449,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -461,7 +461,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -473,7 +473,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -485,7 +485,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -500,7 +500,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -525,7 +525,7 @@ public class TmfExperimentTest extends TestCase { // Read NB_EVENTS ITmfEvent event = null;; for (int i = 0; i < NB_READS; i++) { - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); assertEquals("Event rank", i + 1, context.getRank()); } @@ -544,11 +544,11 @@ public class TmfExperimentTest extends TestCase { // On lower bound, returns the first event (ts = 0) final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0)); - ITmfEvent event = fExperiment.getNextEvent(context); + ITmfEvent event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 2; i < 20; i++) { - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java index a51241131b..9b291307dc 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java @@ -134,7 +134,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { // 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.seekLocation(checkpoint.getLocation()); + 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)); @@ -148,52 +148,52 @@ public class TmfMultiTraceExperimentTest extends TestCase { public void testSeekLocationOnCacheBoundary() throws Exception { // Position trace at event rank 0 - TmfContext context = fExperiment.seekLocation(null); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4002, event.getTimestamp().getValue()); assertEquals("Event rank", 4002, context.getRank()); } @@ -202,53 +202,53 @@ public class TmfMultiTraceExperimentTest extends TestCase { // Position trace at event rank 9 TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0)); - TmfContext context = fExperiment.seekLocation(tmpContext.getLocation()); + TmfContext context = fExperiment.seekEvent(tmpContext.getLocation()); 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + context = fExperiment.seekEvent(tmpContext.getLocation()); 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation()); + 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()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -256,15 +256,15 @@ public class TmfMultiTraceExperimentTest extends TestCase { public void testSeekLocationOutOfScope() throws Exception { // Position trace at beginning - TmfContext tmpContext = fExperiment.seekLocation(null); - final TmfContext context = fExperiment.seekLocation(tmpContext.getLocation()); + 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()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -288,7 +288,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -300,7 +300,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -312,7 +312,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -327,7 +327,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -339,7 +339,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -351,7 +351,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -363,7 +363,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -375,7 +375,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -390,7 +390,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -414,7 +414,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -426,7 +426,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -438,7 +438,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -453,7 +453,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -465,7 +465,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -477,7 +477,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -489,7 +489,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -504,7 +504,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -529,7 +529,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { // Read NB_EVENTS ITmfEvent event = null;; for (int i = 0; i < NB_READS; i++) { - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); assertEquals("Event rank", i + 1, context.getRank()); } @@ -548,11 +548,11 @@ public class TmfMultiTraceExperimentTest extends TestCase { // On lower bound, returns the first event (ts = 0) final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0)); - ITmfEvent event = fExperiment.getNextEvent(context); + ITmfEvent event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 2; i < 20; i++) { - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java index 2b21a106b6..e5d304222d 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java @@ -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.trace; import junit.framework.Test; @@ -5,6 +18,10 @@ import junit.framework.TestSuite; import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin; +/** + * AllTests + *

+ */ @SuppressWarnings("nls") public class AllTests { @@ -12,8 +29,9 @@ public class AllTests { TestSuite suite = new TestSuite("Test suite for " + TmfCorePlugin.PLUGIN_ID + ".trace"); //$NON-NLS-1$); //$JUnit-BEGIN$ suite.addTestSuite(TmfLocationTest.class); + suite.addTestSuite(TmfContextTest.class); suite.addTestSuite(TmfCheckpointTest.class); - suite.addTestSuite(TmfContextTest.class); + suite.addTestSuite(TmfCheckpointIndexTest.class); suite.addTestSuite(TmfTraceTest.class); //$JUnit-END$ return suite; 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 index b8015603b2..c26f6c5089 100644 --- 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 @@ -126,7 +126,7 @@ public class TmfExperimentTest extends TestCase { // 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.seekLocation(checkpoint.getLocation()); + 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)); @@ -152,7 +152,7 @@ public class TmfExperimentTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 1; i < 20; i++) { - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } @@ -171,11 +171,11 @@ public class TmfExperimentTest extends TestCase { // On lower bound, returns the first event (ts = 0) final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0)); - ITmfEvent event = fExperiment.getNextEvent(context); + ITmfEvent event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); for (int i = 2; i < 20; i++) { - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } } @@ -188,34 +188,34 @@ public class TmfExperimentTest extends TestCase { public void testSeekLocationOnCacheBoundary() throws Exception { // Position trace at event rank 0 - TmfContext context = fExperiment.seekLocation(null); + 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); // assertEquals("Event rank", 4001, context.getRank()); } @@ -224,45 +224,45 @@ public class TmfExperimentTest extends TestCase { // Position trace at event rank 9 TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0)); - TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); // assertEquals("Event rank", 4501, context.getRank()); } @@ -270,24 +270,24 @@ public class TmfExperimentTest extends TestCase { public void testSeekLocationOutOfScope() throws Exception { // Position trace at beginning - TmfContext tmpContext = fExperiment.seekLocation(null); - TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(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.seekLocation(tmpContext.getLocation().clone()); + 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.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", null, event); // assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -304,7 +304,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -314,7 +314,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -324,7 +324,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -337,7 +337,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -347,7 +347,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -357,7 +357,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -367,7 +367,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -377,7 +377,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -390,7 +390,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -400,7 +400,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -417,7 +417,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -427,7 +427,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -437,7 +437,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -450,7 +450,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -460,7 +460,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -470,7 +470,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -480,7 +480,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -493,7 +493,7 @@ public class TmfExperimentTest extends TestCase { ITmfEvent event = fExperiment.parseEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -503,7 +503,7 @@ public class TmfExperimentTest extends TestCase { event = fExperiment.parseEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fExperiment.getNextEvent(context); + event = fExperiment.readEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java index a2a58ec2cd..f1c4e43998 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java @@ -27,15 +27,17 @@ import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; 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.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.TmfCheckpointIndexer; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; -import org.eclipse.linuxtools.tmf.core.trace.TmfTraceIndexer; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; /** @@ -253,7 +255,7 @@ public class TmfTraceTest extends TestCase { try { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); testfile = new File(FileLocator.toFileURL(location).toURI()); - original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfTraceIndexer(null)); + original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null)); trace = new TmfTraceStub(original); trace.indexTrace(); } catch (final URISyntaxException e) { @@ -495,13 +497,147 @@ public class TmfTraceTest extends TestCase { } // ------------------------------------------------------------------------ - // seekEvent on timestamp + // seekEvent on location (note: does not reliably set the rank) + // ------------------------------------------------------------------------ + + public void testSeekEventOnCacheBoundary() throws Exception { + + // Position trace at event rank 0 + ITmfContext context = fTrace.seekEvent(0); + ITmfEvent event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); + assertEquals("Event rank", 0, context.getRank()); + + context = fTrace.seekEvent(context.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + // Position trace at event rank 1000 + ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); + context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + // Position trace at event rank 4000 + tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0)); + context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + } + + public void testSeekEventNotOnCacheBoundary() throws Exception { + + // Position trace at event rank 9 + ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); + TmfContext context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + ITmfEvent event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + // Position trace at event rank 999 + tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0)); + context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + // Position trace at event rank 1001 + tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0)); + context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + // Position trace at event rank 4500 + tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0)); + context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + } + + public void testSeekEventOutOfScope() throws Exception { + + // Position trace at beginning + ITmfContext tmpContext = fTrace.seekEvent(0); + ITmfContext context = fTrace.seekEvent(tmpContext.getLocation()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + ITmfEvent event = fTrace.parseEvent(context); + assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(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); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + + event = fTrace.readEvent(context); + assertEquals("Event timestamp", null, event); + assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); + } + + // ------------------------------------------------------------------------ + // seekEvent on timestamp (note: does not reliably set the rank) // ------------------------------------------------------------------------ public void testSeekEventOnNullTimestamp() throws Exception { // Position trace at event rank 0 - ITmfContext context = fTrace.seekEvent(null); + ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -519,7 +655,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -531,7 +667,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -543,7 +679,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -558,7 +694,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 2, event.getTimestamp().getValue()); assertEquals("Event rank", 2, context.getRank()); @@ -570,7 +706,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -582,7 +718,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -594,7 +730,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -606,7 +742,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -621,7 +757,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -633,7 +769,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -663,7 +799,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -675,7 +811,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); @@ -687,7 +823,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4000, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); assertEquals("Event rank", 4001, context.getRank()); } @@ -702,7 +838,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 9, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); assertEquals("Event rank", 10, context.getRank()); @@ -714,7 +850,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 999, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); assertEquals("Event rank", 1000, context.getRank()); @@ -726,7 +862,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1001, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); assertEquals("Event rank", 1002, context.getRank()); @@ -738,7 +874,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4500, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); assertEquals("Event rank", 4501, context.getRank()); } @@ -753,7 +889,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 0, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); assertEquals("Event rank", 1, context.getRank()); @@ -765,7 +901,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", null, event); assertEquals("Event rank", NB_EVENTS, context.getRank()); } @@ -799,7 +935,7 @@ public class TmfTraceTest extends TestCase { // Position the trace at event NB_READS for (int i = 1; i < NB_READS; i++) { - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", i, event.getTimestamp().getValue()); } @@ -816,10 +952,10 @@ public class TmfTraceTest extends TestCase { } // ------------------------------------------------------------------------ - // getNextEvent - updates the context + // readEvent - updates the context // ------------------------------------------------------------------------ - public void testGetNextEvent() throws Exception { + public void testGetEvent() throws Exception { final int NB_READS = 20; @@ -829,7 +965,7 @@ public class TmfTraceTest extends TestCase { // Read NB_EVENTS ITmfEvent event; for (int i = 0; i < NB_READS; i++) { - event = fTrace.getNextEvent(context); + event = fTrace.readEvent(context); assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue()); assertEquals("Event rank", i + 1, context.getRank()); } @@ -845,7 +981,35 @@ public class TmfTraceTest extends TestCase { // ------------------------------------------------------------------------ @SuppressWarnings("unchecked") - public void testProcessRequestForNbEvents() throws Exception { + public void testProcessEventRequestForAllEvents() throws Exception { + final int BLOCK_SIZE = 1; + final Vector requestedEvents = new Vector(); + + final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); + final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { + @Override + public void handleData(final TmfEvent event) { + super.handleData(event); + requestedEvents.add(event); + } + }; + final ITmfDataProvider[] providers = (ITmfDataProvider[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); + providers[0].sendRequest(request); + request.waitForCompletion(); + + assertEquals("nbEvents", NB_EVENTS, 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 < NB_EVENTS; i++) { + assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue()); + } + } + + @SuppressWarnings("unchecked") + public void testProcessEventRequestForNbEvents() throws Exception { final int BLOCK_SIZE = 100; final int NB_EVENTS = 1000; final Vector requestedEvents = new Vector(); @@ -869,16 +1033,18 @@ public class TmfTraceTest extends TestCase { // Ensure that we have distinct events. // Don't go overboard: we are not validating the stub! for (int i = 0; i < NB_EVENTS; i++) { - assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); + assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue()); } } @SuppressWarnings("unchecked") - public void testProcessRequestForAllEvents() throws Exception { + public void testProcessEventRequestForSomeEvents() throws Exception { final int BLOCK_SIZE = 1; + final long startTime = 100; + final int NB_EVENTS = 1000; final Vector requestedEvents = new Vector(); - final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); + final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) { @Override public void handleData(final TmfEvent event) { @@ -897,7 +1063,66 @@ public class TmfTraceTest extends TestCase { // Ensure that we have distinct events. // Don't go overboard: we are not validating the stub! for (int i = 0; i < NB_EVENTS; i++) { - assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue()); + assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue()); + } + } + + @SuppressWarnings("unchecked") + public void testProcessEventRequestForOtherEvents() throws Exception { + final int BLOCK_SIZE = 1; + final int startIndex = 99; + final long startTime = 100; + final int NB_EVENTS = 1000; + final Vector requestedEvents = new Vector(); + + final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); + final TmfEventRequest request = new TmfEventRequest(TmfEvent.class, range, startIndex, NB_EVENTS, BLOCK_SIZE) { + @Override + public void handleData(final TmfEvent event) { + super.handleData(event); + requestedEvents.add(event); + } + }; + final ITmfDataProvider[] providers = (ITmfDataProvider[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); + providers[0].sendRequest(request); + request.waitForCompletion(); + + assertEquals("nbEvents", NB_EVENTS, 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 < NB_EVENTS; i++) { + assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue()); + } + } + + @SuppressWarnings("unchecked") + public void testProcessDataRequestForSomeEvents() throws Exception { + final int startIndex = 100; + final int NB_EVENTS = 1000; + final Vector requestedEvents = new Vector(); + + final TmfDataRequest request = new TmfDataRequest(TmfEvent.class, startIndex, NB_EVENTS) { + @Override + public void handleData(final TmfEvent event) { + super.handleData(event); + requestedEvents.add(event); + } + }; + final ITmfDataProvider[] providers = (ITmfDataProvider[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class); + providers[0].sendRequest(request); + request.waitForCompletion(); + + assertEquals("nbEvents", NB_EVENTS, 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 < NB_EVENTS; i++) { + assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue()); } } @@ -955,166 +1180,4 @@ public class TmfTraceTest extends TestCase { assertEquals("toString", expected, fTrace.toString()); } - -// // ------------------------------------------------------------------------ -// // seekLocation -// // Note: seekLocation() does not reliably set the rank -// // ------------------------------------------------------------------------ -// -// public void testSeekLocationOnCacheBoundary() throws Exception { -// -// // Position trace at event rank 0 -// TmfContext context = fTrace.seekLocation(null); -// ITmfEvent event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); -// assertEquals("Event rank", 0, context.getRank()); -// -// context = fTrace.seekLocation(context.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// // Position trace at event rank 1000 -// ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); -// context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 1001, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// // Position trace at event rank 4000 -// tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0)); -// context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 4001, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// } -// -// public void testSeekLocationNotOnCacheBoundary() throws Exception { -// -// // Position trace at event rank 9 -// ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); -// TmfContext context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// ITmfEvent event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 10, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// // Position trace at event rank 999 -// tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0)); -// context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 1000, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// // Position trace at event rank 1001 -// tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0)); -// context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 1002, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// // Position trace at event rank 4500 -// tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0)); -// context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", 4501, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// } -// -// public void testSeekLocationOutOfScope() throws Exception { -// -// // Position trace at beginning -// ITmfContext tmpContext = fTrace.seekLocation(null); -// ITmfContext context = fTrace.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// ITmfEvent event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", 1, event.getTimestamp().getValue()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(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.seekLocation(tmpContext.getLocation()); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.parseEvent(context); -// assertEquals("Event timestamp", null, event); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// -// event = fTrace.getNextEvent(context); -// assertEquals("Event timestamp", null, event); -// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); -// } - - // ------------------------------------------------------------------------ - // Verify checkpoints - // ------------------------------------------------------------------------ - - // public void testTmfTraceIndexing() throws Exception { - // assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getIndexPageSize()); - // assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents()); - // assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue()); - // assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue()); - // assertEquals("getStartTime", 1, fTrace.getStartTime().getValue()); - // assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue()); - // - // final Vector checkpoints = fTrace.getCheckpoints(); - // final int pageSize = fTrace.getIndexPageSize(); - // 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 TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize); - // final ITmfEvent event = fTrace.parseEvent(context); - // assertTrue(context.getRank() == i * pageSize); - // assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0)); - // } - // } - } \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java index fcf8dfbf35..70b3b6c45a 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java @@ -23,8 +23,8 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; +import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; @@ -34,7 +34,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; * TODO: Implement me. Please. */ @SuppressWarnings("nls") -public class TmfEventParserStub implements ITmfEventParser { +public class TmfEventParserStub implements ITmfEventParser { // ------------------------------------------------------------------------ // Attributes @@ -42,12 +42,14 @@ public class TmfEventParserStub implements ITmfEventParser { private static final int NB_TYPES = 10; private final TmfEventType[] fTypes; + private ITmfTrace fEventStream; // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ - public TmfEventParserStub() { + public TmfEventParserStub(final ITmfTrace eventStream) { + fEventStream = eventStream; fTypes = new TmfEventType[NB_TYPES]; for (int i = 0; i < NB_TYPES; i++) { final Vector fields = new Vector(); @@ -68,13 +70,13 @@ public class TmfEventParserStub implements ITmfEventParser { static final String typePrefix = "Type-"; @Override @SuppressWarnings("unchecked") - public ITmfEvent parseNextEvent(final ITmfTrace eventStream, final ITmfContext context) throws IOException { + public ITmfEvent parseEvent(final ITmfContext context) { - if (! (eventStream instanceof TmfTraceStub)) + if (! (fEventStream instanceof TmfTraceStub)) return null; // Highly inefficient... - final RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream(); + final RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream(); // String name = eventStream.getName(); // name = name.substring(name.lastIndexOf('/') + 1); @@ -83,9 +85,10 @@ public class TmfEventParserStub implements ITmfEventParser { long location = 0; if (context != null) location = ((TmfLocation) (context.getLocation())).getLocation(); - stream.seek(location); try { + stream.seek(location); + final long ts = stream.readLong(); final String source = stream.readUTF(); final String type = stream.readUTF(); @@ -103,11 +106,12 @@ public class TmfEventParserStub implements ITmfEventParser { content.append("]"); final TmfEventField root = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString()); - final ITmfEvent event = new TmfEvent(eventStream, + final ITmfEvent 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; } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java index c9d032d4e6..69d3a87424 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java @@ -22,8 +22,8 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; -import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; 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.ITmfTraceIndexer; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; @@ -36,7 +36,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; * Dummy test trace. Use in conjunction with TmfEventParserStub. */ @SuppressWarnings("nls") -public class TmfTraceStub extends TmfTrace { +public class TmfTraceStub extends TmfTrace implements ITmfEventParser { // ------------------------------------------------------------------------ // Attributes @@ -45,8 +45,8 @@ public class TmfTraceStub extends TmfTrace { // The actual stream private RandomAccessFile fTrace; - // The associated event parser - private ITmfEventParser fParser; +// // The associated event parser +// private ITmfEventParser fParser; // The synchronization lock private final ReentrantLock fLock = new ReentrantLock(); @@ -61,7 +61,7 @@ public class TmfTraceStub extends TmfTrace { */ public TmfTraceStub() { super(); - fParser = new TmfEventParserStub(); + fParser = new TmfEventParserStub(this); } /** @@ -89,7 +89,7 @@ public class TmfTraceStub extends TmfTrace { public TmfTraceStub(final String path, final int cacheSize, final long interval) throws FileNotFoundException { super(null, TmfEvent.class, path, cacheSize, interval); fTrace = new RandomAccessFile(path, "r"); - fParser = new TmfEventParserStub(); + fParser = new TmfEventParserStub(this); } /** @@ -119,7 +119,7 @@ public class TmfTraceStub extends TmfTrace { public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException { super(null, TmfEvent.class, path, cacheSize); fTrace = new RandomAccessFile(path, "r"); - fParser = new TmfEventParserStub(); + fParser = new TmfEventParserStub(this); } /** @@ -131,7 +131,7 @@ public class TmfTraceStub extends TmfTrace { public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException { super(resource, TmfEvent.class, path, cacheSize); fTrace = new RandomAccessFile(path, "r"); - fParser = new TmfEventParserStub(); + fParser = new TmfEventParserStub(this); } /** @@ -141,11 +141,12 @@ public class TmfTraceStub extends TmfTrace { * @param parser * @throws FileNotFoundException */ + @SuppressWarnings("unchecked") public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion, final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws FileNotFoundException { super(null, TmfEvent.class, path, cacheSize, 0, indexer); fTrace = new RandomAccessFile(path, "r"); - fParser = (parser != null) ? parser : new TmfEventParserStub(); + fParser = (ITmfEventParser) ((parser != null) ? parser : new TmfEventParserStub(this)); } /** @@ -154,7 +155,7 @@ public class TmfTraceStub extends TmfTrace { public TmfTraceStub(final TmfTraceStub trace) throws FileNotFoundException { super(trace); fTrace = new RandomAccessFile(getPath(), "r"); - fParser = new TmfEventParserStub(); + fParser = new TmfEventParserStub(this); } public void indexTrace() { @@ -164,7 +165,7 @@ public class TmfTraceStub extends TmfTrace { @Override public void initTrace(final IResource resource, final String path, final Class type) throws FileNotFoundException { fTrace = new RandomAccessFile(path, "r"); - fParser = new TmfEventParserStub(); + fParser = new TmfEventParserStub(this); super.initTrace(resource, path, type); } @@ -187,7 +188,7 @@ public class TmfTraceStub extends TmfTrace { @Override @SuppressWarnings("unchecked") - public TmfContext seekLocation(final ITmfLocation location) { + public TmfContext seekEvent(final ITmfLocation location) { try { fLock.lock(); try { @@ -222,12 +223,12 @@ public class TmfTraceStub extends TmfTrace { @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { fLock.lock(); try { if (fTrace != null) { final ITmfLocation location = new TmfLocation(Long.valueOf((long) (ratio * fTrace.length()))); - final TmfContext context = seekLocation(location); + final TmfContext context = seekEvent(location); context.setRank(ITmfContext.UNKNOWN_RANK); return context; } @@ -276,12 +277,12 @@ public class TmfTraceStub extends TmfTrace { try { // parseNextEvent will update the context if (fTrace != null) { - final ITmfEvent event = fParser.parseNextEvent(this, context.clone()); + final ITmfEvent event = fParser.parseEvent(context.clone()); return event; } - } - catch (final IOException e) { - e.printStackTrace(); +// } +// catch (final IOException e) { +// e.printStackTrace(); } finally { fLock.unlock(); } diff --git a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF index fd0d769f74..3bf8d3f114 100644 --- a/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF @@ -23,7 +23,6 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.core;x-friends:="org.eclipse org.eclipse.linuxtools.tmf.core.filter.xml, org.eclipse.linuxtools.tmf.core.interval, org.eclipse.linuxtools.tmf.core.io, - org.eclipse.linuxtools.tmf.core.parser, org.eclipse.linuxtools.tmf.core.request, org.eclipse.linuxtools.tmf.core.signal, org.eclipse.linuxtools.tmf.core.statesystem, diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java index 9481d2d3e2..1a57e6e5fb 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java @@ -245,7 +245,7 @@ public class CtfTmfTrace extends TmfEventProvider implements ITmfTr // ------------------------------------------------------------------------ @Override - public ITmfContext seekLocation(final ITmfLocation location) { + public ITmfContext seekEvent(final ITmfLocation location) { CtfLocation currentLocation = (CtfLocation) location; if (currentLocation == null) currentLocation = new CtfLocation(0L); @@ -286,21 +286,21 @@ public class CtfTmfTrace extends TmfEventProvider implements ITmfTr * Seek rank ratio */ @Override - public ITmfContext seekLocation(final double ratio) { + public ITmfContext seekEvent(final double ratio) { iterator.seek((long) (this.fNbEvents * ratio)); return iterator; } @Override - public CtfTmfEvent getNextEvent(final ITmfContext context) { + public CtfTmfEvent readEvent(final ITmfContext context) { iterator.advance(); return iterator.getCurrentEvent(); } - @Override - public CtfTmfEvent parseEvent(final ITmfContext context) { - return iterator.getCurrentEvent(); - } +// @Override +// public CtfTmfEvent parseEvent(final ITmfContext context) { +// return iterator.getCurrentEvent(); +// } @Override public IResource getResource() { diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java index ed97585068..4b4cb22639 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java @@ -247,7 +247,7 @@ public class TmfExperiment extends TmfEventProvider impl */ public ITmfTimestamp getTimestamp(final int index) { final TmfExperimentContext context = seekEvent(index); - final ITmfEvent event = getNextEvent(context); + final ITmfEvent event = readEvent(context); return (event != null) ? event.getTimestamp() : null; } @@ -302,7 +302,7 @@ public class TmfExperiment extends TmfEventProvider impl @SuppressWarnings("unchecked") public T getNext(final ITmfContext context) { if (context instanceof TmfExperimentContext) - return (T) getNextEvent(context); + return (T) readEvent(context); return null; } @@ -313,7 +313,7 @@ public class TmfExperiment extends TmfEventProvider impl // Returns a brand new context based on the location provided // and initializes the event queues @Override - public synchronized TmfExperimentContext seekLocation(final ITmfLocation location) { + public synchronized TmfExperimentContext seekEvent(final ITmfLocation location) { // Validate the location if (location != null && !(location instanceof TmfExperimentLocation)) return null; // Throw an exception? @@ -336,7 +336,7 @@ public class TmfExperiment extends TmfEventProvider impl final long traceRank = expLocation.getRanks()[i]; // Set the corresponding sub-context - context.getContexts()[i] = fTraces[i].seekLocation(traceLocation); + context.getContexts()[i] = fTraces[i].seekEvent(traceLocation); context.getContexts()[i].setRank(traceRank); rank += traceRank; @@ -346,7 +346,7 @@ public class TmfExperiment extends TmfEventProvider impl * ourselves higher up. */ expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone(); - context.getEvents()[i] = fTraces[i].getNextEvent(context.getContexts()[i]); + context.getEvents()[i] = fTraces[i].readEvent(context.getContexts()[i]); } // Tracer.trace("Ctx: SeekLocation - done"); @@ -392,13 +392,13 @@ public class TmfExperiment extends TmfEventProvider impl location = null; } - final TmfExperimentContext context = seekLocation(location); + 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)) { - getNextEvent(context); + readEvent(context); event = parseEvent(context); } @@ -431,14 +431,14 @@ public class TmfExperiment extends TmfEventProvider impl } } - final TmfExperimentContext context = seekLocation(location); + 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)) { - getNextEvent(context); + readEvent(context); event = parseEvent(context); } @@ -451,7 +451,7 @@ public class TmfExperiment extends TmfEventProvider impl } @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { final TmfContext context = seekEvent((long) (ratio * getNbEvents())); return context; } @@ -459,7 +459,7 @@ public class TmfExperiment extends TmfEventProvider impl @Override public double getLocationRatio(final ITmfLocation location) { if (location instanceof TmfExperimentLocation) - return (double) seekLocation(location).getRank() / getNbEvents(); + return (double) seekEvent(location).getRank() / getNbEvents(); return 0; } @@ -494,7 +494,7 @@ public class TmfExperiment extends TmfEventProvider impl * @return the next event */ @Override - public synchronized ITmfEvent getNextEvent(final ITmfContext context) { + public synchronized ITmfEvent readEvent(final ITmfContext context) { // Validate the context if (!(context instanceof TmfExperimentContext)) @@ -502,7 +502,7 @@ public class TmfExperiment extends TmfEventProvider impl if (!context.equals(fExperimentContext)) // Tracer.trace("Ctx: Restoring context"); - fExperimentContext = seekLocation(context.getLocation()); + fExperimentContext = seekEvent(context.getLocation()); final TmfExperimentContext expContext = (TmfExperimentContext) context; @@ -512,7 +512,7 @@ public class TmfExperiment extends TmfEventProvider impl final int lastTrace = expContext.getLastTrace(); if (lastTrace != TmfExperimentContext.NO_TRACE) { final ITmfContext traceContext = expContext.getContexts()[lastTrace]; - expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext); + expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext); expContext.setLastTrace(TmfExperimentContext.NO_TRACE); } @@ -585,7 +585,7 @@ public class TmfExperiment extends TmfEventProvider impl /* (non-Javadoc) * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext) */ - @Override +// @Override public ITmfEvent parseEvent(final ITmfContext context) { // Validate the context @@ -594,7 +594,7 @@ public class TmfExperiment extends TmfEventProvider impl if (!context.equals(fExperimentContext)) // Tracer.trace("Ctx: Restoring context"); - seekLocation(context.getLocation()); + seekEvent(context.getLocation()); final TmfExperimentContext expContext = (TmfExperimentContext) context; @@ -602,7 +602,7 @@ public class TmfExperiment extends TmfEventProvider impl final int lastTrace = expContext.getLastTrace(); if (lastTrace != TmfExperimentContext.NO_TRACE) { final ITmfContext traceContext = expContext.getContexts()[lastTrace]; - expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext); + expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext); expContext.setLastTrace(TmfExperimentContext.NO_TRACE); fExperimentContext = (TmfExperimentContext) context; } @@ -647,7 +647,7 @@ public class TmfExperiment extends TmfEventProvider impl fInitialized = true; if (getStreamingInterval() == 0) { - final TmfContext context = seekLocation(null); + final TmfContext context = seekEvent(0); final ITmfEvent event = getNext(context); if (event == null) return; diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfEventRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfEventRequest.java index eb5f9d5987..d490bb007f 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfEventRequest.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfEventRequest.java @@ -114,6 +114,20 @@ public abstract class TmfEventRequest extends TmfDataReques this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND); } + /** + * Request 'n' events of a given type for the given time range (high priority). + * Events are returned in blocks of the given size. + * + * @param dataType the requested data type + * @param range the time range of the requested events + * @param index the index of the first event to retrieve + * @param nbRequested the number of events requested + * @param blockSize the number of events per block + */ + public TmfEventRequest(Class dataType, TmfTimeRange range, int index, int nbRequested, int blockSize) { + this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND); + } + /** * Request 'n' events of a given type for the given time range (given priority). * Events are returned in blocks of the given size. diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java similarity index 61% rename from org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java rename to org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java index abb07bfd71..74fa648a91 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java @@ -8,15 +8,12 @@ * * Contributors: * Francois Chouinard - Initial API and implementation + * Francois Chouinard - Updated as per TMF Trace Model 1.0 *******************************************************************************/ -package org.eclipse.linuxtools.tmf.core.parser; - -import java.io.IOException; +package org.eclipse.linuxtools.tmf.core.trace; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; -import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; -import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; /** * ITmfEventParser @@ -24,17 +21,12 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; */ public interface ITmfEventParser { - /** - * @return a parsed event - * @throws IOException - */ /** * Parses the trace event referenced by the context. * - * @param trace the event stream - * @param context the trace context - * @return the parsed event - * @throws IOException + * @param context + * @return */ - public ITmfEvent parseNextEvent(ITmfTrace trace, ITmfContext context) throws IOException; + public ITmfEvent parseEvent(ITmfContext context); + } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java index befb513660..2ea567caa8 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java @@ -21,22 +21,23 @@ import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; 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.request.ITmfEventRequest; /** * ITmfTrace *

* The event stream structure in TMF. In its basic form, a trace has: *

    - *
  • the associated Eclipse resource - *
  • the path to its location on the file system + *
  • an associated Eclipse resource + *
  • a path to its location on the file system *
  • the type of the events it contains *
  • the number of events it contains *
  • the time range (span) of the events it contains *
* Concrete ITmfTrace classes have to provide a parameter-less constructor and - * an initialization method (initTace())if they are to be opened from the - * Project View. Also, a validation (validate()) method has to be provided to - * ensure that the trace is of the correct type. + * an initialization method (initTrace) if they are to be opened from + * the Project View. Also, a validation method (validate) has to be + * provided to ensure that the trace is of the correct type. *

* A trace can be accessed simultaneously from multiple threads by various * application components. To avoid obvious multi-threading issues, the trace @@ -48,22 +49,22 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; *

* Example 1: Process a whole trace *

- * ITmfContext context = trace.seekLocationt(null);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfContext context = trace.seekEvent(0);
+ * ITmfEvent event = trace.getEvent(context);
  * while (event != null) {
  *     processEvent(event);
- *     event = trace.getNextEvent(context);
+ *     event = trace.getEvent(context);
  * }
  * 
* Example 2: Process 50 events starting from the 1000th event *
  * int nbEventsRead = 0;
  * ITmfContext context = trace.seekEvent(1000);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfEvent event = trace.getEvent(context);
  * while (event != null && nbEventsRead < 50) {
  *     nbEventsRead++;
  *     processEvent(event);
- *     event = trace.getNextEvent(context);
+ *     event = trace.getEvent(context);
  * }
  * 
* Example 3: Process the events between 2 timestamps (inclusive) @@ -71,17 +72,17 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; * ITmfTimestamp startTime = ...; * ITmfTimestamp endTime = ...; * ITmfContext context = trace.seekEvent(startTime); - * ITmfEvent event = trace.getNextEvent(context); + * ITmfEvent event = trace.getEvent(context); * while (event != null && event.getTimestamp().compareTo(endTime) <= 0) { * processEvent(event); - * event = trace.getNextEvent(context); + * event = trace.getEvent(context); * } * * A trace is also an event provider so it can process event requests - * asynchronously (and coalesce compatible requests). + * asynchronously (and coalesce compatible, concurrent requests). *

* - * Example 4: Process a whole trace + * Example 4: Process a whole trace (see ITmfEventRequest for variants) *

  * ITmfRequest request = new TmfEventRequest<MyEventType>(MyEventType.class) {
  *     @Override
@@ -95,6 +96,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
  *         super.handleCompleted();
  *     }
  * };
+ * 
  * fTrace.handleRequest(request);
  * if (youWant) {
  *     request.waitForCompletion();
@@ -102,7 +104,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
  * 
* @see ITmfEvent * @see ITmfEventProvider - * @see ITmfRequest + * @see ITmfEventRequest */ public interface ITmfTrace extends ITmfDataProvider { @@ -201,35 +203,36 @@ public interface ITmfTrace extends ITmfDataProvider { public double getLocationRatio(ITmfLocation location); // ------------------------------------------------------------------------ - // Seek operations (returning a reading context) + // SeekEvent operations (returning a trace context) // ------------------------------------------------------------------------ /** - * Position the trace at the specified location. The null location - * is used to indicate that the first trace event is requested. + * Position the trace at the specified (trace specific) location. + *

+ * A null location is interpreted as seeking for the first event of the + * trace. *

- *

    - *
  • a null location returns the context of the first event - *
  • an invalid location, including beyond the last event, returns a null context - *
+ * If not null, the location requested must be valid otherwise the returned + * context is undefined (up to the implementation to recover if possible). *

- * @param location the trace specific location (null for 1st event) + * @param location the trace specific location * @return a context which can later be used to read the corresponding event */ - public ITmfContext seekLocation(ITmfLocation location); + public ITmfContext seekEvent(ITmfLocation location); /** - * Position the trace at the event located at the specified ratio in the - * trace file. + * Position the trace at the 'rank'th event in the trace. *

- * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left - * voluntarily vague. Typically, it would refer to the event proportional - * rank (arguably more intuitive) or timestamp in the trace file. + * A rank <= 0 is interpreted as seeking for the first event of the + * trace. + *

+ * If the requested rank is beyond the last trace event, the context + * returned will yield a null event if used in a subsequent read. * - * @param ratio the proportional 'rank' in the trace + * @param rank the event rank * @return a context which can later be used to read the corresponding event */ - public ITmfContext seekLocation(double ratio); + public ITmfContext seekEvent(long rank); /** * Position the trace at the first event with the specified timestamp. If @@ -248,15 +251,17 @@ public interface ITmfTrace extends ITmfDataProvider { public ITmfContext seekEvent(ITmfTimestamp timestamp); /** - * Position the trace at the 'rank'th event in the trace. + * Position the trace at the event located at the specified ratio in the + * trace file. *

- * If the requested rank is beyond the last trace event, the context - * returned will yield a null event if used in a subsequent read. + * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left + * voluntarily vague. Typically, it would refer to the event proportional + * rank (arguably more intuitive) or timestamp in the trace file. * - * @param rank the event rank + * @param ratio the proportional 'rank' in the trace * @return a context which can later be used to read the corresponding event */ - public ITmfContext seekEvent(long rank); + public ITmfContext seekEvent(double ratio); // ------------------------------------------------------------------------ // Read operations (returning an actual event) @@ -269,18 +274,19 @@ public interface ITmfTrace extends ITmfDataProvider { * @param context the read context (will be updated) * @return the event pointed to by the context */ - public ITmfEvent getNextEvent(ITmfContext context); + public ITmfEvent readEvent(ITmfContext context); - /** - * Return the event pointed by the supplied context (or null if no event - * left) and *does not* update the context. - * - * @param context the read context - * @return the next event in the stream - */ - public ITmfEvent parseEvent(ITmfContext context); +// /** +// * Return the event pointed by the supplied context (or null if no event +// * left) and *does not* update the context. +// * +// * @param context the read context +// * @return the next event in the stream +// */ +// public ITmfEvent parseEvent(ITmfContext context); // ------------------------------------------------------------------------ + // // ------------------------------------------------------------------------ /** diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceIndexer.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java similarity index 92% rename from org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceIndexer.java rename to org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java index 65b2f83e65..2b35e0a8a1 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceIndexer.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java @@ -42,7 +42,7 @@ 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). */ -public class TmfTraceIndexer> implements ITmfTraceIndexer { +public class TmfCheckpointIndexer> implements ITmfTraceIndexer { // ------------------------------------------------------------------------ // Attributes @@ -74,7 +74,7 @@ public class TmfTraceIndexer> implements ITmfTrac * * @param trace the trace to index */ - public TmfTraceIndexer(final ITmfTrace trace) { + public TmfCheckpointIndexer(final ITmfTrace trace) { this(trace, TmfTrace.DEFAULT_BLOCK_SIZE); } @@ -84,7 +84,7 @@ public class TmfTraceIndexer> implements ITmfTrac * @param trace the trace to index * @param interval the checkpoints interval */ - public TmfTraceIndexer(final ITmfTrace trace, final int interval) { + public TmfCheckpointIndexer(final ITmfTrace trace, final int interval) { fTrace = trace; fCheckpointInterval = interval; fTraceIndex = new Vector(); @@ -164,7 +164,7 @@ public class TmfTraceIndexer> implements ITmfTrac private void updateTraceStatus() { if (getNbRead() != 0) { - notifyListeners(startTime, lastTime); + signalNewTimeRange(startTime, lastTime); } } }; @@ -179,7 +179,13 @@ public class TmfTraceIndexer> implements ITmfTrac } } - private void notifyListeners(final ITmfTimestamp startTime, final ITmfTimestamp endTime) { + /** + * Notify the interested parties that the trace time range has changed + * + * @param startTime the new start time + * @param endTime the new end time + */ + private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) { fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime))); } @@ -216,7 +222,7 @@ public class TmfTraceIndexer> implements ITmfTrac // A null timestamp indicates to seek the first event if (timestamp == null) - return fTrace.seekLocation(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 @@ -237,9 +243,9 @@ public class TmfTraceIndexer> implements ITmfTrac @Override public ITmfContext seekIndex(final long rank) { - // A rank <= 0 indicates to seek the first event - if (rank <= 0) - return fTrace.seekLocation(null); + // A rank < 0 indicates to seek the first event + if (rank < 0) + return fTrace.seekEvent(0); // Find the checkpoint at or before the requested rank. final int index = (int) rank / fCheckpointInterval; @@ -267,7 +273,7 @@ public class TmfTraceIndexer> implements ITmfTrac location = null; } } - final ITmfContext context = fTrace.seekLocation(location); + final ITmfContext context = fTrace.seekEvent(location); context.setRank(index * fCheckpointInterval); return context; } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java index 0f2063a5a1..75891a7a0a 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java @@ -56,14 +56,13 @@ public abstract class TmfTrace extends TmfEventProvider private String fPath; /** - * The cache page size AND trace checkpoints interval + * The cache page size */ protected int fCacheSize = DEFAULT_TRACE_CACHE_SIZE; - // The set of event stream checkpoints -// protected Vector fCheckpoints = new Vector(); - - // The number of events collected + /** + * The number of events collected so far + */ protected long fNbEvents = 0; // The time span of the event stream @@ -80,6 +79,11 @@ public abstract class TmfTrace extends TmfEventProvider */ protected ITmfTraceIndexer> fIndexer; + /** + * The trace parser + */ + protected ITmfEventParser fParser; + // ------------------------------------------------------------------------ // Construction // ------------------------------------------------------------------------ @@ -90,7 +94,7 @@ public abstract class TmfTrace extends TmfEventProvider @SuppressWarnings({ "unchecked", "rawtypes" }) public TmfTrace() { super(); - fIndexer = new TmfTraceIndexer(this); + fIndexer = new TmfCheckpointIndexer(this); } /** @@ -136,7 +140,7 @@ public abstract class TmfTrace extends TmfEventProvider super(); fCacheSize = (cacheSize > 0) ? cacheSize : DEFAULT_TRACE_CACHE_SIZE; fStreamingInterval = interval; - fIndexer = (indexer != null) ? indexer : new TmfTraceIndexer(this, fCacheSize); + fIndexer = (indexer != null) ? indexer : new TmfCheckpointIndexer(this, fCacheSize); initialize(resource, path, type); } @@ -152,10 +156,23 @@ public abstract class TmfTrace extends TmfEventProvider throw new IllegalArgumentException(); fCacheSize = trace.getCacheSize(); fStreamingInterval = trace.getStreamingInterval(); - fIndexer = new TmfTraceIndexer(this); + fIndexer = new TmfCheckpointIndexer(this); initialize(trace.getResource(), trace.getPath(), trace.getType()); } + // ------------------------------------------------------------------------ + // ITmfTrace - Initializers + // ------------------------------------------------------------------------ + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class) + */ + @Override + public void initTrace(final IResource resource, final String path, final Class type) throws FileNotFoundException { + initialize(resource, path, type); + fIndexer.buildIndex(false); + } + /** * Initialize the trace common attributes and the base component. * @@ -179,19 +196,6 @@ public abstract class TmfTrace extends TmfEventProvider super.init(traceName, type); } - // ------------------------------------------------------------------------ - // ITmfTrace - Initializers - // ------------------------------------------------------------------------ - - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class) - */ - @Override - public void initTrace(final IResource resource, final String path, final Class type) throws FileNotFoundException { - initialize(resource, path, type); - fIndexer.buildIndex(false); - } - /* (non-Javadoc) * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String) * @@ -326,53 +330,53 @@ public abstract class TmfTrace extends TmfEventProvider } // ------------------------------------------------------------------------ - // ITmfTrace - Seek operations (returning a reading context) + // ITmfTrace - SeekEvent operations (returning a trace context) // ------------------------------------------------------------------------ /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long) */ @Override - public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) { + public synchronized ITmfContext seekEvent(final long rank) { - // A null timestamp indicates to seek the first event - if (timestamp == null) - return seekLocation(null); + // A rank <= 0 indicates to seek the first event + if (rank <= 0) + return seekEvent((ITmfLocation) null); // Position the trace at the checkpoint - final ITmfContext context = fIndexer.seekIndex(timestamp); + final ITmfContext context = fIndexer.seekIndex(rank); // And locate the requested event context - final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype... - ITmfEvent event = getNextEvent(nextEventContext); - while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) { - context.setLocation(nextEventContext.getLocation().clone()); - context.increaseRank(); - event = getNextEvent(nextEventContext); + long pos = context.getRank(); + if (pos < rank) { + ITmfEvent event = readEvent(context); + while (event != null && ++pos < rank) { + event = readEvent(context); + } } return context; } /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp) */ @Override - public synchronized ITmfContext seekEvent(final long rank) { + public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) { - // A rank <= 0 indicates to seek the first event - if (rank <= 0) - return seekLocation(null); + // A null timestamp indicates to seek the first event + if (timestamp == null) + return seekEvent(0); // Position the trace at the checkpoint - final ITmfContext context = fIndexer.seekIndex(rank); + final ITmfContext context = fIndexer.seekIndex(timestamp); // And locate the requested event context - long pos = context.getRank(); - if (pos < rank) { - ITmfEvent event = getNextEvent(context); - while (event != null && ++pos < rank) { - event = getNextEvent(context); - } + final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype... + ITmfEvent event = readEvent(nextEventContext); + while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) { + context.setLocation(nextEventContext.getLocation().clone()); + context.increaseRank(); + event = readEvent(nextEventContext); } return context; } @@ -382,22 +386,12 @@ public abstract class TmfTrace extends TmfEventProvider // ------------------------------------------------------------------------ /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext) - */ - @Override - public synchronized ITmfEvent parseEvent(final ITmfContext context) { - final ITmfContext tmpContext = context.clone(); - final ITmfEvent event = getNextEvent(tmpContext); - return event; - } - - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext) */ @Override - public synchronized ITmfEvent getNextEvent(final ITmfContext context) { + public synchronized ITmfEvent readEvent(final ITmfContext context) { // parseEvent() does not update the context - final ITmfEvent event = parseEvent(context); + final ITmfEvent event = fParser.parseEvent(context); if (event != null) { updateAttributes(context, event.getTimestamp()); context.setLocation(getCurrentLocation()); @@ -409,7 +403,7 @@ public abstract class TmfTrace extends TmfEventProvider /** * Hook for special event processing by the concrete class - * (called by TmfTrace.getNextEvent()) + * (called by TmfTrace.getEvent()) * * @param event the event */ @@ -467,7 +461,7 @@ public abstract class TmfTrace extends TmfEventProvider @SuppressWarnings("unchecked") public T getNext(final ITmfContext context) { if (context instanceof TmfContext) - return (T) getNextEvent(context); + return (T) readEvent(context); return null; } diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java index f5f254677f..8088ec2adc 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java @@ -23,8 +23,8 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; -import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal; +import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; import org.eclipse.linuxtools.tmf.ui.tests.uml2sd.trace.TmfUml2SDTestTrace; @@ -85,6 +85,7 @@ public class Uml2SDTestFacility { fParser = new TmfUml2SDTestTrace(); fTrace = setupTrace(fParser); + fParser.setTrace(fTrace); IViewPart view; try { @@ -275,7 +276,11 @@ public class Uml2SDTestFacility { */ @SuppressWarnings({ "rawtypes", "unchecked" }) public void selectExperiment(final boolean wait) { + fParser = new TmfUml2SDTestTrace(); fTrace = setupTrace(fParser); + fParser.setTrace(fTrace); + +// fTrace = setupTrace(fParser); final ITmfTrace traces[] = new ITmfTrace[1]; traces[0] = fTrace; diff --git a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java index d836824af2..bdac6e010a 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java @@ -20,23 +20,36 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; +import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; public class TmfUml2SDTestTrace implements ITmfEventParser { + ITmfTrace fEventStream; + + public TmfUml2SDTestTrace() { + } + + public TmfUml2SDTestTrace(ITmfTrace eventStream) { + fEventStream = eventStream; + } + + public void setTrace(ITmfTrace eventStream) { + fEventStream = eventStream; + } + @Override @SuppressWarnings({ "unchecked", "nls" }) - public TmfEvent parseNextEvent(ITmfTrace eventStream, ITmfContext context) throws IOException { - if (! (eventStream instanceof TmfTraceStub)) { + public TmfEvent parseEvent(ITmfContext context) { + if (! (fEventStream instanceof TmfTraceStub)) { return null; } // Highly inefficient... - RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream(); + RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream(); // String name = eventStream.getName(); // name = name.substring(name.lastIndexOf('/') + 1); @@ -44,9 +57,10 @@ public class TmfUml2SDTestTrace implements ITmfEventParser { long location = 0; if (context != null) location = ((TmfLocation) (context.getLocation())).getLocation(); - stream.seek(location); try { + stream.seek(location); + long ts = stream.readLong(); String source = stream.readUTF(); String type = stream.readUTF(); @@ -72,10 +86,11 @@ public class TmfUml2SDTestTrace implements ITmfEventParser { fields[2] = new TmfEventField("signal", signal); ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content, fields); - TmfEvent tmfEvent = new TmfEvent(eventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference); + TmfEvent tmfEvent = new TmfEvent(fEventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference); return tmfEvent; - } catch (EOFException e) { + } catch (final EOFException e) { + } catch (final IOException e) { } return null; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java index 11d435a96b..f1a2cc5357 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -27,12 +27,13 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile; 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.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; -public class CustomTxtTrace extends TmfTrace { +public class CustomTxtTrace extends TmfTrace implements ITmfEventParser { private static final TmfLocation NULL_LOCATION = new TmfLocation((Long) null); private static final int DEFAULT_CACHE_SIZE = 100; @@ -57,7 +58,7 @@ public class CustomTxtTrace extends TmfTrace { } @Override - public TmfContext seekLocation(final ITmfLocation location) { + public TmfContext seekEvent(final ITmfLocation location) { final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK); if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile()) return context; @@ -103,7 +104,7 @@ public class CustomTxtTrace extends TmfTrace { } @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { BufferedRandomAccessFile raFile = null; try { raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$ @@ -116,7 +117,7 @@ public class CustomTxtTrace extends TmfTrace { pos--; } final ITmfLocation location = new TmfLocation(pos); - final TmfContext context = seekLocation(location); + final TmfContext context = seekEvent(location); context.setRank(ITmfContext.UNKNOWN_RANK); return context; } catch (final FileNotFoundException e) { @@ -165,7 +166,7 @@ public class CustomTxtTrace extends TmfTrace { } @Override - public synchronized TmfEvent getNextEvent(final ITmfContext context) { + public synchronized TmfEvent readEvent(final ITmfContext context) { final ITmfContext savedContext = context.clone(); final TmfEvent event = parseEvent(context); if (event != null) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java index 707fddc7c4..bc36be6d80 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -29,6 +29,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile; 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.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; @@ -43,7 +44,7 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; -public class CustomXmlTrace extends TmfTrace { +public class CustomXmlTrace extends TmfTrace implements ITmfEventParser { private static final TmfLocation NULL_LOCATION = new TmfLocation((Long) null); private static final int DEFAULT_CACHE_SIZE = 100; @@ -71,7 +72,7 @@ public class CustomXmlTrace extends TmfTrace { } @Override - public TmfContext seekLocation(final ITmfLocation location) { + public TmfContext seekEvent(final ITmfLocation location) { final CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK); if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile()) return context; @@ -105,7 +106,7 @@ public class CustomXmlTrace extends TmfTrace { } @Override - public TmfContext seekLocation(final double ratio) { + public TmfContext seekEvent(final double ratio) { BufferedRandomAccessFile raFile = null; try { raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$ @@ -118,7 +119,7 @@ public class CustomXmlTrace extends TmfTrace { pos--; } final ITmfLocation location = new TmfLocation(pos); - final TmfContext context = seekLocation(location); + final TmfContext context = seekEvent(location); context.setRank(ITmfContext.UNKNOWN_RANK); return context; } catch (final FileNotFoundException e) { @@ -167,7 +168,7 @@ public class CustomXmlTrace extends TmfTrace { } @Override - public synchronized TmfEvent getNextEvent(final ITmfContext context) { + public synchronized TmfEvent readEvent(final ITmfContext context) { final ITmfContext savedContext = context.clone(); final TmfEvent event = parseEvent(context); if (event != null) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java index e105915b0f..46f0b6797c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java @@ -179,7 +179,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList } while (true) { long rank = context.getRank(); - ITmfEvent event = trace.getNextEvent(context); + ITmfEvent event = trace.readEvent(context); if (event == null) { done = true; break; @@ -447,7 +447,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList if (interrupted) return; long rank = fContext.getRank(); - ITmfEvent event = trace.getNextEvent(fContext); + ITmfEvent event = trace.readEvent(fContext); if (event == null) { break; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java index 1b81dd210e..dc762813ea 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java @@ -334,7 +334,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel } private void setTopPosition(double ratio) { - fBottomContext = fTrace.seekLocation(ratio); + fBottomContext = fTrace.seekEvent(ratio); if (fBottomContext == null) { return; } @@ -382,13 +382,13 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel while (fTopLineIndex < 0) { ITmfLocation endLocation = fLines.get(0).location; firstRatio = Math.max(0, firstRatio - delta); - ITmfContext context = fTrace.seekLocation(firstRatio); + ITmfContext context = fTrace.seekEvent(firstRatio); ITmfLocation location; int index = 0; long rank = 0; while (!context.getLocation().equals(endLocation)) { location = context.getLocation().clone(); - ITmfEvent event = fTrace.getNextEvent(context); + ITmfEvent event = fTrace.readEvent(context); if (event == null) { break; } @@ -427,8 +427,8 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel fBottomContext = fTrace.seekEvent(0); } else { //fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1); - fBottomContext = fTrace.seekLocation(fLines.get(fLines.size() - 1).location); - fTrace.getNextEvent(fBottomContext); + fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location); + fTrace.readEvent(fBottomContext); } if (fBottomContext == null) { break; @@ -436,7 +436,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel } long rank = fBottomContext.getRank(); ITmfLocation location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null; - ITmfEvent event = fTrace.getNextEvent(fBottomContext); + ITmfEvent event = fTrace.readEvent(fBottomContext); if (event == null) { break; } -- 2.34.1