*
* Contributors:
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ * Bernd Hufmann - Bug fixes
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.common;
import java.util.Arrays;
-import org.eclipse.linuxtools.lttng.control.LttngCoreProviderFactory;
-import org.eclipse.linuxtools.lttng.control.LttngSyntheticEventProvider;
-import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent;
-import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
-import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest;
-import org.eclipse.linuxtools.lttng.request.IRequestStatusListener;
-import org.eclipse.linuxtools.lttng.request.LttngSyntEventRequest;
-import org.eclipse.linuxtools.lttng.request.RequestCompletedSignal;
-import org.eclipse.linuxtools.lttng.request.RequestStartedSignal;
-import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor;
+import org.eclipse.linuxtools.lttng.core.LttngConstants;
+import org.eclipse.linuxtools.lttng.core.control.LttngCoreProviderFactory;
+import org.eclipse.linuxtools.lttng.core.control.LttngSyntheticEventProvider;
+import org.eclipse.linuxtools.lttng.core.event.LttngSyntheticEvent;
+import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.core.request.ILttngSyntEventRequest;
+import org.eclipse.linuxtools.lttng.core.request.IRequestStatusListener;
+import org.eclipse.linuxtools.lttng.core.request.LttngSyntEventRequest;
+import org.eclipse.linuxtools.lttng.core.request.RequestCompletedSignal;
+import org.eclipse.linuxtools.lttng.core.request.RequestStartedSignal;
+import org.eclipse.linuxtools.lttng.core.state.evProcessor.ITransEventProcessor;
import org.eclipse.linuxtools.lttng.ui.TraceDebug;
import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
/**
* Number of events before a GUI refresh
*/
- protected static final Long INPUT_CHANGED_REFRESH = 20000L;
- private static final long DEFAULT_OFFSET = 0L;
- private static final int DEFAULT_CHUNK = 1;
+ protected static final Long INPUT_CHANGED_REFRESH = 75000L;
+ private static final long DEFAULT_OFFSET = 0;
protected boolean synch = true; // time synchronization, used to be an option
protected ITimeAnalysisViewer tsfviewer = null;
return INPUT_CHANGED_REFRESH;
}
+ /**
+ * Cancel the ongoing request if another experiment is being selected
+ * @param experimentDisposedSignal
+ */
+ @TmfSignalHandler
+ public void experimentDisposed(TmfExperimentDisposedSignal<? extends TmfEvent> experimentDisposedSignal) {
+ fProvider.conditionallyCancelRequests();
+ }
+
/*
* (non-Javadoc)
*
if (TraceDebug.isDEBUG()) {
TmfTimeRange trange = request.getRange();
if (request.isCancelled()) {
- TraceDebug.debug("Request cancelled "
- + trange.getStartTime() + "-" + trange.getEndTime()
- + " Handled Events: " + request.getSynEventCount()
- + " " + request.toString(), 15);
+ TraceDebug.debug("Request cancelled " //$NON-NLS-1$
+ + trange.getStartTime() + "-" + trange.getEndTime() //$NON-NLS-1$
+ + " Handled Events: " + request.getSynEventCount() //$NON-NLS-1$
+ + " " + request.toString(), 15); //$NON-NLS-1$
} else if (request.isFailed()) {
- TraceDebug.debug("Request Failed " + trange.getStartTime()
- + "-" + trange.getEndTime() + " Handled Events: "
- + request.getSynEventCount() + " "
+ TraceDebug.debug("Request Failed " + trange.getStartTime() //$NON-NLS-1$
+ + "-" + trange.getEndTime() + " Handled Events: " //$NON-NLS-1$ //$NON-NLS-2$
+ + request.getSynEventCount() + " " //$NON-NLS-1$
+ request.toString());
}
}
if (synch) {
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);
+
+ if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
+
+ // Check for GUI thread
+ if (Display.getCurrent() != null) {
+ // GUI thread - execute update right away.
+
+ // Internal value is expected in nano seconds.
+ long selectedTime = signal.getCurrentTime().getValue();
+ if (tsfviewer != null) {
+ tsfviewer.setSelectedTime(selectedTime, true, source);
+
+ ParamsUpdater paramUpdater = getParamsUpdater();
+ Long savedSelTime = paramUpdater.getSelectedTime();
+ if ((savedSelTime == null) || (savedSelTime != selectedTime)) {
+ // Update the parameter updater to save the selected time
+ paramUpdater.setSelectedTime(selectedTime);
+ }
+ }
+ } else {
+ // Perform the updates on the UI thread
+
+ // We need to clone the timestamp in the signal so that it won't be overwritten duo to multipe thread access
+ final TmfTimeSynchSignal savedSignal = new TmfTimeSynchSignal(signal.getSource(), signal.getCurrentTime().clone());
+ tsfviewer.getControl().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
+ synchToTime(savedSignal);
+ }
+ }
+ });
+ }
}
}
}
TmfTimeRange trange = signal.getCurrentRange();
TmfExperiment<?> experiment = TmfExperiment.getCurrentExperiment();
if (experiment == null) {
- TraceDebug.debug("Current selected experiment is null");
+ TraceDebug.debug("Current selected experiment is null"); //$NON-NLS-1$
return;
}
// Clearing of process data is configurable
- dataRequest(trange, experiment.getTimeRange(), clearingData, ExecutionType.FOREGROUND);
+ eventRequest(trange, experiment.getTimeRange(), clearingData, ExecutionType.FOREGROUND);
}
}
}
paramUpdater.setSelectedTime(selTimens);
if (TraceDebug.isDEBUG()) {
- TraceDebug.debug("Selected Time: " + new LttngTimestamp(selTimens) + "\n\t\t" + getName());
+ TraceDebug.debug("Selected Time: " + new LttngTimestamp(selTimens) + "\n\t\t" + getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
/**
* @param zoomedTRange
* @param experimentTRange
+ * @param clearingData
* @param execType
*/
- public void dataRequest(TmfTimeRange zoomedTRange,
- TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
+ public void eventRequest(TmfTimeRange zoomedTRange, TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
// timeRange is the Experiment time range
- boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData, execType);
+ boolean sent = processDataRequest(zoomedTRange, experimentTRange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA, clearingData, execType);
+
+ if (sent) {
+ waitCursor(true);
+ }
+ }
+
+ /**
+ * @param offset
+ * @param nbRequested
+ * @param startTime
+ * @param clearingData
+ * @param execType
+ */
+ public void eventRequest(long offset, TmfTimeRange range, boolean clearingData, ExecutionType execType) {
+
+ // timeRange is the Experiment time range
+ boolean sent = processDataRequest(range, null, offset, TmfDataRequest.ALL_DATA, clearingData, execType);
if (sent) {
waitCursor(true);
* @return
*/
private boolean processDataRequest(TmfTimeRange requestTrange,
- TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
+ TmfTimeRange experimentTRange, long offset, int nbRequested, boolean clearingData, ExecutionType execType) {
// Validate input
- if (requestTrange == null || experimentTRange == null) {
- TraceDebug.debug("Invalid input");
+ if (requestTrange == null) {
+ TraceDebug.debug("Invalid input"); //$NON-NLS-1$
return false;
}
// Cancel the currently executing request before starting a new one
fProvider.conditionallyCancelRequests();
-
fCurrentRequest = new LttngSyntEventRequest(
- requestTrange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA,
- DEFAULT_CHUNK, this, experimentTRange, getEventProcessor(),
+ requestTrange, offset, nbRequested,
+ LttngConstants.DEFAULT_BLOCK_SIZE, this, experimentTRange, getEventProcessor(),
TmfExperiment.getCurrentExperiment().getName(), execType) {
Long fCount = getSynEventCount();
if (TraceDebug.isDEBUG()) {
frunningTimeStamp = event.getTimestamp();
- TraceDebug.debug("handled: " + fCount + " sequence: " + synEvent.getSynType());
+ TraceDebug.debug("handled: " + fCount + " sequence: " + synEvent.getSynType()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
break;
if (TraceDebug.isDEBUG()) {
if (frunningTimeStamp != null) {
- TraceDebug.debug("Last event time stamp: "
- + frunningTimeStamp.getValue());
+ TraceDebug.debug("Last event time stamp: " + frunningTimeStamp.getValue()); //$NON-NLS-1$
}
}
}
* @param complete
* true: yes, false: partial update
*/
+ @SuppressWarnings("deprecation")
protected void modelInputChanged(ILttngSyntEventRequest request, boolean complete) {
long experimentStartTime = -1;
long experimentEndTime = -1;
if ((paramUpdater != null) && (tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
final Long selTime = paramUpdater.getSelectedTime();
if (selTime != null) {
- TraceDebug.debug("View: " + getName() + "\n\t\tRestoring the selected time to: " + selTime);
+ TraceDebug.debug("View: " + getName() + "\n\t\tRestoring the selected time to: " + selTime); //$NON-NLS-1$ //$NON-NLS-2$
Display display = tsfviewer.getControl().getDisplay();
display.asyncExec(new Runnable() {
@Override
int dicardedNotVisible = paramUpdater.getEventsDiscardedNotVisible();
TmfTimeRange range = request.getRange();
- StringBuilder sb = new StringBuilder("View: " + getName() + ", Events handled: " + count
- + ", Events loaded in view: " + eventCount + ", Number of events discarded: " + discarded
- + "\n\tNumber of events discarded with start time earlier than next good time: "
- + discardedOutofOrder + "\n\tDiscarded Not visible: " + dicardedNotVisible
- + "\n\tDiscarded out of view Range: " + discardedOutofViewRange);
-
- sb.append("\n\t\tRequested Time Range: " + range.getStartTime() + "-" + range.getEndTime());
- sb.append("\n\t\tExperiment Time Range: " + experimentStartTime + "-" + experimentEndTime);
+ StringBuilder sb = new StringBuilder("View: " + getName() + ", Events handled: " + count //$NON-NLS-1$ //$NON-NLS-2$
+ + ", Events loaded in view: " + eventCount + ", Number of events discarded: " + discarded //$NON-NLS-1$ //$NON-NLS-2$
+ + "\n\tNumber of events discarded with start time earlier than next good time: " //$NON-NLS-1$
+ + discardedOutofOrder + "\n\tDiscarded Not visible: " + dicardedNotVisible //$NON-NLS-1$
+ + "\n\tDiscarded out of view Range: " + discardedOutofViewRange); //$NON-NLS-1$
+
+ sb.append("\n\t\tRequested Time Range: " + range.getStartTime() + "-" + range.getEndTime()); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append("\n\t\tExperiment Time Range: " + experimentStartTime + "-" + experimentEndTime); //$NON-NLS-1$ //$NON-NLS-2$
TraceDebug.debug(sb.toString());
}
}