From d712a5f35be726cfd882aa10ff946811aad5d27f Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Tue, 13 Oct 2009 01:40:17 +0000 Subject: [PATCH] [291981] Perform cleanup of previous experiment data when loading a new one --- .../ui/views/common/AbsTimeUpdateView.java | 24 ++++++++- .../lttng/ui/views/common/ParamsUpdater.java | 17 +++++++ .../ui/views/controlflow/ControlFlowView.java | 51 +++++++++++++++---- .../model/FlowProcessContainer.java | 7 +++ .../ui/views/resources/ResourcesView.java | 35 ++++++++++--- .../resources/model/ResourceContainer.java | 9 +++- .../lttng/state/StateDataRequest.java | 21 +++++++- .../linuxtools/lttng/state/StateManager.java | 11 +++- .../experiment/StateExperimentManager.java | 12 +++-- .../timeAnalysis/ITimeAnalysisViewer.java | 5 +- .../timeAnalysis/TmfTimeAnalysisViewer.java | 23 ++++++--- 11 files changed, 179 insertions(+), 36 deletions(-) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java index 6d0ff65c2b..5b0ddbe472 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java @@ -80,7 +80,22 @@ public abstract class AbsTimeUpdateView extends TmfView implements // manager. // Leave the GUI in charge of the updated data. String traceId = smanager.getEventLog().getName(); - ModelUpdatePrep(traceId); + + // indicate if the data model needs to be cleared e.g. a new + // experiment is being selected + boolean clearData = request.isclearDataInd(); + // no new time range for zoom orders + TmfTimeRange trange = null; + if (clearData) { + // Time Range will be used to filter out events which are + // not visible in one pixel + trange = StateManagerFactory.getExperimentManager() + .getExperimentTimeRange(); + } + + //Indicate if current data needs to be cleared and if so + //specify the new experiment time range that applies + ModelUpdatePrep(traceId, clearData, trange); } else { // clean up any possible pending request request.cancel(); @@ -211,8 +226,13 @@ public abstract class AbsTimeUpdateView extends TmfView implements * given traceId * * @param traceId + * @param clearAllData + * - reset all data e.g when a new experiment is selected + * @param timeRange + * - new total time range e.g. Experiment level */ - public abstract void ModelUpdatePrep(String traceId); + public abstract void ModelUpdatePrep(String traceId, boolean clearAllData, + TmfTimeRange timeRange); /** * Actions taken by the view to refresh its widget(s) with the updated data diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java index e176d30db8..5659066bd0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/ParamsUpdater.java @@ -88,6 +88,17 @@ public class ParamsUpdater { return selectedTime; } + /** + * Update time range but keep width as is + * + * @param time0 + * @param time1 + * @return + */ + public boolean update(long time0, long time1) { + return update(time0, time1, width); + } + /** * Only positive attributes are expected * @@ -121,6 +132,12 @@ public class ParamsUpdater { TmfTimestamp fTimeEnd = new LttngTimestamp(endTime); trange = new TmfTimeRange(fTimeStart, fTimeEnd); + // make sure the selected time is within the new range or else set + // mark it as invalid + if (selectedTime != null) { + setSelectedTime(selectedTime); + } + // update succeeded updated = true; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java index 86aadb32e2..cbf3df9cfa 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java @@ -964,9 +964,15 @@ public class ControlFlowView extends AbsTimeUpdateView implements table.setLinesVisible(true); } - // @Override + /** + * @param items + * @param startTime + * @param endTime + * @param updateTimeBounds - Update needed e.g. a new Experiment or trace selected + */ public void flowModelUpdates(final ITmfTimeAnalysisEntry[] items, - final long startTime, final long endTime) { + final long startTime, final long endTime, + final boolean updateTimeBounds) { final Table table = tableViewer.getTable(); Display display = table.getDisplay(); @@ -983,7 +989,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements table.update(); tableViewer.refresh(); - tsfviewer.display(items, startTime, endTime); + tsfviewer.display(items, startTime, endTime, updateTimeBounds); tsfviewer.resizeControls(); // Adjust the size of the vertical scroll bar to fit the @@ -1132,14 +1138,36 @@ public class ControlFlowView extends AbsTimeUpdateView implements /* * (non-Javadoc) * - * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# - * ModelUpdatePrep(java.lang.String) + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# + * ModelUpdatePrep(java.lang.String, boolean) */ @Override - public void ModelUpdatePrep(String traceId) { - FlowModelFactory.getProcContainer().clearChildren(traceId); + public void ModelUpdatePrep(String traceId, boolean clearAllData, + TmfTimeRange trange) { + if (clearAllData) { + FlowModelFactory.getProcContainer().clearProcesses(); + // Obtain the current process list + Vector processList = FlowModelFactory + .getProcContainer().readProcesses(); + // convert it to an Array as expected by the widget + TimeRangeEventProcess[] processArr = processList + .toArray(new TimeRangeEventProcess[processList.size()]); + + // initialise to an empty model + flowModelUpdates(processArr, -1, -1, false); + } else { + FlowModelFactory.getProcContainer().clearChildren(traceId); + } + + ParamsUpdater updater = FlowModelFactory.getParamsUpdater(); // Start over - FlowModelFactory.getParamsUpdater().setEventsDiscarded(0); + updater.setEventsDiscarded(0); + + // Update new visible time range if available + if (trange != null) { + updater.update(trange.getStartTime().getValue(), trange + .getEndTime().getValue()); + } } /* @@ -1168,9 +1196,10 @@ public class ControlFlowView extends AbsTimeUpdateView implements Arrays.sort(processArr); // Update the view part - flowModelUpdates(processArr, experimentStartTime, experimentEndTime); + flowModelUpdates(processArr, experimentStartTime, experimentEndTime, + request.isclearDataInd()); - // reselect to original time + // get back to user selected time if still within range ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); final Long selTime = paramUpdater.getSelectedTime(); if (selTime != null) { @@ -1206,6 +1235,8 @@ public class ControlFlowView extends AbsTimeUpdateView implements sb.append("\n\t\tRequested Time Range: " + range.getStartTime() + "-" + range.getEndTime()); + sb.append("\n\t\tExperiment Time Range: " + experimentStartTime + + "-" + experimentEndTime); TraceDebug.debug(sb.toString()); } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java index 18573f77a2..3b04c8dfa5 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java @@ -79,6 +79,13 @@ public class FlowProcessContainer { } } + /** + * Clear all process items + */ + public void clearProcesses() { + processes.clear(); + } + /** * remove the processes related to a specific trace e.g. during trace * removal diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java index 951fbbae53..00db512902 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java @@ -516,12 +516,18 @@ public class ResourcesView extends AbsTimeUpdateView implements return strVal.substring(strVal.length() - 9); } + /** + * @param items + * @param startTime + * @param endTime + * @param timeUpdate - Time bounds updated needed e.g. if a new Experiment or trace is selected + */ public void resourceModelUpdates(final ITmfTimeAnalysisEntry[] items, - final long startTime, final long endTime) { + final long startTime, final long endTime, final boolean timeUpdate) { tsfviewer.getControl().getDisplay().asyncExec(new Runnable() { public void run() { - tsfviewer.display(items, startTime, endTime); + tsfviewer.display(items, startTime, endTime, timeUpdate); tsfviewer.resizeControls(); } }); @@ -599,14 +605,27 @@ public class ResourcesView extends AbsTimeUpdateView implements /* * (non-Javadoc) * - * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# - * ModelUpdatePrep(java.lang.String) + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView# + * ModelUpdatePrep(java.lang.String, boolean) */ @Override - public void ModelUpdatePrep(String traceId) { - ResourceModelFactory.getResourceContainer().clearChildren(traceId); + public void ModelUpdatePrep(String traceId, boolean clearAllData, + TmfTimeRange trange) { + if (clearAllData) { + ResourceModelFactory.getResourceContainer().clearResources(); + } else { + ResourceModelFactory.getResourceContainer().clearChildren(traceId); + } + + ParamsUpdater updater = ResourceModelFactory.getParamsUpdater(); // Start over - ResourceModelFactory.getParamsUpdater().setEventsDiscarded(0); + updater.setEventsDiscarded(0); + + // Update new visible time range if available + if (trange != null) { + updater.update(trange.getStartTime().getValue(), trange + .getEndTime().getValue()); + } } /* @@ -635,7 +654,7 @@ public class ResourcesView extends AbsTimeUpdateView implements // Update the view part resourceModelUpdates(resourceArr, experimentStartTime, - experimentEndTime); + experimentEndTime, request.isclearDataInd()); // reselect to original time ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java index 16e1052535..ff2e6dcc34 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java @@ -85,7 +85,14 @@ public class ResourceContainer { } } } - + + /** + * Clear all resources items e.g. when a new experiment is selected + */ + public void clearResources() { + resources.clear(); + } + /** * remove the resources related to a specific trace e.g. during trace * removal diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateDataRequest.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateDataRequest.java index a9f131c1a8..b4318fb107 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateDataRequest.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateDataRequest.java @@ -35,7 +35,7 @@ public class StateDataRequest extends TmfDataRequest { private StateManager manager = null; private long numOfEvents = 0; private boolean broadcast = false; - + private boolean clearDataInd = false; // ======================================================================== // Constructors // ======================================================================= @@ -165,4 +165,23 @@ public class StateDataRequest extends TmfDataRequest { public long getNumOfEvents() { return numOfEvents; } + + /** + * @param clearAllData + * indicates the need to clear all previous data e.g. a new + * experiment selection + */ + public void setclearDataInd(boolean clearAllData) { + this.clearDataInd = clearAllData; + } + + /** + * Returns indication - clearing of all existing data model is required e.g + * from the selection of a new experiment + * + * @return + */ + public boolean isclearDataInd() { + return clearDataInd; + } } diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateManager.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateManager.java index 62b93d6dbc..0663458a48 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateManager.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/StateManager.java @@ -112,7 +112,13 @@ public class StateManager extends Observable { // ======================================================================== // Methods // ======================================================================= - public void setTraceSelection(TmfExperiment experiment) { + /** + * A new Experiment or trace selected + * @param experiment + * @param clearPreviousData + */ + public void setTraceSelection(TmfExperiment experiment, + boolean clearPreviousData) { // New log in use, read all events and build state transition stack if (experiment != null) { if (fExperiment != null && fExperiment != experiment) { @@ -142,6 +148,7 @@ public class StateManager extends Observable { TmfTimeRange allTraceWindow = fEventLog.getTimeRange(); StateDataRequest request = getDataRequestStateSave(allTraceWindow, null); + request.setclearDataInd(clearPreviousData); // Wait for completion request.startRequestInd(fExperiment, true, true); @@ -612,7 +619,7 @@ public class StateManager extends Observable { TmfExperiment newExpt = new TmfExperiment("trace1", testStream); // This will create all the checkpoint - stateManagerTest.setTraceSelection(newExpt); + stateManagerTest.setTraceSelection(newExpt, false); System.out.println("JOIE JOIE FIN DE LA CREATION DES CHECKPOINTS"); // *** Restore some checkpoint to test diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java index 8489ac4cda..716e22449d 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java @@ -124,19 +124,23 @@ public class StateExperimentManager extends TmfComponent { } /** - * A new trace log is opened, notification received from the framework - * Notify the new log selection to the state handling manager + * A new Experiment selected, notification received from the framework + * Notify the new log selection to the state handling managers * * @param experiment */ private void traceSelected(TmfExperiment experiment) { - // TODO: Re-factor when the experiment provides the list of traces per + // TODO: Re-factor when multiple traces are supported // traceId, as well as when the request can be specified at the trace // level // For the moment it does work for only one trace per experiment. String experimentId = experiment.getExperimentId(); StateManager manager = StateManagerFactory.getManager(experimentId); - manager.setTraceSelection(experiment); + // TODO: clearAllData shall not be applied to all manager calls below + // since that would clean all data loaded within previous iterations in + // the future loop. i.e. It can be applied to first manager in the loop. + boolean clearAllData = true; + manager.setTraceSelection(experiment, clearAllData); } /** diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java index 3a3fa87e54..d0d32d6628 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java @@ -46,8 +46,11 @@ public interface ITimeAnalysisViewer extends ITmfViewer { * displayed * @param end * Specifies a fixed end time to the information to be displayed + * @param updateTimeBounds + * If True - Time Range boundaries update is required */ - public abstract void display(ITmfTimeAnalysisEntry[] traceArr, long start, long end); + public abstract void display(ITmfTimeAnalysisEntry[] traceArr, long start, + long end, boolean updateTimeBounds); /** * The start and End time are taken from the limits used by the children diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java index 6196853528..38e3d166be 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java @@ -89,8 +89,9 @@ public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProv modelUpdate(traceArr); } - public void display(ITmfTimeAnalysisEntry[] traceArr, long start, long end) { - modelUpdate(traceArr, start, end); + public void display(ITmfTimeAnalysisEntry[] traceArr, long start, long end, + boolean updateTimeBounds) { + modelUpdate(traceArr, start, end, updateTimeBounds); } public void controlMoved(ControlEvent e) { @@ -111,12 +112,19 @@ public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProv } // called from the display order in the API - public void modelUpdate(ITmfTimeAnalysisEntry[] traces, long start, long end) { + public void modelUpdate(ITmfTimeAnalysisEntry[] traces, long start, + long end, boolean updateTimeBounds) { if (null != _stateCtrl) { loadOptions(); updateInternalData(traces, start, end); - _stateCtrl.redraw(); - _timeScaleCtrl.redraw(); + if (updateTimeBounds) { + _timeRangeFixed = true; + // set window to match limits + setStartFinishTimeExt(_time0_, _time1_); + } else { + _stateCtrl.redraw(); + _timeScaleCtrl.redraw(); + } } } @@ -243,7 +251,7 @@ public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProv } void setTimeBounds() { - _time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.05); + _time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02); if (_time0_ < 0) _time0_ = 0; // _time1_ = _time0_ + (_endTime - _time0_) * 1.05; @@ -275,7 +283,8 @@ public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProv if (null == traces) traces = new ITmfTimeAnalysisEntry[0]; if (end < 1 || start < 1) { - // End or start time are unspecified + // End or start time are unspecified and need to be determined from + // individual processes setTimeRange(traces); } else { _endTime = end; -- 2.34.1