From e45de797d5093dd294763db61e60fafc257465ce Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Mon, 7 Jan 2013 17:52:57 -0500 Subject: [PATCH] tmf: Remove the TmfStateSystemBuildCompleted signal Views should now use ITmfStateSystem.waitUntilBuild() instead. Its behavior is much more predictable, both if the state history is already built or not. This also removes the need to pass the ID when building a new state history. Only the trace will know the ID->statesystem matching. Change-Id: Ie9b5d98b0e674d607b34ae1984342030a5668b19 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/9505 Tested-by: Hudson CI Reviewed-by: Patrick Tasse IP-Clean: Patrick Tasse --- .../headless/BasicStateSystemExample.java | 3 +- .../StateSystemFullHistoryTest.java | 9 +-- .../kernel/core/trace/CtfKernelTrace.java | 2 +- .../tmf/core/statesystem/HistoryBuilder.java | 18 +---- .../signal/TmfStateSystemBuildCompleted.java | 71 ------------------- .../tmf/core/statesystem/ITmfStateSystem.java | 4 +- .../core/statesystem/StateSystemManager.java | 9 +-- .../core/statistics/TmfStateStatistics.java | 4 +- 8 files changed, 11 insertions(+), 109 deletions(-) delete mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfStateSystemBuildCompleted.java diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java index 216e286315..9dc8f0d183 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java @@ -44,8 +44,7 @@ public class BasicStateSystemExample { try { File newStateFile = new File("/tmp/helloworldctf.ht"); //$NON-NLS-1$ IStateChangeInput input = new CtfKernelStateInput(CtfTestFiles.getTestTrace()); - String name = "test-ss"; //$NON-NLS-1$ - ITmfStateSystem ss = StateSystemManager.loadStateHistory(newStateFile, input, name, true); + ITmfStateSystem ss = StateSystemManager.loadStateHistory(newStateFile, input, true); requestExample(ss); } catch (TmfTraceException e) { diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java index 1a266b88a5..c4e884dc4f 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java @@ -53,9 +53,6 @@ public class StateSystemFullHistoryTest { /* Offset in the trace + start time of the trace */ private final static long interestingTimestamp1 = 18670067372290L + 1331649577946812237L; - /* ID we give to the state system we build */ - private static final String STATE_ID = "test-ss"; - protected static String getTestFileName() { return "/tmp/statefile.ht"; //$NON-NLS-1$ } @@ -66,7 +63,7 @@ public class StateSystemFullHistoryTest { stateFileBenchmark = new File(getTestFileName() + ".benchmark"); //$NON-NLS-1$ try { input = new CtfKernelStateInput(CtfTestFiles.getTestTrace()); - ssq = StateSystemManager.loadStateHistory(stateFile, input, STATE_ID, true); + ssq = StateSystemManager.loadStateHistory(stateFile, input, true); } catch (Exception e) { e.printStackTrace(); } @@ -96,7 +93,7 @@ public class StateSystemFullHistoryTest { ITmfStateSystem ssb2; input2 = new CtfKernelStateInput(CtfTestFiles.getTestTrace()); - ssb2 = StateSystemManager.loadStateHistory(stateFileBenchmark, input2, STATE_ID, true); + ssb2 = StateSystemManager.loadStateHistory(stateFileBenchmark, input2, true); assertEquals(CtfTestFiles.startTime, ssb2.getStartTime()); assertEquals(CtfTestFiles.endTime, ssb2.getCurrentEndTime()); @@ -107,7 +104,7 @@ public class StateSystemFullHistoryTest { ITmfStateSystem ssb2; /* 'newStateFile' should have already been created */ - ssb2 = StateSystemManager.loadStateHistory(stateFile, null, STATE_ID, true); + ssb2 = StateSystemManager.loadStateHistory(stateFile, null, true); assertNotNull(ssb2); assertEquals(CtfTestFiles.startTime, ssb2.getStartTime()); diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java index be140adafa..985073c37d 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java @@ -94,7 +94,7 @@ public class CtfKernelTrace extends CtfTmfTrace { final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME); final IStateChangeInput htInput = new CtfKernelStateInput(this); - ITmfStateSystem ss = StateSystemManager.loadStateHistory(htFile, htInput, STATE_ID, false); + ITmfStateSystem ss = StateSystemManager.loadStateHistory(htFile, htInput, false); fStateSystems.put(STATE_ID, ss); } 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 b25031113c..de62ee1da3 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 @@ -20,10 +20,8 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; -import org.eclipse.linuxtools.tmf.core.signal.TmfSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; -import org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal; import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput; @@ -48,7 +46,6 @@ public class HistoryBuilder extends TmfComponent { private final IStateChangeInput sci; private final StateSystem ss; private final IStateHistoryBackend hb; - private final String id; private boolean started = true; /* Don't handle signals until we're ready */ /** @@ -58,10 +55,6 @@ public class HistoryBuilder extends TmfComponent { * The input plugin to use. This is required. * @param backend * The backend storage to use. - * @param id - * The ID (or name) of the state system that will be built. This - * can be useful in cases where there are more than 1 state - * system per trace/experiment. * @param buildManually * Should we build this history in-band or not. True means we * will start the building ourselves and block the caller until @@ -73,14 +66,13 @@ public class HistoryBuilder extends TmfComponent { * backend) */ public HistoryBuilder(IStateChangeInput stateChangeInput, - IStateHistoryBackend backend, String id, boolean buildManually) + IStateHistoryBackend backend, boolean buildManually) throws IOException { if (stateChangeInput == null || backend == null) { throw new IllegalArgumentException(); } sci = stateChangeInput; hb = backend; - this.id = id; ss = new StateSystem(hb, true); sci.assignTargetStateSystem(ss); @@ -224,18 +216,10 @@ public class HistoryBuilder extends TmfComponent { } void close(boolean deleteFiles) { - TmfSignal doneSig; - sci.dispose(); if (deleteFiles) { hb.removeFiles(); - /* We won't broadcast the signal if the request was cancelled */ - } else { - /* Broadcast the signal saying the history is done building */ - doneSig = new TmfStateSystemBuildCompleted(this, sci.getTrace(), id); - TmfSignalManager.dispatchSignal(doneSig); } - dispose(); } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfStateSystemBuildCompleted.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfStateSystemBuildCompleted.java deleted file mode 100644 index 2f0721033c..0000000000 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfStateSystemBuildCompleted.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.signal; - -import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; - -/** - * Signal sent when the state system has completed its build. - * - * @version 1.0 - * @author Francois Chouinard - */ -public class TmfStateSystemBuildCompleted extends TmfSignal { - - private final ITmfTrace fTrace; - private final String fID; - - /** - * Constructor - * - * @param source - * Object sending this signal - * @param trace - * The state system of which trace just finished building - * @param id - * ID associated with this state system. This can be used in the - * case of a trace containing multiple state systems, to - * differentiate between them. - * @since 2.0 - */ - public TmfStateSystemBuildCompleted(Object source, ITmfTrace trace, String id) { - super(source); - fTrace = trace; - fID = id; - } - - /** - * @return The trace referred to by this signal - */ - public ITmfTrace getTrace() { - return fTrace; - } - - /** - * @return The ID of the state system that just finished building - * @since 2.0 - */ - public String getID() { - return fID; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "[TmfStateSystemBuildCompleted (trace = " + fTrace.toString() + //$NON-NLS-1$ - ", ID = " + fID + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java index fc5a3a7208..9abba46c2c 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java @@ -54,9 +54,7 @@ public interface ITmfStateSystem { * * This method blocks the calling thread until the history back-end is done * building. If it's already built (ie, opening a pre-existing file) this - * should return immediately. It's an alternative to listening to the - * {@link org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted} - * signal. + * should return immediately. * * @return If the build was successful. If false is returned, this either * means there was a problem during the build, or it got cancelled 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 f7a62c2043..b73714ee3e 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,11 +48,6 @@ 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 id - * The ID, or name, to give to the state system we will build. - * The signal that when be sent when the construction is finished - * will carry this ID. 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 @@ -65,7 +60,7 @@ public abstract class StateSystemManager extends TmfComponent { * @since 2.0 */ public static ITmfStateSystem loadStateHistory(File htFile, - IStateChangeInput htInput, String id, boolean buildManually) + IStateChangeInput htInput, boolean buildManually) throws TmfTraceException { ITmfStateSystem ss; IStateHistoryBackend htBackend; @@ -97,7 +92,7 @@ public abstract class StateSystemManager extends TmfComponent { try { htBackend = new ThreadedHistoryTreeBackend(htFile, htInput.getStartTime(), QUEUE_SIZE); - builder = new HistoryBuilder(htInput, htBackend, id, buildManually); + builder = new HistoryBuilder(htInput, htBackend, buildManually); } catch (IOException e) { /* * If it fails here however, it means there was a problem writing to diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfStateStatistics.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfStateStatistics.java index c33a53d419..1a3c6f6163 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfStateStatistics.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfStateStatistics.java @@ -96,7 +96,7 @@ public class TmfStateStatistics implements ITmfStatistics { final File htFile = new File(supplDirectory + File.separator + STATS_STATE_FILENAME); final IStateChangeInput htInput = new StatsStateProvider(trace); - this.stats = StateSystemManager.loadStateHistory(htFile, htInput, STATE_ID, false); + this.stats = StateSystemManager.loadStateHistory(htFile, htInput, false); } /** @@ -114,7 +114,7 @@ public class TmfStateStatistics implements ITmfStatistics { public TmfStateStatistics(ITmfTrace trace, File historyFile) throws TmfTraceException { this.trace = trace; final IStateChangeInput htInput = new StatsStateProvider(trace); - this.stats = StateSystemManager.loadStateHistory(historyFile, htInput, STATE_ID, true); + this.stats = StateSystemManager.loadStateHistory(historyFile, htInput, true); } // ------------------------------------------------------------------------ -- 2.34.1