From: Alexandre Montplaisir Date: Mon, 4 Jun 2012 18:33:26 +0000 (-0400) Subject: tmf: Provide a way to build the state system in-band X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=e34f7caa474b015caedad4289dafeeb47ca53f12;p=deliverable%2Ftracecompass.git tmf: Provide a way to build the state system in-band This makes the regression tests work again. Signed-off-by: Alexandre Montplaisir --- diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/HistoryBuilder.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/HistoryBuilder.java index 7190dd5684..7a187766fd 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/HistoryBuilder.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/HistoryBuilder.java @@ -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 diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystemManager.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystemManager.java index 41eea8d349..7a61a2e1bf 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystemManager.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/StateSystemManager.java @@ -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