From: Francois Chouinard Date: Wed, 30 Sep 2009 21:18:01 +0000 (+0000) Subject: [290968] Contribution X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=41dc35d0ed7447e456ce4449f4cfa486229136b9;p=deliverable%2Ftracecompass.git [290968] Contribution - Refactoring of State Analysis - Cancellation of ongoing data requests when rapidly scrolling w/ mouse - State Provider update for kernel Fork signal - Resource view fix --- diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java index b5100c5a81..428d9070c0 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java @@ -51,6 +51,7 @@ ITmfTimeAnalysisEntry { protected String groupName = ""; protected String className = ""; protected CompositeType contType = CompositeType.UNKNOWN; + protected long next_good_time = -1; // ======================================================================== // Constructors @@ -60,6 +61,7 @@ ITmfTimeAnalysisEntry { this.id = id; this.name = name; contType = type; + next_good_time = stime; } public TimeRangeComposite(Integer id, Long stime, Long etime, String name, String groupName, String className, CompositeType type) { @@ -158,4 +160,32 @@ ITmfTimeAnalysisEntry { return ChildEventComposites; } + /** + * Represents the time where the next time range can start the drawing i.e. + * right after previous time range. + * + * @return + */ + public long getNext_good_time() { + return next_good_time; + } + + /** + * Represents the time where the next time range can start the drawing i.e. + * right after previous time range. + * + * @param nextGoodTime + */ + public void setNext_good_time(long nextGoodTime) { + next_good_time = nextGoodTime; + } + + /** + * Reset this resource to the construction state except for + */ + public void reset() { + getChildEventComposites().clear(); + getTraceEvents().clear(); + next_good_time = startTime; + } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventResource.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventResource.java index 609647dad7..04102f5a30 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventResource.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventResource.java @@ -30,7 +30,6 @@ public abstract class TimeRangeEventResource extends TimeRangeComposite private ResourceTypes type = ResourceTypes.UNKNOWN; private Long resourceId = null; - private long next_good_time = 0; // ======================================================================== // Constructor @@ -57,7 +56,6 @@ public abstract class TimeRangeEventResource extends TimeRangeComposite type = newType; resourceId = newResourceId; - next_good_time = newStartTime; } // ======================================================================== @@ -173,34 +171,5 @@ public abstract class TimeRangeEventResource extends TimeRangeComposite return returnedValue; } - /** - * Represents the time where the next time range can start the drawing i.e. - * right after previous time range. - * - * @return - */ - public long getNext_good_time() { - return next_good_time; - } - - /** - * Represents the time where the next time range can start the drawing i.e. - * right after previous time range. - * - * @param nextGoodTime - */ - public void setNext_good_time(long nextGoodTime) { - next_good_time = nextGoodTime; - } - - /** - * Reset this resource to the construction state except for - */ - public void reset() { - getChildEventComposites().clear(); - getTraceEvents().clear(); - next_good_time = startTime; - } - public abstract String getStateMode(LttngTraceState traceState); } 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 f76cc923d3..5d0bdec3a2 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 @@ -18,6 +18,7 @@ import org.eclipse.linuxtools.lttng.state.StateDataRequest; import org.eclipse.linuxtools.lttng.state.StateManager; import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.lttng.ui.views.common.DataRequestState.RequestState; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.ui.views.TmfView; @@ -42,7 +43,7 @@ public abstract class AbsTimeUpdateView extends TmfView implements // ======================================================================== // Data // ======================================================================== - private DataRequestQueue reqState = UiCommonFactory.getQueue(); + private DataRequestState reqState = new DataRequestState(); private String viewID = ""; // ======================================================================== @@ -65,34 +66,28 @@ public abstract class AbsTimeUpdateView extends TmfView implements public synchronized void processingStarted(RequestStartedSignal signal) { StateDataRequest request = signal.getRequest(); if (request != null) { - // update queue with the id of the current request. - reqState.requestStarted(request); - // if there was no new request then this one is still on - // prepare for the reception of new data - - waitCursor(true); - - StateManager smanager = request.getStateManager(); - // Clear the children on the Processes related to this - // manager. - // Leave the GUI in charge of the updated data. - String traceId = smanager.getEventLog().getName(); - - // 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(); + // Check if a newer request is in the queue + TmfTimeRange newerReq = reqState.peekQueued(); + if (newerReq == null) { + reqState.setState(DataRequestState.RequestState.BUSY); + reqState.setCurrentRequest(request); + + waitCursor(true); + + StateManager smanager = request.getStateManager(); + // Clear the children on the Processes related to this + // manager. + // Leave the GUI in charge of the updated data. + String traceId = smanager.getEventLog().getName(); + ModelUpdatePrep(traceId); + } else { + // clean up any possible pending request + request.cancel(); + + // Start the new request. + StateManagerFactory.getExperimentManager() + .readExperimentTimeWindow(newerReq, viewID, this); } - - // Indicate if current data needs to be cleared and if so - // specify the new experiment time range that applies - ModelUpdatePrep(traceId, clearData, trange); } } @@ -103,20 +98,23 @@ public abstract class AbsTimeUpdateView extends TmfView implements * processingCompleted(org.eclipse.linuxtools.lttng.state.StateDataRequest) */ @TmfSignalHandler - public synchronized void processingCompleted(RequestCompletedSignal signal) { + public void processingCompleted(RequestCompletedSignal signal) { StateDataRequest request = signal.getRequest(); if (request == null) { return; } else { - reqState.requestCompleted(request); + synchronized (this) { + reqState.setCurrentRequest(null); + } } - // Update wait cursor - requestStateUpdate(); // No data refresh actions for cancelled requests. if (request.isCancelled() || request.isFailed()) { + + requestStateUpdate(); + if (TraceDebug.isDEBUG()) { TmfTimeRange trange = request.getRange(); if (request.isCancelled()) { @@ -133,6 +131,7 @@ public abstract class AbsTimeUpdateView extends TmfView implements return; } else { ModelUpdateComplete(request); + requestStateUpdate(); } } @@ -144,20 +143,42 @@ public abstract class AbsTimeUpdateView extends TmfView implements * @param trange */ public synchronized void dataRequest(TmfTimeRange trange) { - boolean sent = reqState.processDataRequest(trange, viewID, this); + if (trange != null) { + // cancelPendingRequests(); + StateDataRequest currentRequest = reqState.getCurrentRequest(); + // If a request is ongoing queue the new request + if (reqState.getState().equals(RequestState.BUSY)) { + reqState.setQueued(trange); + currentRequest = reqState.getCurrentRequest(); + if (currentRequest != null) { + currentRequest.cancel(); + } + } else { + // Set the state to busy + reqState.setState(DataRequestState.RequestState.BUSY); + waitCursor(true); + // no request is ongoing, proceed with request + StateManagerFactory.getExperimentManager() + .readExperimentTimeWindow(trange, viewID, this); - if (sent) { - waitCursor(true); + } } } /** - * Disable the wait cursor if the state is back to idle + * Check for pending request an either send a new request or change the + * state to idle */ private synchronized void requestStateUpdate() { - // disable the wait cursor if the state is back to idle - if (reqState.isIdle()) { - // no more in the queue + // Check if a new time range update is waiting to be processed + TmfTimeRange queuedRequest = reqState.popQueued(); + if (queuedRequest != null) { + // Trigger the pending request + StateManagerFactory.getExperimentManager() + .readExperimentTimeWindow(queuedRequest, viewID, this); + } else { + // All requests cancelled and no more pending requests + reqState.setState(RequestState.IDLE); waitCursor(false); } } @@ -175,13 +196,8 @@ 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, boolean clearAllData, - TmfTimeRange timeRange); + public abstract void ModelUpdatePrep(String traceId); /** * 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/DataRequestState.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/DataRequestState.java new file mode 100644 index 0000000000..0d5e5cdfa8 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/DataRequestState.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2009 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: + * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.lttng.ui.views.common; + +import org.eclipse.linuxtools.lttng.state.StateDataRequest; +import org.eclipse.linuxtools.lttng.ui.TraceDebug; +import org.eclipse.linuxtools.tmf.event.TmfTimeRange; + +/** + * One instance to keep track of the state of data request and a single time + * range data request pending in queue + * + * @author alvaro + * + */ +public class DataRequestState { + + // ======================================================================== + // Data + // ======================================================================== + public enum RequestState { + IDLE, BUSY + } + + private TmfTimeRange queued = null; + RequestState state = RequestState.IDLE; + private StateDataRequest currentRequest = null; + + // ======================================================================== + // Methods + // ======================================================================== + /** + * @return the data request time range in queue + */ + public synchronized TmfTimeRange peekQueued() { + return queued; + } + + /** + * @return the data request time range in queue and reset it reference to + * null to get ready for a new entry in queue + */ + public synchronized TmfTimeRange popQueued() { + // Save the reference to current request + TmfTimeRange result = queued; + // remove from queue + queued = null; + // Send original reference + return result; + } + + /** + * @param queued + *

+ * Set the data request time range to be waiting for processing + *

+ *

+ * Only the latest request is preserved + *

+ */ + public synchronized void setQueued(TmfTimeRange nqueued) { + if (TraceDebug.isDEBUG()) { + if (this.queued != null) { + StringBuilder sb = new StringBuilder( + "Queued request replaced from: " + + queued.getStartTime() + "-" + + queued.getEndTime() + "\n\t\t to: " + + nqueued.getStartTime() + "-" + + nqueued.getEndTime()); + TraceDebug.debug(sb.toString()); + } + } + + this.queued = nqueued; + } + + /** + * @return the state + */ + public synchronized RequestState getState() { + return state; + } + + /** + * @param state + * the state to set + */ + public synchronized void setState(RequestState state) { + this.state = state; + } + + public synchronized void setCurrentRequest(StateDataRequest currentRequest) { + this.currentRequest = currentRequest; + } + + public synchronized StateDataRequest getCurrentRequest() { + return currentRequest; + } + +} 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 d4d2efe9f6..e9216f2fdb 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 @@ -34,9 +34,6 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.lttng.state.IStateDataRequestListener; -import org.eclipse.linuxtools.lttng.state.RequestCompletedSignal; -import org.eclipse.linuxtools.lttng.state.RequestStartedSignal; import org.eclipse.linuxtools.lttng.state.StateDataRequest; import org.eclipse.linuxtools.lttng.state.StateManager; import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy; @@ -45,10 +42,10 @@ import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.ui.TraceDebug; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider; +import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView; import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; import org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor.FlowTRangeUpdateFactory; import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory; -import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceModelFactory; import org.eclipse.linuxtools.tmf.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; @@ -62,7 +59,6 @@ import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeFilterSelection import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; -import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ScrolledComposite; @@ -92,12 +88,16 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; *

