From 3118edf16c70e7a17b3417ede998ca633c22b025 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Fri, 30 Mar 2012 13:12:00 -0400 Subject: [PATCH] Finalize ITmfTrace API --- .../internal/lttng/core/trace/LTTngTrace.java | 14 +- .../tests/stateprovider/CTFTestFiles.java | 3 +- .../tmf/core/tests/ctfadaptor/TestParams.java | 4 +- .../tests/experiment/TmfExperimentTest.java | 2 +- .../TmfMultiTraceExperimentTest.java | 2 +- .../tmf/core/tests/trace/TmfTraceTest.java | 12 +- .../tmf/core/ctfadaptor/CtfTmfTrace.java | 4 +- .../linuxtools/tmf/core/event/ITmfEvent.java | 2 +- .../tmf/core/experiment/TmfExperiment.java | 4 +- .../linuxtools/tmf/core/trace/ITmfTrace.java | 149 ++++++++++++------ .../linuxtools/tmf/core/trace/TmfTrace.java | 18 +-- ...g.eclipse.linuxtools.tmf.ui.tracetype.exsd | 6 +- .../tmf/ui/parsers/custom/CustomTxtTrace.java | 10 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 10 +- .../handlers/OpenExperimentHandler.java | 6 +- .../ui/project/handlers/OpenTraceHandler.java | 4 +- .../tmf/ui/editors/EventsViewEditor.java | 12 +- .../tmf/ui/editors/TmfEventsEditor.java | 18 +-- .../tmf/ui/viewers/events/TmfEventsTable.java | 6 +- .../tmf/ui/views/events/TmfEventsView.java | 2 +- .../ui/views/timechart/TimeChartEvent.java | 2 +- .../tmf/ui/views/timechart/TimeChartView.java | 4 +- 22 files changed, 164 insertions(+), 130 deletions(-) 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 e50fcedc22..d7f7ca9bed 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 @@ -116,12 +116,8 @@ public class LTTngTrace extends TmfTrace { } @Override - public void initTrace(String name, String path, Class eventType, int pageSize) throws FileNotFoundException { - initLTTngTrace(name, path, eventType, pageSize, false); - } - - private synchronized void initLTTngTrace(String name, String path, Class eventType, int pageSize, boolean indexTrace) throws FileNotFoundException { - super.initTrace(name, path, eventType, (pageSize > 0) ? pageSize : CHECKPOINT_PAGE_SIZE); + public synchronized void initTrace(String name, String path, Class eventType) throws FileNotFoundException { + super.initTrace(name, path, eventType); try { currentJniTrace = JniTraceFactory.getJniTrace(path, traceLibPath, SHOW_LTT_DEBUG_DEFAULT); } catch (Exception e) { @@ -305,7 +301,7 @@ public class LTTngTrace extends TmfTrace { public LTTngTrace(String name, String path, String traceLibPath, boolean waitForCompletion, boolean bypassIndexing) throws Exception { super(name, LttngEvent.class, path, CHECKPOINT_PAGE_SIZE, false); - initTrace(name, path, LttngEvent.class, CHECKPOINT_PAGE_SIZE); + initTrace(name, path, LttngEvent.class); if (!bypassIndexing) indexTrace(false); this.traceLibPath = traceLibPath; @@ -543,7 +539,7 @@ public class LTTngTrace extends TmfTrace { } ITmfTimestamp timestamp = null; - long index = position / getCacheSize(); + long index = position / getIndexPageSize(); // Get the timestamp of the closest check point to the given position if (fCheckpoints.size() > 0) { @@ -563,7 +559,7 @@ public class LTTngTrace extends TmfTrace { previousLocation = (LttngLocation) tmpContext.getLocation(); // Ajust the index of the event we found at this check point position - Long currentPosition = index * getCacheSize(); + Long currentPosition = index * getIndexPageSize(); Long lastTimeValueRead = 0L; diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java index d008558062..2c8cffb193 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CTFTestFiles.java @@ -26,7 +26,6 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; public abstract class CTFTestFiles { public final static long NANOSECS_PER_SEC = 1000000000L; - private final static int PAGE_SIZE = 1000; /* * To run these tests, you will need to download the following trace, at: @@ -44,7 +43,7 @@ public abstract class CTFTestFiles { public static CtfTmfTrace getTestTrace() throws FileNotFoundException { if (trace == null) { trace = new CtfTmfTrace(); - trace.initTrace("test-trace2", traceFile, CtfTmfEvent.class, PAGE_SIZE); //$NON-NLS-1$ + trace.initTrace("test-trace2", traceFile, CtfTmfEvent.class); //$NON-NLS-1$ } return trace; } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java index cbf149d82a..9a0a25704e 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/TestParams.java @@ -16,8 +16,6 @@ public abstract class TestParams { private static final File emptyFile = new File(""); //$NON-NLS-1$ private static CtfTmfTrace emptyTrace = new CtfTmfTrace(); - private final static int PAGE_SIZE = 1000; - public static File getEmptyFile() { return emptyFile; } @@ -29,7 +27,7 @@ public abstract class TestParams { public static CtfTmfTrace createTrace() throws FileNotFoundException { if ( testTrace1 == null ) { testTrace1 = new CtfTmfTrace(); - testTrace1.initTrace("test-trace", testTracePath1, CtfTmfEvent.class,PAGE_SIZE); //$NON-NLS-1$ + testTrace1.initTrace("test-trace", testTracePath1, CtfTmfEvent.class); //$NON-NLS-1$ } return testTrace1; } 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 57e418a2aa..01a1534f13 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 @@ -124,7 +124,7 @@ public class TmfExperimentTest extends TestCase { public void testValidateCheckpoints() throws Exception { Vector checkpoints = fExperiment.getCheckpoints(); - int pageSize = fExperiment.getCacheSize(); + int pageSize = fExperiment.getIndexPageSize(); assertTrue("Checkpoints exist", checkpoints != null); // Validate that each checkpoint points to the right event 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 7768390f80..d240e85275 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 @@ -128,7 +128,7 @@ public class TmfMultiTraceExperimentTest extends TestCase { public void testValidateCheckpoints() throws Exception { Vector checkpoints = fExperiment.getCheckpoints(); - int pageSize = fExperiment.getCacheSize(); + int pageSize = fExperiment.getIndexPageSize(); assertTrue("Checkpoints exist", checkpoints != null); // Validate that each checkpoint points to the right event 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 40213c3947..c7c7903d92 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 @@ -125,7 +125,7 @@ public class TmfTraceTest extends TestCase { assertEquals("getType", TmfEvent.class, trace.getType()); assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); assertEquals("getName", TEST_STREAM, trace.getName()); - assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize()); + assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getIndexPageSize()); } public void testTmfTraceDefaultCacheSize() throws Exception { @@ -144,13 +144,13 @@ public class TmfTraceTest extends TestCase { assertEquals("getType", TmfEvent.class, trace.getType()); assertEquals("getPath", testfile.toURI().getPath(), trace.getPath()); assertEquals("getName", TEST_STREAM, trace.getName()); - assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize()); + assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getIndexPageSize()); } public void testTmfTrace() throws Exception { assertEquals("getType", TmfEvent.class, fTrace.getType()); assertEquals("getName", TEST_STREAM, fTrace.getName()); - assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize()); + assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getIndexPageSize()); } public void testClone() throws Exception { @@ -158,7 +158,7 @@ public class TmfTraceTest extends TestCase { assertEquals("getType", TmfEvent.class, trace.getType()); assertEquals("getPath", fTrace.getPath(), trace.getPath()); assertEquals("getName", TEST_STREAM, trace.getName()); - assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize()); + assertEquals("getCacheSize", BLOCK_SIZE, trace.getIndexPageSize()); assertEquals("getTimeRange", fTrace.getTimeRange(), trace.getTimeRange()); } @@ -216,7 +216,7 @@ public class TmfTraceTest extends TestCase { // ------------------------------------------------------------------------ public void testTmfTraceIndexing() throws Exception { - assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize()); + 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()); @@ -224,7 +224,7 @@ public class TmfTraceTest extends TestCase { assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue()); Vector checkpoints = fTrace.getCheckpoints(); - int pageSize = fTrace.getCacheSize(); + int pageSize = fTrace.getIndexPageSize(); assertTrue("Checkpoints exist", checkpoints != null); // Validate that each checkpoint points to the right event 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 3a81bbb0ba..65e7998435 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 @@ -70,7 +70,7 @@ public class CtfTmfTrace extends TmfEventProvider implements } @Override - public void initTrace(String name, String path, Class eventType, int pageSize) + public void initTrace(String name, String path, Class eventType) throws FileNotFoundException { try { this.fTrace = new CTFTrace(path); @@ -154,7 +154,7 @@ public class CtfTmfTrace extends TmfEventProvider implements } @Override - public int getCacheSize() { + public int getIndexPageSize() { return this.fIndexPageSize; } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java index cf9c33cfea..9cd5c73f19 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java @@ -17,7 +17,7 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; /** * ITmfEvent *

- * The basic event structure in the TMF. In its canonical form, a data item has: + * The basic event structure in TMF. In its canonical form, a data item has: *

    *
  • a parent trace *
  • a rank (order within the trace) 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 9a4c1b7b0c..192e1af6f0 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 @@ -96,7 +96,7 @@ public class TmfExperiment extends TmfEventProvider impl } @Override - public void initTrace(String name, String path, Class eventType, int pageSize) { + public void initTrace(String name, String path, Class eventType) { } /** @@ -182,7 +182,7 @@ public class TmfExperiment extends TmfEventProvider impl } @Override - public int getCacheSize() { + public int getIndexPageSize() { return fIndexPageSize; } 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 b032ec10c8..5c8fdb25b1 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 @@ -25,28 +25,59 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; /** * ITmfTrace *

    - * The basic event trace structure in the TMF. + * The basic event trace structure in TMF. */ public interface ITmfTrace extends ITmfComponent { - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ // Initializers // ------------------------------------------------------------------------ + + /** + * Initialize a newly instantiated "empty" trace object. This is used to + * parameterize an ITmfTrace instantiated with its parameterless constructor. + * + * @param name the trace name + * @param path the trace path + * @param eventType the trace event type + * @throws FileNotFoundException + */ + public void initTrace(String name, String path, Class eventType) throws FileNotFoundException; - // initTrace variants - public void initTrace(String name, String path, Class eventType, int pageSize) throws FileNotFoundException; + /** + * Validate that the trace is of the correct type. + * + * @param project the eclipse project + * @param path the trace path + * + * @return true if trace is valid + */ + public boolean validate(IProject project, String path); - public void indexTrace(boolean waitForCompletion); + /** + * Set the resource used for persistent properties on this trace + * + * @param resource the properties resource + */ + public void setResource(IResource resource); - // Trace type validation - public boolean validate(IProject project, String path); + /** + * 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); // ------------------------------------------------------------------------ - // Getters + // Basic getters // ------------------------------------------------------------------------ /** @@ -60,23 +91,24 @@ public interface ITmfTrace extends ITmfComponent { @Override public String getName(); - /** - * @return the cache size - */ - public int getCacheSize(); - /** * @return the number of events in the trace */ public long getNbEvents(); /** - * Trace time range accesses + * @return the trace time range */ public TmfTimeRange getTimeRange(); + /** + * @return the timestamp of the first trace event + */ public ITmfTimestamp getStartTime(); + /** + * @return the timestamp of the last trace event + */ public ITmfTimestamp getEndTime(); /** @@ -84,89 +116,102 @@ public interface ITmfTrace extends ITmfComponent { */ public long getStreamingInterval(); + /** + * @return the trace index page size + */ + public int getIndexPageSize(); + // ------------------------------------------------------------------------ // Seek operations // ------------------------------------------------------------------------ /** - * Positions the trace at the first event with the specified timestamp or index (i.e. the nth event in the trace). + * Position the trace at the specified location. The null location + * is used to indicate that the first trace event. * - * Returns a context which can later be used to read the event. - * - * @param location - * @return a context object for subsequent reads + * @param location the trace specific location (null for 1st event) + * @return a context which can later be used to read the corresponding event */ public ITmfContext seekLocation(ITmfLocation location); - public ITmfContext seekEvent(ITmfTimestamp timestamp); - - public ITmfContext seekEvent(long rank); - /** - * Positions the trace at the event located at the specified ratio. + * Position the trace at the event located at the specified ratio in the + * trace file. * - * Returns a context which can later be used to read the event. + * 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 or timestamp in the trace file. * - * @param ratio - * a floating-point number between 0.0 (beginning) and 1.0 (end) - * @return a context object for subsequent reads + * @param ratio the proportional 'rank' in the trace + * @return a context which can later be used to read the corresponding event */ public ITmfContext seekLocation(double ratio); + /** + * Position the trace at the first event with the specified timestamp. If + * there is no event with the requested timestamp, a context pointing to + * the chronologically next event is returned. + * + * @param timestamp the timestamp of desired event + * @return a context which can later be used to read the corresponding event + */ + public ITmfContext seekEvent(ITmfTimestamp timestamp); + + /** + * Position the trace at the Nth event in the trace. + * + * @param rank the event rank + * @return a context which can later be used to read the corresponding event + */ + public ITmfContext seekEvent(long rank); + // ------------------------------------------------------------------------ // Read operations // ------------------------------------------------------------------------ /** - * Return the event pointed by the supplied context (or null if no event left) and updates the context to the next - * event. + * Return the event pointed by the supplied context (or null if no event + * left) and updates the context to point the next event. * + * @param context the read context * @return the next event in the stream */ public ITmfEvent getNextEvent(ITmfContext context); /** - * Return the event pointed by the supplied context (or null if no event left) and *does not* update the 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); // ------------------------------------------------------------------------ - // misc + // Location getters // ------------------------------------------------------------------------ /** - * Returns the ratio corresponding to the specified location. + * Returns the ratio (proportion) corresponding to the specified location. * - * @param location - * a trace location + * @param location a trace specific location * @return a floating-point number between 0.0 (beginning) and 1.0 (end) */ 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 next event - * (if any). + * Returns the rank of the first event with the requested timestamp. + * If none, returns the index of the subsequent event (if any). * * @param timestamp the requested event timestamp * @return the corresponding event rank */ public long getRank(ITmfTimestamp timestamp); - /** - * Set the resource used for persistent properties on this trace - * @param resource the properties resource - */ - 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(); - } 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 7109971a22..965e93b230 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 @@ -97,11 +97,7 @@ public abstract class TmfTrace extends TmfEventProvider } @Override - public void initTrace(String name, String path, Class eventType, int pageSize) throws FileNotFoundException { - initTmfTrace(name, path, eventType, pageSize, false); - } - - private void initTmfTrace(String name, String path, Class eventType, int pageSize, boolean indexTrace) throws FileNotFoundException { + public void initTrace(String name, String path, Class eventType) throws FileNotFoundException { fPath = path; if (name != null) { fTraceName = name; @@ -114,9 +110,6 @@ public abstract class TmfTrace extends TmfEventProvider } } super.init(fTraceName, eventType); - fIndexPageSize = (pageSize > 0) ? pageSize : DEFAULT_INDEX_PAGE_SIZE; - if (indexTrace) - indexTrace(false); } @Override @@ -157,9 +150,12 @@ public abstract class TmfTrace extends TmfEventProvider * @param indexTrace * @throws FileNotFoundException */ - protected TmfTrace(String name, Class type, String path, int cacheSize, boolean indexTrace) throws FileNotFoundException { + protected TmfTrace(String name, Class type, String path, int indexPageSize, boolean indexTrace) throws FileNotFoundException { super(); - initTmfTrace(name, path, type, cacheSize, indexTrace); + initTrace(name, path, type); + fIndexPageSize = (indexPageSize >0) ? indexPageSize : DEFAULT_INDEX_PAGE_SIZE; + if (indexTrace) + indexTrace(false); } @SuppressWarnings("unchecked") @@ -196,7 +192,7 @@ public abstract class TmfTrace extends TmfEventProvider * @return the size of the cache */ @Override - public int getCacheSize() { + public int getIndexPageSize() { return fIndexPageSize; } diff --git a/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd b/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd index f51f6822b3..758a884e2f 100644 --- a/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd +++ b/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd @@ -90,7 +90,7 @@ - an optional attribute that is composed of the category ID. The referenced category must be declared in a corresponding category element. + An optional attribute that is composed of the category ID. The referenced category must be declared in a corresponding category element. @@ -110,10 +110,10 @@ - The fully qualified name of a class that extends <samp>TmfEvent</samp> . + The fully qualified name of a class that implements the <samp>ITmfEvent</samp> interface - + 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 3790a24b7b..2d94dbb360 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 @@ -34,7 +34,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; public class CustomTxtTrace extends TmfTrace { private static final TmfLocation NULL_LOCATION = new TmfLocation((Long) null); - private static final int DEFAULT_PAGE_SIZE = 100; + private static final int DEFAULT_CACHE_SIZE = 100; private CustomTxtTraceDefinition fDefinition; private CustomTxtEventType fEventType; @@ -44,15 +44,15 @@ public class CustomTxtTrace extends TmfTrace { fEventType = new CustomTxtEventType(fDefinition); } - public CustomTxtTrace(String name, CustomTxtTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException { - super(name, CustomTxtEvent.class, path, cacheSize); + public CustomTxtTrace(String name, CustomTxtTraceDefinition definition, String path, int pageSize) throws FileNotFoundException { + super(name, CustomTxtEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE); fDefinition = definition; fEventType = new CustomTxtEventType(fDefinition); } @Override - public void initTrace(String name, String path, Class eventType, int pageSize) throws FileNotFoundException { - super.initTrace(name, path, eventType, (pageSize > 0) ? pageSize : DEFAULT_PAGE_SIZE); + public void initTrace(String name, String path, Class eventType) throws FileNotFoundException { + super.initTrace(name, path, eventType); } @Override 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 6bade33af3..44abfb4e89 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 @@ -45,7 +45,7 @@ import org.xml.sax.SAXParseException; public class CustomXmlTrace extends TmfTrace { private static final TmfLocation NULL_LOCATION = new TmfLocation((Long) null); - private static final int DEFAULT_PAGE_SIZE = 100; + private static final int DEFAULT_CACHE_SIZE = 100; private CustomXmlTraceDefinition fDefinition; private CustomXmlEventType fEventType; @@ -57,16 +57,16 @@ public class CustomXmlTrace extends TmfTrace { fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement); } - public CustomXmlTrace(String name, CustomXmlTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException { - super(name, CustomXmlEvent.class, path, cacheSize); + public CustomXmlTrace(String name, CustomXmlTraceDefinition definition, String path, int pageSize) throws FileNotFoundException { + super(name, CustomXmlEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE); fDefinition = definition; fEventType = new CustomXmlEventType(fDefinition); fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement); } @Override - public void initTrace(String name, String path, Class eventType, int pageSize) throws FileNotFoundException { - super.initTrace(name, path, eventType, (pageSize > 0) ? pageSize : DEFAULT_PAGE_SIZE); + public void initTrace(String name, String path, Class eventType) throws FileNotFoundException { + super.initTrace(name, path, eventType); } @Override diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java index 7399f8ab88..87fdfb830a 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java @@ -140,12 +140,12 @@ public class OpenExperimentHandler extends AbstractHandler { return null; } try { - trace.initTrace(element.getName(), element.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(element.getName(), element.getLocation().getPath(), traceEvent.getClass()); } catch (FileNotFoundException e) { displayErrorMsg(""); //$NON-NLS-1$ } trace.setResource(element.getResource()); - cacheSize = Math.min(cacheSize, trace.getCacheSize()); + cacheSize = Math.min(cacheSize, trace.getIndexPageSize()); String editorId = element.getEditorId(); if (editorId == null) { useEditor = false; @@ -177,7 +177,7 @@ public class OpenExperimentHandler extends AbstractHandler { } else { activePage.openEditor(editorInput, editorId); } - experiment.initTrace(null, null, null, 0); + experiment.initTrace(null, null, null); experiment.indexTrace(true); IDE.setDefaultEditor(file, editorId); // editor should dispose the experiment on close diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java index 96d0ee5ac0..69b6bba6ec 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenTraceHandler.java @@ -139,7 +139,7 @@ public class OpenTraceHandler extends AbstractHandler { boolean usesEditor = editorId != null && editorId.length() > 0; try { - trace.initTrace(fTrace.getName(), fTrace.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(fTrace.getName(), fTrace.getLocation().getPath(), traceEvent.getClass()); if (usesEditor) trace.indexTrace(false); } catch (FileNotFoundException e) { @@ -199,7 +199,7 @@ public class OpenTraceHandler extends AbstractHandler { } else { // Create the experiment ITmfTrace[] traces = new ITmfTrace[] { trace }; - TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), fTrace.getName(), traces, trace.getCacheSize()); + TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), fTrace.getName(), traces, trace.getIndexPageSize()); experiment.setBookmarksFile(file); TmfExperiment.setCurrentExperiment(experiment); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java index 2ad773c15d..0268dd5479 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/EventsViewEditor.java @@ -136,11 +136,11 @@ public class EventsViewEditor extends TmfEditor { throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType); } try { - trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass()); } catch (FileNotFoundException e) { } trace.setResource(traceElement.getResource()); - cacheSize = Math.min(cacheSize, trace.getCacheSize()); + cacheSize = Math.min(cacheSize, trace.getIndexPageSize()); traces[i] = trace; } TmfExperiment experiment = new TmfExperiment(TmfEvent.class, experimentElement.getName(), traces, cacheSize); @@ -167,12 +167,12 @@ public class EventsViewEditor extends TmfEditor { throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); } try { - trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass()); } catch (FileNotFoundException e) { } trace.setResource(traceElement.getResource()); ITmfTrace[] traces = new ITmfTrace[] { trace }; - TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), traceElement.getName(), traces, trace.getCacheSize()); + TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), traceElement.getName(), traces, trace.getIndexPageSize()); experiment.setBookmarksFile(fFile); fTrace = experiment; TmfExperiment.setCurrentExperiment(experiment); @@ -194,7 +194,7 @@ public class EventsViewEditor extends TmfEditor { throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); } try { - trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass()); trace.indexTrace(false); } catch (FileNotFoundException e) { } @@ -202,7 +202,7 @@ public class EventsViewEditor extends TmfEditor { ((TmfTrace) trace).setResource(traceElement.getResource()); } ITmfTrace[] traces = new ITmfTrace[] { trace }; - TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), traceElement.getName(), traces, trace.getCacheSize()); + TmfExperiment experiment = new TmfExperiment(traceEvent.getClass(), traceElement.getName(), traces, trace.getIndexPageSize()); experiment.setBookmarksFile(fFile); fTrace = experiment; TmfExperiment.setCurrentExperiment(experiment); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index acfe0d17da..9d26d4bc44 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -130,17 +130,17 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType); } try { - trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass()); } catch (FileNotFoundException e) { } trace.setResource(traceElement.getResource()); - cacheSize = Math.min(cacheSize, trace.getCacheSize()); + cacheSize = Math.min(cacheSize, trace.getIndexPageSize()); traces[i] = trace; } TmfExperiment experiment = new TmfExperiment(TmfEvent.class, experimentElement.getName(), traces, cacheSize); experiment.setBookmarksFile(fFile); fTrace = experiment; - experiment.initTrace(null, null, null, 0); + experiment.initTrace(null, null, null); experiment.indexTrace(true); break; } @@ -161,7 +161,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); } try { - trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass()); trace.indexTrace(false); } catch (FileNotFoundException e) { } @@ -184,7 +184,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus throw new PartInitException(Messages.OpenTraceHandler_NoTraceType); } try { - trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass(), 0); + trace.initTrace(traceElement.getName(), traceElement.getLocation().getPath(), traceEvent.getClass()); trace.indexTrace(false); } catch (FileNotFoundException e) { } @@ -238,7 +238,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus super.setInput(new FileEditorInput(fFile)); fEventsTable.dispose(); if (fTrace != null) { - fEventsTable = createEventsTable(fParent, fTrace.getCacheSize()); + fEventsTable = createEventsTable(fParent, fTrace.getIndexPageSize()); fEventsTable.setTrace(fTrace, true); fEventsTable.refreshBookmarks(fFile); broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable)); @@ -254,7 +254,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus fParent = parent; if (fTrace != null) { setPartName(fTrace.getName()); - fEventsTable = createEventsTable(parent, fTrace.getCacheSize()); + fEventsTable = createEventsTable(parent, fTrace.getIndexPageSize()); fEventsTable.setTrace(fTrace, true); fEventsTable.refreshBookmarks(fFile); broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable)); @@ -500,7 +500,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus fTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); String path = fFile.getLocationURI().getPath(); - fTrace.initTrace(name, path, event.getClass(), 0); + fTrace.initTrace(name, path, event.getClass()); fTrace.indexTrace(false); break; } @@ -515,7 +515,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus } fEventsTable.dispose(); if (fTrace != null) { - fEventsTable = createEventsTable(fParent, fTrace.getCacheSize()); + fEventsTable = createEventsTable(fParent, fTrace.getIndexPageSize()); fEventsTable.setTrace(fTrace, true); broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable)); } else { 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 f345f4d31b..c7f8eb259e 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 @@ -1062,7 +1062,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS return; } request = new TmfEventRequest(TmfEvent.class, TmfTimeRange.ETERNITY, (int) fFilterCheckCount, - nbRequested, fTrace.getCacheSize(), ExecutionType.BACKGROUND) { + nbRequested, fTrace.getIndexPageSize(), ExecutionType.BACKGROUND) { @Override public void handleData(TmfEvent event) { super.handleData(event); @@ -1255,9 +1255,9 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS boolean wrapped = false; while (!monitor.isCanceled() && foundRank == -1 && fTrace != null) { int nbRequested = (direction == Direction.FORWARD ? Integer.MAX_VALUE : Math.min((int) rank + 1, - fTrace.getCacheSize())); + fTrace.getIndexPageSize())); if (direction == Direction.BACKWARD) { - rank = Math.max(0, rank - fTrace.getCacheSize() + 1); + rank = Math.max(0, rank - fTrace.getIndexPageSize() + 1); } request = new TmfDataRequest(TmfEvent.class, (int) rank, nbRequested) { long currentRank = rank; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java index 0d20170c43..df749ae875 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/events/TmfEventsView.java @@ -108,7 +108,7 @@ public class TmfEventsView extends TmfView { if (fExperiment == null) { return new TmfEventsTable(parent, DEFAULT_CACHE_SIZE); } - int cacheSize = fExperiment.getCacheSize(); + int cacheSize = fExperiment.getIndexPageSize(); String commonTraceType = null; try { for (ITmfTrace trace : fExperiment.getTraces()) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java index 2c27264ca9..e48fe24dea 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java @@ -195,7 +195,7 @@ public class TimeChartEvent implements ITimeEvent { } public void merge(RankRangeList rankRangeList) { - long threshold = fParentEntry.getTrace().getCacheSize(); + long threshold = fParentEntry.getTrace().getIndexPageSize(); for (RankRange newRange : rankRangeList) { boolean merged = false; for (RankRange oldRange : fRankRangeList) { 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..3b0a377fcf 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 @@ -196,7 +196,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList done = true; break; } - if (context.getRank() % trace.getCacheSize() == 1) { + if (context.getRank() % trace.getIndexPageSize() == 1) { // break for UI refresh break; } @@ -411,7 +411,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList entryIsBookmarked |= event.isBookmarked(); entryIsVisible |= event.isVisible(); entryIsSearchMatch |= event.isSearchMatch(); - if (++fCount % timeAnalysisEntry.getTrace().getCacheSize() == 0) { + if (++fCount % timeAnalysisEntry.getTrace().getIndexPageSize() == 0) { refreshViewer(false); } } -- 2.34.1