From 3791b5dfc3c68ced6b5aa8f0a12f23098bd9429b Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Tue, 3 Apr 2012 15:42:19 -0400 Subject: [PATCH] Update TmfTrace as per ITmfTrace --- .../tests/event/LttngEventContentTest.java | 3 +- .../core/tests/headless/LttngTraceTest.java | 3 +- .../core/tests/trace/LTTngTextTraceTest.java | 5 +- .../internal/lttng/core/trace/LTTngTrace.java | 65 +- .../internal/lttng/stubs/LTTngTraceStub.java | 2 +- .../tmf/core/tests/trace/TmfTraceTest.java | 24 +- .../tmf/tests/stubs/trace/TmfTraceStub.java | 1 - .../tmf/core/component/TmfDataProvider.java | 4 +- .../tmf/core/component/TmfEventProvider.java | 4 +- .../tmf/core/experiment/TmfExperiment.java | 9 +- .../linuxtools/tmf/core/trace/ITmfTrace.java | 59 +- .../linuxtools/tmf/core/trace/TmfTrace.java | 559 ++++++++++-------- .../tmf/ui/parsers/custom/CustomTxtTrace.java | 2 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 2 +- .../tmf/ui/viewers/events/TmfEventsTable.java | 18 +- 15 files changed, 406 insertions(+), 354 deletions(-) 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 85458d41a9..fc2e9c6719 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 @@ -15,6 +15,7 @@ import org.eclipse.linuxtools.internal.lttng.core.event.LttngEventType; import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp; import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTextTrace; import org.eclipse.linuxtools.lttng.core.tests.LTTngCoreTestPlugin; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; @@ -144,7 +145,7 @@ public class LttngEventContentTest extends TestCase { LttngEventContent testContent = null; LTTngTextTrace tmpStream = null; LttngEvent tmpEvent = null; - TmfContext tmpContext = null; + ITmfContext tmpContext = null; // Require an event tmpStream = initializeEventStream(); 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 e5ec546437..acf62d194b 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 @@ -16,6 +16,7 @@ import org.eclipse.linuxtools.internal.lttng.core.event.LttngLocation; import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp; import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTextTrace; import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; @@ -48,7 +49,7 @@ public class LttngTraceTest { // Work variables TmfTrace tmptrace = null; LttngEvent tmpevent = null; - TmfContext tmpContext = null; + ITmfContext tmpContext = null; Long nbEvent = 0L; try { 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 f8d2d2c0ea..4f9957ef2f 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 @@ -11,6 +11,7 @@ import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTextTrace; import org.eclipse.linuxtools.lttng.core.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; @@ -145,7 +146,7 @@ public class LTTngTextTraceTest extends TestCase { public void testSeekEventTimestamp() { ITmfEvent tmpEvent = null; - TmfContext tmpContext = new TmfContext(null, 0); + ITmfContext tmpContext = new TmfContext(null, 0); LTTngTextTrace testStream1 = prepareStreamToTest(); // We should be at the beginning of the trace, we will seek at a certain @@ -176,7 +177,7 @@ public class LTTngTextTraceTest extends TestCase { public void testSeekEventIndex() { ITmfEvent tmpEvent = null; - TmfContext tmpContext = new TmfContext(null, 0); + ITmfContext tmpContext = new TmfContext(null, 0); LTTngTextTrace testStream1 = prepareStreamToTest(); // We should be at the beginning of the trace, we will seek at a certain 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 d7f7ca9bed..a373f9cf3f 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 @@ -97,8 +97,6 @@ public class LTTngTrace extends TmfTrace { private String traceLibPath; - private long fStreamingInterval = 0; - public LTTngTrace() { } @@ -235,14 +233,6 @@ public class LTTngTrace extends TmfTrace { thread.start(); } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.trace.TmfTrace#getStreamingInterval() - */ - @Override - public long getStreamingInterval() { - return fStreamingInterval; - } - /** * Default Constructor. *

@@ -319,42 +309,39 @@ public class LTTngTrace extends TmfTrace { @Override public synchronized LTTngTrace clone() { LTTngTrace clone = null; + clone = (LTTngTrace) super.clone(); try { - clone = (LTTngTrace) super.clone(); - try { - clone.currentJniTrace = JniTraceFactory.getJniTrace(getPath(), getTraceLibPath(), - SHOW_LTT_DEBUG_DEFAULT); - } catch (JniException e) { - // e.printStackTrace(); - } + clone.currentJniTrace = JniTraceFactory.getJniTrace(getPath(), getTraceLibPath(), + SHOW_LTT_DEBUG_DEFAULT); + } catch (JniException e) { + // e.printStackTrace(); + } - // Export all the event types from the JNI side - clone.traceTypes = new HashMap(); - clone.traceTypeNames = new Vector(); - clone.initialiseEventTypes(clone.currentJniTrace); + // Export all the event types from the JNI side + clone.traceTypes = new HashMap(); + clone.traceTypeNames = new Vector(); + clone.initialiseEventTypes(clone.currentJniTrace); - // Verify that all those "default constructor" are safe to use - clone.eventTimestamp = new LttngTimestamp(); - clone.eventSource = ""; //$NON-NLS-1$ - clone.eventType = new LttngEventType(); - clone.eventContent = new LttngEventContent(clone.currentLttngEvent); - clone.eventReference = getName(); + // Verify that all those "default constructor" are safe to use + clone.eventTimestamp = new LttngTimestamp(); + clone.eventSource = ""; //$NON-NLS-1$ + clone.eventType = new LttngEventType(); + clone.eventContent = new LttngEventContent(clone.currentLttngEvent); + clone.eventReference = getName(); - // Create the skeleton event - clone.currentLttngEvent = new LttngEvent(this, clone.eventTimestamp, clone.eventSource, clone.eventType, - clone.eventContent, clone.eventReference, null); + // Create the skeleton event + clone.currentLttngEvent = new LttngEvent(this, clone.eventTimestamp, clone.eventSource, clone.eventType, + clone.eventContent, clone.eventReference, null); - // Create a new current location - clone.previousLocation = new LttngLocation(); + // Create a new current location + clone.previousLocation = new LttngLocation(); - // Set the currentEvent to the eventContent - clone.eventContent.setEvent(clone.currentLttngEvent); + // Set the currentEvent to the eventContent + clone.eventContent.setEvent(clone.currentLttngEvent); - // Set the start time of the trace - setTimeRange(new TmfTimeRange(new LttngTimestamp(clone.currentJniTrace.getStartTime().getTime()), - new LttngTimestamp(clone.currentJniTrace.getEndTime().getTime()))); - } catch (CloneNotSupportedException e) { - } + // Set the start time of the trace + setTimeRange(new TmfTimeRange(new LttngTimestamp(clone.currentJniTrace.getStartTime().getTime()), + new LttngTimestamp(clone.currentJniTrace.getEndTime().getTime()))); return clone; } 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 f987d9b40f..704ec40110 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 @@ -63,7 +63,7 @@ public class LTTngTraceStub extends TmfTrace { * @throws FileNotFoundException */ public LTTngTraceStub(String filename, int cacheSize) throws FileNotFoundException { - super(filename, LttngEvent.class, filename, cacheSize); + super(filename, LttngEvent.class, filename, cacheSize, true); fTrace = new RandomAccessFile(filename, "r"); fParser = new LTTngEventParserStub(); // indexTrace(true); 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 c7c7903d92..782438eeeb 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 @@ -246,7 +246,7 @@ public class TmfTraceTest extends TestCase { int NB_READS = 20; // On lower bound, returns the first event (ts = 0) - TmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); + TmfContext context = (TmfContext) fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); TmfContext svContext = new TmfContext(context); ITmfEvent event = fTrace.parseEvent(context); @@ -291,7 +291,7 @@ public class TmfTraceTest extends TestCase { int NB_READS = 20; // On lower bound, returns the first event (ts = 1) - TmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); + ITmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0)); // Read NB_EVENTS ITmfEvent event; @@ -332,7 +332,7 @@ public class TmfTraceTest extends TestCase { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event rank 1000 - TmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); + ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0)); context = fTrace.seekLocation(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -361,7 +361,7 @@ public class TmfTraceTest extends TestCase { public void testSeekLocationNotOnCacheBoundary() throws Exception { // Position trace at event rank 9 - TmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); + ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0)); TmfContext context = fTrace.seekLocation(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -416,8 +416,8 @@ public class TmfTraceTest extends TestCase { public void testSeekLocationOutOfScope() throws Exception { // Position trace at beginning - TmfContext tmpContext = fTrace.seekLocation(null); - TmfContext context = fTrace.seekLocation(tmpContext.getLocation()); + ITmfContext tmpContext = fTrace.seekLocation(null); + ITmfContext context = fTrace.seekLocation(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -449,7 +449,7 @@ public class TmfTraceTest extends TestCase { public void testSeekEventOnTimestampOnCacheBoundary() throws Exception { // Position trace at event rank 0 - TmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0)); + ITmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0)); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -488,7 +488,7 @@ public class TmfTraceTest extends TestCase { public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception { // Position trace at event rank 1 - TmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0)); + ITmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0)); assertEquals("Event rank", 1, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -551,7 +551,7 @@ public class TmfTraceTest extends TestCase { public void testSeekEventOnTimestampOutOfScope() throws Exception { // Position trace at beginning - TmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0)); + ITmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0)); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -582,7 +582,7 @@ public class TmfTraceTest extends TestCase { public void testSeekOnRankOnCacheBoundary() throws Exception { // On lower bound, returns the first event (ts = 1) - TmfContext context = fTrace.seekEvent(0); + ITmfContext context = fTrace.seekEvent(0); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -621,7 +621,7 @@ public class TmfTraceTest extends TestCase { public void testSeekOnRankNotOnCacheBoundary() throws Exception { // Position trace at event rank 9 - TmfContext context = fTrace.seekEvent(9); + ITmfContext context = fTrace.seekEvent(9); assertEquals("Event rank", 9, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -672,7 +672,7 @@ public class TmfTraceTest extends TestCase { public void testSeekEventOnRankOfScope() throws Exception { // Position trace at beginning - TmfContext context = fTrace.seekEvent(-1); + ITmfContext context = fTrace.seekEvent(-1); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); 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 3d51b712f2..d45025aa08 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 @@ -114,7 +114,6 @@ public class TmfTraceStub extends TmfTrace { clone = (TmfTraceStub) super.clone(); clone.fTrace = new RandomAccessFile(getPath(), "r"); clone.fParser = new TmfEventParserStub(); - } catch (CloneNotSupportedException e) { } catch (FileNotFoundException e) { } return clone; diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java index 2902e53324..cd541d3b38 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java @@ -79,9 +79,9 @@ public abstract class TmfDataProvider extends TmfComponent fExecutor = new TmfRequestExecutor(); } - public void init(String name, Class dataType) { + public void init(String name, Class type) { super.init(name); - fType = dataType; + fType = type; fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue(fQueueSize) : new SynchronousQueue(); fExecutor = new TmfRequestExecutor(); diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfEventProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfEventProvider.java index fa5848fca9..94dc9a7110 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfEventProvider.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfEventProvider.java @@ -36,8 +36,8 @@ public abstract class TmfEventProvider extends TmfDataProvi } @Override - public void init(String name, Class eventType) { - super.init(name, eventType); + public void init(String name, Class type) { + super.init(name, type); } public TmfEventProvider(String name, Class type) { 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 192e1af6f0..1aa669b2d4 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 @@ -68,7 +68,7 @@ public class TmfExperiment extends TmfEventProvider impl // The experiment time range protected TmfTimeRange fTimeRange; - // The experiment reference timestamp (default: Zero) + // The experiment reference timestamp (default: ZERO) protected ITmfTimestamp fEpoch; // The experiment index @@ -90,6 +90,11 @@ public class TmfExperiment extends TmfEventProvider impl // Constructors // ------------------------------------------------------------------------ + @Override + public TmfExperiment clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + @Override public boolean validate(IProject project, String path) { return true; @@ -792,7 +797,7 @@ public class TmfExperiment extends TmfEventProvider impl } @SuppressWarnings("unchecked") - protected void indexExperiment(boolean waitForCompletion, final int index, final TmfTimeRange timeRange) { + private void indexExperiment(boolean waitForCompletion, final int index, final TmfTimeRange timeRange) { synchronized (fCheckpoints) { if (fIndexing) { 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 5c8fdb25b1..4fc217f2f4 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 @@ -27,7 +27,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; *

* The basic event trace structure in TMF. */ -public interface ITmfTrace extends ITmfComponent { +public interface ITmfTrace extends ITmfComponent, Cloneable { // ------------------------------------------------------------------------ // Initializers @@ -39,10 +39,10 @@ public interface ITmfTrace extends ITmfComponent { * * @param name the trace name * @param path the trace path - * @param eventType the trace event type + * @param type the trace event type * @throws FileNotFoundException */ - public void initTrace(String name, String path, Class eventType) throws FileNotFoundException; + public void initTrace(String name, String path, Class type) throws FileNotFoundException; /** * Validate that the trace is of the correct type. @@ -61,21 +61,6 @@ public interface ITmfTrace extends ITmfComponent { */ public void setResource(IResource resource); - /** - * Get the resource used for persistent properties on this trace - * - * @return the properties resource or null if none is set - */ - public IResource getResource(); - - /** - * Start the trace indexing, optionally wait for the index to be fully - * built before returning. - * - * @param waitForCompletion - */ - public void indexTrace(boolean waitForCompletion); - // ------------------------------------------------------------------------ // Basic getters // ------------------------------------------------------------------------ @@ -86,10 +71,9 @@ public interface ITmfTrace extends ITmfComponent { public String getPath(); /** - * @return the trace name + * @return the properties resource or null if none is set */ - @Override - public String getName(); + public IResource getResource(); /** * @return the number of events in the trace @@ -121,6 +105,18 @@ public interface ITmfTrace extends ITmfComponent { */ public int getIndexPageSize(); + // ------------------------------------------------------------------------ + // Indexing + // ------------------------------------------------------------------------ + + /** + * Start the trace indexing, optionally wait for the index to be fully + * built before returning. + * + * @param waitForCompletion true for synchronous indexing + */ + public void indexTrace(boolean waitForCompletion); + // ------------------------------------------------------------------------ // Seek operations // ------------------------------------------------------------------------ @@ -189,9 +185,14 @@ public interface ITmfTrace extends ITmfComponent { // ------------------------------------------------------------------------ - // Location getters + // Location operations // ------------------------------------------------------------------------ + /** + * @return the current trace location + */ + public ITmfLocation getCurrentLocation(); + /** * Returns the ratio (proportion) corresponding to the specified location. * @@ -200,11 +201,6 @@ public interface ITmfTrace extends ITmfComponent { */ public double getLocationRatio(ITmfLocation location); - /** - * @return the curretn trace location - */ - public ITmfLocation getCurrentLocation(); - /** * Returns the rank of the first event with the requested timestamp. * If none, returns the index of the subsequent event (if any). @@ -214,4 +210,13 @@ public interface ITmfTrace extends ITmfComponent { */ public long getRank(ITmfTimestamp timestamp); + // ------------------------------------------------------------------------ + // Cloneable + // ------------------------------------------------------------------------ + + /** + * @return a clone of the trace + */ + public ITmfTrace clone() throws CloneNotSupportedException; + } 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 965e93b230..7c338a7c9b 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 @@ -8,6 +8,7 @@ * * Contributors: * Francois Chouinard - Initial API and implementation + * Francois Chouinard - Updated as per TMF Trace Model 1.0 *******************************************************************************/ package org.eclipse.linuxtools.tmf.core.trace; @@ -38,29 +39,21 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal; /** * TmfTrace *

- * Abstract implementation of ITmfTrace. It should be sufficient to extend this class and provide implementation for - * getCurrentLocation() and seekLocation(), as well as a proper parser, to have a working + * Abstract implementation of ITmfTrace. It should be sufficient to extend this + * class and provide implementation for getCurrentLocation() and + * seekLocation(), as well as a proper parser, to have a working * concrete implementation. - *

- * Note: The notion of event rank is still under heavy discussion. Although used by the Events View and probably useful - * in the general case, there is no easy way to implement it for LTTng (actually a strong case is being made that this - * is useless). - *

- * That it is not supported by LTTng does by no mean indicate that it is not useful for (just about) every other tracing - * tool. Therefore, this class provides a minimal (and partial) implementation of rank. However, the current - * implementation should not be relied on in the general case. - * - * TODO: Add support for live streaming (notifications, incremental indexing, ...) */ -public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, Cloneable { +public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace { // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ - // The default number of events to cache - // TODO: Make the DEFAULT_CACHE_SIZE a preference - public static final int DEFAULT_INDEX_PAGE_SIZE = 50000; + /** + * The default number of events in an index page. Can be used as block size. + */ + public static final int DEFAULT_INDEX_PAGE_SIZE = 1000; // ------------------------------------------------------------------------ // Attributes @@ -69,13 +62,12 @@ public abstract class TmfTrace extends TmfEventProvider // The trace path private String fPath; - // The trace name - private String fTraceName; - - // The cache page size AND checkpoints interval + /** + * The cache page size AND checkpoints interval + */ protected int fIndexPageSize = DEFAULT_INDEX_PAGE_SIZE; - // The set of event stream checkpoints (for random access) + // The set of event stream checkpoints protected Vector fCheckpoints = new Vector(); // The number of events collected @@ -85,91 +77,142 @@ public abstract class TmfTrace extends TmfEventProvider private ITmfTimestamp fStartTime = TmfTimestamp.BIG_CRUNCH; private ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG; - // The properties resource + /** + * The trace streaming interval (0 = no streaming) + */ + protected long fStreamingInterval = 0; + + // The resource used for persistent properties for this trace private IResource fResource; // ------------------------------------------------------------------------ - // Constructors + // Construction // ------------------------------------------------------------------------ - public TmfTrace() { - super(); - } - - @Override - public void initTrace(String name, String path, Class eventType) throws FileNotFoundException { - fPath = path; - if (name != null) { - fTraceName = name; - } - if (fTraceName == null) { - fTraceName = ""; //$NON-NLS-1$ - if (path != null) { - int sep = path.lastIndexOf(Path.SEPARATOR); - fTraceName = (sep >= 0) ? path.substring(sep + 1) : path; - } - } - super.init(fTraceName, eventType); - } - - @Override - public boolean validate(IProject project, String path) { - File file = new File(path); - return file.exists(); - } - - /** - * @param path - * @throws FileNotFoundException - */ - protected TmfTrace(String name, Class type, String path) throws FileNotFoundException { - this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, true); - } - /** - * @param path - * @param cacheSize - * @throws FileNotFoundException + * The default, parameterless, constructor */ - protected TmfTrace(String name, Class type, String path, int cacheSize) throws FileNotFoundException { - this(name, type, path, cacheSize, true); + public TmfTrace() { + super(); } /** - * @param path - * @param indexTrace + * The standard constructor (non-streaming trace) + * + * @param name the trace display name + * @param type the trace event type + * @param path the trace path + * @param pageSize the trace index page size + * @param indexTrace whether to start indexing the trace or not * @throws FileNotFoundException */ - protected TmfTrace(String name, Class type, String path, boolean indexTrace) throws FileNotFoundException { - this(name, type, path, DEFAULT_INDEX_PAGE_SIZE, indexTrace); + protected TmfTrace(String name, Class type, String path, int indexPageSize, boolean indexTrace) throws FileNotFoundException { + this(name, type, path, 0, indexPageSize, indexTrace); } /** - * @param path - * @param cacheSize - * @param indexTrace + * The full constructor + * + * @param name the trace display name + * @param type the trace event type + * @param path the trace path + * @param pageSize the trace index page size + * @param indexTrace whether to start indexing the trace or not * @throws FileNotFoundException */ - protected TmfTrace(String name, Class type, String path, int indexPageSize, boolean indexTrace) throws FileNotFoundException { + protected TmfTrace(String name, Class type, String path, long interval, int indexPageSize, boolean indexTrace) throws FileNotFoundException { super(); initTrace(name, path, type); + fStreamingInterval = interval; fIndexPageSize = (indexPageSize >0) ? indexPageSize : DEFAULT_INDEX_PAGE_SIZE; if (indexTrace) indexTrace(false); } + /** + * Copy constructor + * + * @param trace the original trace + */ @SuppressWarnings("unchecked") + public TmfTrace(ITmfTrace trace) throws FileNotFoundException { + super(); + if (trace == null) + throw new IllegalArgumentException(); + initTrace(getName(), getPath(), (Class) getType()); + fStreamingInterval = getStreamingInterval(); + fIndexPageSize = getIndexPageSize(); + indexTrace(false); + } + + // ------------------------------------------------------------------------ + // Cloneable + // ------------------------------------------------------------------------ + + /* (non-Javadoc) + * @see java.lang.Object#clone() + */ @Override - public TmfTrace clone() throws CloneNotSupportedException { - TmfTrace clone = (TmfTrace) super.clone(); - clone.fCheckpoints = fCheckpoints; - clone.fStartTime = fStartTime.clone(); - clone.fEndTime = fEndTime.clone(); + @SuppressWarnings("unchecked") + public TmfTrace clone() { + TmfTrace clone = null; + try { + clone = (TmfTrace) super.clone(); +// clone.fTrace = fTrace; +// clone.fRank = fRank; +// clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null; +// clone.fSource = fSource; +// clone.fType = fType != null ? fType.clone() : null; +// clone.fContent = fContent != null ? fContent.clone() : null; +// clone.fReference = fReference; + } catch (CloneNotSupportedException e) { + } return clone; } // ------------------------------------------------------------------------ - // Accessors + // ITmfTrace - initializers + // ------------------------------------------------------------------------ + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(java.lang.String, java.lang.String, java.lang.Class) + */ + @Override + public void initTrace(String name, String path, Class type) throws FileNotFoundException { + fPath = path; + String traceName = name; + // If no display name was provided, extract it from the trace path + if (traceName == null) { + if (path != null) { + int sep = path.lastIndexOf(Path.SEPARATOR); + traceName = (sep >= 0) ? path.substring(sep + 1) : path; + } else { + traceName = ""; //$NON-NLS-1$ + } + } + super.init(traceName, type); + } + + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String) + */ + @Override + public boolean validate(IProject project, String path) { + File file = new File(path); + return file.exists(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#setResource(org.eclipse.core.resources.IResource) + */ + @Override + public void setResource(IResource resource) { + fResource = resource; + } + + // ------------------------------------------------------------------------ + // ITmfTrace - accessors // ------------------------------------------------------------------------ /** @@ -180,20 +223,21 @@ public abstract class TmfTrace extends TmfEventProvider return fPath; } - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getNbEvents() + /* + * (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource() */ @Override - public synchronized long getNbEvents() { - return fNbEvents; + public IResource getResource() { + return fResource; } - /** - * @return the size of the cache + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getNbEvents() */ @Override - public int getIndexPageSize() { - return fIndexPageSize; + public synchronized long getNbEvents() { + return fNbEvents; } /* (non-Javadoc) @@ -209,7 +253,7 @@ public abstract class TmfTrace extends TmfEventProvider */ @Override public ITmfTimestamp getStartTime() { - return fStartTime; + return fStartTime.clone(); } /* (non-Javadoc) @@ -217,7 +261,7 @@ public abstract class TmfTrace extends TmfEventProvider */ @Override public ITmfTimestamp getEndTime() { - return fEndTime; + return fEndTime.clone(); } /* (non-Javadoc) @@ -225,88 +269,121 @@ public abstract class TmfTrace extends TmfEventProvider */ @Override public long getStreamingInterval() { - return 0; + return fStreamingInterval; } - @SuppressWarnings("unchecked") - public Vector getCheckpoints() { - return (Vector) fCheckpoints.clone(); - } - - /** - * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event - * (if any). - * - * @param timestamp the requested event timestamp - * @return the corresponding event rank + /* (non-Javadoc) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getIndexPageSize() */ @Override - public long getRank(ITmfTimestamp timestamp) { - TmfContext context = seekEvent(timestamp); - return context.getRank(); + public int getIndexPageSize() { + return fIndexPageSize; } // ------------------------------------------------------------------------ - // Operators + // ITmfTrace - indexing // ------------------------------------------------------------------------ - protected void setTimeRange(TmfTimeRange range) { - fStartTime = range.getStartTime(); - fEndTime = range.getEndTime(); - } + /* + * The index is a list of contexts that point to events at regular interval + * (rank-wise) in the trace. After it is built, the index can be used to + * quickly access any event by rank or timestamp. + * + * fIndexPageSize holds the event interval (default INDEX_PAGE_SIZE). + */ - protected void setStartTime(ITmfTimestamp startTime) { - fStartTime = startTime; - } + @Override + @SuppressWarnings({ "unchecked" }) + public void indexTrace(boolean waitForCompletion) { - protected void setEndTime(ITmfTimestamp endTime) { - fEndTime = endTime; - } + // The monitoring job + final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ + @Override + protected IStatus run(IProgressMonitor monitor) { + while (!monitor.isCanceled()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + return Status.OK_STATUS; + } + } + monitor.done(); + return Status.OK_STATUS; + } + }; + job.schedule(); - // ------------------------------------------------------------------------ - // TmfProvider - // ------------------------------------------------------------------------ + // Clear the checkpoints + fCheckpoints.clear(); - @Override - public ITmfContext armRequest(ITmfDataRequest request) { - if (request instanceof ITmfEventRequest - && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime()) && request.getIndex() == 0) { - ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime()); - ((ITmfEventRequest) request).setStartIndex((int) context.getRank()); - return context; + // Build a background request for all the trace data. The index is + // updated as we go by getNextEvent(). + ITmfEventRequest request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, + TmfDataRequest.ALL_DATA, fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) + { + ITmfTimestamp startTime = null; + ITmfTimestamp lastTime = null; - } - return seekEvent(request.getIndex()); + @Override + public void handleData(ITmfEvent event) { + super.handleData(event); + if (event != null) { + ITmfTimestamp timestamp = event.getTimestamp(); + if (startTime == null) + startTime = timestamp.clone(); + lastTime = timestamp.clone(); + + // Update the trace status at regular intervals + if ((getNbRead() % fIndexPageSize) == 0) { + updateTraceStatus(); + } + } + } + + @Override + public void handleSuccess() { + updateTraceStatus(); + } + + @Override + public void handleCompleted() { + job.cancel(); + super.handleCompleted(); + } + + private synchronized void updateTraceStatus() { + int nbRead = getNbRead(); + if (nbRead != 0) { + fStartTime = startTime; + fEndTime = lastTime; + fNbEvents = nbRead; + notifyListeners(); + } + } + }; + + // Submit the request and wait for completion if required + sendRequest((ITmfDataRequest) request); + if (waitForCompletion) + try { + request.waitForCompletion(); + } catch (InterruptedException e) { + } } - /** - * Return the next piece of data based on the context supplied. The context would typically be updated for the - * subsequent read. - * - * @param context - * @return the event referred to by context - */ - @SuppressWarnings("unchecked") - @Override - public T getNext(ITmfContext context) { - if (context instanceof TmfContext) { - return (T) getNextEvent((TmfContext) context); - } - return null; + private void notifyListeners() { + broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime))); } // ------------------------------------------------------------------------ - // ITmfTrace + // ITmfTrace - seek operations // ------------------------------------------------------------------------ - @Override - public abstract TmfContext seekLocation(ITmfLocation location); - /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.event.TmfTimestamp) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp) */ @Override - public TmfContext seekEvent(ITmfTimestamp ts) { + public ITmfContext seekEvent(ITmfTimestamp ts) { ITmfTimestamp timestamp = ts; if (timestamp == null) { @@ -335,11 +412,11 @@ public abstract class TmfTrace extends TmfEventProvider location = null; } } - TmfContext context = seekLocation(location); + ITmfContext context = seekLocation(location); context.setRank(index * fIndexPageSize); // And locate the event - TmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype... + 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()); @@ -351,10 +428,10 @@ public abstract class TmfTrace extends TmfEventProvider } /* (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(int) + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long) */ @Override - public TmfContext seekEvent(long rank) { + public ITmfContext seekEvent(long rank) { // Position the stream at the previous checkpoint int index = (int) rank / fIndexPageSize; @@ -370,7 +447,7 @@ public abstract class TmfTrace extends TmfEventProvider } } - TmfContext context = seekLocation(location); + ITmfContext context = seekLocation(location); long pos = index * fIndexPageSize; context.setRank(pos); @@ -384,6 +461,86 @@ public abstract class TmfTrace extends TmfEventProvider return context; } + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + @SuppressWarnings("unchecked") + public Vector getCheckpoints() { + return (Vector) fCheckpoints.clone(); + } + + /** + * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event + * (if any). + * + * @param timestamp the requested event timestamp + * @return the corresponding event rank + */ + @Override + public long getRank(ITmfTimestamp timestamp) { + ITmfContext context = seekEvent(timestamp); + return context.getRank(); + } + + // ------------------------------------------------------------------------ + // Operators + // ------------------------------------------------------------------------ + + protected void setTimeRange(TmfTimeRange range) { + fStartTime = range.getStartTime(); + fEndTime = range.getEndTime(); + } + + protected void setStartTime(ITmfTimestamp startTime) { + fStartTime = startTime; + } + + protected void setEndTime(ITmfTimestamp endTime) { + fEndTime = endTime; + } + + // ------------------------------------------------------------------------ + // TmfProvider + // ------------------------------------------------------------------------ + + @Override + public ITmfContext armRequest(ITmfDataRequest request) { + if (request instanceof ITmfEventRequest + && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime()) && request.getIndex() == 0) { + ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime()); + ((ITmfEventRequest) request).setStartIndex((int) context.getRank()); + return context; + + } + return seekEvent(request.getIndex()); + } + + /** + * Return the next piece of data based on the context supplied. The context would typically be updated for the + * subsequent read. + * + * @param context + * @return the event referred to by context + */ + @SuppressWarnings("unchecked") + @Override + public T getNext(ITmfContext context) { + if (context instanceof TmfContext) { + return (T) getNextEvent((TmfContext) context); + } + return null; + } + + // ------------------------------------------------------------------------ + // ITmfTrace + // ------------------------------------------------------------------------ + + /* * (non-Javadoc) * @@ -448,108 +605,4 @@ public abstract class TmfTrace extends TmfEventProvider return "[TmfTrace (" + getName() + ")]"; } - // ------------------------------------------------------------------------ - // Indexing - // ------------------------------------------------------------------------ - - /* - * The purpose of the index is to keep the information needed to rapidly - * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE - * event). - */ - - @Override - @SuppressWarnings({ "unchecked" }) - public void indexTrace(boolean waitForCompletion) { - - final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ - @Override - protected IStatus run(IProgressMonitor monitor) { - while (!monitor.isCanceled()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - return Status.OK_STATUS; - } - } - monitor.done(); - return Status.OK_STATUS; - } - }; - job.schedule(); - - fCheckpoints.clear(); - ITmfEventRequest request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, TmfDataRequest.ALL_DATA, - fIndexPageSize, ITmfDataRequest.ExecutionType.BACKGROUND) { - - ITmfTimestamp startTime = null; - ITmfTimestamp lastTime = null; - - @Override - public void handleData(ITmfEvent event) { - super.handleData(event); - if (event != null) { - ITmfTimestamp ts = event.getTimestamp(); - if (startTime == null) - startTime = ts.clone(); - lastTime = ts.clone(); - - if ((getNbRead() % fIndexPageSize) == 0) { - updateTrace(); - } - } - } - - @Override - public void handleSuccess() { - updateTrace(); - } - - @Override - public void handleCompleted() { - job.cancel(); - super.handleCompleted(); - } - - private synchronized void updateTrace() { - int nbRead = getNbRead(); - if (nbRead != 0) { - fStartTime = startTime; - fEndTime = lastTime; - fNbEvents = nbRead; - notifyListeners(); - } - } - }; - - sendRequest((ITmfDataRequest) request); - if (waitForCompletion) - try { - request.waitForCompletion(); - } catch (InterruptedException e) { -// e.printStackTrace(); - } - } - - protected void notifyListeners() { - broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime))); - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#setResource(org.eclipse.core.resources.IResource) - */ - @Override - public void setResource(IResource resource) { - fResource = resource; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource() - */ - @Override - public IResource getResource() { - return fResource; - } } 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 2d94dbb360..90a7216183 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 @@ -45,7 +45,7 @@ public class CustomTxtTrace extends TmfTrace { } public CustomTxtTrace(String name, CustomTxtTraceDefinition definition, String path, int pageSize) throws FileNotFoundException { - super(name, CustomTxtEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE); + super(name, CustomTxtEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE, true); fDefinition = definition; fEventType = new CustomTxtEventType(fDefinition); } 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 44abfb4e89..697726b227 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 @@ -58,7 +58,7 @@ public class CustomXmlTrace extends TmfTrace { } public CustomXmlTrace(String name, CustomXmlTraceDefinition definition, String path, int pageSize) throws FileNotFoundException { - super(name, CustomXmlEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE); + super(name, CustomXmlEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE, true); fDefinition = definition; fEventType = new CustomXmlEventType(fDefinition); fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index c7f8eb259e..5d0abfe3cf 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -1694,18 +1694,18 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS if (fTrace == null) { return; } - // Verify if event is within the trace range - final ITmfTimestamp timestamp[] = new TmfTimestamp[1]; - timestamp[0] = ts; // signal.getCurrentTime(); - if (timestamp[0].compareTo(fTrace.getStartTime(), true) == -1) { - timestamp[0] = fTrace.getStartTime(); + + // Verify if the event is within the trace range and adjust if necessary + ITmfTimestamp timestamp = ts; + if (timestamp.compareTo(fTrace.getStartTime(), true) == -1) { + timestamp = fTrace.getStartTime(); } - if (timestamp[0].compareTo(fTrace.getEndTime(), true) == 1) { - timestamp[0] = fTrace.getEndTime(); + if (timestamp.compareTo(fTrace.getEndTime(), true) == 1) { + timestamp = fTrace.getEndTime(); } - // Get the rank for the event selection in the table - final long rank = fTrace.getRank(timestamp[0]); + // Get the rank of the selected event in the table + final long rank = fTrace.getRank(timestamp); fSelectedRank = rank; fTable.getDisplay().asyncExec(new Runnable() { -- 2.34.1