* TODO: Implement me. Please. */ -public class ControlFlowView extends TmfView implements +/** + * @author alvaro + * + */ +public class ControlFlowView extends AbsTimeUpdateView implements ITmfTimeSelectionListener, ITmfTimeScaleSelectionListener, - ITmfTimeFilterSelectionListener, IStateDataRequestListener { + ITmfTimeFilterSelectionListener { public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.controlflow"; - + // ======================================================================== // Table data // ======================================================================== @@ -125,8 +125,6 @@ public class ControlFlowView extends TmfView implements // ======================================================================== // Data // ======================================================================== - private Vector pendingDataRequests = new Vector(); - private TableViewer tableViewer; // private int totalNumItems = 0; // Actions @@ -302,6 +300,7 @@ public class ControlFlowView extends TmfView implements * The constructor. */ public ControlFlowView() { + super(ID); } /** @@ -518,7 +517,7 @@ public class ControlFlowView extends TmfView implements tsfviewer.addWidgetSelectionListner(this); tsfviewer.addWidgetTimeScaleSelectionListner(this); - // Traces shall not be grouped to allow synchronization + // Traces shall not be grouped to allow synchronisation tsfviewer.groupTraces(false); tsfviewer.setItemHeight(itemHeight); tsfviewer.setBorderWidth(borderWidth); @@ -529,7 +528,7 @@ public class ControlFlowView extends TmfView implements tsfviewer.setAcceptSelectionAPIcalls(true); // Viewer to notify selection to this class - // This class will synchronize selections with table. + // This class will synchronise selections with table. tsfviewer.addWidgetSelectionListner(this); tsfviewer.addFilterSelectionListner(this); tsfviewer.addWidgetTimeScaleSelectionListner(this); @@ -702,8 +701,8 @@ public class ControlFlowView extends TmfView implements // action6 prevEvent = new Action() { - @Override -public void run() { + @Override + public void run() { if (tsfviewer != null) { tsfviewer.selectPrevEvent(); } @@ -886,7 +885,7 @@ public void run() { tableViewer.setSelection(sel); } - ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); + ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); Long savedSelTime = paramUpdater.getSelectedTime(); long selTimens = event.getSelectedTime(); @@ -908,7 +907,8 @@ public void run() { } } - public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { + public synchronized void tsfTmProcessTimeScaleEvent( + TmfTimeScaleSelectionEvent event) { // source needed to keep track of source values Object source = event.getSource(); @@ -921,8 +921,8 @@ public void run() { // Read the updated time window TmfTimeRange trange = paramUpdater.getTrange(); if (trange != null) { - StateManagerFactory.getExperimentManager() - .readExperimentTimeWindow(trange, "flowView", this); + // Request new data for specified time range + dataRequest(trange); } } } @@ -970,9 +970,10 @@ public void run() { final Table table = tableViewer.getTable(); Display display = table.getDisplay(); - // Perform the updates on the UI thread + // Perform the updates on the UI thread) display.asyncExec(new Runnable() { public void run() { + tableViewer.setInput(items); // This shall be the minimal // initial tableFilter = new ViewProcessFilter(tableViewer); @@ -1042,127 +1043,6 @@ public void run() { } } - /* - * (non-Javadoc) - * - * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener# - * processingCompleted(org.eclipse.linuxtools.lttng.state.StateDataRequest) - */ - @TmfSignalHandler - public void processingCompleted(RequestCompletedSignal signal) { - StateDataRequest request = signal.getRequest(); - - if (request == null) { - return; - } else { - // Remove from the pending requests record - pendingDataRequests.remove(request); - } - - // No data refresh actions for cancelled requests. - if (request.isCancelled() || request.isFailed()) { - if (TraceDebug.isDEBUG()) { - TmfTimeRange range = request.getRange(); - TraceDebug.debug("Request cancelled: " - + range.getStartTime().toString() + " - " - + range.getEndTime().toString()); - } - - return; - } - - long experimentStartTime = -1; - long experimentEndTime = -1; - StateManager smanager = request.getStateManager(); - TmfTimeRange experimentTimeRange = smanager.getExperimentTimeWindow(); - if (experimentTimeRange != null) { - experimentStartTime = experimentTimeRange.getStartTime().getValue(); - experimentEndTime = experimentTimeRange.getEndTime().getValue(); - } - - // 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()]); - // Sort the array by pid - Arrays.sort(processArr); - - // Update the view part - flowModelUpdates(processArr, experimentStartTime, experimentEndTime); - - // reselect to original time - ParamsUpdater paramUpdater = ResourceModelFactory.getParamsUpdater(); - final Long selTime = paramUpdater.getSelectedTime(); - if (selTime != null) { - Display display = tsfviewer.getControl().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - tsfviewer.setSelectedTime(selTime, false, this); - } - }); - } - - if (TraceDebug.isDEBUG()) { - int eventCount = 0; - Long count = smanager.getEventCount(); - for (TimeRangeEventProcess process : processList) { - eventCount += process.getTraceEvents().size(); - } - - int discarded = FlowModelFactory.getParamsUpdater() - .getEventsDiscarded(); - int discardedOutofOrder = ResourceModelFactory.getParamsUpdater() - .getEventsDiscardedWrongOrder(); - TraceDebug - .debug("Events handled: " - + count - + " Events loaded in Control Flow view: " - + eventCount - + " Number of events discarded: " - + discarded - + "\n\tNumber of events discarded with start time earlier than next good time: " - + discardedOutofOrder); - } - } - - /* - * (non-Javadoc) - * - * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener# - * processingStarted(org.eclipse.linuxtools.lttng.state.StateDataRequest) - */ - @TmfSignalHandler - public void processingStarted(RequestStartedSignal signal) { - StateDataRequest request = signal.getRequest(); - cancelPendingRequests(); - if (request != null) { - // make sure there are no duplicates - if (!pendingDataRequests.contains(request)) { - pendingDataRequests.add(request); - } - pendingDataRequests.add(request); - StateManager smanager = request.getStateManager(); - // Clear the children on the Processes related to this manager. - // Leave the GUI in charge of the updated data. - String traceId = smanager.getEventLog().getName(); - FlowModelFactory.getProcContainer().clearChildren(traceId); - // Start over - FlowModelFactory.getParamsUpdater().setEventsDiscarded(0); - } - } - - /** - * Orders cancellation of any pending data requests - */ - private void cancelPendingRequests() { - for (StateDataRequest request : pendingDataRequests) { - request.cancel(); - } - pendingDataRequests.clear(); - } - /** * @param scrollFrame * @param wrapper @@ -1228,4 +1108,102 @@ public void run() { } } -} + /* + * (non-Javadoc) + * + * @see + * org.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView#waitCursor + * (boolean) + */ + protected synchronized void waitCursor(final boolean waitInd) { + if (tsfviewer != null) { + Display display = tsfviewer.getControl().getDisplay(); + + // Perform the updates on the UI thread + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.waitCursor(waitInd); + } + }); + } + } + + /* + * (non-Javadoc) + * + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# + * ModelUpdatePrep(java.lang.String) + */ + public void ModelUpdatePrep(String traceId) { + FlowModelFactory.getProcContainer().clearChildren(traceId); + // Start over + FlowModelFactory.getParamsUpdater().setEventsDiscarded(0); + } + + /* + * (non-Javadoc) + * + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# + * ModelUpdateComplete(org.eclipse.linuxtools.lttng.state.StateDataRequest) + */ + public void ModelUpdateComplete(StateDataRequest request) { + long experimentStartTime = -1; + long experimentEndTime = -1; + StateManager smanager = request.getStateManager(); + TmfTimeRange experimentTimeRange = smanager.getExperimentTimeWindow(); + if (experimentTimeRange != null) { + experimentStartTime = experimentTimeRange.getStartTime().getValue(); + experimentEndTime = experimentTimeRange.getEndTime().getValue(); + } + // 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()]); + // Sort the array by pid + Arrays.sort(processArr); + + // Update the view part + flowModelUpdates(processArr, experimentStartTime, experimentEndTime); + + // reselect to original time + ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater(); + final Long selTime = paramUpdater.getSelectedTime(); + if (selTime != null) { + Display display = tsfviewer.getControl().getDisplay(); + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.setSelectedTime(selTime, false, this); + } + }); + } + + if (TraceDebug.isDEBUG()) { + int eventCount = 0; + Long count = smanager.getEventCount(); + for (TimeRangeEventProcess process : processList) { + eventCount += process.getTraceEvents().size(); + } + + int discarded = FlowModelFactory.getParamsUpdater() + .getEventsDiscarded(); + int discardedOutofOrder = FlowModelFactory.getParamsUpdater() + .getEventsDiscardedWrongOrder(); + TmfTimeRange range = request.getRange(); + StringBuilder sb = new StringBuilder( + "Events handled: " + + count + + " Events loaded in Control Flow view: " + + eventCount + + " Number of events discarded: " + + discarded + + "\n\tNumber of events discarded with start time earlier than next good time: " + + discardedOutofOrder); + + sb.append("\n\t\tRequested Time Range: " + range.getStartTime() + + " - " + range.getEndTime()); + TraceDebug.debug(sb.toString()); + } + } +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/AbsFlowTRangeUpdate.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/AbsFlowTRangeUpdate.java index 124ce153b7..39c87745f4 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/AbsFlowTRangeUpdate.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/AbsFlowTRangeUpdate.java @@ -25,7 +25,6 @@ import org.eclipse.linuxtools.lttng.ui.views.common.AbsTRangeUpdate; import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory; import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowProcessContainer; -import org.eclipse.linuxtools.tmf.event.TmfTimestamp; public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEventProcessing { @@ -132,13 +131,13 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv * @param stateMode * @return */ - protected boolean makeDraw(LttngTraceState traceSt, TmfTimestamp startTime, - TmfTimestamp endTime, TimeRangeEventProcess localProcess, + protected boolean makeDraw(LttngTraceState traceSt, long startTime, + long endTime, TimeRangeEventProcess localProcess, ParamsUpdater params, String stateMode) { // Determine start and end times to establish duration - Long stime = startTime.getValue(); - Long etime = endTime.getValue(); + Long stime = startTime; + Long etime = endTime; if (etime < stime) { // Validate the sequential order of events @@ -218,6 +217,7 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv // I'm not sure about it time_window.setVisible(visible); localProcess.getTraceEvents().add(time_window); + localProcess.setNext_good_time(etime); // *** VERIFY *** // Missing checks like this one? @@ -236,11 +236,12 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv * @param params * @return */ - protected boolean makeDraw(LttngTraceState traceSt, TmfTimestamp evTime, + protected boolean makeDraw(LttngTraceState traceSt, long evTime, LttngProcessState process, TimeRangeEventProcess localProcess, ParamsUpdater params) { - TmfTimestamp stime = process.getState().getChange_LttTime(); + // TmfTimestamp stime = process.getState().getChange_LttTime(); + long stime = localProcess.getNext_good_time(); String stateMode; ProcessStatus procStatus = process.getState().getProc_status(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java index 4840d5ce7e..f94b93986e 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java @@ -75,8 +75,8 @@ class FlowTRangeBeforeUpdateHandlers { } // Do the actual drawing - makeDraw(traceSt, trcEvent.getTimestamp(), stateProcess, - localProcess, params); + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + stateProcess, localProcess, params); } else { TraceDebug .debug("Running process is null! (getStateModesHandler)"); @@ -160,7 +160,8 @@ class FlowTRangeBeforeUpdateHandlers { } // Do the actual drawing - makeDraw(traceSt, trcEvent.getTimestamp(), process, + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, localProcess, params); } else { // Process may be null if the process started BEFORE the @@ -199,7 +200,8 @@ class FlowTRangeBeforeUpdateHandlers { } // Do the actual drawing - makeDraw(traceSt, trcEvent.getTimestamp(), process, + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, localProcess, params); } else { @@ -278,8 +280,8 @@ class FlowTRangeBeforeUpdateHandlers { .getEndTime().getValue(), traceSt .getTraceId()); // Call the function that does the actual drawing - makeDraw(traceSt, trcEvent.getTimestamp(), process, - localProcess, params); + makeDraw(traceSt, trcEvent.getTimestamp() + .getValue(), process, localProcess, params); } else { TraceDebug .debug("Pid is null or Pid == PPID! (getProcessExitHandler)"); @@ -287,7 +289,7 @@ class FlowTRangeBeforeUpdateHandlers { } } else { TraceDebug - .debug("Running proces is null! (getProcessExitHandler)"); + .debug("Running process is null! (getProcessExitHandler)"); } return false; @@ -342,7 +344,8 @@ class FlowTRangeBeforeUpdateHandlers { } // Perform the drawing - makeDraw(traceSt, trcEvent.getTimestamp(), process, + makeDraw(traceSt, trcEvent.getTimestamp().getValue(), + process, localProcess, params); } } else { @@ -405,8 +408,8 @@ class FlowTRangeBeforeUpdateHandlers { if (localProcess != null) { // Call the function that will does the actual // drawing - makeDraw(traceSt, trcEvent.getTimestamp(), process, - localProcess, params); + makeDraw(traceSt, trcEvent.getTimestamp() + .getValue(), process, localProcess, params); } else { TraceDebug .debug("localProcess is null! (getStateDumpEndHandler)"); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java index 6a64d4156e..f759c9173a 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java @@ -13,7 +13,6 @@ package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; import java.util.Vector; import org.eclipse.linuxtools.lttng.event.LttngEvent; -import org.eclipse.linuxtools.lttng.event.LttngTimestamp; import org.eclipse.linuxtools.lttng.state.StateStrings.Events; import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing; import org.eclipse.linuxtools.lttng.state.model.LttngProcessState; @@ -22,7 +21,6 @@ import org.eclipse.linuxtools.lttng.ui.TraceDebug; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; -import org.eclipse.linuxtools.tmf.event.TmfTimestamp; /** * Creates specific finish state data request @@ -40,8 +38,8 @@ public class FlowTRangeFinishUpdateHandler extends AbsFlowTRangeUpdate public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { // Draw a last known state to the end of the trace - TmfTimestamp endReqTime = traceSt.getInputDataRef() - .getTraceTimeWindow().getEndTime(); + long endReqTime = traceSt.getInputDataRef().getTraceTimeWindow() + .getEndTime().getValue(); TraceDebug.debug("Number of localProcesses: " + procContainer.readProcesses().size()); // to identify the process relevant to the traceState @@ -74,13 +72,14 @@ public class FlowTRangeFinishUpdateHandler extends AbsFlowTRangeUpdate if (prevEvent instanceof TimeRangeEvent) { TimeRangeEvent prevTimeRange = (TimeRangeEvent) prevEvent; // calculate the next good time to draw the event - nextGoodTime = prevTimeRange.getStopTime() + 1; + // nextGoodTime = prevTimeRange.getStopTime() + 1; + nextGoodTime = localProcess.getNext_good_time(); stateMode = prevTimeRange.getStateMode(); // Draw with the Local information since the current // request did // not contain events related to this process - makeDraw(traceSt, new LttngTimestamp(nextGoodTime), + makeDraw(traceSt, nextGoodTime, endReqTime, localProcess, params, stateMode); } else { TraceDebug 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 9878d88303..b3ec0f2e1a 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 @@ -74,8 +74,7 @@ public class FlowProcessContainer { for (TimeRangeEventProcess process : processes) { procTraceId = process.getTraceID(); if (procTraceId.equals(traceId)) { - process.getTraceEvents().clear(); - process.getChildEventComposites().clear(); + process.reset(); } } } 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 8babb5837a..76243ec075 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 @@ -11,7 +11,6 @@ package org.eclipse.linuxtools.lttng.ui.views.resources; import java.util.Arrays; -import java.util.Vector; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; @@ -20,18 +19,15 @@ import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.lttng.state.IStateDataRequestListener; -import org.eclipse.linuxtools.lttng.state.RequestCompletedSignal; -import org.eclipse.linuxtools.lttng.state.RequestStartedSignal; import org.eclipse.linuxtools.lttng.state.StateDataRequest; import org.eclipse.linuxtools.lttng.state.StateManager; import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy; import org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManager; import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory; import org.eclipse.linuxtools.lttng.ui.TraceDebug; -import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider; +import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView; import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater; import org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor.ResourcesTRangeUpdateFactory; import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceModelFactory; @@ -46,7 +42,6 @@ import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListe import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; -import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; @@ -61,15 +56,13 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; * @author alvaro * */ -public class ResourcesView extends TmfView implements - ITmfTimeSelectionListener, ITmfTimeScaleSelectionListener, - IStateDataRequestListener { +public class ResourcesView extends AbsTimeUpdateView implements + ITmfTimeSelectionListener, ITmfTimeScaleSelectionListener { // ======================================================================== // Data // ======================================================================== public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.resources"; - private Vector pendingDataRequests = new Vector(); // private int totalNumItems = 0; // Actions @@ -93,15 +86,20 @@ public class ResourcesView extends TmfView implements // private TraceModelImplFactory fact; // ======================================================================== - // Methods + // Constructor // ======================================================================== /** * The constructor. */ public ResourcesView() { + super(ID); } + // ======================================================================== + // Methods + // ======================================================================== + /** * This is a callback that will allow us to create the viewer and initialize * it. @@ -117,12 +115,12 @@ public class ResourcesView extends TmfView implements tsfviewer.addWidgetSelectionListner(this); tsfviewer.addWidgetTimeScaleSelectionListner(this); - // Traces shall not be grouped to allow synchronization + // Traces shall not be grouped to allow synchronisation tsfviewer.groupTraces(true); tsfviewer.setAcceptSelectionAPIcalls(true); // Viewer to notify selection to this class - // This class will synchronize selections with table. + // This class will synchronise selections with table. tsfviewer.addWidgetSelectionListner(this); tsfviewer.addWidgetTimeScaleSelectionListner(this); @@ -141,7 +139,7 @@ public class ResourcesView extends TmfView implements // FlowParamsUpdater listener = FlowModelFactory.getParamsUpdater(); // tsfviewer.addWidgetTimeScaleSelectionListner(listener); - // TODO: refactor regitration / notificatio process + // TODO: re-factor registration / notification process // Register this view to receive updates when the model is updated with // fresh info // ModelListenFactory.getRegister().addFlowModelUpdatesListener(this); @@ -465,6 +463,14 @@ public class ResourcesView extends TmfView implements } } + /* + * (non-Javadoc) + * + * @seeorg.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis. + * ITmfTimeScaleSelectionListener + * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools + * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent) + */ public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { // source needed to keep track of source values Object source = event.getSource(); @@ -478,11 +484,8 @@ public class ResourcesView extends TmfView implements if (newParams) { // Read the updated time window TmfTimeRange trange = paramUpdater.getTrange(); - if (trange != null) { - StateManagerFactory.getExperimentManager() - .readExperimentTimeWindow(trange, "resourceView", - this); - } + // Either send a new request or queue for next opportunity + dataRequest(trange); } } } @@ -513,12 +516,6 @@ public class ResourcesView extends TmfView implements return strVal.substring(strVal.length() - 9); } - // // @Override - // public void resourceModelUpdates(ModelUpdatesEvent event) { - // ITmfTimeAnalysisEntry[] items = event.getItems(); - // resourceModelUpdates(items, event.getStartTime(), event.getEndTime()); - // } - public void resourceModelUpdates(final ITmfTimeAnalysisEntry[] items, final long startTime, final long endTime) { tsfviewer.getControl().getDisplay().asyncExec(new Runnable() { @@ -543,71 +540,80 @@ public class ResourcesView extends TmfView implements tsfviewer = null; } - /* - * (non-Javadoc) + /** + * Trigger time synchronisation to other views this method shall be called + * when a check has been performed to note that an actual change of time has + * been performed vs a pure re-selection of the same time * - * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener# - * processingStarted(org.eclipse.linuxtools.lttng.state.StateDataRequest) + * @param time */ - @TmfSignalHandler - public void processingStarted(RequestStartedSignal startSignal) { - StateDataRequest request = startSignal.getRequest(); - cancelPendingRequests(); - if (request != null) { - // make sure there are no duplicates - if (!pendingDataRequests.contains(request)) { - pendingDataRequests.add(request); - } - - StateManager smanager = request.getStateManager(); - // Clear the children on the Processes related to this manager. - // Leave the GUI in charge of the updated data. - String traceId = smanager.getEventLog().getName(); - ResourceModelFactory.getResourceContainer().clearChildren(traceId); - // Start over - ResourceModelFactory.getParamsUpdater().setEventsDiscarded(0); + private void synchTimeNotification(long time) { + // if synchronisation selected + if (synch.isChecked()) { + // Notify other views + TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(this, + new LttngTimestamp(time))); } } /** - * Orders cancellation of any pending data requests + * Registers as listener of time selection from other tmf views + * + * @param signal */ - private void cancelPendingRequests() { - for (StateDataRequest request : pendingDataRequests) { - request.cancel(); + @TmfSignalHandler + public void synchToTime(TmfTimeSynchSignal signal) { + if (synch.isChecked()) { + Object source = signal.getSource(); + if (signal != null && source != null && source != this) { + // Internal value is expected in nano seconds. + long selectedTime = signal.getCurrentTime().getValue(); + if (tsfviewer != null) { + tsfviewer.setSelectedTime(selectedTime, true, source); + } + } } - pendingDataRequests.clear(); } /* * (non-Javadoc) * - * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener# - * processingCompleted(org.eclipse.linuxtools.lttng.state.StateDataRequest) + * @see + * org.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView#waitCursor + * (boolean) */ - @TmfSignalHandler - public void processingCompleted( - RequestCompletedSignal completedSignal) { - StateDataRequest request = completedSignal.getRequest(); + protected void waitCursor(final boolean waitInd) { + if (tsfviewer != null) { + Display display = tsfviewer.getControl().getDisplay(); - if (request == null) { - return; - } else { - // Remove from the pending requests record - pendingDataRequests.remove(request); + // Perform the updates on the UI thread + display.asyncExec(new Runnable() { + public void run() { + tsfviewer.waitCursor(waitInd); + } + }); } + } - // No data refresh actions for cancelled requests. - if (request.isCancelled() || request.isFailed()) { - if (TraceDebug.isDEBUG()) { - TmfTimeRange range = request.getRange(); - TraceDebug.debug("Request cancelled: " - + range.getStartTime().toString() + " - " - + range.getEndTime().toString()); - } - return; - } + /* + * (non-Javadoc) + * + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# + * ModelUpdatePrep(java.lang.String) + */ + public void ModelUpdatePrep(String traceId) { + ResourceModelFactory.getResourceContainer().clearChildren(traceId); + // Start over + ResourceModelFactory.getParamsUpdater().setEventsDiscarded(0); + } + /* + * (non-Javadoc) + * + * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView# + * ModelUpdateComplete(org.eclipse.linuxtools.lttng.state.StateDataRequest) + */ + public void ModelUpdateComplete(StateDataRequest request) { StateManager smanager = request.getStateManager(); long experimentStartTime = -1; long experimentEndTime = -1; @@ -663,44 +669,4 @@ public class ResourcesView extends TmfView implements } } - - public void newTimeRange(TimeRangeComponent trange) { - // TODO Auto-generated method stub - - } - - /** - * Trigger time synchronisation to other views this method shall be called - * when a check has been performed to note that an actual change of time has - * been performed vs a pure re-selection of the same time - * - * @param time - */ - private void synchTimeNotification(long time) { - // if synchronisation selected - if (synch.isChecked()) { - // Notify other views - TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(this, - new LttngTimestamp(time))); - } - } - - /** - * Registers as listener of time selection from other tmf views - * - * @param signal - */ - @TmfSignalHandler - public void synchToTime(TmfTimeSynchSignal signal) { - if (synch.isChecked()) { - Object source = signal.getSource(); - if (signal != null && source != null && source != this) { - // Internal value is expected in nano seconds. - long selectedTime = signal.getCurrentTime().getValue(); - if (tsfviewer != null) { - tsfviewer.setSelectedTime(selectedTime, true, source); - } - } - } - } } \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java index f6d51100e0..58098e8381 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/evProcessor/ResourcesTRangeUpdateFactory.java @@ -97,7 +97,7 @@ public class ResourcesTRangeUpdateFactory extends AbsEventProcessorFactory { // *** AFTER HOOKS *** - eventNametoBeforeProcessor.put( + eventNametoAfterProcessor.put( StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(), instantiateAfterHandler.getAfterSchedChangeHandler()); diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/IStateDataRequestListener.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/IStateDataRequestListener.java index 9774ec06f7..5cfe500bd2 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/IStateDataRequestListener.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/IStateDataRequestListener.java @@ -24,7 +24,15 @@ public interface IStateDataRequestListener { // Methods // ======================================================================== + /** + * + * @param request + * @return + */ public void processingStarted(RequestStartedSignal request); + /** + * @param signal + */ public void processingCompleted(RequestCompletedSignal signal); } 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 e9bea053f8..a9f131c1a8 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 @@ -86,7 +86,8 @@ public class StateDataRequest extends TmfDataRequest { * @param broadcast * true: All views, false: only to registered listeners */ - public void startRequestInd(TmfExperiment experiment, boolean broadcast) { + public void startRequestInd(TmfExperiment experiment, boolean broadcast, + boolean waitForCompletion) { if (broadcast) { // Notify all state views. this.broadcast = broadcast; @@ -99,7 +100,7 @@ public class StateDataRequest extends TmfDataRequest { } // trigger the start to process this request - experiment.processRequest(this, true); + experiment.processRequest(this, waitForCompletion); } /** 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 5bed1edca9..cca485cc88 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 @@ -142,7 +142,9 @@ public class StateManager extends Observable { TmfTimeRange allTraceWindow = fEventLog.getTimeRange(); StateDataRequest request = getDataRequestStateSave(allTraceWindow, null); - request.startRequestInd(fExperiment, true); + + // Wait for completion + request.startRequestInd(fExperiment, true, true); if (TraceDebug.isDEBUG()) { List processes = stateIn @@ -188,7 +190,8 @@ public class StateManager extends Observable { // Process request to that point StateDataRequest request = getDataRequestByTimeRange(trange, listener); - request.startRequestInd(fExperiment, false); + // don't wait for completion i.e. allow cancellations + request.startRequestInd(fExperiment, false, true); if (TraceDebug.isDEBUG()) { List processes = stateIn.getTraceStateModel() @@ -421,11 +424,9 @@ public class StateManager extends Observable { final TmfEvent[] evt = new TmfEvent[1]; - // ***FIXME*** - // The override of handlePartialResult is exactly the same as the one in + // ***TODO*** + // The override of handlePartialResult is similar to the one in // getDataRequestByPosition() - // However, there is no way to override it in only one place to avoid - // code duplication! // *** // Create the new request and override the handlePartialResult function @@ -440,13 +441,21 @@ public class StateManager extends Observable { // Dispatch information for Event processing stateIn.processEvent(evt[0]); + // increment internal and external number of events + setNumOfEvents(getNumOfEvents() + 1); eventCount++; } @Override public void handleCompleted() { - requestCompleted(); - // notify the associated listener + if (isCancelled() || isFailed()) { + // No notification to end request handlers + } else { + // notify the associated end request handlers + requestCompleted(); + } + + // notify listeners notifyCompletion(); } }; @@ -459,11 +468,9 @@ public class StateManager extends Observable { final TmfEvent[] evt = new TmfEvent[1]; - // ***FIXME*** - // The override of handlePartialResult is exactly the same as the one in + // ***TODO*** + // The override of handlePartialResult is similar to the one in // getDataRequestByPosition() - // However, there is no way to override it in only one place to avoid - // code duplication! // *** // Create the new request and override the handlePartialResult function @@ -495,9 +502,14 @@ public class StateManager extends Observable { @Override public void handleCompleted() { - requestCompleted(); + if (isCancelled() || isFailed()) { + // No notification to end request handlers + } else { + // notify the associated end request handlers + requestCompleted(); + } - // Notify listeners of the completion of this request. + // notify listeners notifyCompletion(); TraceDebug.debug("number of events processed on file opening" + getNumOfEvents()); diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java index 33da153923..8b649b8ccc 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java @@ -1074,6 +1074,7 @@ class StateUpdateHandlers { if (child_process == null) { child_process = create_process(traceSt, cpu, child_pid, child_tgid, timeStamp); + child_process.setPpid(process.getPid(), timeStamp); } else { /* * The process has already been created : due to time @@ -1606,10 +1607,11 @@ class StateUpdateHandlers { if (process == null) { parent_process = lttv_state_find_process(traceSt, ANY_CPU, parent_pid); + TmfTimestamp eventTime = trcEvent.getTimestamp(); process = create_process(traceSt, cpu, pid, tgid, - command, trcEvent.getTimestamp()); + command, eventTime); if (parent_process != null) { - process.setPpid(parent_process.getPid()); + process.setPpid(parent_process.getPid(), eventTime); } /* Keep the stack bottom : a running user mode */ 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 2af87456de..8489ac4cda 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.linuxtools.lttng.state.experiment; -import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -71,9 +70,14 @@ public class StateExperimentManager extends TmfComponent { */ public void readExperimentTimeWindow(TmfTimeRange trange, String transactionID, IStateDataRequestListener listener) { - Collection mamangers = managersByID.values(); - for (StateManager manager : mamangers) { - manager.executeDataRequest(trange, transactionID, listener); + if (fExperiment != null) { + String id = fExperiment.getExperimentId(); + StateManager manager = managersByID.get(id); + if (manager != null) { + // TODO: A loop to request data for each trace needs to be used + // here when multiple traces are supported. + manager.executeDataRequest(trange, transactionID, listener); + } } } diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngProcessState.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngProcessState.java index 61379a592c..8f8e067ad6 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngProcessState.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/model/LttngProcessState.java @@ -86,22 +86,24 @@ public class LttngProcessState implements Cloneable { // Initialize stack LttngExecutionState es = new LttngExecutionState(); - es.setExec_mode(ExecutionMode.LTTV_STATE_USER_MODE); + es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN); es.setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE.getInName()); es.setEntry_Time(this.insertion_time); es.setChange_Time(this.insertion_time); es.setCum_cpu_time(0L); es.setProc_status(ProcessStatus.LTTV_STATE_RUN); this.execution_stack.push(es); - - es = new LttngExecutionState(); - es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL); - es.setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE.getInName()); - es.setEntry_Time(this.insertion_time); - es.setChange_Time(this.insertion_time); - es.setCum_cpu_time(0L); - es.setProc_status(ProcessStatus.LTTV_STATE_WAIT_FORK); - this.execution_stack.push(es); + + //TODO: This initialisation is present in C, however an entry in waiting fork may + //display incorrect states, there is a need for deeper compare of the initialisation phase + // es = new LttngExecutionState(); + // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL); + // es.setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE.getInName()); + // es.setEntry_Time(this.insertion_time); + // es.setChange_Time(this.insertion_time); + // es.setCum_cpu_time(0L); + // es.setProc_status(ProcessStatus.LTTV_STATE_WAIT_FORK); + // this.execution_stack.push(es); // point state to the top of the stack this.state = es; 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 fedb42f3a9..3a3fa87e54 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 @@ -15,9 +15,9 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.linuxtools.tmf.ui.viewers.ITmfViewer; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; +import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.widgets.Control; @@ -145,4 +145,18 @@ public interface ITimeAnalysisViewer extends ITmfViewer { public Control getControl(); public ISelectionProvider getSelectionProvider(); + + /** + *

+ * Provide the possibility to control the wait cursor externally + *

+ *

+ * e.g. data requests in progress + *

+ * + * @param waitInd + * - true change to wait cursor + */ + public void waitCursor(boolean waitInd); + } \ No newline at end of file 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 0364859d90..6196853528 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 @@ -25,13 +25,13 @@ import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs.TmfTimeFilterDialog; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs.TmfTimeLegend; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; +import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TimeScaleCtrl; -import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TmfTimeTipHandler; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TmfTimeStatesCtrl; +import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TmfTimeTipHandler; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme; import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.Utils; import org.eclipse.swt.SWT; @@ -745,4 +745,15 @@ public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProv public ISelectionProvider getSelectionProvider() { return _stateCtrl; } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer + * #waitCursor(boolean) + */ + public void waitCursor(boolean waitInd) { + _stateCtrl.waitCursor(waitInd); + } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java index 091d5b0d1e..a89a066ce8 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java @@ -57,6 +57,10 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.ScrollBar; +/** + * @author alvaro + * + */ public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, @@ -71,6 +75,7 @@ public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, private ITimeDataProvider _timeProvider; private boolean _isInFocus = false; private boolean _isDragCursor3 = false; + private boolean _isWaitCursor = true; private boolean _mouseHover = false; private int _itemHeightDefault = 18; private int _itemHeight = _itemHeightDefault; @@ -92,6 +97,7 @@ public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, private Rectangle _rect0 = new Rectangle(0, 0, 0, 0); private Rectangle _rect1 = new Rectangle(0, 0, 0, 0); private Cursor _dragCursor3; + private Cursor _WaitCursor; private boolean drawTracesInteraction = false; private boolean drawTraceJoins = DEFAULT_DRAW_THREAD_JOIN; private boolean drawTraceWaits = DEFAULT_DRAW_THREAD_WAIT; @@ -131,12 +137,14 @@ public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, } _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE); + _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT); } @Override public void dispose() { super.dispose(); _dragCursor3.dispose(); + _WaitCursor.dispose(); } public void setTimeProvider(ITimeDataProvider timeProvider) { @@ -1656,16 +1664,50 @@ public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, } } + /** + *

+ * If the x, y position is over the vertical split line (name to time + * ranges), then change the cursor to a drag cursor to indicate the user the + * possibility of resizing + *

+ * + * @param x + * @param y + */ void updateCursor(int x, int y) { - int idx = hitSplitTest(x, y); - // No dragcursor is name space is fixed to zero - if (idx > 0 && !_isDragCursor3 && _timeProvider.getNameSpace() > 0) { - setCursor(_dragCursor3); - _isDragCursor3 = true; - } else if (idx <= 0 && _isDragCursor3) { + // if Wait cursor not active, check for the need to change to a drag + // cursor + if (_isWaitCursor == false) { + int idx = hitSplitTest(x, y); + // No dragcursor is name space is fixed to zero + if (idx > 0 && !_isDragCursor3 && _timeProvider.getNameSpace() > 0) { + setCursor(_dragCursor3); + _isDragCursor3 = true; + } else if (idx <= 0 && _isDragCursor3) { + setCursor(null); + _isDragCursor3 = false; + } + } + } + + /** + * Provide the possibilty to control the wait cursor externally e.g. data + * requests in progress + * + * @param waitInd + */ + public void waitCursor(boolean waitInd) { + // Update cursor as indicated + if (waitInd) { + setCursor(_WaitCursor); + _isWaitCursor = true; + } else { setCursor(null); - _isDragCursor3 = false; + _isWaitCursor = false; } + + // Get ready for next mouse move + _isDragCursor3 = false; } public void mouseDown(MouseEvent e) {