import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.linuxtools.lttng.control.LttngCoreProviderFactory;
-import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest;
-import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventToHandlerResolver;
+import org.eclipse.linuxtools.lttng.core.control.LttngCoreProviderFactory;
+import org.eclipse.linuxtools.lttng.core.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.core.model.LTTngTreeNode;
+import org.eclipse.linuxtools.lttng.core.request.ILttngSyntEventRequest;
+import org.eclipse.linuxtools.lttng.core.state.evProcessor.AbsEventToHandlerResolver;
+import org.eclipse.linuxtools.lttng.core.state.experiment.StateManagerFactory;
import org.eclipse.linuxtools.lttng.ui.TraceDebug;
import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer;
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.statistics.evProcessor.StatsTimeCountHandlerFactory;
+import org.eclipse.linuxtools.lttng.ui.views.statistics.model.KernelStatisticsData;
import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode;
import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeRootFactory;
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
private final String ELAPSED_TIME_COLUMN_TIP = Messages.StatisticsView_ElapsedTimeTip;
// Level for which statistics should not be displayed.
- private Set<String> folderLevels = new HashSet<String>(Arrays.asList(
- new String[] { "Event Types", "Modes", "Submodes", "CPUs", "Processes", "Functions" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ private Set<Integer> folderLevels = new HashSet<Integer>(Arrays
+ .asList(new Integer[] { KernelStatisticsData.HEADER_CPUS_INT,
+ KernelStatisticsData.HEADER_EVENT_TYPES_INT,
+ KernelStatisticsData.HEADER_FUNCTIONS_INT,
+ KernelStatisticsData.HEADER_MODES_INT,
+ KernelStatisticsData.HEADER_PROCESSES_INT,
+ KernelStatisticsData.HEADER_SUBMODES_INT }));
// Levels for which sub-levels should not contain time-related statistics.
- private Set<String> levelsWithEmptyTime = new HashSet<String>(Arrays.asList(
- new String[] { "Event Types" })); //$NON-NLS-1$
+ private Set<Integer> levelsWithEmptyTime = new HashSet<Integer>(Arrays
+ .asList(new Integer[] { KernelStatisticsData.HEADER_EVENT_TYPES_INT }));
private DecimalFormat decimalFormat = new DecimalFormat("0.#########"); //$NON-NLS-1$
+
private Cursor fwaitCursor = null;
private static final Long STATS_INPUT_CHANGED_REFRESH = 5000L;
public double getPercentage(StatisticsTreeNode node);
}
+ private boolean fStatisticsUpdateBusy = false;
+ private boolean fStatisticsUpdatePending = false;
+ private TmfTimeRange fStatisticsUpdateRange = null;
+ private final Object fStatisticsUpdateSyncObj = new Object();
+
/**
* Contains all the information necessary to build a column of the table.
*/
new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- return ((StatisticsTreeNode) element).getKey();
+ StatisticsTreeNode node = (StatisticsTreeNode) element;
+ if (folderLevels.contains(node.getKey())) {
+ return (KernelStatisticsData.getCategoryFromId(node.getKey().intValue()));
+ } else {
+ return node.getName();
+ }
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
StatisticsTreeNode n1 = (StatisticsTreeNode) e1;
StatisticsTreeNode n2 = (StatisticsTreeNode) e2;
-
- return n1.getKey().compareTo(n2.getKey());
+
+// return n1.getKey().compareTo(n2.getKey());
+ return n1.compareTo(n2);
}
}, null),
new ColumnData(EVENTS_COUNT_COLUMN, 125, SWT.LEFT,
// Read current data if any available
TmfExperiment<?> experiment = TmfExperiment.getCurrentExperiment();
if (experiment != null) {
- requestData(experiment);
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ TmfExperimentSelectedSignal<?> signal = new TmfExperimentSelectedSignal(this, experiment);
+ experimentSelected(signal);
+
} else {
TraceDebug.debug("No selected experiment information available"); //$NON-NLS-1$
}
public void ModelUpdatePrep(TmfTimeRange timeRange, boolean clearAllData) {
Object input = treeViewer.getInput();
if ((input != null) && (input instanceof StatisticsTreeNode) && (!treeViewer.getTree().isDisposed())) {
- ((StatisticsTreeNode) input).reset();
+ if (clearAllData) {
+ ((StatisticsTreeNode) input).reset();
+ }
treeViewer.getTree().getDisplay().asyncExec(new Runnable() {
// @Override
@Override
public void modelInputChanged(ILttngSyntEventRequest request, boolean complete) {
// Ignore update if disposed
if (treeViewer.getTree().isDisposed()) return;
-
+
if(TraceDebug.isSV() && complete) {
// print results
StatisticsTreeNode node = StatisticsTreeRootFactory.getStatTreeRoot(experiment.getName());
printRecursively(node);
- }
+ }
}
treeViewer.getTree().getDisplay().asyncExec(new Runnable() {
treeViewer.refresh();
}
});
+
+ if (complete) {
+ synchronized (fStatisticsUpdateSyncObj) {
+ fStatisticsUpdateBusy = false;
+ if (fStatisticsUpdatePending) {
+ fStatisticsUpdatePending = false;
+ requestData(TmfExperiment.getCurrentExperiment(), fStatisticsUpdateRange, false);
+ }
+ }
}
+
+ }
+
private static int level = 0;
- private void printRecursively(StatisticsTreeNode node) {
- String tab = ""; //$NON-NLS-1$
- for (int i = 0; i < level; i++) {
+ private void printRecursively(StatisticsTreeNode node) {
+ String tab = ""; //$NON-NLS-1$
+ for (int i = 0; i < level; i++) {
tab += "\t"; //$NON-NLS-1$
}
- level++;
+ level++;
TraceDebug.traceSV(tab + node.getContent());
if (node.hasChildren()) {
LinkedList<StatisticsTreeNode> childreen = (LinkedList<StatisticsTreeNode>)node.getChildren();
Collections.sort(childreen);
+
for (Iterator<StatisticsTreeNode> iterator = childreen.iterator(); iterator.hasNext();) {
StatisticsTreeNode statisticsTreeNode = (StatisticsTreeNode) iterator.next();
printRecursively(statisticsTreeNode);
StatisticsTreeNode experimentTreeNode = StatisticsTreeRootFactory.getStatTreeRoot(experimentName);
ITmfTrace[] traces = experiment.getTraces();
-
+
+ LTTngTreeNode expNode = StateManagerFactory.getExperimentManager().getSelectedExperiment();
+
// check if there is partial data loaded in the experiment
int numTraces = experiment.getTraces().length;
int numNodeTraces = experimentTreeNode.getNbChildren();
// previously selected
for (int i = 0; i < numTraces; i++) {
String traceName = traces[i].getName();
- if (!experimentTreeNode.containsChild(traceName)) {
+ LTTngTreeNode child = expNode.getChildByName(traceName);
+ if ((child == null) || (!experimentTreeNode.containsChild(child.getId().intValue()))) {
same = false;
break;
}
if (same) {
// no need to reload data, all traces are already loaded
treeViewer.setInput(experimentTreeNode);
+ synchronized (fStatisticsUpdateSyncObj) {
+ fStatisticsUpdateBusy = false;
+ fStatisticsUpdatePending = false;
+ }
return;
}
}
}
+ StatisticsTreeNode treeModelRoot = StatisticsTreeRootFactory.getStatTreeRoot(experiment.getName());
+
+ // if the model has contents, clear to start over
+ if (treeModelRoot.hasChildren()) {
+ treeModelRoot.reset();
+ }
+
+ // set input to a clean data model
+ treeViewer.setInput(treeModelRoot);
+
+ synchronized (fStatisticsUpdateSyncObj) {
+ fStatisticsUpdateBusy = false;
+ fStatisticsUpdatePending = false;
+ }
+
// if the data is not available or has changed, reload it
- requestData(experiment);
+ requestData(experiment, experiment.getTimeRange(), true);
+ }
+ }
+
+ /**
+ * @param signal
+ */
+ @SuppressWarnings("unchecked")
+ @TmfSignalHandler
+ public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) {
+ TmfExperiment<LttngEvent> experiment = (TmfExperiment<LttngEvent>) signal.getExperiment();
+ // validate
+ if (! experiment.equals(TmfExperiment.getCurrentExperiment())) {
+ return;
}
+
+ requestData(experiment, signal.getRange(), false);
}
/**
* @param experiment
*/
- private void requestData(TmfExperiment<?> experiment) {
+ private void requestData(TmfExperiment<?> experiment, TmfTimeRange range, boolean clearingData) {
if (experiment != null) {
- StatisticsTreeNode treeModelRoot = StatisticsTreeRootFactory.getStatTreeRoot(experiment.getName());
-
- // if the model has contents, clear to start over
- if (treeModelRoot.hasChildren()) {
- treeModelRoot.reset();
+ synchronized (fStatisticsUpdateSyncObj) {
+ if (fStatisticsUpdateBusy) {
+ fStatisticsUpdatePending = true;
+ fStatisticsUpdateRange = range;
+ return;
+ } else {
+ fStatisticsUpdateBusy = true;
+ }
}
- // set input to a clean data model
- treeViewer.setInput(treeModelRoot);
- TmfTimeRange experimentTRange = experiment.getTimeRange();
+ int index = 0;
+ for (StatisticsTreeNode node : ((StatisticsTreeNode) treeViewer.getInput()).getChildren()) {
+ index += (int) node.getValue().nbEvents;
+ }
// send the initial request, to start filling up model
- dataRequest(experimentTRange, experimentTRange, true, ExecutionType.BACKGROUND);
+ //eventRequest(fStatisticsUpdateIndex, nbRequested, fStatisticsUpdateStartTime, clearingData, ExecutionType.BACKGROUND);
+ eventRequest(index, range, clearingData, ExecutionType.BACKGROUND);
} else {
TraceDebug.debug("No selected experiment information available"); //$NON-NLS-1$
}
protected int getProviderId() {
return LttngCoreProviderFactory.STATISTICS_LTTNG_SYTH_EVENT_PROVIDER;
}
-}
+}
\ No newline at end of file