tmf: Expose the indexTrace() method in the interface
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 19 Apr 2013 19:41:31 +0000 (15:41 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 1 May 2013 15:03:17 +0000 (11:03 -0400)
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 <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/12078
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfCheckpointIndexTest2.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java

index bf6ce382db9ee2680539b63d35f7f4dcd757dd79..c727241a7bc7204e148bddd97ea939b4725ed85b 100644 (file)
@@ -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);
         }
     }
 
index 49900df8c0c11d0c78e0bc7bcb3e6e28b59e6d41..fd150ca45a3544430e99044855775852c45b6ed9 100644 (file)
@@ -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);
         }
     }
 
index 496a6d0b1dbef488af2b1b9b48edc1d31e6ea58c..da3f6acd96f027261a4d9955ff519034fbcdb2a1 100644 (file)
@@ -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) {
index fb363a37b032551d2cf885ab7a3ca08b8b110696..bac3cf0e5469a3a0d907beba24fa131bfbcf974b 100644 (file)
@@ -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<? extends ITmfEvent> type) throws TmfTraceException {
         try {
index 131317549ff43b1a376b897967693c5a18e50d68..eb70c159d6a8989286c081ec38943d3c9b861608 100644 (file)
@@ -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
     // ------------------------------------------------------------------------
index c5f87d725517dd766c6bbcff6a8140709e3e8457..168692467c0e56bc5a0d472cf8e203c0811fa1d6 100644 (file)
@@ -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);
     }
 
This page took 0.031198 seconds and 5 git commands to generate.