From 51e75066980f1c50c1d80be7d3767938ef2dbd55 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 19 Apr 2013 15:41:31 -0400 Subject: [PATCH] tmf: Expose the indexTrace() method in the interface Some trace types could decide to do their indexing manually and such, so expose the already-existing indexTrace() method up to the ITmfTrace interface. Change-Id: I1f9724f3cb20b8bbf19b8a5120cc16155b7de173 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/12078 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann --- .../tests/trace/TmfCheckpointIndexTest.java | 4 +-- .../tests/trace/TmfCheckpointIndexTest2.java | 4 +-- .../tmf/core/tests/trace/TmfTraceTest.java | 26 +++++++++---------- .../tmf/tests/stubs/trace/TmfTraceStub.java | 6 +---- .../linuxtools/tmf/core/trace/ITmfTrace.java | 11 ++++++++ .../linuxtools/tmf/core/trace/TmfTrace.java | 7 +++-- 6 files changed, 32 insertions(+), 26 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java index bf6ce382db..c727241a7b 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java @@ -123,7 +123,7 @@ public class TmfCheckpointIndexTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE); - fTrace.indexTrace(); + fTrace.indexTrace(true); } catch (final TmfTraceException e) { e.printStackTrace(); } catch (final URISyntaxException e) { @@ -135,7 +135,7 @@ public class TmfCheckpointIndexTest { if (fEmptyTrace == null) { fEmptyTrace = new EmptyTestTrace(); - fEmptyTrace.indexTrace(); + fEmptyTrace.indexTrace(true); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest2.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest2.java index 49900df8c0..fd150ca45a 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest2.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest2.java @@ -125,7 +125,7 @@ public class TmfCheckpointIndexTest2 { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE); - fTrace.indexTrace(); + fTrace.indexTrace(true); } catch (final TmfTraceException e) { e.printStackTrace(); } catch (final URISyntaxException e) { @@ -137,7 +137,7 @@ public class TmfCheckpointIndexTest2 { if (fEmptyTrace == null) { fEmptyTrace = new EmptyTestTrace(); - fEmptyTrace.indexTrace(); + fEmptyTrace.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 496a6d0b1d..da3f6acd96 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 @@ -95,7 +95,7 @@ public class TmfTraceTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.toURI().getPath(), BLOCK_SIZE); - fTrace.indexTrace(); + fTrace.indexTrace(true); } catch (final TmfTraceException e) { e.printStackTrace(); } catch (final URISyntaxException e) { @@ -120,7 +120,7 @@ public class TmfTraceTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); testfile = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(testfile.toURI().getPath()); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { @@ -151,7 +151,7 @@ public class TmfTraceTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); testfile = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(testfile.toURI().getPath(), 0); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { @@ -176,7 +176,7 @@ public class TmfTraceTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); testfile = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { @@ -206,7 +206,7 @@ public class TmfTraceTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); testfile = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, null); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { @@ -238,7 +238,7 @@ public class TmfTraceTest { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null); testfile = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, interval); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { @@ -271,7 +271,7 @@ public class TmfTraceTest { testfile = new File(FileLocator.toFileURL(location).toURI()); original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null)); trace = new TmfTraceStub(original); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { @@ -401,7 +401,7 @@ public class TmfTraceTest { // InitTrace and wait for indexing completion... trace.initTrace(null, testfile.toURI().getPath(), ITmfEvent.class); - trace.indexTrace(); + trace.indexTrace(true); int nbSecs = 0; while (trace.getNbEvents() < NB_EVENTS && nbSecs < 10) { Thread.sleep(1000); @@ -457,7 +457,7 @@ public class TmfTraceTest { @Test public void testSetTimeRange() throws TmfTraceException { final TmfTraceStub trace = new TmfTraceStub(fTrace); - trace.indexTrace(); + trace.indexTrace(true); assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); @@ -476,7 +476,7 @@ public class TmfTraceTest { @Test public void testSetStartTime() throws TmfTraceException { final TmfTraceStub trace = new TmfTraceStub(fTrace); - trace.indexTrace(); + trace.indexTrace(true); assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); @@ -495,7 +495,7 @@ public class TmfTraceTest { @Test public void testSetEndTime() throws TmfTraceException { final TmfTraceStub trace = new TmfTraceStub(fTrace); - trace.indexTrace(); + trace.indexTrace(true); assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue()); assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); @@ -514,7 +514,7 @@ public class TmfTraceTest { @Test public void testSetNbEvents() throws TmfTraceException { final TmfTraceStub trace = new TmfTraceStub(fTrace); - trace.indexTrace(); + trace.indexTrace(true); assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents()); @@ -1456,7 +1456,7 @@ public class TmfTraceTest { assertEquals("getCurrentTime", TmfTimestamp.ZERO, trace.getCurrentTime()); assertEquals("getCurrentRange", TmfTimeRange.NULL_RANGE, trace.getCurrentRange()); trace.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE)); - trace.indexTrace(); + trace.indexTrace(true); } catch (final URISyntaxException e) { fail("URISyntaxException"); } catch (final IOException e) { 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 fb363a37b0..bac3cf0e54 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 @@ -133,7 +133,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { } setParser(new TmfEventParserStub(this)); if (waitForCompletion) { - indexTrace(); + indexTrace(true); } } @@ -184,10 +184,6 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser { setParser(new TmfEventParserStub(this)); } - public void indexTrace() { - indexTrace(true); - } - @Override public void initTrace(final IResource resource, final String path, final Class type) throws TmfTraceException { try { 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 131317549f..eb70c159d6 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 @@ -224,6 +224,17 @@ public interface ITmfTrace extends ITmfDataProvider { */ public void registerStateSystem(String id, ITmfStateSystem ss); + /** + * Index the trace. Depending on the trace type, this could be done at the + * constructor or initTrace phase too, so this could be implemented as a + * no-op. + * + * @param waitForCompletion + * Should we block the caller until indexing is finished, or not. + * @since 2.0 + */ + public void indexTrace(boolean waitForCompletion); + // ------------------------------------------------------------------------ // Trace characteristics getters // ------------------------------------------------------------------------ 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 c5f87d7255..168692467c 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 @@ -238,11 +238,10 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace { } /** - * Index the trace - * - * @param waitForCompletion index synchronously (true) or not (false) + * @since 2.0 */ - protected void indexTrace(boolean waitForCompletion) { + @Override + public void indexTrace(boolean waitForCompletion) { getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, waitForCompletion); } -- 2.34.1