tmf: Provide a way to build the state system in-band
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 4 Jun 2012 18:33:26 +0000 (14:33 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 4 Jun 2012 18:35:24 +0000 (14:35 -0400)
This makes the regression tests work again.

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/HistoryBuilder.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystemManager.java

index 7190dd5684893c80524e7ebea252f94a9c5c2ea0..7a187766fddfe51a98634a1da09c8716cfb379e1 100644 (file)
@@ -62,7 +62,8 @@ public class HistoryBuilder extends TmfComponent {
      *             backend)
      */
     public HistoryBuilder(IStateChangeInput stateChangeInput,
-            IStateHistoryBackend backend) throws IOException {
+            IStateHistoryBackend backend, boolean buildManually)
+            throws IOException {
         if (stateChangeInput == null || backend == null) {
             throw new IllegalArgumentException();
         }
@@ -71,7 +72,14 @@ public class HistoryBuilder extends TmfComponent {
         shs = new StateHistorySystem(hb, true);
 
         sci.assignTargetStateSystem(shs);
-        started = false;
+
+        if (buildManually) {
+            TmfSignalManager.deregister(this);
+            this.buildManually();
+        } else {
+            started = false;
+            /* We'll now wait for the signal to start building */
+        }
     }
 
     /**
@@ -111,6 +119,23 @@ public class HistoryBuilder extends TmfComponent {
         return shs;
     }
 
+    /**
+     * Build the state history without waiting for signals or anything
+     */
+    @SuppressWarnings("unchecked")
+    private void buildManually() {
+        StateSystemBuildRequest request = new StateSystemBuildRequest(this);
+
+        /* Send the request to the trace here, since there is probably no
+         * experiment. */
+        sci.getTrace().sendRequest(request);
+        try {
+            request.waitForCompletion();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
 
     // ------------------------------------------------------------------------
     // Signal handlers
index 41eea8d34975324a72d40261f43e85f18b4765af..7a61a2e1bfae64a81916b691b6a88d0647e9fed9 100644 (file)
@@ -48,15 +48,16 @@ public abstract class StateSystemManager extends TmfComponent {
      *            The IStateChangeInput to use for building the history file. It
      *            may be required even if we are opening an already-existing
      *            history (ie, for partial histories).
-     * @param waitForCompletion
-     *            Should we block the calling thread until the construction is
-     *            complete? It has no effect if the file already exists.
+     * @param buildManually
+     *            If false, the construction will wait for a signal before
+     *            starting. If true, it will build everything right now and
+     *            block the caller. It has no effect if the file already exists.
      * @return A IStateSystemQuerier handler to the state system, with which you
      *         can then run queries on the history.
      * @throws TmfTraceException
      */
     public static IStateSystemQuerier loadStateHistory(File htFile,
-            IStateChangeInput htInput, boolean waitForCompletion)
+            IStateChangeInput htInput, boolean buildManually)
             throws TmfTraceException {
         IStateSystemQuerier ss;
         IStateHistoryBackend htBackend;
@@ -88,7 +89,7 @@ public abstract class StateSystemManager extends TmfComponent {
         try {
             htBackend = new ThreadedHistoryTreeBackend(htFile,
                     htInput.getStartTime(), QUEUE_SIZE);
-            builder = new HistoryBuilder(htInput, htBackend);
+            builder = new HistoryBuilder(htInput, htBackend, buildManually);
         } catch (IOException e) {
             /*
              * If it fails here however, it means there was a problem writing to
This page took 0.027155 seconds and 5 git commands to generate.