Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Overholt2011-02-28 03:56:13 +0000
committerAndrew Overholt2011-02-28 03:56:15 +0000
commitbba679b8d8ce887df73574195fb104c77a434c06 (patch)
tree4c84c77293e8a6d85c9fe7995e2f1a129f5db966
parent6b01d3eabd80c2caa4293a9fe99b9999fdc6d512 (diff)
parent165fe74d55ea3875cf779c49300d8022f3f81f2f (diff)
downloadorg.eclipse.linuxtools-bba679b8d8ce887df73574195fb104c77a434c06.tar.gz
org.eclipse.linuxtools-bba679b8d8ce887df73574195fb104c77a434c06.tar.xz
org.eclipse.linuxtools-bba679b8d8ce887df73574195fb104c77a434c06.zip
Merge lttng 0.6.1
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTest.java26
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTextTest.java16
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManagerTextTest.java58
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/AllLTTngCoreTests.java6
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/ChangeLog66
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/plugin.xml2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java33
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java72
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java78
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java91
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java40
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java149
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java42
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasFocusListener.java9
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java6
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java88
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java182
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java4
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java32
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java121
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java203
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java534
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java355
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasControlListener.java67
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java155
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java29
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java1
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java3
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java7
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java213
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java19
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java19
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsProcessExitHandler.java43
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java22
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java18
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTracesetEndHandler.java40
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/FixedArray.java249
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/KernelStatisticsData.java354
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/Statistics.java25
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsData.java217
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java237
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeRootFactory.java42
-rw-r--r--lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java3
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/ChangeLog13
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java181
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java18
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java16
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java17
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/AbsEventToHandlerResolver.java6
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java6
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java5
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java35
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/.options8
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/TmfCoreTestPlugin.java3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/component/TmfEventProviderTest.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfExperimentTest.java353
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfMultiTraceExperimentTest.java665
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/trace/TmfTraceTest.java238
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java37
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/ChangeLog13
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java340
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java298
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java26
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfTable.java528
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java451
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/ChangeLog33
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java31
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/ITmfDataProvider.java1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java182
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfThread.java25
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java386
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentContext.java14
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentLocation.java11
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfCoalescedEventRequest.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java12
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfRequestExecutor.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentUpdatedSignal.java15
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfContext.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java14
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java190
86 files changed, 5905 insertions, 2306 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTest.java b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTest.java
index cc4715d0fb..3c7f861b60 100644
--- a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTest.java
@@ -18,7 +18,7 @@ public class LTTngSyntheticEventProviderTest extends LttngTestPreparation {
// Tests
// ========================================================================
-// public void testPlainDataRequest() {
+ public void testPlainDataRequest() {
// // prepare
// init();
// TmfExperiment<LttngEvent> experiment = prepareExperimentToTest();
@@ -38,12 +38,12 @@ public class LTTngSyntheticEventProviderTest extends LttngTestPreparation {
// boolean expected = true;
// assertEquals("Events received out of expected order", expected,
// validSequence);
-// }
-//
-// /**
-// *
-// */
-// public void testSyntheticEventRequest() {
+ }
+
+ /**
+ *
+ */
+ public void testSyntheticEventRequest() {
// init();
// // Create a new Experiment manager context
// IStateExperimentManager expManager = prepareExperimentContext(false);
@@ -76,6 +76,7 @@ public class LTTngSyntheticEventProviderTest extends LttngTestPreparation {
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
+// System.out.println("EventCount " + feventCount);
//
// synProvider.sendRequest(request2);
// try {
@@ -83,9 +84,18 @@ public class LTTngSyntheticEventProviderTest extends LttngTestPreparation {
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
+// System.out.println("EventCount " + feventCount);
+//
+//// try {
+//// request1.waitForCompletion();
+//// request2.waitForCompletion();
+//// } catch (InterruptedException e) {
+//// e.printStackTrace();
+//// }
+//// System.out.println("EventCount " + feventCount);
//
// // finish
// assertEquals("Unexpected eventCount", 3002, feventCount);
-// }
+ }
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTextTest.java b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTextTest.java
index a63a1b1557..fc1f1de006 100644
--- a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTextTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/control/LTTngSyntheticEventProviderTextTest.java
@@ -23,7 +23,7 @@ public class LTTngSyntheticEventProviderTextTest extends LttngTestPreparation {
/**
*
*/
-// public void testPlainDataRequest() {
+ public void testPlainDataRequest() {
// // prepare
// init();
// TmfExperiment<LttngEvent> experiment = prepareTextExperimentToTest();
@@ -43,12 +43,12 @@ public class LTTngSyntheticEventProviderTextTest extends LttngTestPreparation {
// boolean expected = true;
// assertEquals("Events received out of expected order", expected,
// validSequence);
-// }
-//
-// /**
-// *
-// */
-// public void testSyntheticEventRequest() {
+ }
+
+ /**
+ *
+ */
+ public void testSyntheticEventRequest() {
// init();
// // make sure a synthetic event provider exists and it's registered
// LttngSyntheticEventProvider synProvider = LttngCoreProviderFactory
@@ -72,5 +72,5 @@ public class LTTngSyntheticEventProviderTextTest extends LttngTestPreparation {
//
// // finish
// assertEquals("Unexpected eventCount", 15316, feventCount);
-// }
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManagerTextTest.java b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManagerTextTest.java
index eae057b3e9..3e1c23b78d 100644
--- a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManagerTextTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManagerTextTest.java
@@ -26,35 +26,35 @@ public class StateExperimentManagerTextTest extends LttngTestPreparation {
/**
* Test method for {@link org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManager#experimentSelected_prep(org.eclipse.linuxtools.tmf.experiment.TmfExperiment)}.
*/
- public void testExperimentSelected_text() {
- // make sure a TmfExperiment instance is registered as provider and
- // selected as current
- TmfExperiment<LttngEvent> experiment = prepareTextExperimentToTest();
-
- // Create a new Experiment manager
- IStateExperimentManager expManager = StateManagerFactory
- .getExperimentManager();
- expManager.waitForCompletion(true);
- // Configure the interval to create check points so this can be tested
- // with medium size files i.e. default is 50000 events
- StateManagerFactory.setTraceCheckPointInterval(1000L);
-
- // preparation
- expManager.experimentSelected_prep(experiment);
- // Action trigger
- expManager.experimentSelected(this, experiment);
-
- // Access context tree for Validation
- // access to the context tree
- LTTngTreeNode experimentNode = expManager.getSelectedExperiment();
- StateTraceManager traceManager = (StateTraceManager) experimentNode
- .getChildById(0L);
-
- // validate
- int numProcesses = traceManager.getCheckPointStateModel().getProcesses().length;
- assertEquals("Total number of processes created", 276, numProcesses);
-
- }
+// public void testExperimentSelected_text() {
+// // make sure a TmfExperiment instance is registered as provider and
+// // selected as current
+// TmfExperiment<LttngEvent> experiment = prepareTextExperimentToTest();
+//
+// // Create a new Experiment manager
+// IStateExperimentManager expManager = StateManagerFactory
+// .getExperimentManager();
+// expManager.waitForCompletion(true);
+// // Configure the interval to create check points so this can be tested
+// // with medium size files i.e. default is 50000 events
+// StateManagerFactory.setTraceCheckPointInterval(1000L);
+//
+// // preparation
+// expManager.experimentSelected_prep(experiment);
+// // Action trigger
+// expManager.experimentSelected(this, experiment);
+//
+// // Access context tree for Validation
+// // access to the context tree
+// LTTngTreeNode experimentNode = expManager.getSelectedExperiment();
+// StateTraceManager traceManager = (StateTraceManager) experimentNode
+// .getChildById(0L);
+//
+// // validate
+// int numProcesses = traceManager.getCheckPointStateModel().getProcesses().length;
+// assertEquals("Total number of processes created", 276, numProcesses);
+//
+// }
/**
* Test method for
diff --git a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/AllLTTngCoreTests.java b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/AllLTTngCoreTests.java
index 9e40a5960e..8e299c97fa 100644
--- a/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/AllLTTngCoreTests.java
+++ b/lttng/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/AllLTTngCoreTests.java
@@ -3,6 +3,8 @@ package org.eclipse.linuxtools.lttng.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.linuxtools.lttng.control.LTTngSyntheticEventProviderTest;
+import org.eclipse.linuxtools.lttng.control.LTTngSyntheticEventProviderTextTest;
import org.eclipse.linuxtools.lttng.model.LTTngTreeNodeTest;
import org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManagerTextTest;
import org.eclipse.linuxtools.lttng.state.resource.LTTngStateResourceTest;
@@ -42,8 +44,8 @@ public class AllLTTngCoreTests {
suite.addTestSuite(LTTngTextTraceTest.class);
suite.addTestSuite(LTTngTraceTest.class);
-// suite.addTestSuite(LTTngSyntheticEventProviderTest.class);
-// suite.addTestSuite(LTTngSyntheticEventProviderTextTest.class);
+ suite.addTestSuite(LTTngSyntheticEventProviderTest.class);
+ suite.addTestSuite(LTTngSyntheticEventProviderTextTest.class);
suite.addTestSuite(LTTngTreeNodeTest.class);
suite.addTestSuite(StateExperimentManagerTextTest.class);
suite.addTestSuite(LTTngStateResourceTest.class);
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java b/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java
index 91ba9941e5..5f1a4a072b 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java
@@ -52,7 +52,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> {
* @throws FileNotFoundException
*/
public LTTngTraceStub(String filename) throws FileNotFoundException {
- this(filename, DEFAULT_CACHE_SIZE);
+ this(filename, DEFAULT_INDEX_PAGE_SIZE);
}
/**
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/ChangeLog b/lttng/org.eclipse.linuxtools.lttng.ui/ChangeLog
new file mode 100644
index 0000000000..6cc6fa1704
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/ChangeLog
@@ -0,0 +1,66 @@
+2010-07-30 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasFocusListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasControlListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java:
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java:
+
+2010-07-29 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsProcessExitHandler.java: New file.
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTracesetEndHandler.java: New file.
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/FixedArray.java: New file.
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/KernelStatisticsData.java: New file.
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsData.java: New file.
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java: Adjusted for new stats internal structure
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java: Adjusted for new stats internal structure
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java: Adjusted for new stats internal structure
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java: Hooked to ProcessExitHandler
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java: Hooked to ProcessExitHandler and TracesetEndHandler
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/Statistics.java: Added comments
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java: Adapted to new stats structure
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeRootFactory.java: Adapted to new stats structure
+
+2010-07-28 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java: New file.
+ * src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java: Use decoupled EventsTable
+
+2010-07-14 Francois Chouinard <fchouinard@gmail.com>
+
+ * plugin.xml: Point to the 16x16 LTTng icon for the perspective
+
+2010-07-13 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java: Added null pointer checks
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java: Displaced funtionality from parent class
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java: Displaced the recentering code
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java: Added null pointer checks
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java: Removed a duplicate function call
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java: GUI reorganisation, simplification and some related code improvements
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java: Added event listeners
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasControlListener.java: New file
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java: Cosmetic change.
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java: Updates of text parts of the view
+
+2010-07-08 francois <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java: Selected correct request type
+ * src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java: Selected correct request type
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java: Add missing handleCompleted()
+ * src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java: Selected correct request type
+ * src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java: Use correct time range
+ * src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java: Selected correct request type
+ * src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java: Selected correct request type; Init smaller window to 1s range. \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/plugin.xml b/lttng/org.eclipse.linuxtools.lttng.ui/plugin.xml
index 55bf5083f7..e9fd478e9e 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/plugin.xml
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/plugin.xml
@@ -7,7 +7,7 @@
point="org.eclipse.ui.perspectives">
<perspective
class="org.eclipse.linuxtools.lttng.ui.views.PerspectiveFactory"
- icon="icons/garland32.png"
+ icon="icons/garland16.png"
id="org.eclipse.linuxtools.lttng.ui.perspective"
name="%perspective.name">
</perspective>
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java
index fed6e16d35..45514254bc 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/common/AbsTimeUpdateView.java
@@ -30,6 +30,7 @@ import org.eclipse.linuxtools.tmf.event.TmfEvent;
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;
@@ -205,7 +206,7 @@ public abstract class AbsTimeUpdateView extends TmfView implements
}
// Clearing of process data is configurable
- dataRequest(trange, experiment.getTimeRange(), clearingData);
+ dataRequest(trange, experiment.getTimeRange(), clearingData, ExecutionType.SHORT);
}
}
}
@@ -304,29 +305,47 @@ public abstract class AbsTimeUpdateView extends TmfView implements
/**
* @param zoomedTRange
* @param experimentTRange
+ * @param execType
*/
public void dataRequest(TmfTimeRange zoomedTRange,
- TmfTimeRange experimentTRange, boolean clearingData) {
+ TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
// timeRange is the Experiment time range
- boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData);
+ boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData, execType);
if (sent) {
waitCursor(true);
}
}
+// /**
+// * @param zoomedTRange
+// * @param experimentTRange
+// * @param execType
+// */
+// public void dataRequest(TmfTimeRange zoomedTRange,
+// TmfTimeRange experimentTRange, boolean clearingData) {
+//
+// // timeRange is the Experiment time range
+// boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData);
+//
+// if (sent) {
+// waitCursor(true);
+// }
+// }
+
/**
* send data request directly e.g. doesn't use a queue
*
* @param requestTrange
* @param listener
* @param experimentTRange
+ * @param execType
* @param processor
* @return
*/
private boolean processDataRequest(TmfTimeRange requestTrange,
- TmfTimeRange experimentTRange, boolean clearingData) {
+ TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
// Validate input
if (requestTrange == null || experimentTRange == null) {
TraceDebug.debug("Invalid input");
@@ -335,13 +354,13 @@ public abstract class AbsTimeUpdateView extends TmfView implements
// Cancel the currently executing request before starting a new one
if (fCurrentRequest != null && !fCurrentRequest.isCompleted()) {
- System.out.println("Cancelling request");
+// System.out.println("Cancelling request");
// fCurrentRequest.cancel();
}
fCurrentRequest = new LttngSyntEventRequest(
requestTrange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA,
- DEFAULT_CHUNK, this, experimentTRange, getEventProcessor()) {
+ DEFAULT_CHUNK, this, experimentTRange, getEventProcessor(), execType) {
Long fCount = getSynEventCount();
ITransEventProcessor processor = getProcessor();
@@ -590,6 +609,8 @@ public abstract class AbsTimeUpdateView extends TmfView implements
});
}
+// System.out.println(System.currentTimeMillis() + ": AbsTimeUpdate (" + getName() + ") completed");
+
if (TraceDebug.isDEBUG()) {
int eventCount = 0;
Long count = request.getSynEventCount();
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java
index 342fb026ec..edc10dd4cc 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java
@@ -46,6 +46,7 @@ import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory;
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.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
@@ -885,40 +886,43 @@ public class ControlFlowView extends AbsTimeUpdateView implements
final long startBoundTime, final long endBoundTime,
final boolean updateTimeBounds, final long startVisibleWindow,
final long endVisibleWindow, final Object source) {
- final Table table = tableViewer.getTable();
- Display display = table.getDisplay();
-
- // 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);
- tableViewer.setFilters(new ViewerFilter[] { tableFilter });
-
- resizeTableColumns(table);
- table.update();
- tableViewer.refresh();
-
- tsfviewer.display(items, startBoundTime, endBoundTime,
- updateTimeBounds);
-
- // validate visible boundaries
- if (startVisibleWindow > -1 && endVisibleWindow > -1) {
- tsfviewer.setSelectVisTimeWindow(startVisibleWindow,
- endVisibleWindow, source);
- }
-
- tsfviewer.resizeControls();
-
- // Adjust the size of the vertical scroll bar to fit the
- // contents
- if (scrollFrame != null) {
- updateScrolls(scrollFrame);
+
+ if(tableViewer != null) {
+ final Table table = tableViewer.getTable();
+ Display display = table.getDisplay();
+
+ // 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);
+ tableViewer.setFilters(new ViewerFilter[] { tableFilter });
+
+ resizeTableColumns(table);
+ table.update();
+ tableViewer.refresh();
+
+ tsfviewer.display(items, startBoundTime, endBoundTime,
+ updateTimeBounds);
+
+ // validate visible boundaries
+ if (startVisibleWindow > -1 && endVisibleWindow > -1) {
+ tsfviewer.setSelectVisTimeWindow(startVisibleWindow,
+ endVisibleWindow, source);
+ }
+
+ tsfviewer.resizeControls();
+
+ // Adjust the size of the vertical scroll bar to fit the
+ // contents
+ if (scrollFrame != null) {
+ updateScrolls(scrollFrame);
+ }
}
- }
- });
+ });
+ }
}
@Override
@@ -1044,7 +1048,7 @@ public class ControlFlowView extends AbsTimeUpdateView implements
// user to select the interesting area based on the perspective
TmfTimeRange initTimeWindow = getInitTRange(experimentTRange);
- dataRequest(initTimeWindow, experimentTRange, true);
+ dataRequest(initTimeWindow, experimentTRange, true, ExecutionType.SHORT);
if (TraceDebug.isDEBUG()) {
TraceDebug.debug("Initialization request time range is: "
+ initTimeWindow.getStartTime().toString() + "-"
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java
new file mode 100644
index 0000000000..8108ffcac3
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.events;
+
+import org.eclipse.linuxtools.lttng.event.LttngEventContent;
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
+import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class EventsTable extends TmfEventsTable {
+
+ // ------------------------------------------------------------------------
+ // Table data
+ // ------------------------------------------------------------------------
+
+ // Table column names
+ static private final String TIMESTAMP_COLUMN = "Timestamp";
+ static private final String SOURCE_COLUMN = "Source";
+ static private final String TYPE_COLUMN = "Type";
+ static private final String REFERENCE_COLUMN = "Reference";
+ static private final String CONTENT_COLUMN = "Content";
+ static private final String[] COLUMN_NAMES = new String[] {
+ TIMESTAMP_COLUMN,
+ SOURCE_COLUMN,
+ TYPE_COLUMN,
+ REFERENCE_COLUMN,
+ CONTENT_COLUMN
+ };
+
+ static private final ColumnData[] COLUMN_DATA = new ColumnData[] {
+ new ColumnData(COLUMN_NAMES[0], 125, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[2], 200, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[3], 200, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[4], 100, SWT.LEFT)
+ };
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ public EventsTable(Composite parent, int cacheSize) {
+ super(parent, cacheSize, COLUMN_DATA);
+ }
+
+ /**
+ * @param event
+ * @return
+ */
+ @Override
+ protected String[] extractItemFields(TmfEvent event) {
+ String[] fields = new String[0];
+
+ if (event != null) {
+ fields = new String[] {
+ event.getTimestamp().toString(),
+ event.getSource().toString(),
+ event.getType().toString(),
+ event.getReference().toString(),
+ ((LttngEventContent)event.getContent()).toString()
+ };
+ }
+ return fields;
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java
index 306adfe059..11531d85e3 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java
@@ -12,14 +12,9 @@
package org.eclipse.linuxtools.lttng.ui.views.events;
-import org.eclipse.linuxtools.lttng.event.LttngEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Composite;
/**
* <b><u>EventsView</u></b>
@@ -31,45 +26,6 @@ public class EventsView extends TmfEventsView {
public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.events";
// ------------------------------------------------------------------------
- // Table data
- // ------------------------------------------------------------------------
-
- // Table column names
- private final String TIMESTAMP_COLUMN = "Timestamp";
- private final String SOURCE_COLUMN = "Source";
- private final String TYPE_COLUMN = "Type";
- private final String REFERENCE_COLUMN = "Reference";
- private final String CONTENT_COLUMN = "Content";
- private final String[] columnProperties = new String[] {
- TIMESTAMP_COLUMN,
- SOURCE_COLUMN,
- TYPE_COLUMN,
- REFERENCE_COLUMN,
- CONTENT_COLUMN
- };
-
- // Column data
- private class ColumnData {
- public final String header;
- public final int width;
- public final int alignment;
-
- public ColumnData(String h, int w, int a) {
- header = h;
- width = w;
- alignment = a;
- }
- };
-
- private ColumnData[] columnData = new ColumnData[] {
- new ColumnData(columnProperties[0], 125, SWT.LEFT),
- new ColumnData(columnProperties[1], 100, SWT.LEFT),
- new ColumnData(columnProperties[2], 200, SWT.LEFT),
- new ColumnData(columnProperties[3], 200, SWT.LEFT),
- new ColumnData(columnProperties[4], 100, SWT.LEFT)
- };
-
- // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
@@ -77,48 +33,9 @@ public class EventsView extends TmfEventsView {
super(1);
}
- /**
- * @param table
- *
- * FIXME: Add support for column selection
- */
- @Override
- protected void createColumnHeaders(Table table) {
- for (int i = 0; i < columnData.length; i++) {
- final TableColumn column = new TableColumn(table, columnData[i].alignment, i);
- column.setText(columnData[i].header);
- column.setWidth(columnData[i].width);
- // TODO: Investigate why the column resizing doesn't work by default
- // Anything to do with SWT_VIRTUAL?
- column.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
- }
- public void widgetSelected(SelectionEvent e) {
- column.pack();
- }
- });
- }
- }
-
- /**
- * @param event
- * @return
- */
@Override
- protected String[] extractItemFields(TmfEvent event) {
- String[] fields = new String[0];
-
- if (event != null) {
- fields = new String[] {
- event.getTimestamp().toString(),
- event.getSource().toString(),
- event.getType().toString(),
- event.getReference().toString(),
- ((LttngEventContent)event.getContent()).toString()
- };
- }
- return fields;
+ protected TmfEventsTable createEventsTable(Composite parent, int cacheSize) {
+ return new EventsTable(parent, cacheSize);
}
/* (non-Javadoc)
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java
index 87464d0c65..23ba8adff6 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java
@@ -8,6 +8,10 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-06-20 Yuriy Vashchuk - Histogram optimisations.
+ * 2010-07-16 Yuriy Vashchuk - Base Histogram class simplification.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -22,7 +26,8 @@ import org.eclipse.swt.widgets.Composite;
*/
public class ChildrenHistogramCanvas extends HistogramCanvas {
- protected HistogramView parentHistogramWindow = null;
+ private HistogramCanvasPaintListener paintListener = null;
+ private HistogramCanvasControlListener controlListener = null;
/**
* ChildrenHistogramCanvas constructor.<p>
@@ -31,10 +36,33 @@ public class ChildrenHistogramCanvas extends HistogramCanvas {
* @param parent Composite control which will be the parent of the new instance (cannot be null)
* @param Style the style of control to construct
*/
- public ChildrenHistogramCanvas(HistogramView newParentWindow, Composite parent, int style) {
- super(parent, style);
+ public ChildrenHistogramCanvas(HistogramView histogramView, Composite parent, int style) {
+ super(histogramView, parent, style);
- parentHistogramWindow = newParentWindow;
+ // 2010-06-20 Yuriy: Moved from parent class
+ createAndAddPaintListener();
+ createAndAddControlListener();
+ }
+
+ /*
+ * Create a histogram paint listener and bind it to this canvas.<p>
+ *
+ * Note : This one is a bit particular, as it is made to draw content that is of a power of 2.
+ * The default one draw content that is relative to the real pixels size.
+ */
+ private void createAndAddPaintListener() {
+ paintListener = new HistogramCanvasPaintListener(this);
+ this.addPaintListener( paintListener );
+ }
+
+ /*
+ * Create a histogram control listener and bind it to this canvas.<p>
+ *
+ * @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasControlListener
+ */
+ private void createAndAddControlListener() {
+ controlListener = new HistogramCanvasControlListener(this);
+ this.addControlListener(controlListener);
}
/**
@@ -43,6 +71,8 @@ public class ChildrenHistogramCanvas extends HistogramCanvas {
*/
@Override
public void notifyParentUpdatedInformation() {
- parentHistogramWindow.updateSelectedWindowInformation();
+ if(getHistogramView() != null) {
+ getHistogramView().updateSelectedWindowInformation();
+ }
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java
index b362367446..64aadd5a37 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java
@@ -8,6 +8,12 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-06-20 Yuriy Vashchuk - Histogram optimisations.
+ * 2010-07-16 Yuriy Vashchuk - Histogram class simplification.
+ * Selection Window related methods has been
+ * implemented in Parent Histogram.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -25,17 +31,24 @@ import org.eclipse.swt.widgets.Display;
*/
public class HistogramCanvas extends Canvas
{
+ private static HistogramView histogramView = null;
+
protected AsyncCanvasRedrawer canvasRedrawer = null;
protected HistogramContent histogramContent = null;
- protected HistogramCanvasPaintListener paintListener = null;
+/*
+ // 2010-07-16 Yuriy: Moved to child classes.
+ protected HistogramCanvasPaintListener paintListener = null;
protected HistogramCanvasMouseListener mouseListener = null;
protected HistogramCanvasKeyListener keyListener = null;
- protected HistogramCanvasFocusListener focusListener = null;
protected HistogramCanvasControlListener controlListener = null;
+*/
+ protected HistogramCanvasFocusListener focusListener = null;
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
protected HistogramSelectedWindow currentWindow = null;
-
+*/
/**
* HistogramCanvas constructor
@@ -43,24 +56,33 @@ public class HistogramCanvas extends Canvas
* @param parent Composite control which will be the parent of the new instance (cannot be null)
* @param Style the style of control to construct
*/
- public HistogramCanvas(Composite parent, int style) {
+ public HistogramCanvas(HistogramView histogramView, Composite parent, int style) {
super(parent, style);
+ HistogramCanvas.histogramView = histogramView;
addNeededListeners();
+/*
+ // 2010-06-20 Yuriy: Moved to parent hitogram class.
// New selected window, not visible by default
createNewSelectedWindow(0L);
+*/
}
/*
* Create the needed "event listeners" and hook them to the Canvas.
*/
+
protected void addNeededListeners() {
createAndAddCanvasRedrawer();
+ createAndAddFocusListener();
+
+/*
+ // 2010-06-20 Yuriy: Moved to derived classes.
createAndAddPaintListener();
createAndAddMouseListener();
createAndAddKeyListener();
- createAndAddFocusListener();
createAndAddControlListener();
+*/
}
/*
@@ -73,40 +95,47 @@ public class HistogramCanvas extends Canvas
protected void createAndAddCanvasRedrawer() {
canvasRedrawer = new AsyncCanvasRedrawer(this);
}
-
+
/*
* Create a histogram paint listener and bind it to this canvas.<p>
*
* @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasPaintListener
*/
+/*
+ // 2010-07-16 Yuriy: Moved to derived classes.
protected void createAndAddPaintListener() {
paintListener = new HistogramCanvasPaintListener(this);
this.addPaintListener( paintListener );
}
-
+*/
/*
* Create a histogram mouse listener and bind it to this canvas.<p>
* Note : this mouse listener handle the mouse, the move and the wheel at once.
*
* @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasMouseListener
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class
protected void createAndAddMouseListener() {
mouseListener = new HistogramCanvasMouseListener(this);
this.addMouseListener(mouseListener);
this.addMouseMoveListener(mouseListener);
this.addMouseWheelListener(mouseListener);
}
+*/
/*
* Create a histogram key listener and bind it to this canvas.<p>
*
* @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasKeyListener
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class
protected void createAndAddKeyListener() {
keyListener = new HistogramCanvasKeyListener(this);
this.addKeyListener(keyListener);
}
-
+*/
/*
* Create a histogram focus listener and bind it to this canvas.<p>
*
@@ -116,17 +145,19 @@ public class HistogramCanvas extends Canvas
focusListener = new HistogramCanvasFocusListener(this);
this.addFocusListener(focusListener);
}
-
+
/*
* Create a histogram control listener and bind it to this canvas.<p>
*
* @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasControlListener
*/
+/*
+ // 2010-07-16 Yuriy: Moved to derived classes.
protected void createAndAddControlListener() {
controlListener = new HistogramCanvasControlListener(this);
this.addControlListener(controlListener);
}
-
+*/
/**
* Create a new HistogramContent for this HistogramCanvas<p>
* A new <I>empty</I> content will then be created.
@@ -150,13 +181,15 @@ public class HistogramCanvas extends Canvas
*
* @param windowTimeDuration Time width (in nanosecond) of the window.
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void createNewSelectedWindow(long windowTimeDuration) {
currentWindow = new HistogramSelectedWindow(histogramContent);
currentWindow.setWindowTimeWidth(windowTimeDuration);
currentWindow.setWindowXPositionCenter(0);
}
-
+*/
public HistogramContent getHistogramContent() {
return histogramContent;
}
@@ -168,18 +201,24 @@ public class HistogramCanvas extends Canvas
*
* @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramSelectedWindow
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public HistogramSelectedWindow getCurrentWindow() {
return currentWindow;
}
+*/
/**
* Getter for the selection window width<p>
*
* @return Time width (in nanosecond) of the selection window.
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public long getSelectedWindowSize() {
return currentWindow.getWindowTimeWidth();
}
+*/
/**
* Setter for the selection window width<p>
@@ -189,6 +228,8 @@ public class HistogramCanvas extends Canvas
*
* @param newSelectedWindowSize New time width (in nanosecond) of the selection window.
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void setSelectedWindowSize(long newSelectedWindowSize) {
if ( newSelectedWindowSize <= 0 ) {
@@ -200,7 +241,7 @@ public class HistogramCanvas extends Canvas
currentWindow.setWindowTimeWidth(newSelectedWindowSize);
}
-
+*/
/**
* Method to call the "Asynchronous redrawer" for this canvas<p>
* This allow safe redraw from different threads.
@@ -220,6 +261,8 @@ public class HistogramCanvas extends Canvas
* This allow safe update UI objects from different threads.
*
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void notifyParentSelectionWindowChangedAsynchronously() {
// Create a new redrawer in case it doesn't exist yet (we never know with thread!)
if ( canvasRedrawer == null ) {
@@ -228,6 +271,7 @@ public class HistogramCanvas extends Canvas
canvasRedrawer.asynchronousNotifyParentSelectionWindowChanged();
}
+*/
/**
* Method to call the "Asynchronous NotifyParentUpdatedInformation" for this canvas<p>
@@ -251,10 +295,13 @@ public class HistogramCanvas extends Canvas
*
* @param newRelativeXPosition New position relative to the last known absolute position.
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void moveWindow(int newRelativeXPosition) {
// Nothing : function is a place holder
}
-
+*/
+
/**
* Function that is called when the selection window is re-centered.<p>
* Note: Given position should be absolute to the window and need to be the selection window center.
@@ -263,9 +310,12 @@ public class HistogramCanvas extends Canvas
*
* @param newRelativeXPosition New absolute position.
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void setWindowCenterPosition(int newAbsoluteXPosition) {
// Nothing : function is a place holder
}
+*/
/**
* Function that is called when the selection window size (time width) changed by an absolute time.<p>
@@ -275,20 +325,25 @@ public class HistogramCanvas extends Canvas
*
* @param newTime New absoulte time (in nanoseconds) to apply to the window.
*/
+/*
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void resizeWindowByAbsoluteTime(long newTime) {
// Nothing : function is a place holder
}
-
+*/
/**
* Function that is called to tell the parent that the selection window changed.<p>
*
* <B>METHOD INTENDED TO BE EXTENDED</B>
*
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void notifyParentSelectionWindowChanged() {
// Nothing : function is a place holder
}
-
+*/
/**
* Function that is called to tell the parent that some information changed.<p>
*
@@ -298,6 +353,25 @@ public class HistogramCanvas extends Canvas
public void notifyParentUpdatedInformation() {
// Nothing : function is a place holder
}
+
+ /**
+ * Getter for View
+ *
+ * @return view instance
+ *
+ */
+ public static HistogramView getHistogramView() {
+ return histogramView;
+ }
+
+ /**
+ * Setter for View
+ *
+ * @param histogramView reference to object
+ */
+ public static void setHistogramView(HistogramView histogramView) {
+ HistogramCanvas.histogramView = histogramView;
+ }
}
@@ -329,12 +403,14 @@ class AsyncCanvasRedrawer {
*
*/
public void asynchronousRedraw() {
- Display display = parentCanvas.getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- parentCanvas.redraw();
- }
- });
+ if (parentCanvas != null) {
+ Display display = parentCanvas.getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ parentCanvas.redraw();
+ }
+ });
+ }
}
/**
@@ -343,14 +419,19 @@ class AsyncCanvasRedrawer {
* Basically, it just run "notifyParentSelectionWindowChanged()" in asyncExec.
*
*/
+/*
+ // 2010-07-16 Yuriy: Moved to parent histogram class.
public void asynchronousNotifyParentSelectionWindowChanged() {
- Display display = parentCanvas.getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- parentCanvas.notifyParentSelectionWindowChanged();
- }
- });
+ if(parentCanvas != null) {
+ Display display = parentCanvas.getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ parentCanvas.notifyParentSelectionWindowChanged();
+ }
+ });
+ }
}
+*/
/**
* Function to asynchonously notify the parent of the related canvas that information changed.<p>
@@ -359,11 +440,13 @@ class AsyncCanvasRedrawer {
*
*/
public void asynchronousNotifyParentUpdatedInformation() {
- Display display = parentCanvas.getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- parentCanvas.notifyParentUpdatedInformation();
- }
- });
+ if(parentCanvas != null) {
+ Display display = parentCanvas.getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ parentCanvas.notifyParentUpdatedInformation();
+ }
+ });
+ }
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java
index f361717efb..e811eaf8b3 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Base class simplification
+ *******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.histogram;
import org.eclipse.swt.events.ControlEvent;
@@ -11,7 +23,13 @@ import org.eclipse.swt.events.ControlListener;
*/
public class HistogramCanvasControlListener implements ControlListener {
- protected HistogramCanvas parentCanvas = null;
+ private HistogramCanvas ourCanvas = null;
+
+ /**
+ * HistogramCanvasControlListener default constructor
+ */
+ public HistogramCanvasControlListener() {
+ }
/**
* HistogramCanvasControlListener constructor
@@ -19,7 +37,7 @@ public class HistogramCanvasControlListener implements ControlListener {
* @param newCanvas Related canvas
*/
public HistogramCanvasControlListener(HistogramCanvas newCanvas) {
- parentCanvas = newCanvas;
+ ourCanvas = newCanvas;
}
@@ -31,33 +49,21 @@ public class HistogramCanvasControlListener implements ControlListener {
* @param event The controle event generated by the move.
*/
public void controlMoved(ControlEvent event) {
- parentCanvas.redraw();
+ ourCanvas.redraw();
}
/**
* Method called when the canvas is resized.<p>
*
- * We need to tell the content that the canvas size changed and to recenter the windows
+ * We need to tell the content that the canvas size changed
*
* @param event The control event generated by the resize.
*/
public void controlResized(ControlEvent event) {
- if ( (parentCanvas != null) && (parentCanvas.getHistogramContent() != null) ) {
- int newSize = parentCanvas.getSize().x;
- int oldSize = parentCanvas.getHistogramContent().getCanvasWindowSize();
-
+ if ( (ourCanvas != null) && (ourCanvas.getHistogramContent() != null) ) {
// Set the new canvas size
- parentCanvas.getHistogramContent().setCanvasWindowSize(newSize);
-
- // Try to recenter to window at the same place it was
- // Note : this is a best hope approach and is not intended to be precise;
- // the idea is to avoid issuing a (maybe) long request fo the selection window;
- // There WILL be slight discrepancy between the "window values" (timestamp, etc...) showed
- // and what it really points to. The user should reclick by himself to refresh it.
- int oldWindowCenter = parentCanvas.getCurrentWindow().getWindowXPositionCenter();
- int newWindowCenter = (int)Math.ceil((double)newSize * ((double)oldWindowCenter / (double)oldSize));
- parentCanvas.setWindowCenterPosition(newWindowCenter);
+ ourCanvas.getHistogramContent().setCanvasWindowSize(ourCanvas.getSize().x);
}
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasFocusListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasFocusListener.java
index 8bf3dffe0b..e9ccaccf5a 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasFocusListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasFocusListener.java
@@ -8,6 +8,9 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Heritage corrections.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -22,7 +25,7 @@ import org.eclipse.swt.events.FocusListener;
*/
public class HistogramCanvasFocusListener implements FocusListener {
- protected HistogramCanvas parentCanvas = null;
+ private HistogramCanvas ourCanvas = null;
/**
* HistogramCanvasFocusListener constructor
@@ -30,7 +33,7 @@ public class HistogramCanvasFocusListener implements FocusListener {
* @param newCanvas Related canvas
*/
public HistogramCanvasFocusListener(HistogramCanvas newCanvas) {
- parentCanvas = newCanvas;
+ ourCanvas = newCanvas;
}
/**
@@ -41,7 +44,7 @@ public class HistogramCanvasFocusListener implements FocusListener {
* @param event The focus event generated.
*/
public void focusGained(FocusEvent event) {
- parentCanvas.redrawAsynchronously();
+ ourCanvas.redrawAsynchronously();
}
/**
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java
index 84408e15ca..70632f1e6d 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java
@@ -23,15 +23,15 @@ import org.eclipse.swt.events.KeyListener;
*/
public class HistogramCanvasKeyListener implements KeyListener
{
- protected HistogramCanvas parentCanvas = null;
- protected boolean isShiftPressed = false;
+ private ParentHistogramCanvas parentCanvas = null;
+ private boolean isShiftPressed = false;
/**
* HistogramCanvasKeyListener constructor
*
* @param newCanvas Related canvas
*/
- public HistogramCanvasKeyListener(HistogramCanvas newCanvas) {
+ public HistogramCanvasKeyListener(ParentHistogramCanvas newCanvas) {
parentCanvas = newCanvas;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java
index c27715bcf4..e99be0e19c 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java
@@ -8,6 +8,10 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-06-20 Yuriy Vashchuk - Selection "red square" window optimisation.
+ * Null pointer exception correction.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -24,17 +28,18 @@ import org.eclipse.swt.events.MouseWheelListener;
*/
public class HistogramCanvasMouseListener implements MouseMoveListener, MouseListener, MouseWheelListener
{
- protected DelayedMouseScroll mouseScrollListener = null;
- protected HistogramCanvas parentCanvas = null;
+ private DelayedMouseScroll mouseScrollListener = null;
+ private ParentHistogramCanvas parentCanvas = null;
+ private int oldWindowXPositionCenter = 0;
- protected boolean isWindowMoving = false;
+ private boolean isWindowMoving = false;
/**
* HistogramCanvasMouseListener constructor
*
* @param newCanvas Related canvas
*/
- public HistogramCanvasMouseListener(HistogramCanvas newCanvas) {
+ public HistogramCanvasMouseListener(ParentHistogramCanvas newCanvas) {
parentCanvas = newCanvas;
}
@@ -45,7 +50,8 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
* @param event The generated mouse event when the mouse moved.
*/
public void mouseMove(MouseEvent event) {
- if ( isWindowMoving == true ) {
+ if ( parentCanvas.getHistogramContent() != null && isWindowMoving == true ) {
+
parentCanvas.setWindowCenterPosition(event.x);
}
}
@@ -57,8 +63,10 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
* @param event The generated mouse event when the mouse button was pressed.
*/
public void mouseDown(MouseEvent event) {
- if ( event.button == 1) {
+ if ( parentCanvas.getHistogramContent() != null && event.button == 1) {
isWindowMoving = true;
+
+ oldWindowXPositionCenter = parentCanvas.getCurrentWindow().getWindowXPositionCenter();
parentCanvas.setWindowCenterPosition(event.x);
}
}
@@ -70,9 +78,12 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
* @param event The generated mouse event when the mouse button was released.
*/
public void mouseUp(MouseEvent event) {
- if ( event.button == 1) {
+ if ( parentCanvas.getHistogramContent() != null && event.button == 1) {
isWindowMoving = false;
- parentCanvas.notifyParentSelectionWindowChangedAsynchronously();
+
+ if( oldWindowXPositionCenter != parentCanvas.getCurrentWindow().getWindowXPositionCenter()) {
+ parentCanvas.notifyParentSelectionWindowChangedAsynchronously();
+ }
}
}
@@ -114,33 +125,66 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
mouseScrollListener.decrementMouseScroll();
}
}
-
+
/**
- * Function that will be called at the end of the "wait time" for scroll events.<p>
* This will calculate the correct zoom time and call the canvas to resize its selection window.
*
* @param nbMouseScroll
+ * @return new window timerange
*/
- public void receiveMouseScrollCount(int nbMouseScroll) {
- mouseScrollListener = null;
+ public long receiveMouseScrollCount(int nbMouseScroll) {
- long ajustedTime = 0;
+ double ajustedTime = 0;
+ long selectedWindowSize = parentCanvas.getSelectedWindowSize();
// If we received Negative scroll event, ZoomOut by ZOOM_OUT_FACTOR * the number of scroll events received.
if ( nbMouseScroll < 0 ) {
- ajustedTime = (long)((double)parentCanvas.getSelectedWindowSize() * HistogramConstant.ZOOM_OUT_FACTOR);
+ ajustedTime = (double)selectedWindowSize * HistogramConstant.ZOOM_OUT_FACTOR;
ajustedTime = ajustedTime * Math.abs(nbMouseScroll);
- ajustedTime = parentCanvas.getSelectedWindowSize() + ajustedTime;
+ ajustedTime = selectedWindowSize + ajustedTime;
}
// If we received Positive scroll event, ZoomIn by ZOOM_IN_FACTOR * the number of scroll events received.
else {
- ajustedTime = (long)((double)parentCanvas.getSelectedWindowSize() * HistogramConstant.ZOOM_IN_FACTOR);
- ajustedTime = ajustedTime * Math.abs(nbMouseScroll);
- ajustedTime = parentCanvas.getSelectedWindowSize() - ajustedTime;
+ if(selectedWindowSize > 2) {
+ ajustedTime = (double)selectedWindowSize * HistogramConstant.ZOOM_IN_FACTOR;
+ ajustedTime = ajustedTime * Math.abs(nbMouseScroll);
+ ajustedTime = selectedWindowSize - ajustedTime;
+ }
}
- // Resize the canvas selection window
- parentCanvas.resizeWindowByAbsoluteTime(ajustedTime);
+ return (long)ajustedTime;
+
+ }
+
+ /**
+ * Function that will be called at the end of the "wait time" for scroll events.<p>
+ * This will calculate the correct zoom time and call the canvas to resize its selection window.
+ *
+ * @param nbMouseScroll
+ */
+ public void receiveMouseScrollCountWithNotification(int nbMouseScroll) {
+
+ if(parentCanvas.getHistogramContent() != null) {
+
+ mouseScrollListener = null;
+
+ // Resize the canvas selection window
+ parentCanvas.resizeWindowByAbsoluteTime( receiveMouseScrollCount(nbMouseScroll) );
+ }
+ }
+
+ /**
+ * Function that will be called on mouse scroll.<p>
+ * This will calculate the correct zoom time and call the canvas to resize its selection window.
+ *
+ * @param nbMouseScroll
+ */
+ public void receiveMouseScrollCountWithoutNotification(int nbMouseScroll) {
+ if(parentCanvas.getHistogramContent() != null) {
+
+ // Resize the canvas selection window
+ parentCanvas.resizeWindowByAbsoluteTimeWithoutNotification( receiveMouseScrollCount(nbMouseScroll) );
+ }
}
}
@@ -195,6 +239,7 @@ class DelayedMouseScroll extends Thread {
// Reset the wait timer
lastScrollTime = System.currentTimeMillis();
nbScrollClick++;
+ mouseListener.receiveMouseScrollCountWithoutNotification(nbScrollClick);
}
/**
@@ -207,6 +252,7 @@ class DelayedMouseScroll extends Thread {
// Reset the wait timer
lastScrollTime = System.currentTimeMillis();
nbScrollClick--;
+ mouseListener.receiveMouseScrollCountWithoutNotification(nbScrollClick);
}
/**
@@ -228,6 +274,6 @@ class DelayedMouseScroll extends Thread {
}
// Tell the mouse listener the number of click received
- mouseListener.receiveMouseScrollCount(nbScrollClick);
+ mouseListener.receiveMouseScrollCountWithNotification(nbScrollClick);
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java
index 5b5cc86b00..30acb440a4 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java
@@ -8,12 +8,18 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Heritage corrections. Redraw bug correction.
+ * Double Buffering implementation.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Rectangle;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
/**
* <b><u>HistogramCanvasPaintListener</u></b>
@@ -23,15 +29,21 @@ import org.eclipse.swt.graphics.Rectangle;
*/
public class HistogramCanvasPaintListener implements PaintListener
{
- protected HistogramCanvas parentCanvas = null;
+ private static ChildrenHistogramCanvas childrenCanvas = null;
+
+ /**
+ * HistogramCanvasPaintListener default constructor
+ */
+ public HistogramCanvasPaintListener() {
+ }
/**
* HistogramCanvasPaintListener constructor
*
* @param parentCanvas Related canvas
*/
- public HistogramCanvasPaintListener(HistogramCanvas newParentCanvas) {
- parentCanvas = newParentCanvas;
+ public HistogramCanvasPaintListener(ChildrenHistogramCanvas newCanvas) {
+ childrenCanvas = newCanvas;
}
/**
@@ -40,26 +52,46 @@ public class HistogramCanvasPaintListener implements PaintListener
* @param event The generated paint event when redraw is called.
*/
public void paintControl(PaintEvent event) {
-
- // First clear the whole canvas to have a clean section where to draw
- clearDrawingSection(event);
-
- // If the content is null or has rady to draw we quit the function here
- if ( (parentCanvas.getHistogramContent() == null) || (parentCanvas.getHistogramContent().getReadyUpToPosition() == 0) ) {
- return;
- }
-
- // Call the function that draw the bars
- drawHistogram(event);
-
- // Pinpoint a position if set
- if (parentCanvas.getHistogramContent().getSelectedEventTimeInWindow() > 0 ) {
- drawSelectedEventInWindow(event);
- }
-
- // If we have a selected window set to visible, call the function to draw it
- if ( (parentCanvas.getCurrentWindow() != null) && (parentCanvas.getCurrentWindow().getSelectedWindowVisible() == true) ) {
- drawSelectedWindow(event);
+
+ if (childrenCanvas.getSize().x > 0 && childrenCanvas.getSize().y > 0) {
+ Image image = (Image) childrenCanvas.getData("double-buffer-image");
+
+ // Creates new image only absolutely necessary.
+ if (image == null
+ || image.getBounds().width != childrenCanvas.getBounds().width
+ || image.getBounds().height != childrenCanvas.getBounds().height) {
+
+ image = new Image(
+ event.display,
+ childrenCanvas.getBounds().width,
+ childrenCanvas.getBounds().height
+ );
+
+ childrenCanvas.setData("double-buffer-image", image);
+ }
+
+ // Initializes the graphics context of the image.
+ GC imageGC = new GC(image);
+
+ // First clear the whole canvas to have a clean section where to draw
+ clearDrawingSection(imageGC, image, childrenCanvas);
+
+ // If the content is null or has rady to draw we quit the function here
+ if ( (childrenCanvas.getHistogramContent() != null) && (childrenCanvas.getHistogramContent().getReadyUpToPosition() != 0) ) {
+
+ // Call the function that draw the bars
+ drawHistogram(imageGC, image);
+
+ // Pinpoint a position if set
+ if (childrenCanvas.getHistogramContent().getSelectedEventTimeInWindow() > 0 ) {
+ drawSelectedEventInWindow(imageGC, image);
+ }
+
+ // Draws the buffer image onto the canvas.
+ event.gc.drawImage(image, 0, 0);
+ }
+
+ imageGC.dispose();
}
}
@@ -67,14 +99,16 @@ public class HistogramCanvasPaintListener implements PaintListener
* Clear the drawing section of the canvas<p>
* This paint the whole background in EMPTY_BACKGROUND_COLOR, so we have something clean to draw on.
*
- * @param event The generated paint event when redraw is called.
+ * @param imageGC GC content.
+ * @param image Image content.
+ * @param ourCanvas Canvas to clean.
*/
- public void clearDrawingSection(PaintEvent event) {
- event.gc.setForeground(event.display.getSystemColor(HistogramConstant.EMPTY_BACKGROUND_COLOR));
- event.gc.setBackground(event.display.getSystemColor(HistogramConstant.EMPTY_BACKGROUND_COLOR));
- Rectangle allSection = new Rectangle(0, 0, event.width, event.height);
- event.gc.fillRectangle(allSection);
- event.gc.drawRectangle(allSection);
+ public void clearDrawingSection(GC imageGC, Image image, HistogramCanvas ourCanvas) {
+ imageGC.setBackground(ourCanvas.getDisplay().getSystemColor(HistogramConstant.EMPTY_BACKGROUND_COLOR));
+ imageGC.setForeground(ourCanvas.getDisplay().getSystemColor(HistogramConstant.EMPTY_BACKGROUND_COLOR));
+
+ // Fills background.
+ imageGC.fillRectangle(0, 0, image.getBounds().width + 1, image.getBounds().height + 1);
}
// *** VERIFY ***
@@ -85,83 +119,51 @@ public class HistogramCanvasPaintListener implements PaintListener
* Use existing elements in HistogramContent to draw bars on the cancas;
* the element table in content need to be populated and have consistent value.
*
- * @param event The generated paint event when redraw is called.
+ * @param imageGC GC content.
+ * @param image image content.
*/
- public synchronized void drawHistogram(PaintEvent event) {
- HistogramContent tmpContent = parentCanvas.getHistogramContent();
- int tmpBarWidth = tmpContent.getBarsWidth();
+ public synchronized void drawHistogram(GC imageGC, Image image) {
// This will be the color for all the bars that wil be draw below.
- event.gc.setBackground(event.display.getSystemColor(HistogramConstant.HISTOGRAM_BARS_COLOR));
+ imageGC.setBackground(childrenCanvas.getDisplay().getSystemColor(HistogramConstant.HISTOGRAM_BARS_COLOR));
// *** NOTE ***
// Y Position in a canvas is REVERSED, so "0" is on top of the screen and "MAX" is on bottom.
// Not very instinctive, isn't it?
// Draw a bar from the left (pos X=0) until the pos=(NbBars*barWidth). If space is left, it will be blanked after.
- for ( int x=0; x<tmpContent.getReadyUpToPosition(); x++) {
- Rectangle rect = new Rectangle(tmpBarWidth*x, event.height - tmpContent.getElementByIndex(x).intervalHeight, tmpBarWidth, tmpContent.getElementByIndex(x).intervalHeight);
- event.gc.fillRectangle(rect);
+ for ( int x = 0; x < childrenCanvas.getHistogramContent().getReadyUpToPosition(); x++) {
+ imageGC.fillRectangle(
+ childrenCanvas.getHistogramContent().getBarsWidth() * x,
+ image.getBounds().height - childrenCanvas.getHistogramContent().getElementByIndex(x).intervalHeight,
+ childrenCanvas.getHistogramContent().getBarsWidth(),
+ childrenCanvas.getHistogramContent().getElementByIndex(x).intervalHeight
+ );
}
-
- // Clear the remaining space in the canvas (if any) so it appears clean.
- event.gc.setBackground(event.display.getSystemColor(HistogramConstant.EMPTY_BACKGROUND_COLOR));
- Rectangle rect = new Rectangle(tmpBarWidth*tmpContent.getNbElement(), 0, event.width, event.height);
- event.gc.fillRectangle(rect);
- }
-
- /**
- * Draw a certain event selected in the window.<p>
- *
- * @param event The generated paint event when redraw is called.
- */
- public synchronized void drawSelectedEventInWindow(PaintEvent event) {
- HistogramContent tmpContent = parentCanvas.getHistogramContent();
- int tmpBarWidth = tmpContent.getBarsWidth();
-
- // This will be the color for all the bars that wil be draw below.
- event.gc.setBackground(event.display.getSystemColor(HistogramConstant.SELECTED_EVENT_COLOR));
-
- int position = tmpContent.getClosestXPositionFromTimestamp(tmpContent.getSelectedEventTimeInWindow());
- Rectangle rect = new Rectangle(tmpBarWidth*position, 0, tmpBarWidth, event.height);
- event.gc.fillRectangle(rect);
}
/**
- * Draw the selection window in the canvas.<p>
- * This draw a square around the selected section with a crosshair in the middle.
- * The square cannot be smaller than "MINIMUM_WINDOW_WIDTH"
+ * Draw a certain event selected in the window.<p>
*
- * @param event The generated paint event when redraw is called.
+ * @param imageGC GC content.
+ * @param image image content.
*/
- public void drawSelectedWindow(PaintEvent event) {
- HistogramSelectedWindow tmpWindow = parentCanvas.getCurrentWindow();
+ public synchronized void drawSelectedEventInWindow(GC imageGC, Image image) {
- // Attributes (color and width) of the lines
- event.gc.setForeground(event.display.getSystemColor(HistogramConstant.SELECTION_WINDOW_COLOR));
- event.gc.setLineWidth(HistogramConstant.SELECTION_LINE_WIDTH);
-
- // Get the window position... this would fail if the window is not initialized yet
- int positionCenter = tmpWindow.getWindowXPositionCenter();
- int positionLeft = tmpWindow.getWindowXPositionLeft();
- int positionRight = tmpWindow.getWindowXPositionRight();
+ final HistogramContent tmpContent = childrenCanvas.getHistogramContent();
+ final int tmpBarWidth = tmpContent.getBarsWidth();
+ final int position = tmpContent.getClosestXPositionFromTimestamp(tmpContent.getSelectedEventTimeInWindow());
- // Minimal size verification.
- if ( (positionRight - positionLeft) < HistogramConstant.MINIMUM_WINDOW_WIDTH ) {
- positionLeft = positionCenter - (HistogramConstant.MINIMUM_WINDOW_WIDTH/2);
- positionRight = positionCenter + (HistogramConstant.MINIMUM_WINDOW_WIDTH/2);
+ // This will be the color for all the bars that will be draw below.
+ imageGC.setForeground(childrenCanvas.getDisplay().getSystemColor(HistogramConstant.SELECTED_EVENT_COLOR));
+ imageGC.setLineWidth(HistogramConstant.SELECTION_LINE_WIDTH);
+ imageGC.drawLine(
+ tmpBarWidth * position,
+ 0,
+ tmpBarWidth * position,
+ image.getBounds().height
+ );
}
-
- // Draw the selection window square
- event.gc.drawLine(positionLeft , 0 , positionLeft , event.height);
- event.gc.drawLine(positionLeft , event.height, positionRight, event.height);
- event.gc.drawLine(positionRight, event.height, positionRight, 0);
- event.gc.drawLine(positionLeft , 0 , positionRight, 0);
-
- // Draw the crosshair section
- event.gc.drawLine(positionCenter + HistogramConstant.SELECTION_CROSSHAIR_LENGTH, event.height/2, positionCenter - HistogramConstant.SELECTION_CROSSHAIR_LENGTH, event.height/2);
- event.gc.drawLine(positionCenter, (event.height/2) + HistogramConstant.SELECTION_CROSSHAIR_LENGTH, positionCenter, (event.height/2) - HistogramConstant.SELECTION_CROSSHAIR_LENGTH);
- }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java
index 092a10d8a7..6c310f47c1 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java
@@ -41,7 +41,7 @@ public abstract class HistogramConstant {
// Constants relative to wait time while listening for scroll events
// "FULL" is time to wait to stop "to count" mouse scroll click events
// "INTERVAL" is time to wait between polling for scroll click events
- public final static long FULL_WAIT_MS_TIME_BETWEEN_MOUSE_SCROLL = 500L;
+ public final static long FULL_WAIT_MS_TIME_BETWEEN_MOUSE_SCROLL = 1000L;
public final static long INTERVAL_WAIT_MS_TIME_BETWEEN_POLL = 100L;
@@ -62,7 +62,7 @@ public abstract class HistogramConstant {
// Dimension for the line of the "Selection Window"
public final static int MINIMUM_WINDOW_WIDTH = 3;
public final static int SELECTION_LINE_WIDTH = 2;
- public final static int SELECTION_CROSSHAIR_LENGTH = 3;
+ public final static int SELECTION_CROSSHAIR_LENGTH = 6;
/**
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java
index 0959def0b6..c552b93984 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java
@@ -8,6 +8,9 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Heritage correction.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -21,38 +24,38 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
public class HistogramContent {
// Start and end time of the content
- protected long startTime = 0L;
- protected long endTime = 0L;
+ private long startTime = 0L;
+ private long endTime = 0L;
// Some information about the content
// Most of them are required to calculate position and/or draw
// Make sure they stay consistent!
- protected long elementsTimeInterval = 1L;
- protected double heightFactor = 100.0;
- protected long heighestEventCount = 0L;
- protected int maxHeight = 0;
- protected int canvasWindowSize = 0;
- protected int barsWidth = 0;
+ private long elementsTimeInterval = 1L;
+ private double heightFactor = 100.0;
+ private long heighestEventCount = 0L;
+ private int maxHeight = 0;
+ private int canvasWindowSize = 0;
+ private int barsWidth = 0;
// This value is used to calculate at which point we should "cut" bar that are too tall.
// Default value is large enought so that no bar should be cut
- protected double maxDifferenceToAverage = HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE;
+ private double maxDifferenceToAverage = HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE;
// This is a factor we might apply on the max difference to average, as example if we concatenate interval together
- protected double maxDifferenceFactor = 1.0;
+ private double maxDifferenceFactor = 1.0;
// By default we will only consider element up to this position
- protected int readyUpToPosition = 0;
+ private int readyUpToPosition = 0;
// The average number of events in the content
// Note : this IS needed to draw
- protected int averageNumberOfEvents = 0;
+ private int averageNumberOfEvents = 0;
// This is to draw the selected event of the TMF framework in another color
// Set the 0 to ignore
- protected long selectedEventTimeInWindow = -1L;
+ private long selectedEventTimeInWindow = -1L;
// The table that hold the elements
- protected HistogramElement[] elementTable;
+ private HistogramElement[] elementTable;
/**
@@ -135,7 +138,6 @@ public class HistogramContent {
* @param newEndTime The new stop time to use
*/
public void resetTable(long newStartTime, long newEndTime) {
- recalculateElementsTimeInterval(newStartTime, newEndTime);
resetTable(newStartTime, newEndTime, elementsTimeInterval);
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java
index 9d43a7ddb8..4426326b5a 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java
@@ -8,6 +8,9 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Heritage correction.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -23,18 +26,22 @@ import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
* <p>
*/
public class HistogramRequest extends TmfEventRequest<LttngEvent> {
- protected HistogramContent histogramContent = null;
+/*
+ private HistogramContent histogramContent = null;
+*/
- protected int lastInterval = 0;
- protected long lastRangeTime = 0L;
- protected long nbEventsInInterval = 0L;
+ private int lastInterval = 0;
+ private long lastRangeTime = 0L;
+ private long nbEventsInInterval = 0L;
- protected int nbIntervalNotEmpty = 1;
- protected int nbEventRead = 0;
+ private int nbIntervalNotEmpty = 1;
+ private int nbEventRead = 0;
- protected int lastDrawPosition = 0;
+ private int lastDrawPosition = 0;
- protected HistogramCanvas parentCanvas = null;
+ private HistogramCanvas parentCanvas = null;
+
+ private boolean isCompleted = false;
/**
* Constructor for HistogramRequest.<p>
@@ -50,17 +57,18 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
public HistogramRequest(TmfTimeRange range, int nbRequested, HistogramCanvas newParentCanvas, long timeInterval, ITmfDataRequest.ExecutionType execType) {
super((Class<LttngEvent>)LttngEvent.class, range, nbRequested, HistogramConstant.MAX_EVENTS_PER_READ, execType);
+ setIsCompleted(false);
+
// *** FIXME ***
// This does not work! The request won't be processed or the number of events returned is wrong!
// We cannot use this !
//super((Class<LttngEvent>)dataType, range);
parentCanvas = newParentCanvas;
- histogramContent = parentCanvas.getHistogramContent();
// Reset the content of the HistogramContent... the given data better be valid or this will fail.
- histogramContent.clearContentData();
- histogramContent.resetTable(range.getStartTime().getValue(), range.getEndTime().getValue(), timeInterval);
+ parentCanvas.getHistogramContent().clearContentData();
+ parentCanvas.getHistogramContent().resetTable(range.getStartTime().getValue(), range.getEndTime().getValue(), timeInterval);
lastRangeTime = range.getStartTime().getValue();
@@ -86,24 +94,26 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
if (event != null) {
LttngEvent tmpEvent = (LttngEvent) event;
+
+// Tracer.trace("Hst: " + event.getTimestamp());
// This check is linked to the evil fix mentionned above
- if ( ( tmpEvent.getTimestamp().getValue() >= histogramContent.getStartTime() ) &&
- ( tmpEvent.getTimestamp().getValue() <= histogramContent.getEndTime() ) )
+ if ( ( tmpEvent.getTimestamp().getValue() >= parentCanvas.getHistogramContent().getStartTime() ) &&
+ ( tmpEvent.getTimestamp().getValue() <= parentCanvas.getHistogramContent().getEndTime() ) )
{
// Distance (in time) between this event and the last one we read
long distance = ( tmpEvent.getTimestamp().getValue() - lastRangeTime );
// Check if we changed of interval (the distance is higher than the interval time)
- if ( distance > histogramContent.getElementsTimeInterval() ) {
+ if ( distance > parentCanvas.getHistogramContent().getElementsTimeInterval() ) {
- histogramContent.getElementByIndex(lastInterval).intervalNbEvents = nbEventsInInterval;
+ parentCanvas.getHistogramContent().getElementByIndex(lastInterval).intervalNbEvents = nbEventsInInterval;
lastRangeTime = tmpEvent.getTimestamp().getValue();
// * NOTE *
// We can skip several interval at once, so we need to find what was our interval now
- lastInterval = (int)((lastRangeTime - histogramContent.getStartTime()) / histogramContent.getElementsTimeInterval() );
+ lastInterval = (int)((lastRangeTime - parentCanvas.getHistogramContent().getStartTime()) / parentCanvas.getHistogramContent().getElementsTimeInterval() );
// *** HACK ***
// Because of the threads, weird phenomenons seem to happen here, like a position after the
@@ -112,14 +122,14 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
if ( lastInterval < 0 ) {
lastInterval = 0;
}
- else if ( lastInterval >= histogramContent.getNbElement() ) {
- lastInterval = (histogramContent.getNbElement()-1);
+ else if ( lastInterval >= parentCanvas.getHistogramContent().getNbElement() ) {
+ lastInterval = (parentCanvas.getHistogramContent().getNbElement()-1);
}
// * NOTE *
// We save the time we have here. This mean only the FIRST time read in an interval will be saved.
- histogramContent.getElementByIndex(lastInterval).firstIntervalTimestamp = lastRangeTime;
- histogramContent.setReadyUpToPosition(lastInterval);
+ parentCanvas.getHistogramContent().getElementByIndex(lastInterval).firstIntervalTimestamp = lastRangeTime;
+ parentCanvas.getHistogramContent().setReadyUpToPosition(lastInterval);
nbIntervalNotEmpty++;
nbEventsInInterval = 1L;
@@ -129,8 +139,8 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
nbEventsInInterval++;
}
- if ( nbEventsInInterval > histogramContent.getHeighestEventCount() ) {
- histogramContent.setHeighestEventCount(nbEventsInInterval);
+ if ( nbEventsInInterval > parentCanvas.getHistogramContent().getHeighestEventCount() ) {
+ parentCanvas.getHistogramContent().setHeighestEventCount(nbEventsInInterval);
}
nbEventRead++;
@@ -145,9 +155,9 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
// Save the last interval we had, so we won't miss the very last events at the end.
else {
// Save the last events
- histogramContent.getElementByIndex(lastInterval).intervalNbEvents = nbEventsInInterval;
+ parentCanvas.getHistogramContent().getElementByIndex(lastInterval).intervalNbEvents = nbEventsInInterval;
// We reached the end of the request, so assume we fill up the content as well
- histogramContent.setReadyUpToPosition(histogramContent.getNbElement());
+ parentCanvas.getHistogramContent().setReadyUpToPosition(parentCanvas.getHistogramContent().getNbElement());
// If the interval wasn't null, count this as a "non empty" interval
if (nbEventsInInterval > 0) {
@@ -162,25 +172,28 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
*/
@Override
public void handleCompleted() {
+ setIsCompleted(true);
parentCanvas.notifyParentUpdatedInformationAsynchronously();
redrawAsyncronously();
+ super.handleCompleted();
+// System.out.println(System.currentTimeMillis() + ": HistogramView (" + ((getExecType() == ExecutionType.LONG) ? "long" : "short") + ") completed");
}
- /**
- * Function that is called when the request completed successfully.<p>
- */
- @Override
- public void handleSuccess() {
- // Nothing different from completed.
- }
+// /**
+// * Function that is called when the request completed successfully.<p>
+// */
+// @Override
+// public void handleSuccess() {
+// // Nothing different from completed.
+// }
- /**
- * Function that is called when the request completed in failure.<p>
- */
- @Override
- public void handleFailure() {
- // Nothing different from cancel.
- }
+// /**
+// * Function that is called when the request completed in failure.<p>
+// */
+// @Override
+// public void handleFailure() {
+// // Nothing different from cancel.
+// }
/**
* Function that is called when the request was cancelled.<p>
@@ -203,24 +216,24 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
averageNumberOfEvents = (int)Math.ceil((double)nbEventRead / (double)nbIntervalNotEmpty);
}
else {
- averageNumberOfEvents = (int)Math.ceil((double)nbEventRead / (double)histogramContent.getNbElement());
+ averageNumberOfEvents = (int)Math.ceil((double)nbEventRead / (double)parentCanvas.getHistogramContent().getNbElement());
}
- histogramContent.setAverageNumberOfEvents(averageNumberOfEvents);
+ parentCanvas.getHistogramContent().setAverageNumberOfEvents(averageNumberOfEvents);
// It is possible that the height factor didn't change;
// If not, we only need to redraw the updated section, no the whole content
// Save the actual height, recalculate the height and check if there was any changes
- double previousHeightFactor = histogramContent.getHeightFactor();
- histogramContent.recalculateHeightFactor();
- if ( histogramContent.getHeightFactor() != previousHeightFactor ) {
- histogramContent.recalculateEventHeight();
+ double previousHeightFactor = parentCanvas.getHistogramContent().getHeightFactor();
+ parentCanvas.getHistogramContent().recalculateHeightFactor();
+ if ( parentCanvas.getHistogramContent().getHeightFactor() != previousHeightFactor ) {
+ parentCanvas.getHistogramContent().recalculateEventHeight();
}
else {
- histogramContent.recalculateEventHeightInInterval(lastDrawPosition, histogramContent.getReadyUpToPosition());
+ parentCanvas.getHistogramContent().recalculateEventHeightInInterval(lastDrawPosition, parentCanvas.getHistogramContent().getReadyUpToPosition());
}
- lastDrawPosition = histogramContent.getReadyUpToPosition();
+ lastDrawPosition = parentCanvas.getHistogramContent().getReadyUpToPosition();
}
/**
@@ -231,5 +244,21 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
// Canvas redraw is already asynchronous
parentCanvas.redrawAsynchronously();
}
+
+ /**
+ * Getter for isCompleted variable
+ * @return true if the request is completed
+ */
+ public boolean getIsCompleted() {
+ return isCompleted;
+ }
+
+ /**
+ * Setter for isCompleted variable
+ * @param isCompleted value to set the completed flag
+ */
+ public void setIsCompleted(boolean isCompleted) {
+ this.isCompleted = isCompleted;
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java
index 562da82b90..cd8abadd2b 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java
@@ -8,6 +8,10 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Heritage correction and selection window
+ * optimisations.
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
@@ -27,22 +31,14 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
*/
public class HistogramSelectedWindow {
- protected int windowCenterPosition = 0;
- protected long windowTimeWidth = 0L;
-
- protected Boolean isSelectedWindowVisible = false;
-
- protected HistogramContent histogramContent = null;
-
- /**
- * Default constructor for HistogramSelectedWindow.<p>
- * Position and TimeWidth are both set to 0
- *
- * @param newTraceContent HistogramContent to read window's data from
- */
- public HistogramSelectedWindow(HistogramContent newTraceContent) {
- histogramContent = newTraceContent;
- }
+ private long timestampOfLeftPosition = 0;
+ private long timestampOfCenterPosition = 0;
+ private long timestampOfRightPosition = 0;
+ private long windowTimeWidth = 0L;
+ private int windowXPositionLeft = 0;
+ private int windowXPositionCenter = 0;
+ private int windowXPositionRight = 0;
+ private Boolean isSelectedWindowVisible = false;
/**
* Default constructor for HistogramSelectedWindow.<p>
@@ -52,33 +48,15 @@ public class HistogramSelectedWindow {
* @param centralPosition Central X Position of the selection window in the canvas (0 to canvasWidth)
* @param newWindowWidth Time width (size) of the window. (0 or greater)
*/
- public HistogramSelectedWindow(HistogramContent newTraceContent, int centralPosition, long newWindowWidth) {
- histogramContent = newTraceContent;
- windowCenterPosition = centralPosition;
- windowTimeWidth = newWindowWidth;
- }
-
- /**
- * Getter for the HistogramContent used by the window.<p>
- *
- * @return HistogramContent tied to this selection window.
- */
- public HistogramContent getTraceContent() {
- return histogramContent;
- }
-
- /**
- * Setter for the HistogramContent used by the window.<p>
- * This need to be a valid, initialized HistogramContent;
- * the data in the content are needed for positionning the window.
- *
- * @param newTraceContent A new HistogramContent
- */
- public void setTraceContent(HistogramContent newTraceContent) {
- this.histogramContent = newTraceContent;
+ public HistogramSelectedWindow(HistogramContent newTraceContent, long timestampOfLeftPosition, long newWindowWidth) {
+ if(newTraceContent != null) {
+ setWindowTimeWidth(newWindowWidth);
+ setTimestampOfLeftPosition(timestampOfLeftPosition);
+ setTimestampOfRightPosition(timestampOfLeftPosition + newWindowWidth);
+ setTimestampOfCenterPosition(timestampOfLeftPosition + newWindowWidth / 2);
+ }
}
-
/**
* Getter for the window visibility.<p>
*
@@ -118,95 +96,116 @@ public class HistogramSelectedWindow {
this.windowTimeWidth = newWindowTimeWidth;
}
-
/**
- * Getter for the central position of the window.<p>
+ * Getter for the timestamp of left border of the window.<p>
+ * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
*
- * @return Center X position of this window on the canvas.
+ * @return The left timestamp of the window, or 0 if it cannot compute it.
*/
- public int getWindowXPositionCenter() {
- return windowCenterPosition;
+ public long getTimestampOfLeftPosition() {
+ return timestampOfLeftPosition;
}
/**
- * Setter for the central position of the window.<p>
- * The new position need to be valid on the canvas (0 to canvasWidth).
- *
- * @param newPosCenter The new central position.
+ * Setter for the timestamp of left border of the window.<p>
+ * @param timestampOfLeftPosition The left timestamp of the window.
*/
- public void setWindowXPositionCenter(int newPosCenter) {
- this.windowCenterPosition = newPosCenter;
- }
+ public void setTimestampOfLeftPosition(long timestampOfLeftPosition) {
+ this.timestampOfLeftPosition = timestampOfLeftPosition;
+ }
/**
- * Getter for the left border of the window.<p>
- * Compute the position from the HistogramContent data; may return 0 if the content data are wrong.
+ * Getter for the timestamp of the center of the window.<p>
+ * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
*
- * @return The left position of the window, or 0 if it cannot compute it.
+ * @return The center timestamp of the window, or 0 if it cannot compute it.
*/
- public int getWindowXPositionLeft() {
-
- // If the timewidth is too small, we would pick the same position as the center one.
- // To avoid this, we take a "full interval" when the window size is too small
- if ( windowTimeWidth < histogramContent.getElementsTimeInterval() ) {
- // Use intervalTime and not intervalTime/2 to make sure we step into the next interval
- // Otherwise, if we are in the beginning of an interval, adding IntervalTime/2 could lead us into the same one
- // The rounding operation will then return a correct position
- return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, -(histogramContent.getElementsTimeInterval() ) );
- }
- else {
- return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, -(windowTimeWidth / 2) );
- }
+ public long getTimestampOfCenterPosition() {
+ return timestampOfCenterPosition;
}
-
+
/**
- * Getter for the right border of the window.<p>
- * Compute the position from the HistogramContent data; may return 0 if the content data are wrong.
- *
- * @return The right position of the window, or 0 if it cannot compute it.
+ * Setter for the timestamp of center border of the window.<p>
*/
- public int getWindowXPositionRight() {
- // If the timewidth is too small, we would pick the same position as the center one.
- // To avoid this, we take a "full interval" when the window size is too small
- if ( windowTimeWidth < histogramContent.getElementsTimeInterval() ) {
- // Use intervalTime and not intervalTime/2 to make sure we step into the next interval
- // Otherwise, if we are in the beginning of an interval, adding IntervalTime/2 could lead us into the same one
- // The rounding operation will then return a correct position
- return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, +(histogramContent.getElementsTimeInterval() ) );
- }
- else {
- return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, +(windowTimeWidth / 2) );
- }
-
+ public void setTimestampOfCenterPosition(long timestampOfCenterPosition) {
+ this.timestampOfCenterPosition = timestampOfCenterPosition;
}
/**
- * Getter for the timestamp of left border of the window.<p>
+ * Setter for the timestamp of center border of the window.<p>
+ */
+ public void setTimestampOfLeftCenterRightPositions(long timestampOfCenterPosition) {
+ this.timestampOfLeftPosition = timestampOfCenterPosition - windowTimeWidth / 2;
+ this.timestampOfCenterPosition = timestampOfCenterPosition;
+ this.timestampOfRightPosition = timestampOfCenterPosition + windowTimeWidth / 2;
+ }
+
+ /**
+ * Getter for the timestamp of right border of the window.<p>
* Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
*
- * @return The left timestamp of the window, or 0 if it cannot compute it.
+ * @return The right timestamp of the window, or 0 if it cannot compute it.
*/
- public long getTimestampOfLeftPosition() {
- return histogramContent.getClosestElementFromXPosition( getWindowXPositionLeft() ).firstIntervalTimestamp;
+ public long getTimestampOfRightPosition() {
+ return timestampOfRightPosition;
}
/**
- * Getter for the timestamp of the center of the window.<p>
- * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
+ * Setter for the timestamp of right border of the window.<p>
+ * @param timestampOfRightPosition The right timestamp of the window.
+ */
+ public void setTimestampOfRightPosition(long timestampOfRightPosition) {
+ this.timestampOfRightPosition = timestampOfRightPosition;
+ }
+
+ /**
+ * Getter for the coordinate of left border of the window.<p>
*
- * @return The center timestamp of the window, or 0 if it cannot compute it.
+ * @return The left coordinate.
*/
- public long getTimestampOfCenterPosition() {
- return histogramContent.getClosestElementFromXPosition( getWindowXPositionCenter() ).firstIntervalTimestamp;
+ public int getWindowXPositionLeft() {
+ return windowXPositionLeft;
}
-
+
/**
- * Getter for the timestamp of right border of the window.<p>
- * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
+ * Setter for the coordinate of left border of the window.<p>
+ * @param windowXPositionLeft The left coordinate of the window.
+ */
+ public void setWindowXPositionLeft(int windowXPositionLeft) {
+ this.windowXPositionLeft = windowXPositionLeft;
+ }
+
+ /**
+ * Getter for the coordinate of center border of the window.<p>
*
- * @return The right timestamp of the window, or 0 if it cannot compute it.
+ * @return The center coordinate.
*/
- public long getTimestampOfRightPosition() {
- return histogramContent.getClosestElementFromXPosition( getWindowXPositionRight() ).firstIntervalTimestamp;
+ public int getWindowXPositionCenter() {
+ return windowXPositionCenter;
+ }
+
+ /**
+ * Setter for the coordinate of center of the window.<p>
+ * @param windowXPositionCenter The center coordinate of the window.
+ */
+ public void setWindowXPositionCenter(int windowXPositionCenter) {
+ this.windowXPositionCenter = windowXPositionCenter;
+ }
+
+ /**
+ * Getter for the coordinate of right border of the window.<p>
+ *
+ * @return The right coordinate.
+ */
+ public int getWindowXPositionRight() {
+ return windowXPositionRight;
+ }
+
+ /**
+ * Setter for the coordinate of right border of the window.<p>
+ * @param windowXPositionRight The right coordinate of the window.
+ */
+ public void setWindowXPositionRight(int windowXPositionRight) {
+ this.windowXPositionRight = windowXPositionRight;
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java
index 7c6f5da156..fed5e11450 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java
@@ -8,7 +8,14 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-06-10 Yuriy Vashchuk - GUI reorganisation, simplification and some
+ * related code improvements.
+ * 2010-06-20 Yuriy Vashchuk - Histograms optimisation.
+ * 2010-07-16 Yuriy Vashchuk - Histogram Canvas Heritage correction
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.histogram;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
@@ -20,7 +27,6 @@ import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
@@ -51,7 +57,7 @@ public class HistogramView extends TmfView implements ControlListener {
// *** TODO ***
// Here is what's left to do in this view
//
- // 1- Make sure the interval time is small enought on very big trace (bug 311930)
+ // 1- Make sure the interval time is small enough on very big trace (bug 311930)
// The interval time of the content is dynamically assigned from the screen width and trace duration.
// However, on very big trace (more than 1 hour), we could end up with time interval that are > 1 seconds,
// which is not very precise.
@@ -65,7 +71,7 @@ public class HistogramView extends TmfView implements ControlListener {
// All basic control should be subclassed to offer "Asynchronous" functions.
//
// 3- Implement a "preferences view" for the HistogramView (bug 311935)
- // There is a lot of ajustable preferences in the view, however there is no way to ajust them right now
+ // There is a lot of adjustable preferences in the view, however there is no way to adjust them right now
// at run time. There should be a view of some kind of "menu" to allow the user to change them while executing.
// Most of the pertinent values are in HistogramConstant.java or in this file.
@@ -74,30 +80,35 @@ public class HistogramView extends TmfView implements ControlListener {
// "Minimum" screen width size. On smaller screen, we will apply several space saving technique
private static final int SCREEN_SMALL_IF_SMALLER_THAN = 1600;
- // Size of the "fulll trace" canvas
+/*
+ // 2010-06-20 Yuriy: We will use the dynamic height.
+ // Size of the "full trace" canvas
private static final int FULL_TRACE_CANVAS_HEIGHT = 25;
+*/
private static final int FULL_TRACE_BAR_WIDTH = 1;
private static final double FULL_TRACE_DIFFERENCE_TO_AVERAGE = 1.5;
// Size of the "Selected Window" canvas
+/*
+ // 2010-06-20 Yuriy
private static final int SELECTED_WINDOW_CANVAS_WIDTH = 300;
private static final int SMALL_SELECTED_WINDOW_CANVAS_WIDTH = 200;
private static final int SELECTED_WINDOW_CANVAS_HEIGHT = 60;
+*/
private static final int SELECTED_WINDOW_BAR_WIDTH = 1;
private static final double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE = 10.0;
- // For the two "events" label (Max and min number of events in the selection), we force a width
+ // For the two "events" label (Max and Min number of events in the selection), we force a width
// This will prevent the control from moving horizontally if the number of events in the selection varies
private static final int NB_EVENTS_FIXED_WIDTH = 50;
-
// The "small font" height used to display time will be "default font" minus this constant
private static final int SMALL_FONT_MODIFIER = 2;
private static final int VERY_SMALL_FONT_MODIFIER = 4;
// *** TODO ***
// This need to be changed as soon the framework implement a "window"
- private static long DEFAULT_WINDOW_SIZE = (1L * 100 * 1000 * 1000); // 0.1sec
+ private static long DEFAULT_WINDOW_SIZE = (10L * 100 * 1000 * 1000); // 1sec
// The last experiment received/used by the view
private TmfExperiment<LttngEvent> lastUsedExperiment = null;
@@ -107,17 +118,15 @@ public class HistogramView extends TmfView implements ControlListener {
// Request and canvas for the "full trace" part
private HistogramRequest dataBackgroundFullRequest = null;
- private ParentHistogramCanvas fullExperimentCanvas = null;
+ private static ParentHistogramCanvas fullExperimentCanvas = null;
// Request and canvas for the "selected window"
private HistogramRequest selectedWindowRequest = null;
- private ChildrenHistogramCanvas selectedWindowCanvas = null;
+ private static ChildrenHistogramCanvas selectedWindowCanvas = null;
// Content of the timeTextGroup
// Since the user can modify them with erroneous value,
// we will keep track of the value internally
- private long selectedWindowTime = 0L;
- private long selectedWindowTimerange = 0L;
private long currentEventTime = 0L;
// *** All the UI control below
@@ -132,9 +141,11 @@ public class HistogramView extends TmfView implements ControlListener {
private Text txtWindowMaxNbEvents = null;
private Text txtWindowMinNbEvents = null;
- private static final String WINDOW_TIMERANGE_LABEL_TEXT = "Window Timerange ";
- private static final String WINDOW_CURRENT_TIME_LABEL_TEXT = "Cursor Centered on ";
- private static final String EVENT_CURRENT_TIME_LABEL_TEXT = "Current Event Time ";
+ // We move the time label to header from TimeTextGroup.java
+ protected static final String NANOSEC_LABEL = "(sec)";
+ private static final String WINDOW_TIMERANGE_LABEL_TEXT = "Window Timerange, " + NANOSEC_LABEL;
+ private static final String WINDOW_CURRENT_TIME_LABEL_TEXT = "Cursor Centered on, " + NANOSEC_LABEL;
+ private static final String EVENT_CURRENT_TIME_LABEL_TEXT = "Current Event Time, " + NANOSEC_LABEL;
private TimeTextGroup ntgTimeRangeWindow = null;
private TimeTextGroup ntgCurrentWindowTime = null;
private TimeTextGroup ntgCurrentEventTime = null;
@@ -168,33 +179,45 @@ public class HistogramView extends TmfView implements ControlListener {
// Calculate if we need "small screen" fixes
if ( parent.getDisplay().getBounds().width < SCREEN_SMALL_IF_SMALLER_THAN ) {
+
// A lot smaller font for timstampe
smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - VERY_SMALL_FONT_MODIFIER, tmpFontData.getStyle());
+/*
+ // 2010-06-20 Yuriy
// Smaller selection window canvas
selectedCanvasWidth = SMALL_SELECTED_WINDOW_CANVAS_WIDTH;
+*/
// Smaller event number text field
nbEventWidth = NB_EVENTS_FIXED_WIDTH/2;
// Tell the text group to ajust
doesTimeTextGroupNeedAdjustment = true;
- }
- else {
+
+ } else {
+
// Slightly smaller font for timestamp
smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - SMALL_FONT_MODIFIER, tmpFontData.getStyle());
// Usual size for selected window and event number text field
nbEventWidth = NB_EVENTS_FIXED_WIDTH;
+/*
+ // 2010-06-20 Yuriy
selectedCanvasWidth = SELECTED_WINDOW_CANVAS_WIDTH;
+*/
// No ajustement needed by the text group
doesTimeTextGroupNeedAdjustment = false;
+
}
+
+ /////////////////////////////////////////////////////////////////////////////////////
// Layout for the whole view, other elements will be in a child composite of this one
// Contains :
// Composite layoutSelectionWindow
// Composite layoutTimesSpinner
// Composite layoutExperimentHistogram
- Composite layoutFullView = new Composite(parent, SWT.NONE);
+ /////////////////////////////////////////////////////////////////////////////////////
+ Composite layoutFullView = new Composite(parent, SWT.FILL);
GridLayout gridFullView = new GridLayout();
gridFullView.numColumns = 2;
gridFullView.horizontalSpacing = 0;
@@ -202,32 +225,15 @@ public class HistogramView extends TmfView implements ControlListener {
gridFullView.marginHeight = 0;
gridFullView.marginWidth = 0;
layoutFullView.setLayout(gridFullView);
+
-
- // Layout that contain the SelectionWindow
- // Contains :
- // Label lblWindowStartTime
- // Label lblWindowStopTime
- // Label lblWindowMaxNbEvents
- // Label lblWindowMinNbEvents
- // ChildrenHistogramCanvas selectedWindowCanvas
- Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.NONE);
- GridLayout gridSelectionWindow = new GridLayout();
- gridSelectionWindow.numColumns = 3;
- gridSelectionWindow.marginHeight = 0;
- gridSelectionWindow.marginWidth = 0;
- gridSelectionWindow.horizontalSpacing = 0;
- gridSelectionWindow.verticalSpacing = 0;
- layoutSelectionWindow.setLayout(gridSelectionWindow);
- GridData gridDataSelectionWindow = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
- layoutSelectionWindow.setLayoutData(gridDataSelectionWindow);
-
-
+ /////////////////////////////////////////////////////////////////////////////////////
// Layout that contain the time spinner
// Contains :
// NanosecTextGroup spTimeRangeWindow
// NanosecTextGroup spCurrentWindowTime
// NanosecTextGroup spCurrentEventTime
+ /////////////////////////////////////////////////////////////////////////////////////
Composite layoutTimesSpinner = new Composite(layoutFullView, SWT.NONE);
GridLayout gridTimesSpinner = new GridLayout();
gridTimesSpinner.numColumns = 3;
@@ -236,75 +242,112 @@ public class HistogramView extends TmfView implements ControlListener {
gridTimesSpinner.horizontalSpacing = 0;
gridTimesSpinner.verticalSpacing = 0;
layoutTimesSpinner.setLayout(gridTimesSpinner);
- GridData gridDataTimesSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
- layoutTimesSpinner.setLayoutData(gridDataTimesSpinner);
+ GridData gridDataCurrentEvent = new GridData();
+ gridDataCurrentEvent.horizontalAlignment = SWT.LEFT;
+ gridDataCurrentEvent.verticalAlignment = SWT.CENTER;
+ ntgCurrentEventTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
+ ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
+
+ GridData gridDataTimeRange = new GridData();
+ gridDataCurrentEvent.horizontalAlignment = SWT.CENTER;
+ gridDataCurrentEvent.verticalAlignment = SWT.CENTER;
+ ntgTimeRangeWindow = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
+ ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
+
+ GridData gridDataCurrentWindow = new GridData();
+ gridDataCurrentEvent.horizontalAlignment = SWT.RIGHT;
+ gridDataCurrentEvent.verticalAlignment = SWT.CENTER;
+ ntgCurrentWindowTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
+ ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
- // Layout that contain the complete experiment histogram and related controls.
- // Contains :
- // Label lblExperimentStartTime
- // Label lblExperimentStopTime
- // ParentHistogramCanvas fullTraceCanvas
- Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.NONE);
- GridLayout gridExperimentHistogram = new GridLayout();
- gridExperimentHistogram.numColumns = 2;
- gridExperimentHistogram.marginHeight = 0;
- gridExperimentHistogram.marginWidth = 0;
- gridExperimentHistogram.horizontalSpacing = 0;
- gridExperimentHistogram.verticalSpacing = 0;
- layoutExperimentHistogram.setLayout(gridExperimentHistogram);
- GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
- layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
+ /////////////////////////////////////////////////////////////////////////////////////
+ // Layout that contain the SelectionWindow
+ // Contains :
+ // Label txtWindowStartTime
+ // Label txtWindowStopTime
+ // Label txtWindowMaxNbEvents
+ // Label txtWindowMinNbEvents
+ // ChildrenHistogramCanvas selectedWindowCanvas
+ /////////////////////////////////////////////////////////////////////////////////////
+ Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.FILL);
+ GridLayout gridSelectionWindow = new GridLayout();
+ gridSelectionWindow.numColumns = 3;
+ gridSelectionWindow.marginHeight = 0;
+ gridSelectionWindow.marginWidth = 0;
+ gridSelectionWindow.horizontalSpacing = 0;
+ gridSelectionWindow.verticalSpacing = 0;
+ layoutSelectionWindow.setLayout(gridSelectionWindow);
+ GridData gridDataSelectionWindow = new GridData();
+ gridDataSelectionWindow.horizontalAlignment = SWT.FILL;
+ gridDataSelectionWindow.verticalAlignment = SWT.FILL;
+ layoutSelectionWindow.setLayoutData(gridDataSelectionWindow);
- // *** Everything related to the selection window is below
- GridData gridDataSelectionWindowCanvas = new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 2);
+ GridData gridDataSelectionWindowCanvas = new GridData();
+ gridDataSelectionWindowCanvas.horizontalSpan = 2;
+ gridDataSelectionWindowCanvas.verticalSpan = 2;
+ gridDataSelectionWindowCanvas.horizontalAlignment = SWT.FILL;
+ gridDataSelectionWindowCanvas.grabExcessHorizontalSpace = true;
+ gridDataSelectionWindowCanvas.verticalAlignment = SWT.FILL;
+/*
+ // 2010-06-20 Yuriy
gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
+*/
gridDataSelectionWindowCanvas.widthHint = selectedCanvasWidth;
gridDataSelectionWindowCanvas.minimumWidth = selectedCanvasWidth;
selectedWindowCanvas = new ChildrenHistogramCanvas(this, layoutSelectionWindow, SWT.BORDER);
selectedWindowCanvas.setLayoutData(gridDataSelectionWindowCanvas);
- GridData gridDataWindowMaxEvents = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
+ GridData gridDataWindowMaxEvents = new GridData();
+ gridDataWindowMaxEvents.horizontalAlignment = SWT.RIGHT;
+ gridDataWindowMaxEvents.verticalAlignment = SWT.TOP;
// Force a width, to avoid the control to enlarge if the number of events change
gridDataWindowMaxEvents.minimumWidth = nbEventWidth;
txtWindowMaxNbEvents = new Text(layoutSelectionWindow, SWT.READ_ONLY);
txtWindowMaxNbEvents.setFont(smallFont);
txtWindowMaxNbEvents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
txtWindowMaxNbEvents.setEditable(false);
- txtWindowMaxNbEvents.setText("");
+ txtWindowMaxNbEvents.setText("0");
txtWindowMaxNbEvents.setLayoutData(gridDataWindowMaxEvents);
- GridData gridDataWindowMinEvents = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1);
+ GridData gridDataWindowMinEvents = new GridData();
+ gridDataWindowMinEvents.horizontalAlignment = SWT.RIGHT;
+ gridDataWindowMinEvents.verticalAlignment = SWT.BOTTOM;
// Force a width, to avoid the control to enlarge if the number of events change
gridDataWindowMinEvents.minimumWidth = nbEventWidth;
txtWindowMinNbEvents = new Text(layoutSelectionWindow, SWT.READ_ONLY);
txtWindowMinNbEvents.setFont(smallFont);
txtWindowMinNbEvents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
txtWindowMinNbEvents.setEditable(false);
- txtWindowMinNbEvents.setText("");
+ txtWindowMinNbEvents.setText("0");
txtWindowMinNbEvents.setLayoutData(gridDataWindowMinEvents);
- GridData gridDataWindowStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
+ GridData gridDataWindowStart = new GridData();
+ gridDataWindowStart.horizontalAlignment = SWT.LEFT;
+ gridDataWindowStart.verticalAlignment = SWT.BOTTOM;
txtWindowStartTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
txtWindowStartTime.setFont(smallFont);
txtWindowStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
txtWindowStartTime.setEditable(false);
- txtWindowStartTime.setText("");
+ txtWindowStartTime.setText("0.000000000");
txtWindowStartTime.setLayoutData(gridDataWindowStart);
- GridData gridDataWindowStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
+ GridData gridDataWindowStop = new GridData();
+ gridDataWindowStop.horizontalAlignment = SWT.RIGHT;
+ gridDataWindowStop.verticalAlignment = SWT.BOTTOM;
txtWindowStopTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
txtWindowStopTime.setFont(smallFont);
txtWindowStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
txtWindowStopTime.setEditable(false);
- txtWindowStopTime.setText("");
+ txtWindowStopTime.setText("0.000000000");
txtWindowStopTime.setLayoutData(gridDataWindowStop);
- GridData gridDataSpacer = new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1);
- gridDataSpacer.minimumWidth = nbEventWidth;
+
+/*
+ // 2010-06-10 Yuriy: NOT NEEDED AFTER GUI IMPROVEMENTS. WORK FINE WITOUT THIS HACK
// *** HACK ***
// To align properly AND to make sure the canvas size is fixed, we NEED to make sure all "section" of the
// gridlayout are taken (and if possible of a fixed size).
@@ -338,47 +381,73 @@ public class HistogramView extends TmfView implements ControlListener {
// to make the text "invisible", I have to keep it enabled (but read only), so it can be clicked on.
//
// Label uselessControlToByPassSWTStupidBug = new Label(layoutSelectionWindow, SWT.BORDER); // WON'T align correctly!!!
+ //GridData gridDataSpacer = new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1);
+ GridData gridDataSpacer = new GridData();
+ gridDataWindowStop.horizontalAlignment = SWT.FILL;
+ gridDataWindowStop.verticalAlignment = SWT.TOP;
+ gridDataSpacer.minimumWidth = nbEventWidth;
Text uselessControlToByPassSWTStupidBug = new Text(layoutSelectionWindow, SWT.READ_ONLY); // WILL align correctly!!!
uselessControlToByPassSWTStupidBug.setEditable(false);
uselessControlToByPassSWTStupidBug.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
uselessControlToByPassSWTStupidBug.setLayoutData(gridDataSpacer);
+*/
+ /////////////////////////////////////////////////////////////////////////////////////
+ // Layout that contain the complete experiment histogram and related controls.
+ // Contains :
+ // ParentHistogramCanvas fullExperimentCanvas
+ // Text txtExperimentStartTime
+ // Text txtExperimentStopTime
+ /////////////////////////////////////////////////////////////////////////////////////
+ Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.FILL);
- // *** Everything related to the time text group is below
- GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
- ntgCurrentEventTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
- ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
-
- GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
- ntgTimeRangeWindow = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
- ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
-
- GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
- ntgCurrentWindowTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
- ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
-
+ GridLayout gridExperimentHistogram = new GridLayout();
+ gridExperimentHistogram.numColumns = 2;
+ gridExperimentHistogram.marginHeight = 0;
+ gridExperimentHistogram.marginWidth = 0;
+ gridExperimentHistogram.horizontalSpacing = 0;
+ gridExperimentHistogram.verticalSpacing = 0;
+ layoutExperimentHistogram.setLayout(gridExperimentHistogram);
+/*
+ // 2010-06-10 Yuriy: NOT NEEDED AFTER GUI IMPROVEMENTS
+ GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
+*/
// *** Everything related to the experiment canvas is below
- GridData gridDataExperimentCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
+ GridData gridDataExperimentCanvas = new GridData();
+ gridDataExperimentCanvas.horizontalSpan = 2;
+ gridDataExperimentCanvas.horizontalAlignment = SWT.FILL;
+ gridDataExperimentCanvas.grabExcessHorizontalSpace = true;
+ gridDataExperimentCanvas.verticalAlignment = SWT.FILL;
+ gridDataExperimentCanvas.grabExcessVerticalSpace = true;
+/*
+ // 2010-06-20 Yuriy: We use the dynamic height.
gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT;
gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
+*/
fullExperimentCanvas = new ParentHistogramCanvas(this, layoutExperimentHistogram, SWT.BORDER);
fullExperimentCanvas.setLayoutData(gridDataExperimentCanvas);
+ layoutExperimentHistogram.setLayoutData(gridDataExperimentCanvas);
- GridData gridDataExperimentStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
+ GridData gridDataExperimentStart = new GridData();
+ gridDataExperimentStart.horizontalAlignment = SWT.LEFT;
+ gridDataExperimentStart.verticalAlignment = SWT.BOTTOM;
txtExperimentStartTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
txtExperimentStartTime.setFont(smallFont);
- txtExperimentStartTime.setText("");
+ txtExperimentStartTime.setText("0.000000000");
txtExperimentStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
txtExperimentStartTime.setEditable(false);
txtExperimentStartTime.setLayoutData(gridDataExperimentStart);
- GridData gridDataExperimentStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
+ GridData gridDataExperimentStop = new GridData();
+ gridDataExperimentStop.horizontalAlignment = SWT.RIGHT;
+ gridDataExperimentStop.verticalAlignment = SWT.BOTTOM;
txtExperimentStopTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
txtExperimentStopTime.setFont(smallFont);
- txtExperimentStopTime.setText("");
+ txtExperimentStopTime.setText("0.000000000");
txtExperimentStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
txtExperimentStopTime.setEditable(false);
txtExperimentStopTime.setLayoutData(gridDataExperimentStop);
@@ -417,6 +486,7 @@ public class HistogramView extends TmfView implements ControlListener {
createCanvasAndRequests(tmpExperiment);
}
+
// *** VERIFY ***
// Not sure what this should do since I don't know when it will be called
// Let's do the same thing as experimentSelected for now
@@ -427,22 +497,24 @@ public class HistogramView extends TmfView implements ControlListener {
*
* @param signal Signal received from the framework. Contain the experiment.
*/
-// @SuppressWarnings("unchecked")
+/*
+ @SuppressWarnings("unchecked")
@TmfSignalHandler
public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
-//
-// TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
-//
-// // Make sure the UI object are sane
-// resetControlsContent();
-//
-// // Redraw the canvas right away to have something "clean" as soon as we can
-// fullExperimentCanvas.redraw();
-// selectedWindowCanvas.redraw();
-//
-// // Recreate the request
-// createCanvasAndRequests(tmpExperiment);
+
+ TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
+
+ // Make sure the UI object are sane
+ resetControlsContent();
+
+ // Redraw the canvas right away to have something "clean" as soon as we can
+ fullExperimentCanvas.redraw();
+ selectedWindowCanvas.redraw();
+
+ // Recreate the request
+ createCanvasAndRequests(tmpExperiment);
}
+*/
/**
* Method called when synchonization is active and that the user select an event.<p>
@@ -453,7 +525,7 @@ public class HistogramView extends TmfView implements ControlListener {
@TmfSignalHandler
public void currentTimeUpdated(TmfTimeSynchSignal signal) {
// In case we received our own signal
- if (signal.getSource() != this) {
+ if ( (signal != null) && (signal.getSource() != this) ) {
TmfTimestamp currentTime = signal.getCurrentTime();
// Update the current event controls
@@ -481,8 +553,8 @@ public class HistogramView extends TmfView implements ControlListener {
long windowTimeWidth = (windowEnd - windowStart);
// Recenter the window
- fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(windowStart + (windowTimeWidth/2)) );
fullExperimentCanvas.setSelectedWindowSize(windowTimeWidth);
+ fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(windowStart + (windowTimeWidth/2)) );
// *** HACK ***
// Views could send us incorrect current event value (event outside the current window)
@@ -516,18 +588,45 @@ public class HistogramView extends TmfView implements ControlListener {
// Create the content for the full experiment.
// This NEED to be created first, as we use it in the selectedWindowCanvas
- fullExperimentCanvas.createNewHistogramContent(fullExperimentCanvas.getSize().x, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE);
- fullExperimentCanvas.createNewSelectedWindow(DEFAULT_WINDOW_SIZE);
+ fullExperimentCanvas.createNewHistogramContent(
+ fullExperimentCanvas.getSize().x,
+ FULL_TRACE_BAR_WIDTH,
+/*
+ // 2010-06-20 Yuriy: We will use the dynamic height.
+ FULL_TRACE_CANVAS_HEIGHT
+*/
+ fullExperimentCanvas.getSize().y / 2,
+ FULL_TRACE_DIFFERENCE_TO_AVERAGE
+ );
TmfTimeRange timeRange = getExperimentTimeRange(newExperiment);
+
+ // We will take the half of the full experiment length in case of bigger window size than the full experiment length
+ if(timeRange.getEndTime().getValue() - timeRange.getStartTime().getValue() > DEFAULT_WINDOW_SIZE ) {
+ fullExperimentCanvas.createNewSelectedWindow(
+ timeRange.getStartTime().getValue(),
+ DEFAULT_WINDOW_SIZE
+ );
+ } else {
+ fullExperimentCanvas.createNewSelectedWindow(
+ timeRange.getStartTime().getValue(),
+ (timeRange.getEndTime().getValue() - timeRange.getStartTime().getValue() ) / 2
+ );
+ }
+
currentEventTime = timeRange.getStartTime().getValue();
// Set the window of the fullTrace canvas visible.
fullExperimentCanvas.getCurrentWindow().setSelectedWindowVisible(true);
fullExperimentCanvas.getHistogramContent().resetTable(timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue());
-
+
// Create the content for the selected window.
- selectedWindowCanvas.createNewHistogramContent(selectedWindowCanvas.getSize().x ,SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE);
+ selectedWindowCanvas.createNewHistogramContent(
+ selectedWindowCanvas.getSize().x,
+ SELECTED_WINDOW_BAR_WIDTH,
+ selectedWindowCanvas.getSize().y,
+ SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE
+ );
selectedWindowCanvas.getHistogramContent().resetTable(fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition(), fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition());
// Make sure the UI object are sane
@@ -547,7 +646,6 @@ public class HistogramView extends TmfView implements ControlListener {
// Perform both request.
// Order is important here, the small/synchronous request for the selection window should go first
performSelectedWindowEventsRequest(newExperiment);
-// performAllTraceEventsRequest(experimentCopy);
performAllTraceEventsRequest(newExperiment);
}
@@ -584,26 +682,43 @@ public class HistogramView extends TmfView implements ControlListener {
*/
public void performSelectedWindowEventsRequest(TmfExperiment<LttngEvent> experiment) {
- HistogramSelectedWindow curSelectedWindow = fullExperimentCanvas.getCurrentWindow();
-
- // If no selection window exists, we will try to create one;
- // however this will most likely fail as the content is probably not created either
- if ( curSelectedWindow == null ) {
- fullExperimentCanvas.createNewSelectedWindow( DEFAULT_WINDOW_SIZE );
- curSelectedWindow = fullExperimentCanvas.getCurrentWindow();
+ if(fullExperimentCanvas != null) {
+ HistogramSelectedWindow curSelectedWindow = fullExperimentCanvas.getCurrentWindow();
+
+ TmfTimeRange timeRange = getExperimentTimeRange(experiment);
+
+ // If no selection window exists, we will try to create one;
+ // however this will most likely fail as the content is probably not created either
+ if ( curSelectedWindow == null ) {
+ // We will take the half of the full experiment length in case of bigger window size than the full experiment length
+ if(timeRange.getEndTime().getValue() - timeRange.getStartTime().getValue() > DEFAULT_WINDOW_SIZE ) {
+ fullExperimentCanvas.createNewSelectedWindow(
+ timeRange.getStartTime().getValue(),
+ DEFAULT_WINDOW_SIZE
+ );
+ } else {
+ fullExperimentCanvas.createNewSelectedWindow(
+ timeRange.getStartTime().getValue(),
+ (timeRange.getEndTime().getValue() - timeRange.getStartTime().getValue() ) / 2
+ );
+ }
+ curSelectedWindow = fullExperimentCanvas.getCurrentWindow();
+ }
+
+ // The request will go from the Left timestamp of the window to the Right timestamp
+ // This assume that out-of-bound value are handled by the SelectionWindow itself
+ LttngTimestamp ts1 = new LttngTimestamp( curSelectedWindow.getTimestampOfLeftPosition() );
+ LttngTimestamp ts2 = new LttngTimestamp( curSelectedWindow.getTimestampOfRightPosition() );
+ TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
+
+ // Set a (dynamic) time interval
+ long intervalTime = ( (ts2.getValue() - ts1.getValue()) / selectedWindowCanvas.getHistogramContent().getNbElement() );
+
+ selectedWindowRequest = performRequest(experiment, selectedWindowCanvas, tmpRange, intervalTime,
+ ExecutionType.SHORT);
+ selectedWindowCanvas.redrawAsynchronously();
}
- // The request will go from the Left timestamp of the window to the Right timestamp
- // This assume that out-of-bound value are handled by the SelectionWindow itself
- LttngTimestamp ts1 = new LttngTimestamp( curSelectedWindow.getTimestampOfLeftPosition() );
- LttngTimestamp ts2 = new LttngTimestamp( curSelectedWindow.getTimestampOfRightPosition() );
- TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
-
- // Set a (dynamic) time interval
- long intervalTime = ( (ts2.getValue() - ts1.getValue()) / selectedWindowCanvas.getHistogramContent().getNbElement() );
-
- selectedWindowRequest = performRequest(experiment, selectedWindowCanvas, tmpRange, intervalTime, ExecutionType.LONG);
- selectedWindowCanvas.redrawAsynchronously();
}
/**
@@ -637,6 +752,12 @@ public class HistogramView extends TmfView implements ControlListener {
// Mean a completetly independant copy of the Expereiment would be done and we would proceed on that.
//
dataBackgroundFullRequest = performRequest(experiment, fullExperimentCanvas, tmpRange, intervalTime, ExecutionType.LONG);
+
+
+ fullExperimentCanvas.getCurrentWindow().setWindowXPositionLeft(fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition()));
+ fullExperimentCanvas.getCurrentWindow().setWindowXPositionCenter(fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition()));
+ fullExperimentCanvas.getCurrentWindow().setWindowXPositionRight(fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition()));
+
fullExperimentCanvas.redrawAsynchronously();
}
@@ -683,15 +804,13 @@ public class HistogramView extends TmfView implements ControlListener {
selectedWindowRequest.cancel();
}
- // Get the latest window information
- selectedWindowTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition();
- selectedWindowTimerange = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth();
-
- // If the current event time is outside the new window, change the current event
- // The new current event will be the one closest to the LEFT side of the new window
- if ( isGivenTimestampInSelectedWindow(currentEventTime) == false ) {
- currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition() );
- }
+ if(fullExperimentCanvas != null) {
+ // If the current event time is outside the new window, change the current event
+ // The new current event will be the one closest to the LEFT side of the new window
+ if ( isGivenTimestampInSelectedWindow(currentEventTime) == false ) {
+ currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition() );
+ }
+ }
// Perform a new request to read data about the new window
performSelectedWindowEventsRequest(lastUsedExperiment);
@@ -735,21 +854,16 @@ public class HistogramView extends TmfView implements ControlListener {
*/
public void sendTmfRangeSynchSignalBroadcast() {
-// System.out.println("sendTmfRangeSynchSignalBroadcast " + System.currentTimeMillis());
-
- // *** TODO ***
- // Not very elegant... we need to chance this below.
- //
- long centerTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition();
- long windowWidth = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth();
-
- long startTime = centerTime-windowWidth;
+ if (TmfExperiment.getCurrentExperiment() == null)
+ return;
+
+ long startTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition();
if ( startTime < fullExperimentCanvas.getHistogramContent().getStartTime() ) {
startTime = fullExperimentCanvas.getHistogramContent().getStartTime();
}
LttngTimestamp tmpStartTime = new LttngTimestamp(startTime);
- long endTime = centerTime+windowWidth;
+ long endTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition();
if ( endTime > fullExperimentCanvas.getHistogramContent().getEndTime() ) {
endTime = fullExperimentCanvas.getHistogramContent().getEndTime();
}
@@ -768,34 +882,36 @@ public class HistogramView extends TmfView implements ControlListener {
*/
public void timeTextGroupChangeNotification() {
- // Get all the time text group value
- long newCurrentTime = ntgCurrentEventTime.getValue();
- long newSelectedWindowTime = ntgCurrentWindowTime.getValue();
- long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue();
+ if(ntgCurrentEventTime != null) {
+ // If the user changed the current event time, call the notification
+ long newCurrentTime = ntgCurrentEventTime.getValue();
+ if ( newCurrentTime != currentEventTime ) {
+ currentEventChangeNotification( newCurrentTime );
+ // Send a broadcast to the framework about the window change
+ sendTmfTimeSynchSignalBroadcast();
+ }
+ }
- // If the user changed the current event time, call the notification
- if ( newCurrentTime != currentEventTime ) {
- currentEventChangeNotification( newCurrentTime );
- // Send a broadcast to the framework about the window change
- sendTmfTimeSynchSignalBroadcast();
+ if(ntgCurrentWindowTime != null && fullExperimentCanvas != null) {
+ // If the user changed the selected window time, recenter the window and call the notification
+ long newSelectedWindowTime = ntgCurrentWindowTime.getValue();
+ if ( newSelectedWindowTime != fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() ) {
+ fullExperimentCanvas.setWindowCenterPosition(newSelectedWindowTime);
+ windowChangedNotification();
+ // Send a broadcast to the framework about the window change
+ sendTmfRangeSynchSignalBroadcast();
+ }
}
- // If the user changed the selected window time, recenter the window and call the notification
- if ( newSelectedWindowTime != selectedWindowTime ) {
- selectedWindowTime = newSelectedWindowTime;
- fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(selectedWindowTime) );
- windowChangedNotification();
- // Send a broadcast to the framework about the window change
- sendTmfRangeSynchSignalBroadcast();
- }
-
- // If the user changed the selected window size, resize the window and call the notification
- if ( newSelectedWindowTimeRange != selectedWindowTimerange ) {
- selectedWindowTimerange = newSelectedWindowTimeRange;
- fullExperimentCanvas.resizeWindowByAbsoluteTime(selectedWindowTimerange);
- windowChangedNotification();
- // Send a broadcast to the framework about the window change
- sendTmfRangeSynchSignalBroadcast();
+ if(ntgTimeRangeWindow != null && fullExperimentCanvas != null) {
+ // If the user changed the selected window size, resize the window and call the notification
+ long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue();
+ if ( newSelectedWindowTimeRange != fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth() ) {
+ fullExperimentCanvas.resizeWindowByAbsoluteTime(newSelectedWindowTimeRange);
+ windowChangedNotification();
+ // Send a broadcast to the framework about the window change
+ sendTmfRangeSynchSignalBroadcast();
+ }
}
}
@@ -875,11 +991,13 @@ public class HistogramView extends TmfView implements ControlListener {
*/
public void updateFullExperimentInformation() {
- String startTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getStartTime() );
- String stopTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getEndTime() );
-
- txtExperimentStartTime.setText( startTime );
- txtExperimentStopTime.setText( stopTime );
+ if(fullExperimentCanvas != null) {
+ String startTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getStartTime() );
+ String stopTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getEndTime() );
+
+ txtExperimentStartTime.setText( startTime );
+ txtExperimentStopTime.setText( stopTime );
+ }
// Take one of the parent and call its layout to update control size
// Since both control have the same parent, only one call is needed
@@ -898,8 +1016,10 @@ public class HistogramView extends TmfView implements ControlListener {
// Update the timestamp as well
updateSelectedWindowTimestamp();
- txtWindowMaxNbEvents.setText( Long.toString(selectedWindowCanvas.getHistogramContent().getHeighestEventCount()) );
- txtWindowMinNbEvents.setText(Long.toString(0));
+ if(selectedWindowCanvas != null) {
+ txtWindowMaxNbEvents.setText( Long.toString(selectedWindowCanvas.getHistogramContent().getHeighestEventCount()) );
+ txtWindowMinNbEvents.setText(Long.toString(0));
+ }
// Refresh the layout
txtWindowMaxNbEvents.getParent().layout();
@@ -910,17 +1030,22 @@ public class HistogramView extends TmfView implements ControlListener {
* WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
*/
public void updateSelectedWindowTimestamp() {
- String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() );
- String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() );
- txtWindowStartTime.setText( startTime );
- txtWindowStopTime.setText( stopTime );
- ntgCurrentWindowTime.setValue( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() );
- ntgTimeRangeWindow.setValue( fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth() );
+ if(selectedWindowCanvas != null) {
+ String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() );
+ String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() );
+ txtWindowStartTime.setText( startTime );
+ txtWindowStopTime.setText( stopTime );
+ }
- // If the current event time is outside the selection window, recenter our window
- if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime.getValue()) == false ) {
- currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() );
+ if(fullExperimentCanvas != null) {
+ ntgCurrentWindowTime.setValue( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() );
+ ntgTimeRangeWindow.setValue( fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth() );
+
+ // If the current event time is outside the selection window, recenter our window
+ if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime.getValue()) == false ) {
+ currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() );
+ }
}
// Take one control in each group to call to refresh the layout
@@ -970,4 +1095,49 @@ public class HistogramView extends TmfView implements ControlListener {
}
}
+
+ /*
+ * Getter of FullExperimentCanvas
+ *
+ * @return FullExperimentCanvas object
+ */
+ public static ParentHistogramCanvas getFullExperimentCanvas() {
+ return fullExperimentCanvas;
+ }
+
+ /*
+ * Getter of SelectedWindowCanvas
+ *
+ * @return SelectedWindowCanvas object
+ */
+ public static ChildrenHistogramCanvas getSelectedWindowCanvas() {
+ return selectedWindowCanvas;
+ }
+
+
+ /*
+ * Getter of DEFAULT_WINDOW_SIZE
+ *
+ * @return DEFAULT_WINDOW_SIZE value
+ */
+ public static long getDEFAULT_WINDOW_SIZE() {
+ return DEFAULT_WINDOW_SIZE;
+ }
+
+ /**
+ * Getter for dataBackgroundFullRequest variable
+ * @return the dataBackgroundFullRequest instance
+ */
+ public HistogramRequest getDataBackgroundFullRequest() {
+ return dataBackgroundFullRequest;
+ }
+
+ /**
+ * Getter for selectedWindowRequest variable
+ * @return the selectedWindowRequest instance
+ */
+ public HistogramRequest getSelectedWindowRequest() {
+ return selectedWindowRequest;
+ }
+
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java
index cb2ce61ddc..30c71cd9b0 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java
@@ -8,10 +8,17 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-06-20 Yuriy Vashchuk - Histogram optimisations.
+ * 2010-07-16 Yuriy Vashchuk - Base Histogram class simplification.
+ * Selection Window related methods has been
+ * implemented here (Parent Histogram).
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.histogram;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
/**
* <b><u>ParentHistogramCanvas</u></b>
@@ -22,7 +29,12 @@ import org.eclipse.swt.widgets.Composite;
*/
public class ParentHistogramCanvas extends HistogramCanvas {
- protected HistogramView parentHistogramWindow = null;
+ private ParentHistogramCanvasPaintListener paintListener = null;
+ private HistogramCanvasMouseListener mouseListener = null;
+ private HistogramCanvasKeyListener keyListener = null;
+ private ParentHistogramCanvasControlListener controlListener = null;
+
+ private HistogramSelectedWindow currentWindow = null;
/**
* ParentHistogramCanvas constructor.<p>
@@ -31,10 +43,22 @@ public class ParentHistogramCanvas extends HistogramCanvas {
* @param parent Composite control which will be the parent of the new instance (cannot be null)
* @param Style the style of control to construct
*/
- public ParentHistogramCanvas(HistogramView newParentWindow, Composite parent, int style) {
- super(parent, style);
+ public ParentHistogramCanvas(HistogramView histogramView, Composite parent, int style) {
+ super(histogramView, parent, style);
+
+ // New selected window, not visible by default
+ if (histogramView !=null && HistogramView.getFullExperimentCanvas() != null) {
+ createNewSelectedWindow(
+ HistogramView.getFullExperimentCanvas().getHistogramContent().getStartTime() + HistogramView.getDEFAULT_WINDOW_SIZE() / 2,
+ HistogramView.getDEFAULT_WINDOW_SIZE()
+ );
+ }
- parentHistogramWindow = newParentWindow;
+ // 2010-06-20 Yuriy: Moved from parent class
+ createAndAddPaintListener();
+ createAndAddMouseListener();
+ createAndAddKeyListener();
+ createAndAddControlListener();
}
/**
@@ -78,6 +102,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
double maxBarsDiffFactor = ((double)contentSize / Math.pow(2, exp-1));
histogramContent.setMaxDifferenceToAverageFactor(maxBarsDiffFactor);
}
+
/*
* Create a histogram paint listener and bind it to this canvas.<p>
@@ -85,11 +110,94 @@ public class ParentHistogramCanvas extends HistogramCanvas {
* Note : This one is a bit particular, as it is made to draw content that is of a power of 2.
* The default one draw content that is relative to the real pixels size.
*/
- @Override
- protected void createAndAddPaintListener() {
- paintListener = new ParentHistogramCanvasPaintListener(this);;
+ private void createAndAddPaintListener() {
+ paintListener = new ParentHistogramCanvasPaintListener(this);
this.addPaintListener( paintListener );
}
+
+ /*
+ * Create a histogram mouse listener and bind it to this canvas.<p>
+ * Note : this mouse listener handle the mouse, the move and the wheel at once.
+ *
+ * @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasMouseListener
+ */
+ private void createAndAddMouseListener() {
+ mouseListener = new HistogramCanvasMouseListener(this);
+ this.addMouseListener(mouseListener);
+ this.addMouseMoveListener(mouseListener);
+ this.addMouseWheelListener(mouseListener);
+ }
+
+ /*
+ * Create a histogram key listener and bind it to this canvas.<p>
+ *
+ * @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasKeyListener
+ */
+ private void createAndAddKeyListener() {
+ keyListener = new HistogramCanvasKeyListener(this);
+ this.addKeyListener(keyListener);
+ }
+
+ /*
+ * Create a histogram control listener and bind it to this canvas.<p>
+ *
+ * @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramCanvasControlListener
+ */
+ private void createAndAddControlListener() {
+ controlListener = new ParentHistogramCanvasControlListener(this);
+ this.addControlListener(controlListener);
+ }
+
+ /**
+ * Create a new selection window of the size (time width) given.<p>
+ * The window initial position is at X = 0.
+ * The window is created hidden, it won't be draw unless it is set to visible.<p>
+ *
+ * @param windowTimeDuration Time width (in nanosecond) of the window.
+ */
+ public void createNewSelectedWindow(long timestampOfLeftPosition, long windowTimeDuration) {
+ currentWindow = new HistogramSelectedWindow(histogramContent, timestampOfLeftPosition, windowTimeDuration);
+ }
+
+ /**
+ * Getter for the selection window<p>
+ *
+ * @return the current selection window
+ *
+ * @see org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramSelectedWindow
+ */
+ public HistogramSelectedWindow getCurrentWindow() {
+ return currentWindow;
+ }
+
+ /**
+ * Getter for the selection window width<p>
+ *
+ * @return Time width (in nanosecond) of the selection window.
+ */
+ public long getSelectedWindowSize() {
+ return currentWindow.getWindowTimeWidth();
+ }
+
+ /**
+ * Setter for the selection window width<p>
+ * The window size will be ajusted if it does not respect one of these constraints :
+ * - The window size cannot be smaller than a single histogram content interval.<p>
+ * - The window size cannot be larger than twice the histogram content complete time interval.<p>
+ *
+ * @param newSelectedWindowSize New time width (in nanosecond) of the selection window.
+ */
+ public void setSelectedWindowSize(long newSelectedWindowSize) {
+
+ if ( newSelectedWindowSize <= 0 ) {
+ newSelectedWindowSize = 1L;
+ }
+ else if ( newSelectedWindowSize > (2*histogramContent.getCompleteTimeInterval()) ) {
+ newSelectedWindowSize = (2*histogramContent.getCompleteTimeInterval());
+ }
+
+ currentWindow.setWindowTimeWidth(newSelectedWindowSize);
+ }
/**
* Function that is called when the selection window is moved.<p>
@@ -100,14 +208,13 @@ public class ParentHistogramCanvas extends HistogramCanvas {
*
* @param newRelativeXPosition New position relative to the last known absolute position.
*/
- @Override
public void moveWindow(int newRelativeXPosition) {
int absolutePosition = currentWindow.getWindowXPositionCenter() + newRelativeXPosition;
setWindowCenterPosition(absolutePosition);
notifyParentSelectionWindowChangedAsynchronously();
}
-
+
/**
* Function that is called when the selection window is re-centered.<p>
* Note: Given position should be absolute to the window and need to be the selection window center.<p>
@@ -116,22 +223,132 @@ public class ParentHistogramCanvas extends HistogramCanvas {
*
* @param newRelativeXPosition New absolute position.
*/
- @Override
public void setWindowCenterPosition(int newAbsoluteXPosition) {
- if ( newAbsoluteXPosition < 0 ) {
- newAbsoluteXPosition = 0;
- }
- else if ( newAbsoluteXPosition > getParent().getSize().x ) {
- newAbsoluteXPosition = getParent().getSize().x;
+ // We will check if the coordinate the same
+ if ( newAbsoluteXPosition != currentWindow.getWindowXPositionCenter() ) {
+
+ long timestampOfLeftPosition = this.getHistogramContent().getClosestElementFromXPosition( newAbsoluteXPosition ).firstIntervalTimestamp - currentWindow.getWindowTimeWidth() / 2;
+ long timestampOfCenterPosition = 0;
+ long timestampOfRightPosition = 0;
+
+ // Let's do the border verifications
+ if ( timestampOfLeftPosition < histogramContent.getStartTime() ) {
+
+ timestampOfLeftPosition = histogramContent.getStartTime();
+ timestampOfCenterPosition = timestampOfLeftPosition + currentWindow.getWindowTimeWidth() / 2;
+ timestampOfRightPosition = timestampOfLeftPosition + currentWindow.getWindowTimeWidth();
+
+ } else {
+
+ timestampOfRightPosition = this.getHistogramContent().getClosestElementFromXPosition( newAbsoluteXPosition ).firstIntervalTimestamp + currentWindow.getWindowTimeWidth() / 2;
+
+ if ( timestampOfRightPosition > histogramContent.getEndTime() ) {
+
+ timestampOfRightPosition = histogramContent.getEndTime();
+ timestampOfCenterPosition = timestampOfRightPosition - currentWindow.getWindowTimeWidth() / 2;
+ timestampOfLeftPosition = timestampOfRightPosition - currentWindow.getWindowTimeWidth();
+
+ } else {
+
+ timestampOfCenterPosition = this.getHistogramContent().getClosestElementFromXPosition( newAbsoluteXPosition ).firstIntervalTimestamp;
+
+ }
+
+ }
+
+ // We will do the update in case of different center timestamp
+ if( timestampOfCenterPosition != currentWindow.getTimestampOfCenterPosition() ) {
+ // Firstly we will setup new left, right and center timestamps
+ currentWindow.setTimestampOfLeftPosition( timestampOfLeftPosition );
+ currentWindow.setTimestampOfCenterPosition( timestampOfCenterPosition );
+ currentWindow.setTimestampOfRightPosition( timestampOfRightPosition );
+
+ // After we will update coordonates using timestamps already recalculated
+ currentWindow.setWindowXPositionLeft( histogramContent.getClosestXPositionFromTimestamp(timestampOfLeftPosition) );
+ currentWindow.setWindowXPositionCenter( histogramContent.getClosestXPositionFromTimestamp(timestampOfCenterPosition) );
+ currentWindow.setWindowXPositionRight( histogramContent.getClosestXPositionFromTimestamp(timestampOfRightPosition) );
+
+ redrawAsynchronously();
+ }
}
+ }
+
+ /**
+ * Function that is called when the selection window is re-centered.<p>
+ * Note: Given position should be timestamp in the experiment timerange<p>
+ *
+ * Recenter the window and notify the HistogramView that the window changed.
+ *
+ * @param timestampOfCenterPosition New timestamp of center position.
+ */
+ public void setWindowCenterPosition(long timestampOfCenterPosition) {
- if ( newAbsoluteXPosition != currentWindow.getWindowXPositionCenter() ) {
- currentWindow.setWindowXPositionCenter(newAbsoluteXPosition);
- redrawAsynchronously();
+ // We will check if the coordinate the same
+ if ( timestampOfCenterPosition != currentWindow.getTimestampOfCenterPosition() ) {
+
+ long timestampOfLeft = timestampOfCenterPosition - currentWindow.getWindowTimeWidth() / 2;
+ long timestampOfCenter = 0;
+ long timestampOfRight = 0;
+
+ int windowXPositionLeft = histogramContent.getClosestXPositionFromTimestamp(timestampOfLeft);
+ int windowXPositionCenter = 0;
+ int windowXPositionRight = 0;
+
+ // Let's do the border verifications
+ if ( timestampOfLeft < histogramContent.getStartTime() ) {
+
+ timestampOfLeft = histogramContent.getStartTime();
+ timestampOfCenter = timestampOfLeft + currentWindow.getWindowTimeWidth() / 2;
+ timestampOfRight = timestampOfLeft + currentWindow.getWindowTimeWidth();
+
+ windowXPositionLeft = histogramContent.getClosestXPositionFromTimestamp(timestampOfLeft);
+ windowXPositionCenter = histogramContent.getClosestXPositionFromTimestamp(timestampOfCenter);
+ windowXPositionRight = histogramContent.getClosestXPositionFromTimestamp(timestampOfRight);
+
+ } else {
+
+ timestampOfRight = timestampOfCenterPosition + currentWindow.getWindowTimeWidth() / 2;
+ windowXPositionRight = histogramContent.getClosestXPositionFromTimestamp(timestampOfRight);
+
+ if ( windowXPositionRight > histogramContent.getEndTime() ) {
+
+ timestampOfRight = histogramContent.getEndTime();
+ timestampOfCenter = timestampOfRight - currentWindow.getWindowTimeWidth() / 2;
+ timestampOfLeft = timestampOfRight - currentWindow.getWindowTimeWidth();
+
+ windowXPositionLeft = histogramContent.getClosestXPositionFromTimestamp(timestampOfLeft);
+ windowXPositionCenter = histogramContent.getClosestXPositionFromTimestamp(timestampOfCenter);
+ windowXPositionRight = histogramContent.getClosestXPositionFromTimestamp(timestampOfRight);
+
+ } else {
+
+ timestampOfCenter = timestampOfCenterPosition;
+ windowXPositionCenter = histogramContent.getClosestXPositionFromTimestamp(timestampOfCenter);
+
+ }
+
+ }
+
+ // Firstly we will setup new left, right and center timestamps
+ currentWindow.setTimestampOfLeftPosition( timestampOfLeft );
+ currentWindow.setTimestampOfCenterPosition( timestampOfCenter );
+ currentWindow.setTimestampOfRightPosition( timestampOfRight );
+
+ // We will do the update in case of different center timestamp
+ if( windowXPositionCenter != currentWindow.getWindowXPositionCenter() ) {
+
+ // After we will update coordonates using timestamps already recalculated
+ currentWindow.setWindowXPositionLeft(windowXPositionLeft);
+ currentWindow.setWindowXPositionCenter(windowXPositionCenter);
+ currentWindow.setWindowXPositionRight(windowXPositionRight);
+
+ redrawAsynchronously();
+ }
}
}
+
/**
* Function that is called when the selection window size (time width) changed by an absolute time.<p>
* Note: Given time should be in nanoseconds, positive.
@@ -140,12 +357,74 @@ public class ParentHistogramCanvas extends HistogramCanvas {
*
* @param newTime New absoulte time (in nanoseconds) to apply to the window.
*/
- @Override
public void resizeWindowByAbsoluteTime(long newTime) {
if ( newTime != getSelectedWindowSize() ) {
- setSelectedWindowSize(newTime);
+
+ resizeWindowByAbsoluteTimeWithoutNotification(newTime);
notifyParentSelectionWindowChangedAsynchronously();
+ }
+ }
+
+ /**
+ * Function that is called when the selection window size (time width) changed by an absolute time.<p>
+ * Note: Given time should be in nanoseconds, positive.
+ *
+ * Set the new window size and notify the HistogramView that the window changed.
+ *
+ * @param newTime New absoulte time (in nanoseconds) to apply to the window.
+ */
+ public void resizeWindowByAbsoluteTimeWithoutNotification(long newTime) {
+
+ // We will change the size in case of delta (newTime) != 0
+ if (newTime != 0 ) {
+
+ if(newTime > getHistogramContent().getEndTime() - getHistogramContent().getStartTime()) {
+ newTime = getHistogramContent().getEndTime() - getHistogramContent().getStartTime();
+ }
+
+ setSelectedWindowSize(newTime);
+
+ /*
+ // Yuriy: we can't use this function because we change the left and right coordinates.
+ setWindowCenterPosition(currentWindow.getWindowXPositionCenter());
+ */
+
+ long timestampOfLeftPosition = currentWindow.getTimestampOfCenterPosition() - currentWindow.getWindowTimeWidth() / 2;
+ long timestampOfCenterPosition = currentWindow.getTimestampOfCenterPosition();
+ long timestampOfRightPosition = 0;
+
+ // Let's do the border verifications
+ if ( timestampOfLeftPosition < histogramContent.getStartTime() ) {
+
+ timestampOfLeftPosition = histogramContent.getStartTime();
+ timestampOfCenterPosition = timestampOfLeftPosition + currentWindow.getWindowTimeWidth() / 2;
+ timestampOfRightPosition = timestampOfLeftPosition + currentWindow.getWindowTimeWidth();
+
+ } else {
+
+ timestampOfRightPosition = currentWindow.getTimestampOfCenterPosition() + currentWindow.getWindowTimeWidth() / 2;
+
+ if ( timestampOfRightPosition > histogramContent.getEndTime() ) {
+
+ timestampOfRightPosition = histogramContent.getEndTime();
+ timestampOfCenterPosition = timestampOfRightPosition - currentWindow.getWindowTimeWidth() / 2;
+ timestampOfLeftPosition = timestampOfRightPosition - currentWindow.getWindowTimeWidth();
+
+ }
+
+ }
+
+ // Firstly we will setup new left, right and center timestamps
+ currentWindow.setTimestampOfLeftPosition( timestampOfLeftPosition );
+ currentWindow.setTimestampOfCenterPosition( timestampOfCenterPosition );
+ currentWindow.setTimestampOfRightPosition( timestampOfRightPosition );
+
+ // After we will update coordonates using timestamps already recalculated
+ currentWindow.setWindowXPositionLeft( histogramContent.getClosestXPositionFromTimestamp(timestampOfLeftPosition) );
+ currentWindow.setWindowXPositionCenter( histogramContent.getClosestXPositionFromTimestamp(timestampOfCenterPosition) );
+ currentWindow.setWindowXPositionRight( histogramContent.getClosestXPositionFromTimestamp(timestampOfRightPosition) );
+
redrawAsynchronously();
}
}
@@ -156,18 +435,46 @@ public class ParentHistogramCanvas extends HistogramCanvas {
*/
@Override
public void notifyParentUpdatedInformation() {
- parentHistogramWindow.updateFullExperimentInformation();
+ getHistogramView().updateFullExperimentInformation();
}
/**
* Notify the parent HistogramView that the SelectionWindow changed.<p>
* This is intended to be called when the window move or is resized.
*/
- @Override
public void notifyParentSelectionWindowChanged() {
// Notify the parent view that something changed
- parentHistogramWindow.windowChangedNotification();
+ getHistogramView().windowChangedNotification();
// Send a broadcast to the framework about the window change
- parentHistogramWindow.sendTmfRangeSynchSignalBroadcast();
+ getHistogramView().sendTmfRangeSynchSignalBroadcast();
}
+
+ /**
+ * Method to call the "Asynchronous NotifyParentSelectionWindowChanged" for this canvas<p>
+ * This allow safe update UI objects from different threads.
+ *
+ */
+ public void notifyParentSelectionWindowChangedAsynchronously() {
+ // Create a new redrawer in case it doesn't exist yet (we never know with thread!)
+ if ( canvasRedrawer == null ) {
+ canvasRedrawer = new AsyncCanvasRedrawer(this);
+ }
+
+ asynchronousNotifyParentSelectionWindowChanged();
+ }
+
+ /**
+ * Function to asynchonously notify the parent of the related canvas that the window changed.<p>
+ *
+ * Basically, it just run "notifyParentSelectionWindowChanged()" in asyncExec.
+ *
+ */
+ public void asynchronousNotifyParentSelectionWindowChanged() {
+ Display display = this.getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ notifyParentSelectionWindowChanged();
+ }
+ });
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasControlListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasControlListener.java
new file mode 100644
index 0000000000..ba5e4c6f56
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasControlListener.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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:
+ * 2010-06-20 Yuriy Vashchuk - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Base class simplification.
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.histogram;
+
+import org.eclipse.swt.events.ControlEvent;
+
+/**
+ * <b><u>ParentHistogramCanvasControlListener</u></b>
+ * <p>
+ * Implementation of a ControlListener for the need of the ParentHistogramCanvas
+ * <p>
+ */
+public class ParentHistogramCanvasControlListener extends HistogramCanvasControlListener {
+
+ private ParentHistogramCanvas ourCanvas = null;
+
+ /**
+ * ParentHistogramCanvasControlListenerl constructor
+ *
+ * @param newCanvas Related canvas
+ */
+ public ParentHistogramCanvasControlListener(ParentHistogramCanvas newCanvas) {
+ ourCanvas = newCanvas;
+ }
+
+
+ /**
+ * Method called when the canvas is resized.<p>
+ *
+ * We need to tell the content that the canvas size changed and to recenter the windows
+ *
+ * @param event The control event generated by the resize.
+ */
+ @Override
+ public void controlResized(ControlEvent event) {
+
+ if ( (ourCanvas != null) && (ourCanvas.getHistogramContent() != null) ) {
+ int newSize = ourCanvas.getSize().x;
+ int oldSize = ourCanvas.getHistogramContent().getCanvasWindowSize();
+
+ // Set the new canvas size
+ ourCanvas.getHistogramContent().setCanvasWindowSize(newSize);
+
+ // Try to recenter to window at the same place it was
+ // Note : this is a best hope approach and is not intended to be precise;
+ // the idea is to avoid issuing a (maybe) long request fo the selection window;
+ // There WILL be slight discrepancy between the "window values" (timestamp, etc...) showed
+ // and what it really points to. The user should reclick by himself to refresh it.
+ int oldWindowCenter = ourCanvas.getCurrentWindow().getWindowXPositionCenter();
+ int newWindowCenter = (int)Math.ceil((double)newSize * ((double)oldWindowCenter / (double)oldSize));
+ ourCanvas.setWindowCenterPosition(newWindowCenter);
+ }
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java
index 932aaecb37..f32cc5c5b9 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java
@@ -8,11 +8,18 @@
*
* Contributors:
* William Bourque - Initial API and implementation
+ *
+ * Modifications:
+ * 2010-07-16 Yuriy Vashchuk - Base class simplification. Redraw bug correction.
+ * Double Buffering implementation.
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.histogram;
import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.Rectangle;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
/**
* <b><u>HistogramCanvasPaintListener</u></b>
@@ -29,11 +36,17 @@ import org.eclipse.swt.graphics.Rectangle;
*/
public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintListener
{
- public ParentHistogramCanvasPaintListener(HistogramCanvas newParentCanvas) {
- super(newParentCanvas);
+ private static ParentHistogramCanvas parentCanvas = null;
+
+ /**
+ * ParentHistogramCanvasPaintListener constructor
+ *
+ * @param newCanvas Related canvas
+ */
+ public ParentHistogramCanvasPaintListener(ParentHistogramCanvas newCanvas) {
+ parentCanvas = newCanvas;
}
-
// *** VERIFY ***
// Is it good to put this synchronized?
//
@@ -47,23 +60,22 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
* @param event The generated paint event when redraw is called.
*/
@Override
- public synchronized void drawHistogram(PaintEvent event) {
- HistogramContent tmpContent = parentCanvas.getHistogramContent();
- int tmpBarWidth = tmpContent.getBarsWidth();
- int canvasSize = event.width;
+ public synchronized void drawHistogram(GC imageGC, Image image) {
+ final HistogramContent tmpContent = parentCanvas.getHistogramContent();
+ final int tmpBarWidth = tmpContent.getBarsWidth();
- event.gc.setBackground(event.display.getSystemColor(HistogramConstant.HISTOGRAM_BARS_COLOR));
+ imageGC.setBackground(parentCanvas.getDisplay().getSystemColor(HistogramConstant.HISTOGRAM_BARS_COLOR));
// Calculate the closest power of 2 just smaller than the canvas size
- int closestPowerToCanvas = (int)Math.pow(2, Math.floor( Math.log( canvasSize ) / Math.log(2.0) ));
+ final int closestPowerToCanvas = (int)Math.pow(2, Math.floor( Math.log( image.getBounds().width ) / Math.log(2.0) ));
// Make sure the canvas didn't change size, it which case we need to recalculate our heights
recalculateHeightIfCanvasSizeChanged();
// Calculate the factor of difference between canvas and the power
- double factor = (double)canvasSize / (double)closestPowerToCanvas;
+ final double factor = (double)image.getBounds().width / (double)closestPowerToCanvas;
// Calculate how many interval will need to be concatenated into one pixel
- int intervalDifference = (tmpContent.getNbElement() / closestPowerToCanvas)*tmpBarWidth;
+ final int intervalDifference = (tmpContent.getNbElement() / closestPowerToCanvas)*tmpBarWidth;
// This keep a link between the position in "power" and the pixel we draw
// I.e. correlation between position in the power ("fake" pixels) and the position in the canvas ("real" pixels)
@@ -73,18 +85,20 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
// Read from 0 up to the currently ready position
// We advance by "intervalDifference" as the bars migth not represent 1 interval only
+ int itemWidth = 0;
+ int thisElementHeight = 0;
for( int contentPos=0; contentPos < tmpContent.getReadyUpToPosition(); contentPos += intervalDifference ) {
// Width of the current item.
// Vary because of the difference between the power of 2 and the canvas size
// Ex: if power == 1024 and canvas == 1500, a bars every (1024/1500) will have a size of 2 instead of 1.
- int itemWidth = (int)( Math.ceil((double)(posInPower+1)*factor) - Math.ceil((double)posInPower*factor) );
- itemWidth = itemWidth*tmpBarWidth;
+ itemWidth = (int)( Math.ceil((double)(posInPower+1)*factor) - Math.ceil((double)posInPower*factor) );
+ itemWidth = itemWidth * tmpBarWidth;
// Concatenate all the element in the interval
// Ex : if power == 1024 and content == 2048, every (2048/1024)*bars_width will be concatenated
- int thisElementHeight = 0;
+ thisElementHeight = 0;
for ( int concatPos=0; concatPos<intervalDifference; concatPos++) {
- int updatedPos = contentPos + concatPos;
+ final int updatedPos = contentPos + concatPos;
// Make sure we don't cross the last element available.
if ( updatedPos < tmpContent.getReadyUpToPosition() ) {
thisElementHeight += tmpContent.getElementByIndex(contentPos + concatPos).intervalHeight;
@@ -96,8 +110,12 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
// Not very instinctive, isn't it?
// Draw our rectangle
- Rectangle rect = new Rectangle(widthFilled, event.height - thisElementHeight, itemWidth, thisElementHeight);
- event.gc.fillRectangle(rect);
+ imageGC.fillRectangle(
+ widthFilled,
+ image.getBounds().height - thisElementHeight,
+ itemWidth,
+ thisElementHeight
+ );
// Keep in a variable how much width we filld so far
widthFilled += itemWidth;
@@ -105,11 +123,6 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
// this is used to calculate the width of each element
posInPower++;
}
-
- // Clear the remaining space in the canvas (there should not be any) so it appears clean.
- event.gc.setBackground(event.display.getSystemColor(HistogramConstant.EMPTY_BACKGROUND_COLOR));
- Rectangle rect = new Rectangle(widthFilled, 0, event.width, event.height);
- event.gc.fillRectangle(rect);
}
/*
@@ -119,7 +132,7 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
* The factor might change if the canvas is resized by a big factor.<p>
*/
protected void recalculateHeightIfCanvasSizeChanged() {
- HistogramContent tmpContent = parentCanvas.getHistogramContent();
+ final HistogramContent tmpContent = parentCanvas.getHistogramContent();
// We need to ajust the "maxDifferenceToAverageFactor" as the bars we draw might be slitghly larger than the value asked
// Each "interval" are concatenated when draw so the worst case should be :
// contentSize / (closest power of 2 to canvasMaxSize)
@@ -127,9 +140,9 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
//
// His is set in the create content of the canvas, but we need to recalculate it
// here because the window might have been resized!
- int exp = (int)Math.floor( Math.log( (double)tmpContent.getCanvasWindowSize() ) / Math.log(2.0) );
- int contentSize = (int)Math.pow(2, exp);
- double maxBarsDiffFactor = ((double)tmpContent.getNbElement() / (double)contentSize );
+ final int exp = (int)Math.floor( Math.log( (double)tmpContent.getCanvasWindowSize() ) / Math.log(2.0) );
+ final int contentSize = (int)Math.pow(2, exp);
+ final double maxBarsDiffFactor = ((double)tmpContent.getNbElement() / (double)contentSize );
// Floating point comparaison :
// We consider it is different if the difference is greater than 10^-3
@@ -141,4 +154,92 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
}
}
+ /**
+ * Function called when the canvas need to redraw.<p>
+ *
+ * @param event The generated paint event when redraw is called.
+ */
+ @Override
+ public void paintControl(PaintEvent event) {
+
+ if (parentCanvas.getSize().x > 0 && parentCanvas.getSize().y > 0) {
+ Image image = (Image) parentCanvas.getData("double-buffer-image");
+
+ // Creates new image only absolutely necessary.
+ if (image == null
+ || image.getBounds().width != parentCanvas.getBounds().width
+ || image.getBounds().height != parentCanvas.getBounds().height) {
+
+ image = new Image(
+ event.display,
+ parentCanvas.getBounds().width,
+ parentCanvas.getBounds().height
+ );
+
+ parentCanvas.setData("double-buffer-image", image);
+ }
+
+ // Initializes the graphics context of the image.
+ GC imageGC = new GC(image);
+
+ // First clear the whole canvas to have a clean section where to draw
+ clearDrawingSection(imageGC, image, parentCanvas);
+
+ // If the content is null or has rady to draw we quit the function here
+ if ( (parentCanvas.getHistogramContent() != null) && (parentCanvas.getHistogramContent().getReadyUpToPosition() != 0) ) {
+ // Call the function that draw the bars
+ drawHistogram(imageGC, image);
+
+ // If we have a selected window set to visible, call the function to draw it
+ if ( (parentCanvas.getCurrentWindow() != null) && (parentCanvas.getCurrentWindow().getSelectedWindowVisible()) ) {
+ drawSelectedWindow(
+ imageGC,
+ image
+ );
+ }
+
+ // Draws the buffer image onto the canvas.
+ event.gc.drawImage(image, 0, 0);
+ }
+
+ imageGC.dispose();
+ }
+
+ }
+
+ /**
+ * Draw the selection window in the canvas.<p>
+ * This draw a square around the selected section with a crosshair in the middle.
+ * The square cannot be smaller than "MINIMUM_WINDOW_WIDTH"
+ *
+ * @param imageGC GC content.
+ * @param image Image content.
+ */
+ public void drawSelectedWindow(GC imageGC, Image image) {
+ // Get the window position... this would fail if the window is not initialized yet
+ final int positionCenter = parentCanvas.getCurrentWindow().getWindowXPositionCenter();
+ final int positionLeft = parentCanvas.getCurrentWindow().getWindowXPositionLeft();
+ final int positionRight = parentCanvas.getCurrentWindow().getWindowXPositionRight();
+
+ final int imageHeight = image.getBounds().height;
+
+ // Draw the selection window square
+ // Attributes (color and width) of the lines
+ imageGC.setForeground(parentCanvas.getDisplay().getSystemColor(HistogramConstant.SELECTION_WINDOW_COLOR));
+ imageGC.setLineWidth(HistogramConstant.SELECTION_LINE_WIDTH);
+ imageGC.drawLine(positionLeft , 0 , positionLeft , imageHeight);
+ imageGC.drawLine(positionLeft , imageHeight, positionRight, imageHeight);
+ imageGC.drawLine(positionRight, imageHeight, positionRight, 0);
+ imageGC.drawLine(positionLeft , 0 , positionRight, 0);
+
+ // Draw the crosshair section
+ imageGC.setBackground(parentCanvas.getDisplay().getSystemColor(HistogramConstant.SELECTION_WINDOW_COLOR));
+ imageGC.fillOval(
+ positionCenter,
+ imageHeight / 2,
+ HistogramConstant.SELECTION_CROSSHAIR_LENGTH,
+ HistogramConstant.SELECTION_CROSSHAIR_LENGTH
+ );
+ }
+
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java
index 1c887aa662..543cc7b7f0 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java
@@ -35,26 +35,29 @@ import org.eclipse.swt.widgets.Text;
* This control will give you a group, a text box and a label at once.
*/
public class TimeTextGroup implements FocusListener, KeyListener {
-
+
+/*
+ // 2010-06-10 Yuriy: Has been moved to header into HistogramView.java
protected static final String NANOSEC_LABEL = "sec";
- protected static final String LONGEST_STRING_VALUE = "." + Long.MAX_VALUE;
- protected static final int MAX_CHAR_IN_TEXTBOX = LONGEST_STRING_VALUE.length();
+*/
+ private static final String LONGEST_STRING_VALUE = "." + Long.MAX_VALUE;
+ private static final int MAX_CHAR_IN_TEXTBOX = LONGEST_STRING_VALUE.length();
// The "small font" height used to display time will be "default font" minus this constant
- protected static final int VERY_SMALL_FONT_MODIFIER = 2;
- protected static final int SMALL_FONT_MODIFIER = 1;
+ private static final int VERY_SMALL_FONT_MODIFIER = 2;
+ private static final int SMALL_FONT_MODIFIER = 1;
// Indentation size
- protected static final int DEFAULT_INDENT_SIZE = 10;
+ private static final int DEFAULT_INDENT_SIZE = 10;
- protected HistogramView parentView = null;
- protected AsyncTimeTextGroupRedrawer asyncRedrawer = null;
+ private HistogramView parentView = null;
+ private AsyncTimeTextGroupRedrawer asyncRedrawer = null;
- protected Group grpName = null;
- protected Text txtNanosec = null;
- protected Label lblNanosec = null;
+ private Group grpName = null;
+ private Text txtNanosec = null;
+ private Label lblNanosec = null;
- protected long timeValue = 0L;
+ private long timeValue = 0L;
/**
* Default Constructor.<p>
@@ -157,6 +160,7 @@ public class TimeTextGroup implements FocusListener, KeyListener {
txtNanosec.setLayoutData(gridDataTextBox);
// ** Creation of the label
+/*
lblNanosec = new Label(grpName, SWT.LEFT);
lblNanosec.setText(NANOSEC_LABEL);
lblNanosec.setFont(smallFont);
@@ -164,6 +168,7 @@ public class TimeTextGroup implements FocusListener, KeyListener {
gridDataLabel.horizontalIndent = indentSize;
gridDataLabel.verticalIndent = 0;
lblNanosec.setLayoutData(gridDataLabel);
+*/
// Add all listener
addNeededListeners();
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java
index ecc0eb5a47..1999aa05cf 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java
@@ -190,6 +190,7 @@ public class ProjectView extends TmfView {
StateManagerFactory.getExperimentManager().experimentSelected_prep(
(TmfExperiment<LttngEvent>) fSelectedExperiment);
+// System.out.println(System.currentTimeMillis() + ": Experiment selected");
broadcast(new TmfExperimentSelectedSignal<LttngEvent>(this, fSelectedExperiment));
} catch (FileNotFoundException e) {
return;
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java
index 8dde5f3b35..6d7041d046 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/ResourcesView.java
@@ -28,6 +28,7 @@ import org.eclipse.linuxtools.lttng.ui.views.resources.model.ResourceModelFactor
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.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
@@ -532,7 +533,7 @@ public class ResourcesView extends AbsTimeUpdateView implements
// user to select the interesting area based on the perspective
TmfTimeRange initTimeWindow = getInitTRange(experimentTRange);
- dataRequest(initTimeWindow, experimentTRange, true);
+ dataRequest(initTimeWindow, experimentTRange, true, ExecutionType.SHORT);
if (TraceDebug.isDEBUG()) {
TraceDebug.debug("Initialization request time range is: " + initTimeWindow.getStartTime().toString() + "-"
+ initTimeWindow.getEndTime().toString());
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java
index 269b0beb68..8807678885 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/StatisticsView.java
@@ -36,6 +36,7 @@ import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeRoot
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;
@@ -581,8 +582,8 @@ public class StatisticsView extends AbsTimeUpdateView {
for (int i = 0; i < numTraces; i++) {
String traceName = traces[i].getName();
if (!experimentTreeNode.containsChild(traceName)) {
- same = false;
- break;
+ same = false;
+ break;
}
}
@@ -616,7 +617,7 @@ public class StatisticsView extends AbsTimeUpdateView {
TmfTimeRange experimentTRange = experiment.getTimeRange();
// send the initial request, to start filling up model
- dataRequest(experimentTRange, experimentTRange, true);
+ dataRequest(experimentTRange, experimentTRange, true, ExecutionType.LONG);
} else {
TraceDebug.debug("No selected experiment information available");
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java
index 91a02369b0..7aec59ac33 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/AbstractStatsEventHandler.java
@@ -13,231 +13,34 @@ package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
-import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;
-import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
-import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData;
import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeRootFactory;
-import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode;
abstract class AbstractStatsEventHandler implements ILttngEventProcessor {
- private Events eventType;
+ private Events fEventType;
public AbstractStatsEventHandler(Events eventType) {
super();
- this.eventType = eventType;
+ fEventType = eventType;
}
/**
* @return root of of the tree for this experiment.
*/
- protected StatisticsTreeNode getStatisticsTree(LttngTraceState trcState) {
+ protected StatisticsData getStatisticsTree(LttngTraceState trcState) {
String experimentName = trcState.getContext().getExperimentName();
- StatisticsTreeNode tree = StatisticsTreeRootFactory.getStatTreeRoot(experimentName);
- return tree;
+ return StatisticsTreeRootFactory.getStatTree(experimentName);
}
- /**
- * @return list of paths that should be updated for this event.
- */
- protected String[][] getRelevantPaths(LttngEvent event,
- LttngTraceState traceState) {
- String trace = traceState.getContext().getTraceId();
-
- Long cpu = event.getCpuId();
-
- LttngProcessState process = traceState.getRunning_process().get(
- cpu);
-
- String processName = getPocessName(process);
-
- String mode = process.getState().getExec_mode().getInName();
-
- String submode = process.getState().getExec_submode();
-
- Long function = process.getCurrent_function();
-
- // String type = event.getType().getTypeId();
-
- String[][] paths = {
- {trace},
- {trace, "Modes", mode},
- {trace, "Modes", mode, "Submodes", submode},
- {trace, "Processes", processName},
- {trace, "Processes", processName, "CPUs", cpu.toString()},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Functions", function.toString()},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Modes", mode},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Modes", mode, "Submodes", submode},
- {trace, "Processes", processName, "Modes", mode},
- {trace, "Processes", processName, "Modes", mode, "Submodes", submode},
- {trace, "CPUs", cpu.toString()},
- {trace, "CPUs", cpu.toString(), "Modes", mode},
- {trace, "CPUs", cpu.toString(), "Modes", mode, "Submodes", submode},
- };
- return paths;
- }
-
- /**
- * @return list of event types paths that should be updated for this event.
- */
- protected String[][] getRelevantEventTypesPaths(LttngEvent event,
- LttngTraceState traceState) {
- String trace = traceState.getContext().getTraceId();
-
- Long cpu = event.getCpuId();
-
- LttngProcessState process = traceState.getRunning_process().get(
- cpu);
-
- String processName = getPocessName(process);
-
- String mode = process.getState().getExec_mode().getInName();
-
- String submode = process.getState().getExec_submode();
-
- Long function = process.getCurrent_function();
-
- String type = event.getType().getTypeId();
-
- String[][] paths = {
- {trace, "Event Types", type},
- {trace, "Modes", mode, "Event Types", type},
- {trace, "Modes", mode, "Submodes", submode, "Event Types", type},
- {trace, "Processes", processName, "Event Types", type},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Event Types", type},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Functions", function.toString(), "Event Types", type},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Modes", mode, "Event Types", type},
- {trace, "Processes", processName, "CPUs", cpu.toString(), "Modes", mode, "Submodes", submode, "Event Types", type},
- {trace, "Processes", processName, "Modes", mode, "Event Types", type},
- {trace, "Processes", processName, "Modes", mode, "Submodes", submode, "Event Types", type},
- {trace, "CPUs", cpu.toString(), "Event Types", type},
- {trace, "CPUs", cpu.toString(), "Modes", mode, "Event Types", type},
- {trace, "CPUs", cpu.toString(), "Modes", mode, "Submodes", submode, "Event Types", type},
- };
- return paths;
- }
-
- /**
- * @return name of the process. Returns special string if the name is "".
- */
- private String getPocessName(LttngProcessState process) {
- if (process.getName() == null) {
- return "Unknown process";
- }
- if (process.getName() == "") {
- return process.getPid().toString();
- }
- else {
- return process.getName();
- }
- }
-
- /**
- * Increase the NbEvents counter of this node.
- */
- protected void increaseNbEvents(StatisticsTreeNode node) {
- node.getValue().nbEvents++;
- }
-
- /**
- * Increase the CPU Time according to the trace state.
- */
- protected void increaseCPUTime(StatisticsTreeNode node, LttngEvent event,
- LttngTraceState traceState) {
- Long cpu = event.getCpuId();
-
- LttngProcessState process = traceState.getRunning_process().get(
- cpu);
-
- if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
- !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- node.getValue().cpuTime += event.getTimestamp().getValue()
- - process.getState().getChange_LttTime();
- }
- }
-
- /**
- * Increase the Elapsed Time according to the trace state.
- */
- protected void increaseElapsedTime(StatisticsTreeNode node, LttngEvent event,
- LttngTraceState traceState) {
- Long cpu = event.getCpuId();
-
- LttngProcessState process = traceState.getRunning_process().get(
- cpu);
-
- if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- node.getValue().elapsedTime += event.getTimestamp().getValue()
- - process.getState().getEntry_LttTime();
- }
- }
-
- /**
- * Increase the Cumulative CPU Time according to the trace state.
- */
- protected void increaseCumulativeCPUTime(StatisticsTreeNode node, LttngEvent event,
- LttngTraceState traceState) {
- Long cpu = event.getCpuId();
-
- LttngProcessState process = traceState.getRunning_process().get(
- cpu);
-
- if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
- process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
- node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
- }
- else if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
- !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
- process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
- node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
- }
- }
-
- /**
- * Increase the State-bound Cumulative CPU Time according to the trace state.
- */
- protected void increaseStateCumulativeCPUTime(LttngEvent event,
- LttngTraceState traceState) {
- Long cpu = event.getCpuId();
-
- LttngProcessState process = traceState.getRunning_process().get(cpu);
-
- if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
- !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
- long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
- process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
- }
- }
-
-// @Override
public Events getEventHandleType() {
- return eventType;
+ return fEventType;
}
protected void stepCount(LttngEvent event, LttngTraceState traceState) {
- StatisticsTreeNode root = getStatisticsTree(traceState);
-
- String[][] paths = getRelevantPaths(event, traceState);
-
- for (String[] path : paths) {
- StatisticsTreeNode node = root.getOrCreateChildFromPath(path);
-
- increaseNbEvents(node);
- }
-
- String[][] eventTypesPaths = getRelevantEventTypesPaths(event, traceState);
-
- for (String[] path : eventTypesPaths) {
- StatisticsTreeNode node = root.getOrCreateChildFromPath(path);
-
- increaseNbEvents(node);
- }
+ StatisticsData tree = getStatisticsTree(traceState);
+ tree.registerEvent(event, traceState);
}
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java
index 0e0b861882..42710987a3 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeChangeHandler.java
@@ -9,12 +9,13 @@
* Contributors:
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
-import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode;
+import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData;
class StatsModeChangeHandler extends AbstractStatsEventHandler {
@@ -25,19 +26,9 @@ class StatsModeChangeHandler extends AbstractStatsEventHandler {
/* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
*/
- public boolean process(LttngEvent event, LttngTraceState traceState) {
- StatisticsTreeNode root = getStatisticsTree(traceState);
-
- String[][] paths = getRelevantPaths(event, traceState);
-
- for (String[] path : paths) {
- StatisticsTreeNode node = root.getOrCreateChildFromPath(path);
-
- increaseCPUTime(node, event, traceState);
-
- increaseStateCumulativeCPUTime(event, traceState);
- }
-
+ public boolean process(LttngEvent event, LttngTraceState traceState) {
+ StatisticsData tree = getStatisticsTree(traceState);
+ tree.increase(event, traceState, StatisticsData.Values.CPU_TIME | StatisticsData.Values.STATE_CUMULATIVE_CPU_TIME);
return false;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java
index 265b92ef4b..1759caa30a 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsModeEndHandler.java
@@ -9,12 +9,13 @@
* Contributors:
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
-import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsTreeNode;
+import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData;
class StatsModeEndHandler extends AbstractStatsEventHandler {
@@ -26,20 +27,8 @@ class StatsModeEndHandler extends AbstractStatsEventHandler {
* @see org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
*/
public boolean process(LttngEvent event, LttngTraceState traceState) {
- StatisticsTreeNode root = getStatisticsTree(traceState);
-
- String[][] paths = getRelevantPaths(event, traceState);
-
- for (String[] path : paths) {
- StatisticsTreeNode node = root.getOrCreateChildFromPath(path);
-
- increaseCPUTime(node, event, traceState);
-
- increaseElapsedTime(node, event, traceState);
-
- increaseCumulativeCPUTime(node, event, traceState);
- }
-
+ StatisticsData tree = getStatisticsTree(traceState);
+ tree.increase(event, traceState, StatisticsData.Values.CPU_TIME | StatisticsData.Values.ELAPSED_TIME | StatisticsData.Values.CUMULATIVE_CPU_TIME);
return false;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsProcessExitHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsProcessExitHandler.java
new file mode 100644
index 0000000000..ec74514cd5
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsProcessExitHandler.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Godin (copelnug@gmail.com) - Initial design and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
+
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData;
+
+/**
+ * <h4>Handler for process exit event statistics</h4>
+ */
+public class StatsProcessExitHandler extends AbstractStatsEventHandler {
+ /**
+ * <h4>Constructor</h4>
+ * <p>
+ * Define the LTT_EVENT_PROCESS_EXIT type.
+ * </p>
+ */
+ public StatsProcessExitHandler() {
+ super(Events.LTT_EVENT_PROCESS_EXIT);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ public boolean process(LttngEvent event, LttngTraceState traceState) {
+ StatisticsData tree = getStatisticsTree(traceState);
+ tree.process_exit(event, traceState);
+
+ return false;
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java
index 97236913e2..06aea15aa8 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlerFactory.java
@@ -10,6 +10,7 @@
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
import java.util.HashMap;
@@ -34,17 +35,20 @@ import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
*
*/
public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver {
- // ========================================================================
+
+ // -----------------------------------------------------------------------
// Data
- // =======================================================================
+ // -----------------------------------------------------------------------
+
private final Map<String, ILttngEventProcessor> eventNametoBeforeProcessor = new HashMap<String, ILttngEventProcessor>();
ILttngEventProcessor afterhandler;
private static StatsTimeCountHandlerFactory instance = null;
private StatsTimeCountHandlers instantiateHandler = new StatsTimeCountHandlers();
- // ========================================================================
+ // -----------------------------------------------------------------------
// Constructors
- // =======================================================================
+ // -----------------------------------------------------------------------
+
private StatsTimeCountHandlerFactory() {
super();
//create one instance of each individual event handler and add the instance to the map
@@ -93,13 +97,16 @@ public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver {
eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
.getInName(), instantiateHandler.getSchedChangeBeforeHandler());
+ eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_EXIT
+ .getInName(), instantiateHandler.getProcessExitHandler());
+
afterhandler = instantiateHandler.getAfterHandler();
}
- // ========================================================================
+ // -----------------------------------------------------------------------
// Public methods
- // =======================================================================
+ // -----------------------------------------------------------------------
/**
* The event processors are common to all traces an multiple instances will
* use more memory unnecessarily
@@ -126,8 +133,7 @@ public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver {
@Override
public ILttngEventProcessor getfinishProcessor() {
- // No finishing processor used
- return null;
+ return instantiateHandler.getTracesetEndHandler();
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java
index 8890829489..d1583b0f6f 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTimeCountHandlers.java
@@ -9,6 +9,7 @@
* Contributors:
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
@@ -175,5 +176,20 @@ class StatsTimeCountHandlers {
return handler;
}
-
+ /**
+ * <h4>Get the trace end handler</h4>
+ * <p>Allow to do some calculations when the trace is finished.</p>
+ * @return The handler.
+ */
+ ILttngEventProcessor getTracesetEndHandler() {
+ return new StatsTracesetEndHandler();
+ }
+ /**
+ * <h4>Get the process exit handler</h4>
+ * <p> Handles: {@link org.eclipse.linuxtools.lttng.state.StateStrings.Events#LTT_EVENT_PROCESS_EXIT}.</p>
+ * @return The handler.
+ */
+ ILttngEventProcessor getProcessExitHandler() {
+ return new StatsProcessExitHandler();
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTracesetEndHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTracesetEndHandler.java
new file mode 100644
index 0000000000..db7894dcd8
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/evProcessor/StatsTracesetEndHandler.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Godin (copelnug@gmail.com) - Initial design and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
+
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData;
+
+/**
+ * <h4>Handler for the traceset end</h4>
+ * <p>This class allow to react to the end of the traceset.</p>
+ */
+public class StatsTracesetEndHandler extends AbstractStatsEventHandler {
+ /**
+ * <h4>Constructor</h4>
+ */
+ public StatsTracesetEndHandler() {
+ super(null);
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor#process(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ public boolean process(LttngEvent event, LttngTraceState traceState) {
+ StatisticsData tree = getStatisticsTree(traceState);
+ tree.endTraceset(event, traceState);
+ return false;
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/FixedArray.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/FixedArray.java
new file mode 100644
index 0000000000..8b310b6a0b
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/FixedArray.java
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Godin (copelnug@gmail.com) - Initial design and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
+
+import java.lang.reflect.Array;
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.RandomAccess;
+
+/**
+ * <h4>Allow to create a List object that contain an already existing array.</h4>
+ * <p>Works like {@link java.util.Arrays#asList} but offers more functions :
+ * <ul>
+ * <li>{@link #hashCode()}</li>
+ * <li>{@link #equals(Object)}</li>
+ * </ul></p>
+ * <p>Those functions allow to use the FixedArray as the key of a {@link java.util.HashMap}.</p>
+ *
+ * @param <T> Type of the array content.
+ */
+public final class FixedArray<T> extends AbstractList<T> implements RandomAccess {
+ /**
+ * Replace {@link java.util.Arrays#copyOf(Object[], int)} that do not exist in java 5.
+ * @param <E> Content of the array.
+ * @param array Original array to copy from.
+ * @param newLength Length of the copy to be returned.
+ * @return A new array consisting of the elements specified.
+ */
+ @SuppressWarnings("unchecked")
+ private static <E> E[] copyOf(final E[] array, int newLength) {
+ E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), newLength); // Is it useful to use newInstance?
+ System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
+ return result;
+ }
+ /**
+ * Replace {@link java.util.Arrays#copyOf(Object[], int, Class)} that do not exist in java 5.
+ * @param <E> Content of the array.
+ * @param array Original array to copy from.
+ * @param newLength Length of the copy to be returned.
+ * @param newType Type of the array to be returned.
+ * @return A new array consisting of the elements specified.
+ */
+ @SuppressWarnings("unchecked")
+ private static <E, U> E[] copyOf(final U[] array, int newLength, Class<? extends E[]> newType) {
+ E[] result = (E[])Array.newInstance(newType.getComponentType(), newLength);
+ System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
+ return result;
+ }
+ /**
+ * Replace {@link java.util.Arrays#copyOfRange(Object[], int, int)} that do not exist in java 5.
+ * @param <E> Content of the array.
+ * @param array Original array to copy from.
+ * @param start Starting position of the range.
+ * @param end Ending position of the range.
+ * @return A new array consisting of the elements specified.
+ */
+ @SuppressWarnings("unchecked")
+ private static <E> E[] copyOfRange(final E[] array, int start, int end) {
+ E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), end - start);
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+ }
+ /**
+ * The array.
+ */
+ private final T[] fArray;
+ /**
+ * Constructor.
+ * @param array Array to use. WILL NOT BE COPIED.
+ */
+ public FixedArray(final T... array) {
+ fArray = array;
+ }
+ /**
+ * Append a FixedArray to this FixedArray.
+ * @param value The FixedArray to append.
+ * @return A new FixedArray with the elements of the two FixedArray.
+ */
+ public FixedArray<T> append(final FixedArray<T> value) {
+ FixedArray<T> result = new FixedArray<T>(copyOf(fArray, fArray.length + value.size()));
+ System.arraycopy(value.fArray, 0, result.fArray, fArray.length, value.fArray.length);
+ return result;
+ }
+ /**
+ * Append in order many FixedArray to this FixedArray.
+ * @param values The FixedArrays to append.
+ * @return A new FixedArray with the element of all the FixedArray.
+ */
+ public FixedArray<T> append(final FixedArray<T>... values) {
+ int newLength = 0;
+ for(FixedArray<T> value : values)
+ newLength += value.size();
+ FixedArray<T> result = new FixedArray<T>(copyOf(fArray, fArray.length + newLength));
+ newLength = fArray.length;
+ for(FixedArray<T> value : values)
+ {
+ System.arraycopy(value.fArray, 0, result.fArray, newLength, value.fArray.length);
+ newLength += value.fArray.length;
+ }
+ return result;
+ }
+ /**
+ * Append an element to the array.
+ * @param value Element to append.
+ * @return A new FixedArray with the element appended.
+ */
+ public FixedArray<T> append(final T value) {
+ FixedArray<T> result = new FixedArray<T>(copyOf(fArray, fArray.length + 1));
+ result.set(fArray.length, value);
+ return result;
+ }
+ /**
+ * Append an array of element to the array.
+ * @param values Elements array to append.
+ * @return A new FixedArray with the elements appended.
+ */
+ public FixedArray<T> append(final T... values) {
+ FixedArray<T> result = new FixedArray<T>(copyOf(fArray, fArray.length + values.length));
+ for(int i = 0; i < values.length; ++i)
+ result.set(fArray.length + i, values[i]);
+ return result;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone()
+ {
+ return new FixedArray<T>(copyOf(fArray, fArray.length));
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractList#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(o instanceof FixedArray<?>)
+ return Arrays.equals(fArray, ((FixedArray<?>)o).fArray);
+ if(!(o instanceof List))
+ return false;
+ for(int i = 0; i < fArray.length; ++i)
+ if(!fArray[i].equals((List<?>)o))
+ return false;
+ return true;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractList#get(int)
+ */
+ @Override
+ public T get(int index) {
+ return fArray[index];
+ }
+ /**
+ * Get the array reference.
+ * @return The array reference.
+ * @see #toArray FixedArray.toArray() to get a copy of the array.
+ */
+ public T[] getArray() {
+ return fArray;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractList#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(fArray);
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractList#set(int, java.lang.Object)
+ */
+ @Override
+ public T set(int index, T element) {
+ T temp = fArray[index];
+ fArray[index] = element;
+ return temp;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractCollection#size()
+ */
+ @Override
+ public int size() {
+ return fArray.length;
+ }
+ /**
+ * Get a array covering only a part of the array.
+ * @param start Starting position of the new array.
+ * @return A new array covering the elements specified.
+ */
+ public FixedArray<T> subArray(int start) {
+ return new FixedArray<T>(copyOfRange(fArray, start, fArray.length - 1));
+ }
+ /**
+ * Get a array covering only a part of the array.
+ * @param start Starting position of the new array.
+ * @param length Number of element to include in the new array.
+ * @return A new array covering the elements specified.
+ */
+ public FixedArray<T> subArray(int start, int length) {
+ return new FixedArray<T>(copyOfRange(fArray, start, length + start));
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractCollection#toArray()
+ */
+ @Override
+ public T[] toArray()
+ {
+ return copyOf(fArray, fArray.length);
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractCollection#toArray(T[])
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public <E> E[] toArray(E[] array)
+ {
+ if(array.length < fArray.length)
+ return copyOf(fArray, fArray.length,(Class<? extends E[]>)array.getClass());
+ System.arraycopy(fArray, 0, array, 0, fArray.length);
+ if(array.length > fArray.length)
+ array[fArray.length] = null;
+ return array;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.util.AbstractCollection#toString()
+ */
+ @Override
+ public String toString() {
+ return Arrays.toString(fArray);
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/KernelStatisticsData.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/KernelStatisticsData.java
new file mode 100644
index 0000000000..fd003be99b
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/KernelStatisticsData.java
@@ -0,0 +1,354 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Godin (copelnug@gmail.com) - Initial design and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.Map;
+
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;
+import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
+import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+
+/**
+ * <h4>Class that process the LTTng kernel events.</h4>
+ */
+public class KernelStatisticsData extends StatisticsData {
+ /**
+ * <h4>Header for the mode categories.</h4>
+ */
+ private static final String HEADER_CPUS = "CPUs";
+ /**
+ * <h4>Header for the event types categories.</h4>
+ */
+ private static final String HEADER_EVENT_TYPES = "Event Types";
+ /**
+ * <h4>Header for the function categories.</h4>
+ */
+ private static final String HEADER_FUNCTIONS = "Functions";
+ /**
+ * <h4>Header for the mode categories.</h4>
+ */
+ private static final String HEADER_MODES = "Modes";
+ /**
+ * <h4>Header for the processes categories.</h4>
+ */
+ private static final String HEADER_PROCESSES = "Processes";
+ /**
+ * <h4>Header for the submode categories.</h4>
+ */
+ private static final String HEADER_SUBMODES ="Submodes";
+ /**
+ * <h4>Indicate that it's a value.</h4>
+ * <p>Used when checking the possible child node for a node.</p>
+ * <p>It differentiate a category of a value by being appended to a value.</p>
+ */
+ private static final String NODE = "z";
+ private static final String ROOT_NODE_KEY = mergeString(ROOT.get(0), NODE);
+ /**
+ * <h4>Constructor.</h4>
+ * @param traceName
+ */
+ public KernelStatisticsData(String traceName) {
+ super();
+ Map<String, Set<String>> keys = getKeys();
+
+ ////////////// Adding category sets
+ keys.put(HEADER_PROCESSES, new HashSet<String>());
+ keys.put(HEADER_MODES, new HashSet<String>());
+ keys.put(HEADER_CPUS, new HashSet<String>(4)); // Over 4 CPUs is not common
+ keys.put(HEADER_SUBMODES, new HashSet<String>());
+ keys.put(HEADER_EVENT_TYPES, new HashSet<String>());
+ keys.put(HEADER_FUNCTIONS, new HashSet<String>(4)); // Seems to be always one.
+
+ ///////////// Adding value sets
+ // Under a trace
+ Set<String> temp = new HashSet<String>(8);
+ temp.add(HEADER_PROCESSES);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_CPUS);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(ROOT_NODE_KEY, temp);
+ // Under a process
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_CPUS);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_PROCESSES,NODE), temp);
+ // Under a CPUs : Functions is a special case
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_CPUS,NODE), temp);
+ // Under a functions
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_MODES);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_FUNCTIONS,NODE), temp);
+ // Under a mode
+ temp = new HashSet<String>(4);
+ temp.add(HEADER_SUBMODES);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_MODES,NODE), temp);
+ // Under a submodes
+ temp = new HashSet<String>(2);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(mergeString(HEADER_SUBMODES,NODE), temp);
+ // Under an event type
+ temp = new HashSet<String>(16);
+ keys.put(mergeString(HEADER_EVENT_TYPES,NODE),temp);
+
+ ////////////// CREATE root
+ keys.put(ROOT.get(0), new HashSet<String>(2)); // 1 trace at the time
+ getOrCreate(ROOT);
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#endTraceset(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ @Override
+ public void endTraceset(LttngEvent event, LttngTraceState traceState) {
+ // TODO Should we uncomment the rest?
+ // It include in the cpu time the time between the last event of each cpu and the time of the last global event.
+ // Because we know that there won't be a change of mode or process between those time.
+ /*if(last_ == null)
+ return;
+
+ LttngProcessState process = traceState.getRunning_process().get(0L);
+ System.out.println(process.getState().getChange_LttTime());
+ for(long cpu : traceState.getRunning_process().keySet()) {
+ LttngEventType newType = new LttngEventType(last_.getType().getTracefileName(), cpu, last_.getType().getMarkerName(), last_.getType().getLabels());
+ last_.setType(newType);
+ increase(last_, traceState,
+ Values.CPU_TIME | Values.CUMULATIVE_CPU_TIME | Values.ELAPSED_TIME | Values.STATE_CUMULATIVE_CPU_TIME);
+ // TODO Are all those values required?
+ }*/
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#getChildren(org.eclipse.linuxtools.lttng.ui.views.statistics.model.FixedArray)
+ */
+ @Override
+ public Collection<StatisticsTreeNode> getChildren(final FixedArray<String> path) {
+ LinkedList<StatisticsTreeNode> result = new LinkedList<StatisticsTreeNode>();
+
+ if(path.size() % 2 == 0) { // if we are at a Category
+ StatisticsTreeNode current = null;
+ for(String value : getKeys().get(path.get(path.size() - 1))) {
+ current = get(path.append(value));
+ if(current != null && current.getValue().nbEvents != 0)
+ result.add(current);
+ }
+ }
+ else if(path.size() == 1) { // Special case.
+ if(path.equals(ROOT)) // Asking for the root.
+ for(String value : getKeys().get(ROOT.get(0)))
+ result.add(getOrCreate(new FixedArray<String>(value)));
+ else // Get value under the root
+ for (String value : getKeys().get(ROOT_NODE_KEY))
+ result.add(getOrCreate(path.append(value)));
+ }
+ else {// If we are at a value
+ for(String value : getKeys().get(mergeString(path.get(path.size() -2),NODE))) // Search the parent name + NODE
+ result.add(getOrCreate(path.append(value)));
+
+ if(path.size() == 5 && path.get(3).equals(HEADER_CPUS)) // Special the Functions is just there. We want the fourth element but it start at 0. So #3
+ result.add(getOrCreate(path.append(HEADER_FUNCTIONS)));
+ }
+
+ return result;
+ }
+ /**
+ * <h4>Get the standard paths for an event.</h4>
+ * @param event Event to get the path for.
+ * @param traceState State of the trace for this event.
+ * @return Array of FixedArray representing the paths.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private FixedArray<String>[] getNormalPaths(LttngEvent event, LttngTraceState traceState) {
+ String trace = traceState.getContext().getTraceId();
+ Long cpu = event.getCpuId();
+ String cpus = String.valueOf(cpu);
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+ String processName = getProcessName(process);
+ String mode = process.getState().getExec_mode().getInName();
+ String submode = process.getState().getExec_submode();
+ String function = process.getCurrent_function().toString();
+
+ FixedArray[] paths = {
+ new FixedArray<String>(trace),
+ new FixedArray<String>(trace,HEADER_MODES,mode),
+ new FixedArray<String>(trace,HEADER_MODES,mode,HEADER_SUBMODES,submode),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode, HEADER_SUBMODES, submode),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode,HEADER_SUBMODES,submode),
+ new FixedArray<String>(trace,HEADER_CPUS,cpus),
+ new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode),
+ new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode),
+ };
+
+ return paths;
+ }
+ /**
+ * <h4>Get the event types paths.</h4>
+ * @param event Event to get the path for.
+ * @param traceState State of the trace for this event.
+ * @return Array of FixedArray representing the paths.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private FixedArray<String>[] getTypePaths(LttngEvent event, LttngTraceState traceState) {
+ String trace = traceState.getContext().getTraceId();
+ Long cpu = event.getCpuId();
+ String cpus = String.valueOf(cpu);
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+ String processName = getProcessName(process);
+ String mode = process.getState().getExec_mode().getInName();
+ String submode = process.getState().getExec_submode();
+ String function = process.getCurrent_function().toString();
+ //String type = event.getType().getTypeId(); // Add too much informations
+ String type = event.getMarkerName();
+
+ FixedArray[] paths = {
+ new FixedArray<String>(trace,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_FUNCTIONS,function, HEADER_MODES, mode, HEADER_SUBMODES, submode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_PROCESSES,processName,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_EVENT_TYPES,type),
+ new FixedArray<String>(trace,HEADER_CPUS,cpus,HEADER_MODES,mode,HEADER_SUBMODES,submode,HEADER_EVENT_TYPES,type),
+ };
+
+ return paths;
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#process_exit(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ @Override
+ public void process_exit(LttngEvent event, LttngTraceState traceState) {
+ FixedArray<String>[] paths = getNormalPaths(event,traceState);
+ Long cpu = event.getCpuId();
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+
+ for(FixedArray<String> path : paths) {
+ StatisticsTreeNode node = getOrCreate(path);
+
+ if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ node.getValue().cpuTime += event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ }
+ }
+
+ // TODO Unstacks cumulative CPU time
+ // TODO Elapsed time?
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#increase(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState, int)
+ */
+ @Override
+ public void increase(LttngEvent event, LttngTraceState traceState, int values) {
+ FixedArray<String>[] paths = getNormalPaths(event, traceState);
+ Long cpu = event.getCpuId();
+ LttngProcessState process = traceState.getRunning_process().get(cpu);
+
+ for(FixedArray<String> path : paths)
+ {
+ StatisticsTreeNode node = getOrCreate(path);
+
+ if((values & Values.CPU_TIME) != 0) {
+ // TODO Uncomment if the event after process_exit need to be count.
+ if ((process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) /*|| process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_EXIT)*/) &&
+ !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ node.getValue().cpuTime += event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ }
+ }
+ if((values & Values.CUMULATIVE_CPU_TIME) != 0) {
+ if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ long cumulativeCpuTime = process.getState().getCum_cpu_time();
+ long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
+ process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
+ node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
+ }
+ else if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
+ !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ long cumulativeCpuTime = process.getState().getCum_cpu_time();
+ long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
+ node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
+ }
+ }
+ if((values & Values.ELAPSED_TIME) != 0) {
+ if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ node.getValue().elapsedTime += event.getTimestamp().getValue()
+ - process.getState().getEntry_LttTime();
+ }
+ }
+ if((values & Values.STATE_CUMULATIVE_CPU_TIME) != 0) {
+ if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
+ !process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
+ long cumulativeCpuTime = process.getState().getCum_cpu_time();
+ long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
+ process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
+ }
+ }
+ }
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#registerEvent(org.eclipse.linuxtools.lttng.event.LttngEvent, org.eclipse.linuxtools.lttng.state.model.LttngTraceState)
+ */
+ @Override
+ public void registerEvent(LttngEvent event, LttngTraceState traceState) {
+ FixedArray<String>[] paths = getNormalPaths(event, traceState);
+ for(FixedArray<String> path : paths)
+ ++(getOrCreate(path).getValue().nbEvents);
+
+ paths = getTypePaths(event, traceState);
+ for(FixedArray<String> path : paths)
+ ++(getOrCreate(path).getValue().nbEvents);
+
+ //last_ = event; // TODO Used by endTraceset
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.statistics.model.StatisticsData#registerName(org.eclipse.linuxtools.lttng.ui.views.statistics.model.FixedArray)
+ */
+ @Override
+ protected void registerName(final FixedArray<String> path) {
+ if(path.size() == 1) {
+ if(!path.equals(ROOT))
+ getKeys().get(ROOT.get(0)).add(path.get(0));
+ }
+ else if(path.size() % 2 != 0)
+ getKeys().get(path.get(path.size() - 2)).add(path.get(path.size() - 1));
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/Statistics.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/Statistics.java
index 53caa96580..5bf15d6ed3 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/Statistics.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/Statistics.java
@@ -9,14 +9,33 @@
* Contributors:
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
public class Statistics {
+ /**
+ * <h4>Number of event</h4>
+ */
public long nbEvents = 0;
-
+ /**
+ * <h4>CPU time</h4>
+ * <p>Many events are excluded of the CPU time:
+ * <ul>
+ * <li>All events in MODE_UNKNOWN</li>
+ * <li>All events before a sched_schedule on a given CPU</li>
+ * <li>All events in a process after the process_exit</li>
+ * <li>Maybe some others</li>
+ * </ul>
+ */
public long cpuTime = 0;
-
+ /**
+ * <h4>Cumulative CPU time</h4>
+ * <p>Currently broken.</p>
+ */
public long cumulativeCpuTime = 0;
-
+ /**
+ * <h4>Elapsed time</h4>
+ * <p>Result validity in eclipse unknown.</p>
+ */
public long elapsedTime = 0;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsData.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsData.java
new file mode 100644
index 0000000000..5bac44c5c3
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsData.java
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Godin (copelnug@gmail.com) - Initial design and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
+import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+
+/**
+ * <h4>Base class for the statistics storage.</h4>
+ * <p>It allow to implement a tree structure while avoiding the need to run through the tree each time you need to add a node at a given place.</p>
+ */
+public abstract class StatisticsData {
+ /**
+ * <h4>Define values that can be used like a C++ enumeration.</h4>
+ * <p>The values can be used with binary "or" and "and" to mix them.</p>
+ */
+ public static class Values {
+ /**
+ * <h4>Indicate the cpu time</h4>
+ * <p>The actual time the cpu as passed in this state making calculations.</p>
+ */
+ public static final int CPU_TIME = 1;
+ /**
+ * <h4>Indicate the cumulative cpu time</h4>
+ * <p>Include the time the cpu as passed in this state and substate.</p>
+ * <p>Example:
+ * <ul>
+ * <li>PID:1, Mode:USER_MODE</li>
+ * <ul>
+ * <li>PID:1, Mode:SYSCALL</li>
+ * </ul>
+ * <li>PID:2, Mode:USER_MODE</li>
+ * </ul>
+ * </p>
+ * <p>In this example, the cumulative cpu time for "PID:1, Mode:USER_MODE" would
+ * be equal to its cpu time plus the cpu time of "PID:1, Mode:SYSCALL".</p>
+ * TODO Validate values. Not tested in LTTv.
+ * TODO Validate description.
+ */
+ public static final int CUMULATIVE_CPU_TIME = 2;
+ /**
+ * <h4>Elapsed time</h4>
+ * <p>Description...</p>
+ * TODO Give a correct description.
+ */
+ public static final int ELAPSED_TIME = 4;
+ /**
+ * <h4>State cumulative cpu time</h4>
+ * <p>Description...</p>
+ * TODO Give a correct description.
+ */
+ public static final int STATE_CUMULATIVE_CPU_TIME = 8;
+ }
+ /**
+ * <h4>String builder used to merge string with more efficacy.</h4>
+ */
+ protected static StringBuilder fBuilder = new StringBuilder();
+ /**
+ * <h4>Identification of the root.</h4>
+ */
+ public static final FixedArray<String> ROOT = new FixedArray<String>("root");
+ /**
+ * <h4>Function to merge many string with more efficacy.</h4>
+ * @param strings Strings to merge.
+ * @return A new string containing all the strings.
+ */
+ protected synchronized static String mergeString(String...strings) {
+ fBuilder.setLength(0);
+ for(String s : strings)
+ fBuilder.append(s);
+ return fBuilder.toString();
+ }
+ /**
+ * <h4>Define what child a node can have. </h4>
+ * <p>The management and usage of this map is done by subclass.</p>
+ * <p>HashSet are always faster than TreeSet.</p>
+ */
+ private Map<String, Set<String>> fKeys;
+ /**
+ * <h4>The nodes in the tree.</f4>
+ */
+ private HashMap<FixedArray<String>, StatisticsTreeNode> fNodes;
+ /**
+ * <h4>Constructor.</h4>
+ */
+ public StatisticsData() {
+ fNodes = new HashMap<FixedArray<String>,StatisticsTreeNode>();
+ fKeys = new HashMap<String, Set<String>>();
+ }
+ /**
+ * <h4>Indicate the end of the traceset</4>
+ * <p>Can be used to trigger necessary calculations.</p>
+ * @param event Event receive (May have timestamp of 0).
+ * @param traceState State of the trace at that moment.
+ */
+ public abstract void endTraceset(LttngEvent event, LttngTraceState traceState);
+ /**
+ * <h4>Get a node.</h4>
+ * @param path Path to the node.
+ * @return The node or null.
+ */
+ public StatisticsTreeNode get(final FixedArray<String> path) {
+ return fNodes.get(path);
+ }
+ /**
+ * <h4>Get the children of a node.</h4>
+ * @param path Path to the node.
+ * @return Collection containing the children.
+ */
+ public abstract Collection<StatisticsTreeNode> getChildren(final FixedArray<String> path);
+ /**
+ * <h4>Get the map of existing elements of path classified by parent.</h4>
+ * @return The map.
+ */
+ protected Map<String, Set<String>> getKeys() {
+ return fKeys;
+ }
+ /**
+ * <h4>Get or create a node.</h4>
+ * @param path Path to the node.
+ * @return The node.
+ */
+ public StatisticsTreeNode getOrCreate(final FixedArray<String> path) {
+ StatisticsTreeNode current = fNodes.get(path);
+ if(current == null) {
+ registerName(path);
+ current = new StatisticsTreeNode(path,this);
+ fNodes.put(path, current);
+ }
+ return current;
+ }
+ /**
+ * <h4>Get the parent of a node.</h4>
+ * @param path Path to the node.
+ * @return Parent node or null.
+ */
+ public StatisticsTreeNode getParent(final FixedArray<String> path) {
+ if(path.size() == 1) {
+ if(path.equals(ROOT))
+ return null;
+ else
+ return get(ROOT);
+ }
+ // TODO Get or GetOrCreate?
+ return get(path.subArray(0,path.size()-1));
+ }
+ /**
+ * <h4>Get the name of a process.</h4>
+ * @param process The process.
+ * @return The name of the process.
+ * //TODO Adding the creation time of the process may be needed to differentiate two process.
+ */
+ protected String getProcessName(LttngProcessState process) {
+ if(process.getPid() == -1)
+ return "Unknown process";
+ if(process.getName() == null)
+ return mergeString("Unknown process - ", String.valueOf(process.getPid()));
+ if(process.getName().equals(""))
+ return process.getPid().toString();
+ else
+ return mergeString(process.getName(), " - ",String.valueOf(process.getPid()));
+ }
+ /**
+ * <h4>Increase some values.</h4>
+ * <p>Values is an binary or operation on the desired values between {@link Values#CPU_TIME}, {@link Values#CUMULATIVE_CPU_TIME}, {@link Values#ELAPSED_TIME} and {@link Values#STATE_CUMULATIVE_CPU_TIME} .
+ * @param event Current event.
+ * @param traceState State of the trace at that moment.
+ * @param values Values desired.
+ */
+ public abstract void increase(LttngEvent event, LttngTraceState traceState, int values);
+ /**
+ * <h4>Register an event.</h4>
+ * <p>This method must be implemented by subclass.</p>
+ * @param event Event to process.
+ * @param traceState State of the trace at the moment of the event.
+ */
+ public abstract void registerEvent(LttngEvent event, LttngTraceState traceState);
+ /**
+ * <h4>Register that a new node was created.</h4>
+ * <p>Must make sure the {@link #getChildren(FixedArray)} on the parent node will return the newly created node.</p>
+ * @param path Path of the new node.
+ */
+ protected abstract void registerName(final FixedArray<String> path);
+ /**
+ * <h4>Reset a node.</h4>
+ * <p>Work recursively.</p>
+ * @param path Path to the node.
+ */
+ public void reset(final FixedArray<String> path) {
+ for(StatisticsTreeNode node : getChildren(path)) {
+ reset(node.getPath());
+ fNodes.remove(node.getPath());
+ }
+ }
+ /**
+ * Indicate that the process is finishing.
+ * @param event The event indicating the end of the process.
+ * @param traceState State of the trace at that moment.
+ */
+ public abstract void process_exit(LttngEvent event, LttngTraceState traceState);
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java
index 172e05e3ad..042dc758b3 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeNode.java
@@ -8,208 +8,105 @@
*
* Contributors:
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
+ * Francois Godin (copelnug@gmail.com) - Re-design for new stats structure
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
-import java.util.AbstractMap;
import java.util.Collection;
-import java.util.HashMap;
-/*
- * A tree where nodes can be accessed efficiently using paths.
- *
- * It works like file systems. Each node is identified by a key. A path is a list of keys separated by the character '/'.
- * For example, the path 'persons/yann' will browse to the child 'persons' and return it's 'yann' child.
+/**
+ * <h4>A tree where nodes can be accessed efficiently using paths.</h4>
*
- * If a key might contains the character '/', use the #escapeKey method to get an escaped key. Use the #unescapeKey
- * method to unescaped the key.
+ * <p>It works like file systems. Each node is identified by a key. A path is an array ({@link FixedArray}) of String. The elements of the array represent the path from the root to this node.</p>
*/
public class StatisticsTreeNode {
-
- private StatisticsTreeNode parent;
-
- private String key;
-
- private Statistics value;
-
- private AbstractMap<String, StatisticsTreeNode> children;
-
- /*
- * Construct a node with the given key
- */
- public StatisticsTreeNode(String key) {
- this(null, key);
- }
-
- /*
- * Construct a node with the given parent, key and value.
- */
- public StatisticsTreeNode(StatisticsTreeNode parent, String key) {
- super();
- this.parent = parent;
- this.key = key;
- this.value = new Statistics();
- this.children = new HashMap<String, StatisticsTreeNode>();
- }
-
- /*
- * @return key associated with this node.
- */
- public StatisticsTreeNode getParent() {
- return this.parent;
- }
-
- /*
- * @return key associated with this node.
+ /**
+ * <h4>Value of the node.</h4>
*/
- public String getKey() {
- return this.key;
- }
-
- /*
- * @return value associated with this node.
+ private Statistics fValue;
+ /**
+ * <h4>Path of the node.</h4>
*/
- public Statistics getValue() {
- return this.value;
- }
-
- /*
- * Add a direct child with the given value at the given path.
- *
- * @return children node that was created.
+ private FixedArray<String> fPath;
+ /**
+ * <h4>Corresponding StatisticsData.</h4>
*/
- public StatisticsTreeNode addChild(String key) {
- StatisticsTreeNode created = new StatisticsTreeNode(this, key);
-
- this.children.put(key, created);
-
- return created;
- }
-
- /*
- * @return direct children node with the given key. null if not found.
+ private StatisticsData fNodes;
+ /**
+ * <h4>Constructor.</h4>
+ * @param path Path to the node.
+ * @param nodes Corresponding StatisticsData.
*/
- public StatisticsTreeNode getChild(String key) {
- if (!this.children.containsKey(key)) {
- return null;
- }
-
- return this.children.get(key);
+ public StatisticsTreeNode(final FixedArray<String> path, StatisticsData nodes) {
+ fPath = path;
+ fNodes = nodes;
+ fValue = new Statistics();
}
-
- /*
- * @return number of direct children of this node.
+ /**
+ * <h4>Test if a node contain the specified child.</h4>
+ * @param key Name of the child.
+ * @return true: if child with given key is present, false: if no child exists with given key name
*/
- public boolean hasChildren() {
- return getNbChildren() > 0;
+ public boolean containsChild(String key) {
+ if(StatisticsData.ROOT.equals(fPath))
+ return fNodes.get(new FixedArray<String>(key)) != null;
+ return (fNodes.get(fPath.append(key)) != null);
}
-
- /*
- * @return direct children of this node.
+ /**
+ * <h4>Get the children of this node.</h4>
+ * @return Direct children of this node.
*/
public Collection<StatisticsTreeNode> getChildren() {
- return children.values();
+ return fNodes.getChildren(fPath);
}
-
- /*
- * @return number of direct children of this node.
- */
- public int getNbChildren() {
- return children.size();
- }
-
- /*
- * Get the node at the given path. If it doesn't exist each node in the path
- * will be created with the given class.
- *
- * @return children node with the given path. null if not found.
+ /**
+ * <h4>Get the key for this node.</h4>
+ * @return Key associated with this node.
*/
- public StatisticsTreeNode getOrCreateChildFromPath(String[] path) {
- // StatisticsTreeNode previous = this.parent;
- StatisticsTreeNode current = this;
- for (String key : path) {
- if (!current.children.containsKey(key)) {
- current.children.put(key, new StatisticsTreeNode(current, key));
- }
-
- // previous = current;
- current = current.children.get(key);
- }
-
- return current;
+ public String getKey() {
+ return fPath.get(fPath.size() - 1);
}
-
- /*
- * Get the node at the given path. If it doesn't exist each node in the path
- * will be created with the given class.
- *
- * @return children node with the given path. null if not found.
+ /**
+ * <h4>Get the number of children this node have.</h4>
+ * @return Number of direct children of this node.
*/
- public StatisticsTreeNode getOrCreateChildFromPath(String path) {
- StatisticsTreeNode previous = this.parent;
- StatisticsTreeNode current = this;
- for (String key : path.split("/")) {
- if (!current.children.containsKey(key)) {
- current.children.put(key, new StatisticsTreeNode(previous, key));
- }
-
- previous = current;
- current = current.children.get(key);
- }
-
- return current;
+ public int getNbChildren() {
+ return fNodes.getChildren(fPath).size();
}
-
- /*
- * @return children node with the given path. null if not found.
+ /**
+ * <h4>Return the parent node.</h4>
+ * @return Parent node.
*/
- public StatisticsTreeNode getChildFromPath(String path) {
- StatisticsTreeNode current = this;
- for (String key : path.split("/")) {
- if (!current.children.containsKey(key)) {
- return null;
- }
-
- current = current.children.get(key);
- }
-
- return current;
+ public StatisticsTreeNode getParent() {
+ return fNodes.getParent(fPath);
}
-
- /*
- * Use this to escape a key that might contain the '/' character.
- *
- * @return escaped key
+ /**
+ * <h4>Get the path of the node.</h4>
+ * @return The path of the node.
*/
- public static String escapeKey(String key) {
- return key.replace("%", "%25").replace("/", "%2F");
+ public FixedArray<String> getPath() {
+ return fPath;
}
-
- /*
- * Use this to unescape a key.
- *
- * @return unescaped key
+ /**
+ * <h4>Get the value of this node.</h4>
+ * @return Value associated with this node.
*/
- public static String unescapeKey(String key) {
- return key.replace("%2F", "/").replace("%25", "%");
+ public Statistics getValue() {
+ return fValue;
}
-
/**
- * Start from creation time i.e. keep key and parent but new statistics and
- * no children
+ * <h4>Indicate if the node have children.</h4>
+ * @return True if the node has children.
*/
- public void reset() {
- this.value = new Statistics();
- this.children = new HashMap<String, StatisticsTreeNode>();
+ public boolean hasChildren() {
+ return !fNodes.getChildren(fPath).isEmpty();
}
-
/**
- *
- * @param key
- * @return true: if child with given key is present, false: if no child
- * exists with given key name
+ * <h4>Start from creation time i.e. keep key and parent but new statistics and no children.</h4>
*/
- public boolean containsChild(String key) {
- return children.containsKey(key);
+ public void reset() {
+ fValue = new Statistics();
+ fNodes.reset(fPath);
}
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeRootFactory.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeRootFactory.java
index 23038062f2..2b4d003438 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeRootFactory.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/statistics/model/StatisticsTreeRootFactory.java
@@ -9,21 +9,23 @@
* Contributors:
* Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.ui.views.statistics.model;
import java.util.HashMap;
import java.util.Map;
public class StatisticsTreeRootFactory {
- // ========================================================================
+
+ // -----------------------------------------------------------------------
// Data
- // =======================================================================
+ // -----------------------------------------------------------------------
- private static final Map<String, StatisticsTreeNode> rootInstances = new HashMap<String, StatisticsTreeNode>();
+ private static final Map<String, StatisticsData> fTreeInstances = new HashMap<String, StatisticsData>();
- // ========================================================================
+ // -----------------------------------------------------------------------
// Methods
- // =======================================================================
+ // -----------------------------------------------------------------------
/**
* Provide a statisticsTree instance per trace
@@ -31,27 +33,25 @@ public class StatisticsTreeRootFactory {
* @return
*/
public static StatisticsTreeNode getStatTreeRoot(String traceUniqueId) {
- if (traceUniqueId == null) {
+ return getStatTree(traceUniqueId).getOrCreate(StatisticsData.ROOT);
+ }
+ public static StatisticsData getStatTree(String traceUniqueId) {
+ if(traceUniqueId == null)
return null;
- }
-
- if (rootInstances.containsKey(traceUniqueId)) {
- return rootInstances.get(traceUniqueId);
- }
-
- StatisticsTreeNode tree = new StatisticsTreeNode(traceUniqueId);
-
- rootInstances.put(traceUniqueId, tree);
+ StatisticsData tree = fTreeInstances.get(traceUniqueId);
+ if(tree == null) {
+ tree = new KernelStatisticsData(traceUniqueId); // NOTE
+ fTreeInstances.put(traceUniqueId, tree);
+ }
return tree;
}
-
/**
* @param traceUniqueId
* @return
*/
public static boolean containsTreeRoot(String traceUniqueId) {
- return rootInstances.containsKey(traceUniqueId);
+ return fTreeInstances.containsKey(traceUniqueId);
}
/**
@@ -59,15 +59,15 @@ public class StatisticsTreeRootFactory {
* @param traceUniqueId
*/
public static void removeStatTreeRoot(String traceUniqueId) {
- if (traceUniqueId != null && rootInstances.containsKey(traceUniqueId)) {
- rootInstances.remove(traceUniqueId);
+ if (traceUniqueId != null && fTreeInstances.containsKey(traceUniqueId)) {
+ fTreeInstances.remove(traceUniqueId);
}
}
/**
- * Remove all tree root instances
+ * Remove all tree and root instances
*/
public static void removeAll() {
- rootInstances.clear();
+ fTreeInstances.clear();
}
}
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java
index 1ee55437bd..dd234847e1 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java
@@ -307,7 +307,8 @@ public class TimeFrameView extends TmfView {
public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
// Update the time frame
- fTraceTimeRange = signal.getTrace().getTimeRange();
+// fTraceTimeRange = signal.getTrace().getTimeRange();
+ fTraceTimeRange = signal.getExperiment().getTimeRange();
fTraceStartTime = fTraceTimeRange.getStartTime();
fTraceEndTime = fTraceTimeRange.getEndTime();
fScale = fTraceStartTime.getScale();
diff --git a/lttng/org.eclipse.linuxtools.lttng/ChangeLog b/lttng/org.eclipse.linuxtools.lttng/ChangeLog
new file mode 100644
index 0000000000..6ed398b383
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng/ChangeLog
@@ -0,0 +1,13 @@
+2010-07-29 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java: Fixed state of running process
+ * src/org/eclipse/linuxtools/lttng/state/evProcessor/AbsEventToHandlerResolver.java: Optimized condition handling
+
+2010-07-08 francois <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java: Issue a single request to experiment and dispatch events to proper trace state manager
+ * src/org/eclipse/linuxtools/lttng/event/LttngLocation.java: Added equals() and tweaked toString()
+ * src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java: New constructor
+ * src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java: New constructor
+ * src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java: Minor changes
+ * src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java: Synchronized clone() \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
index f441fa5bcf..430c333892 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
@@ -35,7 +35,10 @@ import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.signal.TmfEndSynchSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfStartSynchSignal;
import org.eclipse.linuxtools.tmf.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.trace.TmfContext;
import org.eclipse.linuxtools.tmf.trace.TmfTrace;
@@ -50,7 +53,7 @@ public class LttngSyntheticEventProvider extends
// Data
// ========================================================================
public static final int BLOCK_SIZE = 1;
- public static final int NB_EVENTS = 1;
+ public static final int NB_EVENTS = 1;
public static final int QUEUE_SIZE = 1; // lttng specific, one event at a
// time
@@ -134,6 +137,8 @@ public class LttngSyntheticEventProvider extends
// loop for every traceManager in current experiment
boolean subRequestQueued = false;
+ TmfExperiment<LttngEvent> experiment = (TmfExperiment<LttngEvent>) fExperiment.getValue();
+ experiment.startSynch(new TmfStartSynchSignal(0));
for (IStateTraceManager traceManager : fEventProviderRequests.keySet()) {
// restore trace state system to nearest check point
@@ -158,10 +163,12 @@ public class LttngSyntheticEventProvider extends
}
LttngTraceState traceModel = traceManager.getStateModel();
+ // String key = (traceManager.getTrace().getPath() +
+ // traceManager.getTrace().getName()).hashCode();
+ ITmfTrace trace = traceManager.getTrace();
// create sub-request for one trace within experiment
- final LttngBaseEventRequest subRequest = new LttngBaseEventRequest(
- adjustedRange, reqWindow.getStartTime(), 0,
- TmfEventRequest.ALL_DATA, BLOCK_SIZE, traceModel, ITmfDataRequest.ExecutionType.SHORT) {
+ final LttngBaseEventRequest subRequest = new LttngBaseEventRequest(adjustedRange, reqWindow.getStartTime(),
+ 0, TmfEventRequest.ALL_DATA, BLOCK_SIZE, traceModel, ITmfDataRequest.ExecutionType.SHORT, trace) {
private LttngSyntheticEvent syntheticEvent = null;
private LttngSyntheticEvent syntheticAckIndicator = null;
@@ -180,6 +187,9 @@ public class LttngSyntheticEventProvider extends
@Override
public void handleData() {
LttngEvent[] events = getData();
+
+// Tracer.trace("Sep: " + events[0].getTimestamp());
+
if (events.length > 0) {
for (LttngEvent e : events) {
handleIncomingData(e);
@@ -217,41 +227,57 @@ public class LttngSyntheticEventProvider extends
// System.out.println("debug mark at 13589777932952L");
// }
+ TmfTrace<LttngEvent> inTrace = e.getParentTrace();
+ if (!(inTrace == getTrace())) {
+// System.out.println("Event from a different trace discarded");
+ return;
+ }
+
// queue the new event data and an ACK
updateSynEvent(e);
// If time at or above requested time, update application
- try {
- if (eventTime >= fDispatchTime) {
- // Before update
- syntheticEvent.setSequenceInd(SequenceInd.BEFORE);
- queueResult(syntheticEvent);
- queueResult(syntheticAckIndicator);
-
- // Update state locally
- syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
- fstateUpdateProcessor.process(syntheticEvent, fTraceModel);
-
- // After Update
- syntheticEvent.setSequenceInd(SequenceInd.AFTER);
- queueResult(syntheticEvent);
- queueResult(syntheticAckIndicator);
-
- // increment once per dispatch
- incrementSynEvenCount();
- subEventCount++;
- } else {
- // event time is between checkpoint adjusted time and
- // requested time i.e. application does not expect the
- // event, however the state system needs to be re-built
- // to the dispatch point
- syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
- fstateUpdateProcessor.process(syntheticEvent, fTraceModel);
- }
- } catch (InterruptedException e1) {
- // TODO: Cancel this request
- request.cancel();
-// e1.printStackTrace();
+ if (eventTime >= fDispatchTime) {
+ // Before update
+ syntheticEvent.setSequenceInd(SequenceInd.BEFORE);
+// queueResult(syntheticEvent);
+// queueResult(syntheticAckIndicator);
+
+ LttngSyntheticEvent[] result = new LttngSyntheticEvent[1];
+ result[0] = syntheticEvent;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+ result[0] = syntheticAckIndicator;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+
+ // Update state locally
+ syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
+ fstateUpdateProcessor.process(syntheticEvent, fTraceModel);
+
+ // After Update
+ syntheticEvent.setSequenceInd(SequenceInd.AFTER);
+// queueResult(syntheticEvent);
+// queueResult(syntheticAckIndicator);
+
+ result = new LttngSyntheticEvent[1];
+ result[0] = syntheticEvent;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+ result[0] = syntheticAckIndicator;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+
+ // increment once per dispatch
+ incrementSynEvenCount();
+ subEventCount++;
+ } else {
+ // event time is between checkpoint adjusted time and
+ // requested time i.e. application does not expect the
+ // event, however the state system needs to be re-built
+ // to the dispatch point
+ syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
+ fstateUpdateProcessor.process(syntheticEvent, fTraceModel);
}
}
@@ -292,13 +318,15 @@ public class LttngSyntheticEventProvider extends
fEventProviderRequests.put(traceManager, subRequest);
// start request
- TmfTrace<LttngEvent> provider = (TmfTrace<LttngEvent>) traceManager
- .getTrace();
- // provider.sendRequest(subRequest, ExecutionType.LONG);
+ TmfExperiment<LttngEvent> provider = (TmfExperiment<LttngEvent>) fExperiment.getValue();
provider.sendRequest(subRequest);
+
+ // provider.sendRequest(subRequest, ExecutionType.LONG);
subRequestQueued = true;
}
+ experiment.endSynch(new TmfEndSynchSignal(0));
+
// Return a dummy context, not used for relay provider
return (subRequestQueued) ? new TmfContext() : null;
}
@@ -307,18 +335,25 @@ public class LttngSyntheticEventProvider extends
* Notify listeners to prepare to receive data e.g. clean previous data etc.
*/
public void handleProviderStarted(LttngTraceState traceModel) {
- LttngSyntheticEvent startIndEvent = new LttngSyntheticEvent(
- fStatusEvent);
+ LttngSyntheticEvent startIndEvent = new LttngSyntheticEvent(fStatusEvent);
startIndEvent.setSequenceInd(SequenceInd.STARTREQ);
// Notify application
- try {
- queueResult(startIndEvent);
- queueResult(fStatusEventAck);
- } catch (InterruptedException e) {
- // TODO: cancel this request
+ LttngSyntheticEvent[] result = new LttngSyntheticEvent[1];
+ result[0] = startIndEvent;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+ result[0] = fStatusEventAck;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+
+// try {
+// queueResult(startIndEvent);
+// queueResult(fStatusEventAck);
+// } catch (InterruptedException e) {
+// // TODO: cancel this request
// e.printStackTrace();
- }
+// }
// Notify state event processor
fstateUpdateProcessor.process(startIndEvent, null);
@@ -352,17 +387,27 @@ public class LttngSyntheticEventProvider extends
finishEvent.setSequenceInd(SequenceInd.ENDREQ);
finishEvent.setTraceModel(traceModel);
- try {
- queueResult(finishEvent);
- queueResult(fStatusEventAck);
- // End the loop in the main request
- queueResult(LttngSyntheticEvent.NullEvent);
- } catch (InterruptedException e) {
- // System.out.println(getName() +
- // ":handleProviderDone() failed to queue request");
- // TODO: Cancel the request
-// e.printStackTrace();
- }
+ LttngSyntheticEvent[] result = new LttngSyntheticEvent[1];
+ result[0] = finishEvent;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+ result[0] = fStatusEventAck;
+ fmainRequest.setData(result);
+ fmainRequest.handleData();
+
+ fmainRequest.done();
+
+ // try {
+// queueResult(finishEvent);
+// queueResult(fStatusEventAck);
+// // End the loop in the main request
+// queueResult(LttngSyntheticEvent.NullEvent);
+// } catch (InterruptedException e) {
+// // System.out.println(getName() +
+// // ":handleProviderDone() failed to queue request");
+// // TODO: Cancel the request
+//// e.printStackTrace();
+// }
}
/**
@@ -464,13 +509,23 @@ public class LttngSyntheticEventProvider extends
}
@Override
- public LttngSyntheticEvent getNext(ITmfContext context) throws InterruptedException {
- return super.getNext(context);
+ public LttngSyntheticEvent getNext(ITmfContext context) {
+ try {
+ fmainRequest.waitForCompletion();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return null;
}
- @Override
- public void queueResult(LttngSyntheticEvent data) throws InterruptedException {
- super.queueResult(data);
- }
+// @Override
+// public LttngSyntheticEvent getNext(ITmfContext context) {
+// return super.getNext(context);
+// }
+
+// @Override
+// public void queueResult(LttngSyntheticEvent data) {
+// super.queueResult(data);
+// }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java
index 08ae5aae88..e209fcd596 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java
@@ -119,14 +119,30 @@ public class LttngLocation implements ITmfLocation<LttngTimestamp> {
isLastOperationSeek = false;
}
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof LttngLocation)) {
+ return false;
+ }
+ LttngLocation o = (LttngLocation) other;
+ return (operationTime.equals(o.operationTime)) && (isLastOperationParse == o.isLastOperationParse) &&
+ (isLastOperationReadNext == o.isLastOperationReadNext) && (isLastOperationSeek == o.isLastOperationSeek);
+ }
+
@Override
public String toString() {
- return "\tLttngLocation[ P/R/S : " + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + " Current : " + operationTime + " ]";
+// return "\tLttngLocation[ P/R/S : " + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + " Current : " + operationTime + " ]";
+ return operationTime.toString();
}
// ------------------------------------------------------------------------
// ITmfLocation
// ------------------------------------------------------------------------
+
public void setLocation(LttngTimestamp location) {
operationTime = (LttngTimestamp)location;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java
index dd666fd9ee..700b355c34 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java
@@ -18,6 +18,7 @@ import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
/**
* This class is an extension of Tmf Event Request which includes specific
@@ -35,6 +36,7 @@ public abstract class LttngBaseEventRequest extends TmfEventRequest<LttngEvent>
private long numOfEvents = 0;
private boolean clearDataInd = false;
private final LttngTraceState ftraceModel;
+ private final ITmfTrace ftrace;
/**
* The time to send events to the application as requested, Note: The start
* time of the request for base events is adjusted to the nearest check
@@ -54,12 +56,13 @@ public abstract class LttngBaseEventRequest extends TmfEventRequest<LttngEvent>
* @param traceModel
* @param listener
*/
- public LttngBaseEventRequest(TmfTimeRange range, TmfTimestamp dispatchTime,
- long offset, int nbEvents, int maxBlockSize,
- LttngTraceState traceModel, ITmfDataRequest.ExecutionType execType) {
+ public LttngBaseEventRequest(TmfTimeRange range, TmfTimestamp dispatchTime, long offset, int nbEvents,
+ int maxBlockSize, LttngTraceState traceModel, ITmfDataRequest.ExecutionType execType, ITmfTrace trace) {
super(LttngEvent.class, range, nbEvents, maxBlockSize, execType);
ftraceModel = traceModel;
fDispatchTime = dispatchTime;
+ ftrace = trace;
+
}
@Override
@@ -132,4 +135,11 @@ public abstract class LttngBaseEventRequest extends TmfEventRequest<LttngEvent>
public TmfTimestamp getDispatchTime() {
return fDispatchTime;
}
+
+ /**
+ * @return
+ */
+ public ITmfTrace getTrace() {
+ return ftrace;
+ }
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java
index 83fad35415..1a59d8210f 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java
@@ -17,7 +17,6 @@ import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent;
import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor;
import org.eclipse.linuxtools.tmf.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
/**
@@ -54,7 +53,21 @@ public class LttngSyntEventRequest extends TmfEventRequest<LttngSyntheticEvent>
int maxBlockSize, IRequestStatusListener listener,
TmfTimeRange experimentTimeRange, ITransEventProcessor processor) {
- super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize, ITmfDataRequest.ExecutionType.LONG);
+ this(range, offset, nbEvents, maxBlockSize, listener, experimentTimeRange, processor, ExecutionType.SHORT);
+ }
+
+ /**
+ * @param range
+ * @param offset
+ * @param nbEvents
+ * @param maxBlockSize
+ * @param listener
+ */
+ public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents,
+ int maxBlockSize, IRequestStatusListener listener,
+ TmfTimeRange experimentTimeRange, ITransEventProcessor processor, ExecutionType execType) {
+
+ super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize, execType);
//super(0, nbEvents, maxBlockSize);
fExperimentTimeRange = experimentTimeRange;
addListener(listener);
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/AbsEventToHandlerResolver.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/AbsEventToHandlerResolver.java
index dbbf5b26cc..36e21dc913 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/AbsEventToHandlerResolver.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/AbsEventToHandlerResolver.java
@@ -83,13 +83,11 @@ public abstract class AbsEventToHandlerResolver implements
// prevent duplicated updates in the state system
incrementBeforeEventCount();
}
-
- if (synEvent.getSynType() == SequenceInd.UPDATE) {
+ else if (synEvent.getSynType() == SequenceInd.UPDATE) {
processor = getStateUpdaterProcessor(eventType);
incrementStateUpdateCount();
}
-
- if (synEvent.getSynType() == SequenceInd.AFTER) {
+ else if (synEvent.getSynType() == SequenceInd.AFTER) {
processor = getAfterProcessor(eventType);
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java
index c4b604eff9..6a0dfe9318 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/evProcessor/state/StateUpdateHandlers.java
@@ -9,6 +9,7 @@
* Contributors:
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
*******************************************************************************/
+
package org.eclipse.linuxtools.lttng.state.evProcessor.state;
import java.util.Map;
@@ -1274,6 +1275,11 @@ class StateUpdateHandlers {
fix_process(processes[pos], time);
}
+ // Set the current process to be running
+ // TODO Should we do it for all process running on a cpu?
+ LttngProcessState process = traceSt.getRunning_process().get(trcEvent.getCpuId());
+ process.getState().setProc_status(ProcessStatus.LTTV_STATE_RUN);
+
return false;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java
index 89b0ffa0ac..dbd53ba3f8 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java
@@ -344,6 +344,9 @@ public class StateExperimentManager extends LTTngTreeNode implements
nbEvents++;
LttngEvent event = (LttngEvent) events[0];
+
+// Tracer.trace("Chk: " + event.getTimestamp());
+
ITmfTrace trace = event.getParentTrace();
IStateTraceManager traceManager = ftraceToManagerMap.get(getTraceKey(trace));
if (traceManager != null) {
@@ -397,6 +400,8 @@ public class StateExperimentManager extends LTTngTreeNode implements
* @param header
*/
private void printCompletedMessage() {
+// System.out.println(System.currentTimeMillis() + ": StateExperimentManager completed checkpoints");
+
// super.handleCompleted();
if (TraceDebug.isDEBUG()) {
TraceDebug.debug("Trace check point building completed, number of events handled: " + nbEvents
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java
index 8e668f02f9..9574719dc1 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java
@@ -55,7 +55,7 @@ class LTTngTraceException extends LttngException {
public class LTTngTrace extends TmfTrace<LttngEvent> {
// // [lmcfrch]
-// private long lastTime = 0;
+// private long lastTime = 0;
public static boolean printDebug = false;
public static boolean uniqueEvent = false;
@@ -172,6 +172,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
new LttngTimestamp(currentJniTrace.getEndTime().getTime())
) );
// }
+
}
/*
@@ -184,7 +185,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
// *** VERIFY ***
// Is this safe?
this.fCheckpoints = oldTrace.fCheckpoints;
-
+
/*
// This would only work if the index is already done
this.fCheckpoints = new Vector<TmfCheckpoint>( oldTrace.fCheckpoints.size() );
@@ -214,7 +215,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
}
@Override
- public LTTngTrace clone() {
+ public synchronized LTTngTrace clone() {
LTTngTrace clone = null;
try {
clone = (LTTngTrace) super.clone();
@@ -437,7 +438,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
public synchronized TmfContext seekEvent(TmfTimestamp timestamp) {
// // [lmcfrch]
-// lastTime = 0;
+ // lastTime = 0;
if ( printDebug == true ) {
System.out.println("seekEvent(timestamp) timestamp -> " + timestamp);
@@ -568,6 +569,10 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
curLocation = (LttngLocation)context.getLocation();
}
+//// [lmcfrch]
+// TmfContext savedContext = context.clone();
+//// [/lmcfrch]
+
// *** HACK ***
// TMF assumes it is possible to read (GetNextEvent) to the next Event once ParseEvent() is called
// In LTTNG, there is not difference between "Parsing" and "Reading" an event.
@@ -612,16 +617,18 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
if ( returnedEvent != null ) {
previousLocation.setOperationTime((LttngTimestamp)returnedEvent.getTimestamp());
curLocation.setOperationTime((LttngTimestamp)returnedEvent.getTimestamp());
-
+
+//// [lmcfrch]
+// LttngLocation prevLocation = (LttngLocation) savedContext.getLocation();
+// LttngLocation currLocation = (LttngLocation) context.getLocation();
+// Tracer.trace("Trc: " + context.getRank() + ": " + returnedEvent.getTimestamp().toString() + " (" +
+// (prevLocation.isLastOperationParse() ? "T" : "F") + "," + (prevLocation.isLastOperationReadNext() ? "T" : "F") + "," + (prevLocation.isLastOperationSeek() ? "T" : "F") + "), (" +
+// (currLocation.isLastOperationParse() ? "T" : "F") + "," + (currLocation.isLastOperationReadNext() ? "T" : "F") + "," + (currLocation.isLastOperationSeek() ? "T" : "F") + ")"
+// );
+//// [/lmcfrch]
+
updateIndex(context, context.getRank(), returnedEvent.getTimestamp());
context.updateRank(1);
-
-// // [lmcfrch]
-// long newTime = returnedEvent.getOriginalTimestamp().getValue();
-// if ((newTime-lastTime) <= 0)
-// System.out.println("Going back in time (or not moving): " + newTime + ", " + lastTime);
-// lastTime = newTime;
-// System.out.println(getName() + Thread.currentThread() + ", ts=" + lastTime);
}
return returnedEvent;
@@ -952,10 +959,6 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
return returnedData;
}
- @Override
- public void queueResult(LttngEvent data) throws InterruptedException {
- super.queueResult(data);
- }
}
/*
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/.options b/lttng/org.eclipse.linuxtools.tmf.tests/.options
new file mode 100644
index 0000000000..290591c805
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/.options
@@ -0,0 +1,8 @@
+org.eclipse.linuxtools.tmf/error=false
+org.eclipse.linuxtools.tmf/warning=false
+org.eclipse.linuxtools.tmf/info=false
+
+org.eclipse.linuxtools.tmf/component=false
+org.eclipse.linuxtools.tmf/request=false
+org.eclipse.linuxtools.tmf/signals=false
+org.eclipse.linuxtools.tmf/event=false
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/TmfCoreTestPlugin.java b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/TmfCoreTestPlugin.java
index 3c60797663..ff7be5ff96 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/TmfCoreTestPlugin.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/TmfCoreTestPlugin.java
@@ -13,6 +13,7 @@
package org.eclipse.linuxtools.tmf.tests;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.linuxtools.tmf.Tracer;
import org.osgi.framework.BundleContext;
/**
@@ -69,10 +70,12 @@ public class TmfCoreTestPlugin extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
setDefault(this);
+ Tracer.init();
}
@Override
public void stop(BundleContext context) throws Exception {
+ Tracer.stop();
setDefault(null);
super.stop(context);
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/component/TmfEventProviderTest.java b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/component/TmfEventProviderTest.java
index 298560dc15..8e354a648e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/component/TmfEventProviderTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/component/TmfEventProviderTest.java
@@ -199,17 +199,18 @@ public class TmfEventProviderTest extends TestCase {
public void testGetSyntheticEvents_WeirdTimeRange1() {
TmfTimestamp start = TmfTimestamp.BigBang;
- TmfTimestamp end = new TmfTimestamp(0, (byte) -3, 0);
+ TmfTimestamp end = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte) -3, 0);
TmfTimeRange range = new TmfTimeRange(start, end);
try {
getSyntheticData(range, -1, TmfSyntheticEventProviderStub.BLOCK_SIZE);
+// System.out.println("aie");
} catch (InterruptedException e) {
fail();
}
}
public void testGetSyntheticEvents_WeirdTimeRange2() {
- TmfTimestamp start = new TmfTimestamp(0, (byte) -3, 0);
+ TmfTimestamp start = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte) -3, 0);
TmfTimestamp end = TmfTimestamp.BigCrunch;
TmfTimeRange range = new TmfTimeRange(start, end);
try {
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfExperimentTest.java b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfExperimentTest.java
index 94366b3223..3943bd0859 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfExperimentTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfExperimentTest.java
@@ -29,6 +29,7 @@ import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.experiment.TmfExperimentContext;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.trace.TmfCheckpoint;
import org.eclipse.linuxtools.tmf.trace.TmfContext;
@@ -112,182 +113,155 @@ public class TmfExperimentTest extends TestCase {
// ------------------------------------------------------------------------
// Verify checkpoints
- // Note: seekLocation() does not reliably set the rank
// ------------------------------------------------------------------------
public void testValidateCheckpoints() throws Exception {
Vector<TmfCheckpoint> checkpoints = fExperiment.getCheckpoints();
-// int pageSize = fExperiment.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
+ int pageSize = fExperiment.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
// Validate that each checkpoint points to the right event
for (int i = 0; i < checkpoints.size(); i++) {
TmfCheckpoint checkpoint = checkpoints.get(i);
TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
TmfEvent event = fExperiment.parseEvent(context);
-// assertEquals("Event rank", context.getRank(), i * pageSize);
+ assertEquals("Event rank", i * pageSize, context.getRank());
assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
}
}
// ------------------------------------------------------------------------
- // parseEvent - make sure parseEvent doesn't update the context
- // ------------------------------------------------------------------------
-
- public void testParseEvent() throws Exception {
-
- // On lower bound, returns the first event (ts = 1)
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- for (int i = 1; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
- }
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
- }
-
- // ------------------------------------------------------------------------
- // getNextEvent - updates the context
- // ------------------------------------------------------------------------
-
- public void testGetNextEvent() throws Exception {
-
- // On lower bound, returns the first event (ts = 0)
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
- TmfEvent event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- for (int i = 2; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
- }
- }
-
- // ------------------------------------------------------------------------
// seekLocation
- // Note: seekLocation() does not reliably set the rank
// ------------------------------------------------------------------------
public void testSeekLocationOnCacheBoundary() throws Exception {
// Position trace at event rank 0
TmfContext context = fExperiment.seekLocation(null);
-// assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event rank", 0, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 0, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1, context.getRank());
+ assertEquals("Event rank", 1, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
+ assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 1000
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.parseEvent(context);
+ context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 1000, context.getRank());
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 1000, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1001, context.getRank());
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4000
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.parseEvent(context);
+ context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 4000, context.getRank());
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 4000, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4001, context.getRank());
+ assertEquals("Event rank", 4001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4002, context.getRank());
}
public void testSeekLocationNotOnCacheBoundary() throws Exception {
// Position trace at event rank 9
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 9, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+ TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 9, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-// assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 9, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-// assertEquals("Event rank", 10, context.getRank());
+ assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.parseEvent(context);
+ context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 999, context.getRank());
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-// assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 999, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1000, context.getRank());
+ assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.parseEvent(context);
+ context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1002, context.getRank());
+ assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.parseEvent(context);
+ context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 4500, context.getRank());
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 4500, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4501, context.getRank());
+ assertEquals("Event rank", 4501, context.getRank());
}
public void testSeekLocationOutOfScope() throws Exception {
// Position trace at beginning
TmfContext tmpContext = fExperiment.seekLocation(null);
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+ TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+ assertEquals("Event rank", 0, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ assertEquals("Event rank", 0, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1, context.getRank());
+ assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", null, event);
-// assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", null, event);
-// assertEquals("Event rank", NB_EVENTS, context.getRank());
+ assertEquals("Event location", null, tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, tmpContext.getRank());
}
// ------------------------------------------------------------------------
@@ -299,30 +273,36 @@ public class TmfExperimentTest extends TestCase {
// Position trace at event rank 0
TmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event rank 1000
context = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
// Position trace at event rank 4000
context = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
@@ -332,50 +312,60 @@ public class TmfExperimentTest extends TestCase {
// Position trace at event rank 1
TmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
assertEquals("Event rank", 1, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 9
context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
@@ -385,22 +375,19 @@ public class TmfExperimentTest extends TestCase {
// Position trace at beginning
TmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
+ assertEquals("Event location", null, context.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
// ------------------------------------------------------------------------
@@ -412,30 +399,36 @@ public class TmfExperimentTest extends TestCase {
// On lower bound, returns the first event (ts = 1)
TmfContext context = fExperiment.seekEvent(0);
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event rank 1000
context = fExperiment.seekEvent(1000);
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
// Position trace at event rank 4000
context = fExperiment.seekEvent(4000);
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
@@ -445,68 +438,116 @@ public class TmfExperimentTest extends TestCase {
// Position trace at event rank 9
TmfContext context = fExperiment.seekEvent(9);
assertEquals("Event rank", 9, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
context = fExperiment.seekEvent(999);
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
context = fExperiment.seekEvent(1001);
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
context = fExperiment.seekEvent(4500);
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
- public void testSeekEventOnRankOfScope() throws Exception {
+ public void testSeekEventOnRankOutOfScope() throws Exception {
// Position trace at beginning
TmfContext context = fExperiment.seekEvent(-1);
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
context = fExperiment.seekEvent(NB_EVENTS);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
+ assertEquals("Event location", null, context.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
// ------------------------------------------------------------------------
+ // parseEvent - make sure parseEvent doesn't update the context
+ // Note: This test is essentially the same as the one from TmfTraceTest
+ // ------------------------------------------------------------------------
+
+ public void testParseEvent() throws Exception {
+
+ int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 1)
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
+
+ // Read NB_EVENTS
+ TmfEvent event = null;;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", i + 1, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", NB_READS, context.getRank());
+ }
+
+ // ------------------------------------------------------------------------
+ // getNextEvent - updates the context
+ // ------------------------------------------------------------------------
+
+ public void testGetNextEvent() throws Exception {
+
+ // On lower bound, returns the first event (ts = 0)
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
+ TmfEvent event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+
+ for (int i = 2; i < 20; i++) {
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", i, event.getTimestamp().getValue());
+ }
+ }
+
+ // ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfMultiTraceExperimentTest.java b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfMultiTraceExperimentTest.java
index b5818de5b7..739ad21bd9 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfMultiTraceExperimentTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/experiment/TmfMultiTraceExperimentTest.java
@@ -26,9 +26,12 @@ import org.eclipse.linuxtools.tmf.event.TmfEvent;
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.experiment.TmfExperimentContext;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.trace.TmfCheckpoint;
import org.eclipse.linuxtools.tmf.trace.TmfContext;
import org.eclipse.linuxtools.tmf.trace.TmfTraceStub;
@@ -44,7 +47,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
private static final String TEST_STREAM2 = "E-Test-10K";
private static final String EXPERIMENT = "MyExperiment";
private static int NB_EVENTS = 20000;
- private static int fDefaultBlockSize = 1000;
+ private static int BLOCK_SIZE = 1000;
private static ITmfTrace[] fTraces;
private static TmfExperiment<TmfEvent> fExperiment;
@@ -79,7 +82,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
private synchronized static void setupExperiment() {
synchronized (TmfMultiTraceExperimentTest.class) {
if (fExperiment == null) {
- fExperiment = new TmfExperiment<TmfEvent>(TmfEvent.class, EXPERIMENT, fTraces, TmfTimestamp.Zero, 1000, true);
+ fExperiment = new TmfExperiment<TmfEvent>(TmfEvent.class, EXPERIMENT, fTraces, TmfTimestamp.Zero, BLOCK_SIZE, true);
}
}
}
@@ -105,6 +108,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
// ------------------------------------------------------------------------
public void testBasicTmfExperimentConstructor() {
+
assertEquals("GetId", EXPERIMENT, fExperiment.getName());
assertEquals("GetEpoch", TmfTimestamp.Zero, fExperiment.getEpoch());
assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
@@ -115,386 +119,448 @@ public class TmfMultiTraceExperimentTest extends TestCase {
}
// ------------------------------------------------------------------------
- // parseEvent - make sure parseEvent doesn't update the context
- // ------------------------------------------------------------------------
-
- public void testParseEvent() throws Exception {
-
- // On lower bound, returns the first event (ts = 0)
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
- for (int i = 1; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
- }
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
-
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
- }
-
- // ------------------------------------------------------------------------
- // getNextEvent - updates the context
+ // Verify checkpoints
// ------------------------------------------------------------------------
- public void testGetNextEvent() throws Exception {
+ public void testValidateCheckpoints() throws Exception {
- // On lower bound, returns the first event (ts = 0)
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
- TmfEvent event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ Vector<TmfCheckpoint> checkpoints = fExperiment.getCheckpoints();
+ int pageSize = fExperiment.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
- for (int i = 2; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
- }
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ TmfCheckpoint checkpoint = checkpoints.get(i);
+ TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event rank", context.getRank(), i * pageSize);
+ assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
}
// ------------------------------------------------------------------------
// seekLocation
- // Note: seekLocation() does not reliably set the rank
// ------------------------------------------------------------------------
public void testSeekLocationOnCacheBoundary() throws Exception {
// Position trace at event rank 0
TmfContext context = fExperiment.seekLocation(null);
-// assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event rank 1000
- TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1001, context.getRank());
-
- // Position trace at event rank 4000
- tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4001, context.getRank());
- }
-
- public void testSeekLocationNotOnCacheBoundary() throws Exception {
-
- // Position trace at event rank 9
- TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 9, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-// assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-// assertEquals("Event rank", 10, context.getRank());
-
- // Position trace at event rank 999
- tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-// assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1000, context.getRank());
-
- // Position trace at event rank 1001
- tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1002, context.getRank());
-
- // Position trace at event rank 4500
- tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-// assertEquals("Event rank", 4501, context.getRank());
- }
-
- public void testSeekLocationOutOfScope() throws Exception {
-
- // Position trace at beginning
- TmfContext tmpContext = fExperiment.seekLocation(null);
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 1, context.getRank());
-
- // Position trace at event passed the end
- tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
-// assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", null, event);
-// assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", null, event);
-// assertEquals("Event rank", NB_EVENTS, context.getRank());
- }
-
- // ------------------------------------------------------------------------
- // seekEvent on timestamp
- // ------------------------------------------------------------------------
-
- public void testSeekEventOnTimestampOnCacheBoundary() throws Exception {
-
- // Position trace at event rank 0
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
+ assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 1000
- context = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
+ TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
+ context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4000
- context = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
+ tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
+ context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4002, context.getRank());
}
- public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception {
-
- // Position trace at event rank 1
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
- assertEquals("Event rank", 1, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
- assertEquals("Event rank", 2, context.getRank());
+ public void testSeekLocationNotOnCacheBoundary() throws Exception {
// Position trace at event rank 9
- context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
+ TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
+ TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
- context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
+ tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
+ context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
- context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
+ tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
+ context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
- context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
+ tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
+ context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.parseEvent(context);
+
+ event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
- public void testSeekEventOnTimestampoutOfScope() throws Exception {
+ public void testSeekLocationOutOfScope() throws Exception {
// Position trace at beginning
- TmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
+ TmfContext tmpContext = fExperiment.seekLocation(null);
+ TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
+
+ TmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+
+ event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
- context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
+ tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
+ assertEquals("Event location", null, tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, tmpContext.getRank());
}
- // ------------------------------------------------------------------------
- // seekEvent on rank
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ // seekEvent on timestamp
+ // ------------------------------------------------------------------------
+
+ public void testSeekEventOnTimestampOnCacheBoundary() throws Exception {
+
+ // Position trace at event rank 0
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE, 0));
+ assertEquals("Event rank", 0, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1, context.getRank());
+
+ // Position trace at event rank 1000
+ context = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
+ assertEquals("Event rank", 1000, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1000, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1001, context.getRank());
+
+ // Position trace at event rank 4000
+ context = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
+ assertEquals("Event rank", 4000, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4000, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4001, context.getRank());
+ }
- public void testSeekOnRankOnCacheBoundary() throws Exception {
+ public void testSeekEventOnTimestampNotOnCacheBoundary() throws Exception {
+
+ // Position trace at event rank 1
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE, 0));
+ assertEquals("Event rank", 1, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
+ assertEquals("Event rank", 2, context.getRank());
+
+ // Position trace at event rank 9
+ context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
+ assertEquals("Event rank", 9, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+ assertEquals("Event rank", 9, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+ assertEquals("Event rank", 10, context.getRank());
+
+ // Position trace at event rank 999
+ context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
+ assertEquals("Event rank", 999, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+ assertEquals("Event rank", 999, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1000, context.getRank());
+
+ // Position trace at event rank 1001
+ context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1002, context.getRank());
+
+ // Position trace at event rank 4500
+ context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
+ assertEquals("Event rank", 4500, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4500, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4501, context.getRank());
+ }
- // On lower bound, returns the first event (ts = 1)
- TmfContext context = fExperiment.seekEvent(0);
- assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
+ public void testSeekEventOnTimestampOutOfScope() throws Exception {
+
+ // Position trace at beginning
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE, 0));
+ assertEquals("Event rank", 0, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1, context.getRank());
+
+ // Position trace at event passed the end
+ context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
+ assertEquals("Event location", null, context.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+ }
- // Position trace at event rank 1000
- context = fExperiment.seekEvent(1000);
- assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
- assertEquals("Event rank", 1001, context.getRank());
+ // ------------------------------------------------------------------------
+ // seekEvent on rank
+ // ------------------------------------------------------------------------
+
+ public void testSeekOnRankOnCacheBoundary() throws Exception {
+
+ // On lower bound, returns the first event (ts = 1)
+ TmfContext context = fExperiment.seekEvent(0);
+ assertEquals("Event rank", 0, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1, context.getRank());
+
+ // Position trace at event rank 1000
+ context = fExperiment.seekEvent(1000);
+ assertEquals("Event rank", 1000, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1000, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1001, context.getRank());
+
+ // Position trace at event rank 4000
+ context = fExperiment.seekEvent(4000);
+ assertEquals("Event rank", 4000, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4000, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4001, context.getRank());
+ }
- // Position trace at event rank 4000
- context = fExperiment.seekEvent(4000);
- assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
- assertEquals("Event rank", 4001, context.getRank());
- }
+ public void testSeekOnRankNotOnCacheBoundary() throws Exception {
+
+ // Position trace at event rank 9
+ TmfContext context = fExperiment.seekEvent(9);
+ assertEquals("Event rank", 9, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+ assertEquals("Event rank", 9, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+ assertEquals("Event rank", 10, context.getRank());
+
+ // Position trace at event rank 999
+ context = fExperiment.seekEvent(999);
+ assertEquals("Event rank", 999, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+ assertEquals("Event rank", 999, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1000, context.getRank());
+
+ // Position trace at event rank 1001
+ context = fExperiment.seekEvent(1001);
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1001, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1002, context.getRank());
+
+ // Position trace at event rank 4500
+ context = fExperiment.seekEvent(4500);
+ assertEquals("Event rank", 4500, context.getRank());
+
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4500, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+ assertEquals("Event rank", 4501, context.getRank());
+ }
- public void testSeekOnRankNotOnCacheBoundary() throws Exception {
+ public void testSeekEventOnRankOutOfScope() throws Exception {
+
+ // Position trace at beginning
+ TmfContext context = fExperiment.seekEvent(-1);
+ assertEquals("Event rank", 0, context.getRank());
+
+ TmfEvent event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 1, context.getRank());
+
+ // Position trace at event passed the end
+ context = fExperiment.seekEvent(NB_EVENTS);
+ assertEquals("Event location", null, context.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+ }
- // Position trace at event rank 9
- TmfContext context = fExperiment.seekEvent(9);
- assertEquals("Event rank", 9, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
- assertEquals("Event rank", 10, context.getRank());
+ // ------------------------------------------------------------------------
+ // parseEvent - make sure parseEvent doesn't update the context
+ // Note: This test is essentially the same as the one from TmfTraceTest
+ // ------------------------------------------------------------------------
- // Position trace at event rank 999
- context = fExperiment.seekEvent(999);
- assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
- assertEquals("Event rank", 1000, context.getRank());
+ public void testParseEvent() throws Exception {
- // Position trace at event rank 1001
- context = fExperiment.seekEvent(1001);
- assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
- assertEquals("Event rank", 1002, context.getRank());
+ int NB_READS = 20;
- // Position trace at event rank 4500
- context = fExperiment.seekEvent(4500);
- assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
- assertEquals("Event rank", 4501, context.getRank());
+ // On lower bound, returns the first event (ts = 1)
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
+
+ // Read NB_EVENTS
+ TmfEvent event = null;;
+ for (int i = 0; i < NB_READS; i++) {
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", i + 1, context.getRank());
+ }
+
+ // Make sure we stay positioned
+ event = fExperiment.parseEvent(context);
+ assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", NB_READS, context.getRank());
}
- public void testSeekEventOnRankOfScope() throws Exception {
+ // ------------------------------------------------------------------------
+ // getNextEvent - updates the context
+ // ------------------------------------------------------------------------
- // Position trace at beginning
- TmfContext context = fExperiment.seekEvent(-1);
- assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ public void testGetNextEvent() throws Exception {
+
+ // On lower bound, returns the first event (ts = 0)
+ TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
+ TmfEvent event = fExperiment.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
- // Position trace at event passed the end
- context = fExperiment.seekEvent(NB_EVENTS);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.parseEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
- assertEquals("Event timestamp", null, event);
- assertEquals("Event rank", NB_EVENTS, context.getRank());
+ for (int i = 2; i < 20; i++) {
+ event = fExperiment.getNextEvent(context);
+ assertEquals("Event timestamp", i, event.getTimestamp().getValue());
+ }
}
-
+
// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
public void testProcessRequestForNbEvents() throws Exception {
- final int blockSize = 100;
+
+ final int blockSize = 100;
final int nbEvents = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
@@ -523,7 +589,8 @@ public class TmfMultiTraceExperimentTest extends TestCase {
}
public void testProcessRequestForNbEvents2() throws Exception {
- final int blockSize = 2 * NB_EVENTS;
+
+ final int blockSize = 2 * NB_EVENTS;
final int nbEvents = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
@@ -552,10 +619,11 @@ public class TmfMultiTraceExperimentTest extends TestCase {
}
public void testProcessRequestForAllEvents() throws Exception {
- final int nbEvents = TmfEventRequest.ALL_DATA;
+
+ final int nbEvents = TmfEventRequest.ALL_DATA;
final int blockSize = 1;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
- long nbExpectedEvents = fExperiment.getNbEvents();
+ long nbExpectedEvents = NB_EVENTS;
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, nbEvents, blockSize) {
@@ -570,7 +638,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
fExperiment.sendRequest(request);
request.waitForCompletion();
- assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+ assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertFalse("isCancelled", request.isCancelled());
@@ -586,8 +654,9 @@ public class TmfMultiTraceExperimentTest extends TestCase {
// ------------------------------------------------------------------------
public void testCancel() throws Exception {
- final int nbEvents = NB_EVENTS;
- final int blockSize = fDefaultBlockSize;
+
+ final int nbEvents = NB_EVENTS;
+ final int blockSize = BLOCK_SIZE;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
@@ -601,6 +670,12 @@ public class TmfMultiTraceExperimentTest extends TestCase {
// Cancel request after the first chunk is received
cancel();
}
+ @Override
+ public void handleCancel() {
+ if (requestedEvents.size() < blockSize) {
+ System.out.println("aie");
+ }
+ }
};
fExperiment.sendRequest(request);
request.waitForCompletion();
@@ -615,7 +690,8 @@ public class TmfMultiTraceExperimentTest extends TestCase {
// ------------------------------------------------------------------------
public void testGetRank() throws Exception {
- assertEquals("getRank", 0, fExperiment.getRank(new TmfTimestamp()));
+
+ assertEquals("getRank", 0, fExperiment.getRank(new TmfTimestamp()));
assertEquals("getRank", 0, fExperiment.getRank(new TmfTimestamp( 1, (byte) -3)));
assertEquals("getRank", 10, fExperiment.getRank(new TmfTimestamp( 11, (byte) -3)));
assertEquals("getRank", 100, fExperiment.getRank(new TmfTimestamp( 101, (byte) -3)));
@@ -629,7 +705,8 @@ public class TmfMultiTraceExperimentTest extends TestCase {
// ------------------------------------------------------------------------
public void testGetTimestamp() throws Exception {
- assertTrue("getTimestamp", fExperiment.getTimestamp( 0).equals(new TmfTimestamp( 1, (byte) -3)));
+
+ assertTrue("getTimestamp", fExperiment.getTimestamp( 0).equals(new TmfTimestamp( 1, (byte) -3)));
assertTrue("getTimestamp", fExperiment.getTimestamp( 10).equals(new TmfTimestamp( 11, (byte) -3)));
assertTrue("getTimestamp", fExperiment.getTimestamp( 100).equals(new TmfTimestamp( 101, (byte) -3)));
assertTrue("getTimestamp", fExperiment.getTimestamp(1000).equals(new TmfTimestamp(1001, (byte) -3)));
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/trace/TmfTraceTest.java b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/trace/TmfTraceTest.java
index ea8fc23721..8f3ce4903c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/trace/TmfTraceTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/trace/TmfTraceTest.java
@@ -66,6 +66,7 @@ public class TmfTraceTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
fTrace = setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ // Dummy request to force the trace indexing
TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class) {
@Override
public void handleData() {
@@ -92,7 +93,6 @@ public class TmfTraceTest extends TestCase {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
File test = new File(FileLocator.toFileURL(location).toURI());
fTrace = new TmfTraceStub(test.getPath(), BLOCK_SIZE, false);
-// fTrace.indexTrace(true);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
@@ -122,7 +122,7 @@ public class TmfTraceTest extends TestCase {
assertEquals("getType", TmfEvent.class, trace.getType());
assertEquals("getPath", testfile.getPath(), trace.getPath());
assertEquals("getName", TEST_STREAM, trace.getName());
- assertEquals("getCacheSize", TmfTrace.DEFAULT_CACHE_SIZE, trace.getCacheSize());
+ assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize());
}
public void testTmfTraceDefaultCacheSize() throws Exception {
@@ -141,7 +141,7 @@ public class TmfTraceTest extends TestCase {
assertEquals("getType", TmfEvent.class, trace.getType());
assertEquals("getPath", testfile.getPath(), trace.getPath());
assertEquals("getName", TEST_STREAM, trace.getName());
- assertEquals("getCacheSize", TmfTrace.DEFAULT_CACHE_SIZE, trace.getCacheSize());
+ assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize());
}
public void testTmfTrace() throws Exception {
@@ -240,28 +240,43 @@ public class TmfTraceTest extends TestCase {
public void testParseEvent() throws Exception {
+ int NB_READS = 20;
+
// On lower bound, returns the first event (ts = 0)
TmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0));
+ TmfContext svContext = new TmfContext(context);
TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+ assertTrue("parseEvent", context.equals(svContext));
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+ assertTrue("parseEvent", context.equals(svContext));
event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+ assertTrue("parseEvent", context.equals(svContext));
- for (int i = 1; i < 20; i++) {
+ // Position the trace at event NB_READS
+ for (int i = 1; i < NB_READS; i++) {
event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", i, event.getTimestamp().getValue());
}
+ svContext = new TmfContext(context);
event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
+ assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", NB_READS -1 , context.getRank());
+ assertTrue("parseEvent", context.equals(svContext));
event = fTrace.parseEvent(context);
- assertEquals("Event timestamp", 20, event.getTimestamp().getValue());
+ assertEquals("Event timestamp", NB_READS, event.getTimestamp().getValue());
+ assertEquals("Event rank", NB_READS - 1, context.getRank());
+ assertTrue("parseEvent", context.equals(svContext));
}
// ------------------------------------------------------------------------
@@ -270,15 +285,23 @@ public class TmfTraceTest extends TestCase {
public void testGetNextEvent() throws Exception {
- // On lower bound, returns the first event (ts = 0)
+ int NB_READS = 20;
+
+ // On lower bound, returns the first event (ts = 1)
TmfContext context = fTrace.seekEvent(new TmfTimestamp(0, SCALE, 0));
- TmfEvent event = fTrace.getNextEvent(context);
- assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- for (int i = 2; i < 20; i++) {
+ // Read NB_EVENTS
+ TmfEvent event;
+ for (int i = 0; i < NB_READS; i++) {
event = fTrace.getNextEvent(context);
- assertEquals("Event timestamp", i, event.getTimestamp().getValue());
+ assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", i + 1, context.getRank());
}
+
+ // Make sure we stay positioned
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", NB_READS + 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", NB_READS, context.getRank());
}
// ------------------------------------------------------------------------
@@ -290,33 +313,44 @@ public class TmfTraceTest extends TestCase {
// Position trace at event rank 0
TmfContext context = fTrace.seekLocation(null);
- assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ context = fTrace.seekLocation(context.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
- assertEquals("Event rank", 1, context.getRank());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.getNextEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 1000
TmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 4000
tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
@@ -325,45 +359,53 @@ public class TmfTraceTest extends TestCase {
// Position trace at event rank 9
TmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ TmfContext context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 999
tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 1001
tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 4500
tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
@@ -372,23 +414,27 @@ public class TmfTraceTest extends TestCase {
// Position trace at beginning
TmfContext tmpContext = fTrace.seekLocation(null);
- TmfContext context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ TmfContext context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event passed the end
tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- context = fTrace.seekLocation(tmpContext.getLocation().clone());
+ context = fTrace.seekLocation(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
}
@@ -402,30 +448,36 @@ public class TmfTraceTest extends TestCase {
// Position trace at event rank 0
TmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE, 0));
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event rank 1000
context = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
assertEquals("Event rank", 1000, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
// Position trace at event rank 4000
context = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
assertEquals("Event rank", 4000, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
@@ -435,50 +487,60 @@ public class TmfTraceTest extends TestCase {
// Position trace at event rank 1
TmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE, 0));
assertEquals("Event rank", 1, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 9
context = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
assertEquals("Event rank", 9, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
context = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
assertEquals("Event rank", 999, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
context = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
assertEquals("Event rank", 1001, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
context = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
assertEquals("Event rank", 4500, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
@@ -488,20 +550,24 @@ public class TmfTraceTest extends TestCase {
// Position trace at beginning
TmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE, 0));
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
@@ -515,30 +581,36 @@ public class TmfTraceTest extends TestCase {
// On lower bound, returns the first event (ts = 1)
TmfContext context = fTrace.seekEvent(0);
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event rank 1000
context = fTrace.seekEvent(1000);
assertEquals("Event rank", 1000, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
// Position trace at event rank 4000
context = fTrace.seekEvent(4000);
assertEquals("Event rank", 4000, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
@@ -548,40 +620,48 @@ public class TmfTraceTest extends TestCase {
// Position trace at event rank 9
TmfContext context = fTrace.seekEvent(9);
assertEquals("Event rank", 9, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
context = fTrace.seekEvent(999);
assertEquals("Event rank", 999, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
context = fTrace.seekEvent(1001);
assertEquals("Event rank", 1001, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
context = fTrace.seekEvent(4500);
assertEquals("Event rank", 4500, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
@@ -591,20 +671,24 @@ public class TmfTraceTest extends TestCase {
// Position trace at beginning
TmfContext context = fTrace.seekEvent(-1);
assertEquals("Event rank", 0, context.getRank());
- TmfEvent event = fTrace.parseEvent(context);
+
+ TmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
context = fTrace.seekEvent(NB_EVENTS);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fTrace.parseEvent(context);
+
+ event = fTrace.parseEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fTrace.getNextEvent(context);
+
+ event = fTrace.getNextEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java b/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java
index b48936f9fa..6de6d76363 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java
@@ -12,6 +12,8 @@
package org.eclipse.linuxtools.tmf.component;
+import java.util.concurrent.TimeUnit;
+
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfSyntheticEventStub;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
@@ -73,17 +75,36 @@ public class TmfSyntheticEventProviderStub extends TmfEventProvider<TmfSynthetic
// Queue 2 synthetic events per base event
private void handleIncomingData(TmfEvent e) {
+ queueResult(new TmfSyntheticEventStub(e));
+ queueResult(new TmfSyntheticEventStub(e));
+ }
+
+ private static final int TIMEOUT = 10000;
+
+ @Override
+ public TmfSyntheticEventStub getNext(ITmfContext context) {
+ TmfSyntheticEventStub data = null;
try {
- queueResult(new TmfSyntheticEventStub(e));
- queueResult(new TmfSyntheticEventStub(e));
- } catch (InterruptedException e1) {
-// e1.printStackTrace();
+ data = fDataQueue.poll(TIMEOUT, TimeUnit.MILLISECONDS);
+ if (data == null) {
+ throw new InterruptedException();
+ }
+ }
+ catch (InterruptedException e) {
}
+ return data;
}
- @Override
- public void sendRequest(ITmfDataRequest<TmfSyntheticEventStub> request) {
- super.sendRequest(request);
+ public void queueResult(TmfSyntheticEventStub data) {
+ boolean ok = false;
+ try {
+ ok = fDataQueue.offer(data, TIMEOUT, TimeUnit.MILLISECONDS);
+ if (!ok) {
+ throw new InterruptedException();
+ }
+ }
+ catch (InterruptedException e) {
+ }
}
-
+
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java b/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java
index b691326758..da556ba029 100644
--- a/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java
+++ b/lttng/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java
@@ -47,7 +47,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
* @throws FileNotFoundException
*/
public TmfTraceStub(String filename) throws FileNotFoundException {
- this(filename, DEFAULT_CACHE_SIZE, false);
+ this(filename, DEFAULT_INDEX_PAGE_SIZE, false);
}
/**
@@ -65,7 +65,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
* @throws FileNotFoundException
*/
public TmfTraceStub(String filename, boolean waitForCompletion) throws FileNotFoundException {
- this(filename, DEFAULT_CACHE_SIZE, waitForCompletion);
+ this(filename, DEFAULT_INDEX_PAGE_SIZE, waitForCompletion);
}
/**
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/ChangeLog b/lttng/org.eclipse.linuxtools.tmf.ui/ChangeLog
new file mode 100644
index 0000000000..937b57efe7
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/ChangeLog
@@ -0,0 +1,13 @@
+2010-07-28 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/tmf/ui/widgets/TMFTable.java: Removed.
+ * src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java: New file.
+ * src/org/eclipse/linuxtools/tmf/ui/widgets/TmfTable.java: New file.
+ * src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java: New file.
+ * META-INF/MANIFEST.MF: Exported widgets
+ * src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java: Repalced Table by TmfVirtualTable
+ * src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java:
+
+2010-07-08 francois <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java: Cosmetic change \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
index 192c41e9b8..543d299f7a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
@@ -12,9 +12,11 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.linuxtools.tmf.ui,
org.eclipse.linuxtools.tmf.ui.viewers,
+ org.eclipse.linuxtools.tmf.ui.viewers.events,
org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis,
org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs,
org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model,
org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets,
- org.eclipse.linuxtools.tmf.ui.views
+ org.eclipse.linuxtools.tmf.ui.views,
+ org.eclipse.linuxtools.tmf.ui.widgets
Bundle-Localization: plugin
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
new file mode 100644
index 0000000000..e0d96324b5
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
@@ -0,0 +1,340 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Patrick Tasse - Factored out from events view
+ * Francois Chouinard - Replaced Table by TmfVirtualTable
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.events;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.tmf.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.component.TmfComponent;
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData;
+import org.eclipse.linuxtools.tmf.ui.widgets.TmfVirtualTable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * <b><u>TmfEventsTable</u></b>
+ */
+public class TmfEventsTable extends TmfComponent {
+
+// private Shell fShell;
+
+ // ------------------------------------------------------------------------
+ // Table data
+ // ------------------------------------------------------------------------
+
+ protected TmfVirtualTable fTable;
+ protected ITmfTrace fTrace;
+ protected boolean fPackDone = false;
+
+ // Table column names
+ static private final String TIMESTAMP_COLUMN = "Timestamp";
+ static private final String SOURCE_COLUMN = "Source";
+ static private final String TYPE_COLUMN = "Type";
+ static private final String REFERENCE_COLUMN = "File";
+ static private final String CONTENT_COLUMN = "Content";
+ static private final String[] COLUMN_NAMES = new String[] {
+ TIMESTAMP_COLUMN,
+ SOURCE_COLUMN,
+ TYPE_COLUMN,
+ REFERENCE_COLUMN,
+ CONTENT_COLUMN
+ };
+
+ static private ColumnData[] COLUMN_DATA = new ColumnData[] {
+ new ColumnData(COLUMN_NAMES[0], 100, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[2], 100, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT),
+ new ColumnData(COLUMN_NAMES[4], 100, SWT.LEFT)
+ };
+
+ // ------------------------------------------------------------------------
+ // Event cache
+ // ------------------------------------------------------------------------
+
+ private final int fCacheSize;
+ private TmfEvent[] fCache;
+ private int fCacheStartIndex = 0;
+ private int fCacheEndIndex = 0;
+
+ private boolean fDisposeOnClose;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ public TmfEventsTable(Composite parent, int cacheSize) {
+ this(parent, cacheSize, COLUMN_DATA);
+ }
+
+ public TmfEventsTable(Composite parent, int cacheSize, ColumnData[] columnData) {
+ super("TmfEventsTable");
+
+ fCacheSize = cacheSize;
+ fCache = new TmfEvent[fCacheSize];
+
+ // Create a virtual table
+ final int style = SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER;
+ fTable = new TmfVirtualTable(parent, style);
+
+ // Set the table layout
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ fTable.setLayoutData(layoutData);
+
+ // Some cosmetic enhancements
+ fTable.setHeaderVisible(true);
+ fTable.setLinesVisible(true);
+
+ // Set the columns
+ setColumnHeaders(columnData);
+
+ // Handle the table item requests
+ fTable.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TmfTimestamp ts = (TmfTimestamp) fTable.getSelection()[0].getData();
+ broadcast(new TmfTimeSynchSignal(fTable, ts));
+ }
+ });
+
+ // Handle the table item requests
+ fTable.addListener(SWT.SetData, new Listener() {
+
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event event) {
+
+ final TableItem item = (TableItem) event.item;
+ final int index = fTable.indexOf(item);
+
+ // Note: this works because handleEvent() is called once for each row, in sequence
+ if ((index >= fCacheStartIndex) && (index < fCacheEndIndex)) {
+ int i = index - fCacheStartIndex;
+ item.setText(extractItemFields(fCache[i]));
+ item.setData(new TmfTimestamp(fCache[i].getTimestamp()));
+ return;
+ }
+
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(TmfEvent.class, index, fCacheSize) {
+ @Override
+ public void handleData() {
+ TmfEvent[] tmpEvent = getData();
+ if ((tmpEvent != null) && (tmpEvent.length > 0)) {
+ fCache = tmpEvent;
+ fCacheStartIndex = index;
+ fCacheEndIndex = index + tmpEvent.length;
+ }
+ }
+ };
+ ((ITmfDataProvider<TmfEvent>) fTrace).sendRequest(request);
+ try {
+ request.waitForCompletion();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ if (fCache[0] != null && fCacheStartIndex == index) {
+ item.setText(extractItemFields(fCache[0]));
+ item.setData(new TmfTimestamp(fCache[0].getTimestamp()));
+ packColumns();
+ }
+
+ }
+ });
+
+ fTable.setItemCount(0);
+ }
+
+ @Override
+ public void dispose() {
+ fTable.dispose();
+ if (fTrace != null && fDisposeOnClose) {
+ fTrace.dispose();
+ }
+ super.dispose();
+ }
+
+ public TmfVirtualTable getTable() {
+ return fTable;
+ }
+
+ /**
+ * @param table
+ *
+ * FIXME: Add support for column selection
+ */
+ protected void setColumnHeaders(ColumnData[] columnData) {
+ fTable.setColumnHeaders(columnData);
+ }
+
+ protected void packColumns() {
+ if (fPackDone) return;
+ for (TableColumn column : fTable.getColumns()) {
+ int headerWidth = column.getWidth();
+ column.pack();
+ if (column.getWidth() < headerWidth) {
+ column.setWidth(headerWidth);
+ }
+ }
+ fPackDone = true;
+ }
+
+ /**
+ * @param event
+ * @return
+ *
+ * FIXME: Add support for column selection
+ */
+ protected String[] extractItemFields(TmfEvent event) {
+ String[] fields = new String[0];
+ if (event != null) {
+ fields = new String[] {
+ new Long(event.getTimestamp().getValue()).toString(),
+ event.getSource().getSourceId().toString(),
+ event.getType().getTypeId().toString(),
+ event.getReference().getReference().toString(),
+ event.getContent().toString()
+ };
+ }
+ return fields;
+ }
+
+ public void setFocus() {
+ fTable.setFocus();
+ }
+
+ /**
+ * @param trace
+ * @param disposeOnClose true if the trace should be disposed when the table is disposed
+ */
+ public void setTrace(ITmfTrace trace, boolean disposeOnClose) {
+ if (fTrace != null && fDisposeOnClose) {
+ fTrace.dispose();
+ }
+ fTrace = trace;
+ fDisposeOnClose = disposeOnClose;
+
+ // Perform the updates on the UI thread
+ fTable.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ //fTable.setSelection(0);
+ fTable.removeAll();
+ fCacheStartIndex = fCacheEndIndex = 0; // Clear the cache
+
+ if (!fTable.isDisposed() && fTrace != null) {
+ //int nbEvents = (int) fTrace.getNbEvents();
+ //fTable.setItemCount((nbEvents > 100) ? nbEvents : 100);
+ fTable.setItemCount((int) fTrace.getNbEvents());
+ }
+ }
+ });
+ }
+
+ // ------------------------------------------------------------------------
+ // Signal handlers
+ // ------------------------------------------------------------------------
+
+ @TmfSignalHandler
+ public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
+ if (signal.getExperiment() != fTrace) return;
+ // Perform the refresh on the UI thread
+ fTable.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (!fTable.isDisposed() && fTrace != null) {
+ fTable.setItemCount((int) fTrace.getNbEvents());
+ fTable.refresh();
+ }
+ }
+ });
+ }
+
+ @TmfSignalHandler
+ public void traceUpdated(TmfTraceUpdatedSignal signal) {
+ if (signal.getTrace() != fTrace) return;
+ // Perform the refresh on the UI thread
+ fTable.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (!fTable.isDisposed() && fTrace != null) {
+ //int nbEvents = (int) fTrace.getNbEvents();
+ //fTable.setItemCount((nbEvents > 100) ? nbEvents : 100);
+ fTable.setItemCount((int) fTrace.getNbEvents());
+ }
+ }
+ });
+ }
+
+ private boolean fRefreshPending = false;
+ @TmfSignalHandler
+ public synchronized void rangeSynched(TmfRangeSynchSignal signal) {
+ if (!fRefreshPending) {
+ // Perform the refresh on the UI thread
+ fRefreshPending = true;
+ fTable.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ fRefreshPending = false;
+ if (!fTable.isDisposed() && fTrace != null) {
+ fTable.setItemCount((int) fTrace.getNbEvents());
+ }
+ }
+ });
+ }
+ }
+
+ @TmfSignalHandler
+ public void currentTimeUpdated(final TmfTimeSynchSignal signal) {
+ if (signal.getSource() != fTable && fTrace != null) {
+ Job job = new Job("seeking...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ final int index = (int) fTrace.getRank(signal.getCurrentTime());
+ // Perform the updates on the UI thread
+ fTable.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ fTable.setSelection(index);
+ // The timestamp might not correspond to an actual event
+ // and the selection will point to the next experiment event.
+ // But we would like to display both the event before and
+ // after the selected timestamp.
+ // This works fine by default except when the selected event
+ // is the top displayed event. The following ensures that we
+ // always see both events.
+ if ((index > 0) && (index == fTable.getTopIndex())) {
+ fTable.setTopIndex(index - 1);
+ }
+ }
+ });
+ return Status.OK_STATUS;
+ }};
+ job.schedule();
+ }
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java
index cbd774bce3..f44c1a9bd2 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java
@@ -8,35 +8,17 @@
*
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Patrick Tasse - Factored out events table
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.views;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
/**
* <b><u>TmfEventsView</u></b>
@@ -51,60 +33,10 @@ public class TmfEventsView extends TmfView {
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.events";
private TmfExperiment<TmfEvent> fExperiment;
- private String fTitlePrefix;
-
- private Shell fShell;
-
- // ------------------------------------------------------------------------
- // Table data
- // ------------------------------------------------------------------------
-
- private Table fTable;
-
- // Table column names
- private final String TIMESTAMP_COLUMN = "Timestamp";
- private final String SOURCE_COLUMN = "Source";
- private final String TYPE_COLUMN = "Type";
- private final String REFERENCE_COLUMN = "File";
- private final String CONTENT_COLUMN = "Content";
- private final String[] columnProperties = new String[] {
- TIMESTAMP_COLUMN,
- SOURCE_COLUMN,
- TYPE_COLUMN,
- REFERENCE_COLUMN,
- CONTENT_COLUMN
- };
-
- // Column data
- private class ColumnData {
- public final String header;
- public final int width;
- public final int alignment;
-
- public ColumnData(String h, int w, int a) {
- header = h;
- width = w;
- alignment = a;
- }
- };
-
- private ColumnData[] columnData = new ColumnData[] {
- new ColumnData(columnProperties[0], 100, SWT.LEFT),
- new ColumnData(columnProperties[1], 100, SWT.LEFT),
- new ColumnData(columnProperties[2], 100, SWT.LEFT),
- new ColumnData(columnProperties[3], 100, SWT.LEFT),
- new ColumnData(columnProperties[4], 100, SWT.LEFT)
- };
-
- // ------------------------------------------------------------------------
- // Event cache
- // ------------------------------------------------------------------------
-
- private static final int DEFAULT_CACHE_SIZE = 1000;
+ private TmfEventsTable fEventsTable;
+ private static final int DEFAULT_CACHE_SIZE = 100;
private final int fCacheSize;
- private TmfEvent[] cache = new TmfEvent[1];
- private int cacheStartIndex = 0;
- private int cacheEndIndex = 0;
+ private String fTitlePrefix;
// ------------------------------------------------------------------------
// Constructor
@@ -126,124 +58,35 @@ public class TmfEventsView extends TmfView {
@SuppressWarnings("unchecked")
@Override
public void createPartControl(Composite parent) {
-
- fShell = parent.getShell();
-
- // Create a virtual table
- // TODO: change SINGLE to MULTI line selection and adjust the selection listener
- final int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL;
- fTable = new Table(parent, style);
-
- // Set the table layout
- GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
- fTable.setLayoutData(layoutData);
-
- // Some cosmetic enhancements
- fTable.setHeaderVisible(true);
- fTable.setLinesVisible(true);
-
- // Set the columns
- createColumnHeaders(fTable);
-
- // Handle the table item requests
- fTable.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- TmfTimestamp ts = (TmfTimestamp) fTable.getSelection()[0].getData();
- broadcast(new TmfTimeSynchSignal(fTable, ts));
- }
- });
-
- // Handle the table item requests
- fTable.addListener(SWT.SetData, new Listener() {
-
- public void handleEvent(Event event) {
-
- final TableItem item = (TableItem) event.item;
- final int index = fTable.indexOf(item);
-
- // Note: this works because handleEvent() is called once for each row, in sequence
- if ((index >= cacheStartIndex ) && (index < cacheEndIndex)) {
- int i = index - cacheStartIndex;
- item.setText(extractItemFields(cache[i]));
- item.setData(new TmfTimestamp(cache[i].getTimestamp()));
- return;
- }
-
- TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(TmfEvent.class, index, fCacheSize) {
- @Override
- public void handleData() {
- TmfEvent[] tmpEvent = getData();
- if ((tmpEvent != null) && (tmpEvent.length > 0)) {
- cache = tmpEvent;
- cacheStartIndex = index;
- cacheEndIndex = index + tmpEvent.length;
-// System.out.println("TmfTableView: entry#" + index);
- }
- }
- };
- fExperiment.sendRequest(request);
- try {
- request.waitForCompletion();
- if (cache[0] != null && cacheStartIndex == index) {
- item.setText(extractItemFields(cache[0]));
- item.setData(new TmfTimestamp(cache[0].getTimestamp()));
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
-
- fTable.setItemCount(0);
- fTitlePrefix = getTitle();
-
- // If an experiment is already selected, update the table
- fExperiment = (TmfExperiment<TmfEvent>) TmfExperiment.getCurrentExperiment();
- if (fExperiment != null) {
- experimentSelected(new TmfExperimentSelectedSignal<TmfEvent>(fTable, fExperiment));
- }
+ fEventsTable = createEventsTable(parent, fCacheSize);
+
+ fTitlePrefix = getTitle();
+
+ // If an experiment is already selected, update the table
+ fExperiment = (TmfExperiment<TmfEvent>) TmfExperiment.getCurrentExperiment();
+ if (fExperiment != null) {
+ experimentSelected(new TmfExperimentSelectedSignal<TmfEvent>(fEventsTable, fExperiment));
+ }
}
- /**
- * @param table
- *
- * FIXME: Add support for column selection
- */
- protected void createColumnHeaders(Table table) {
- for (int i = 0; i < columnData.length; i++) {
- TableColumn column = new TableColumn(table, columnData[i].alignment, i);
- column.setText(columnData[i].header);
- column.setWidth(columnData[i].width);
+ @Override
+ public void dispose() {
+ if (fEventsTable != null) {
+ fEventsTable.dispose();
}
- }
+ super.dispose();
+ }
- /**
- * @param event
- * @return
- *
- * FIXME: Add support for column selection
- */
- protected String[] extractItemFields(TmfEvent event) {
- String[] fields = new String[0];
- if (event != null) {
- fields = new String[] {
- new Long(event.getTimestamp().getValue()).toString(),
- event.getSource().getSourceId().toString(),
- event.getType().getTypeId().toString(),
- event.getReference().getReference().toString(),
- event.getContent().toString()
- };
- }
- return fields;
- }
+ protected TmfEventsTable createEventsTable(Composite parent, int cacheSize) {
+ return new TmfEventsTable(parent, cacheSize);
+ }
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
@Override
public void setFocus() {
+ fEventsTable.setFocus();
}
/* (non-Javadoc)
@@ -254,97 +97,20 @@ public class TmfEventsView extends TmfView {
return "[TmfEventsView]";
}
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
@SuppressWarnings("unchecked")
- @TmfSignalHandler
+ @TmfSignalHandler
public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) {
- // Update the trace reference
- fExperiment = (TmfExperiment<TmfEvent>) signal.getExperiment();
- setPartName(fTitlePrefix + " - " + fExperiment.getName());
+ // Update the trace reference
+ fExperiment = (TmfExperiment<TmfEvent>) signal.getExperiment();
+ setPartName(fTitlePrefix + " - " + fExperiment.getName());
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(fShell);
- try {
- dialog.run(false, false, new IRunnableWithProgress() {
- public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Cleaning up, please wait", 0);
-
- // Perform the updates on the UI thread
- fTable.getDisplay().syncExec(new Runnable() {
- public void run() {
- fTable.setSelection(0);
- fTable.removeAll();
- cacheStartIndex = cacheEndIndex = 0; // Clear the cache
-
- if (!fTable.isDisposed() && fExperiment != null) {
- int nbEvents = (int) fExperiment.getNbEvents();
- fTable.setItemCount((nbEvents > 100) ? nbEvents : 100);
- }
- }
- });
-
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- } catch (InterruptedException e) {
- }
- }
-
- @TmfSignalHandler
- public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
- // Perform the refresh on the UI thread
- fTable.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!fTable.isDisposed() && fExperiment != null) {
- int nbEvents = (int) fExperiment.getNbEvents();
- fTable.setItemCount((nbEvents > 100) ? nbEvents : 100);
- }
- }
- });
- }
-
- private boolean fRefreshPending = false;
- @TmfSignalHandler
- public synchronized void rangeSynched(TmfRangeSynchSignal signal) {
- if (!fRefreshPending) {
- // Perform the refresh on the UI thread
- fRefreshPending = true;
- fTable.getDisplay().asyncExec(new Runnable() {
- public void run() {
- fRefreshPending = false;
- if (!fTable.isDisposed() && fExperiment != null) {
- fTable.setItemCount((int) fExperiment.getNbEvents());
-// if (Tracer.INTERNALS) Tracer.trace("TmfEventsView: itemCount=" + fTable.getItemCount());
- }
- }
- });
- }
- }
-
- @TmfSignalHandler
- public void currentTimeUpdated(TmfTimeSynchSignal signal) {
- if (signal.getSource() != fTable && fExperiment != null) {
- final int index = (int) fExperiment.getRank(signal.getCurrentTime());
- // Perform the updates on the UI thread
- fTable.getDisplay().asyncExec(new Runnable() {
- public void run() {
- fTable.setSelection(index);
- // The timestamp might not correspond to an actual event
- // and the selection will point to the next experiment event.
- // But we would like to display both the event before and
- // after the selected timestamp.
- // This works fine by default except when the selected event
- // is the top displayed event. The following ensures that we
- // always see both events.
- if ((index > 0) && (index == fTable.getTopIndex())) {
- fTable.setTopIndex(index - 1);
- }
- }
- });
- }
+ if (fEventsTable != null) {
+ fEventsTable.setTrace(fExperiment, false);
+ }
}
} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java
new file mode 100644
index 0000000000..625e66984d
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets;
+
+public class ColumnData {
+ public final String header;
+ public final int width;
+ public final int alignment;
+
+ public ColumnData(String h, int w, int a) {
+ header = h;
+ width = w;
+ alignment = a;
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfTable.java
new file mode 100644
index 0000000000..e125e9ffaa
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfTable.java
@@ -0,0 +1,528 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Matthew Khouzam - Initial API and implementation
+ * Francois Chouinard - Refactoring and minor adjustments
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets;
+
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
+import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseWheelListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * <b><u>TmfVirtualTable</u></b>
+ * <p>
+ * The TmfTable is a table that allows scrolling through arbitrarily large
+ * set of TmfEvents.
+ *
+ * It is a composite of 2 synchronized widgets that simulates an SWT table:
+ * - a fixed-size Table acting as a window on the data (like a regular table)
+ * - a Slider acting as a vertical scroll bar.
+ */
+public class TmfTable extends Composite {
+
+ // The "fixed" size table
+ private Table fTable = null;
+ private int fFirstRowOffset = 0;
+ private int fRelativeRow = 0;
+ private int fAbsoluteRow = 0;
+ private int fItemCount = 0;
+
+ // Selection handling
+ private TableItem fSelectedItem[] = null;
+
+ // The slider
+ private Slider fSlider;
+
+ // A placeholder for the controls (table and slider)
+ private Control fControl[];
+
+ // ???
+ private int fSliderMax;
+ private TableItem fTableItems[];
+ private int fNumberOfVisibleRows;
+
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ public TmfTable(Composite parent, int style, ColumnData columnData[]) {
+ super(parent, style);
+
+ // Create the table widget
+ createEventsTable(style, columnData);
+
+ initialize();
+ }
+
+ // ------------------------------------------------------------------------
+ // Table
+ // ------------------------------------------------------------------------
+
+ private void createEventsTable(int style, ColumnData columnData[]) {
+
+ // Adjust the style
+ int tableStyle = style | (SWT.NO_SCROLL) & (~SWT.MULTI) & (~SWT.V_SCROLL) & (~SWT.VIRTUAL);
+ fTable = new Table(this, tableStyle);
+ setColumnHeaders(columnData);
+
+ fTable.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ handleTableSelection();
+ }
+ });
+
+ fTable.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent event) {
+ handleTableKeyEvent(event);
+ }
+ public void keyReleased(KeyEvent event) {
+ }
+ });
+ }
+
+ public void setItemCount(int count)
+ {
+ count = (count > 0) ? count : 0;
+ if (count != fItemCount) {
+ fItemCount = count;
+ resize();
+ }
+ }
+
+ /*
+ * setColumnHeaders
+ *
+ * @param columnData
+ */
+ private void setColumnHeaders(ColumnData columnData[]) {
+ for (int i = 0; i < columnData.length; i++) {
+ TableColumn column = new TableColumn(fTable, columnData[i].alignment, i);
+ column.setText(columnData[i].header);
+ column.setWidth(columnData[i].width);
+ }
+ }
+
+ /*
+ * handleTableSelection
+ *
+ * Update the selection and broadcast the timestamp of the selected event
+ */
+ private void handleTableSelection() {
+ fRelativeRow = fTable.getSelectionIndices()[0];
+ fAbsoluteRow = fRelativeRow + fFirstRowOffset;
+ fSelectedItem = new TableItem[1];
+ fSelectedItem[0] = fTable.getSelection()[0];
+
+ TmfTimestamp ts = (TmfTimestamp) fTable.getSelection()[0].getData();
+ TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(fTable, ts));
+ }
+
+ /*
+ * handleTableKeyEvent
+ *
+ * Allow the selection to move within the visible area of the table only
+ * Simulate scrolling by adjusting fFirstRowOffset and re-populating the table
+ *
+ * @param event
+ */
+ private void handleTableKeyEvent(KeyEvent event)
+ {
+ boolean updateDisplay = false;
+ int firstRow = 0;
+ int lastRow = fItemCount - 1;
+ int firstRowOfLastPage = (fItemCount > fNumberOfVisibleRows) ? (lastRow - fNumberOfVisibleRows + 1) : 0;
+
+ switch (event.keyCode) {
+
+ case SWT.ARROW_DOWN: {
+ event.doit = false;
+ if (fAbsoluteRow < lastRow) {
+ fAbsoluteRow++;
+ if (fRelativeRow < fNumberOfVisibleRows - 1) {
+ fRelativeRow++;
+ fTable.setSelection(fRelativeRow);
+ } else {
+ fFirstRowOffset++;
+ updateDisplay = true;
+ }
+ }
+ break;
+ }
+
+ case SWT.ARROW_UP: {
+ event.doit = false;
+ if (fAbsoluteRow > firstRow) {
+ fAbsoluteRow--;
+ if (fRelativeRow > 0) {
+ fRelativeRow--;
+ fTable.setSelection(fRelativeRow);
+ } else {
+ fFirstRowOffset--;
+ updateDisplay = true;
+ }
+ }
+ break;
+ }
+
+ case SWT.PAGE_DOWN: {
+ event.doit = false;
+ if (fAbsoluteRow < lastRow) {
+ fAbsoluteRow += fNumberOfVisibleRows;
+ if (fAbsoluteRow > lastRow) {
+ fAbsoluteRow = lastRow;
+ fFirstRowOffset = firstRowOfLastPage;
+ fRelativeRow = fNumberOfVisibleRows - 1;
+ fTable.setSelection(fRelativeRow);
+ } else {
+ fFirstRowOffset += fNumberOfVisibleRows;
+ }
+ updateDisplay = true;
+ }
+ break;
+ }
+
+ case SWT.PAGE_UP: {
+ event.doit = false;
+ if (fAbsoluteRow > firstRow) {
+ fAbsoluteRow -= fNumberOfVisibleRows;
+ if (fAbsoluteRow < firstRow) {
+ fAbsoluteRow = firstRow;
+ fFirstRowOffset = firstRow;
+ fRelativeRow = firstRow;
+ fTable.setSelection(fRelativeRow);
+ } else {
+ fFirstRowOffset -= fNumberOfVisibleRows;
+ }
+ updateDisplay = true;
+ }
+ break;
+ }
+
+ case SWT.HOME: {
+ event.doit = false;
+ fAbsoluteRow = firstRow;
+ fRelativeRow = firstRow;
+ fTable.setSelection(fRelativeRow);
+ if (fFirstRowOffset != firstRow) {
+ fFirstRowOffset = firstRow;
+ updateDisplay = true;
+ }
+ break;
+ }
+
+ case SWT.END: {
+ event.doit = false;
+ fAbsoluteRow = lastRow;
+ fRelativeRow = fNumberOfVisibleRows - 1;
+ fTable.setSelection(fRelativeRow);
+ if (fFirstRowOffset != firstRowOfLastPage) {
+ fFirstRowOffset = firstRowOfLastPage;
+ updateDisplay = true;
+ }
+ break;
+ }
+
+ };
+
+ if (updateDisplay) {
+ refresh();
+ fTable.setSelection(fRelativeRow);
+ fSlider.setSelection(fFirstRowOffset + fRelativeRow);
+ }
+
+ }
+
+ public void refresh() {
+ for (int i = 0; i < fTableItems.length; i++) {
+ setDataItem(fTableItems[i]);
+ }
+ }
+
+ private void setDataItem(TableItem item) {
+ int index = fTable.indexOf(item);
+ if( index != -1) {
+ Event event = new Event();
+ event.item = item;
+ event.index = index + fFirstRowOffset;
+ event.doit = true;
+ notifyListeners(SWT.SetData, event);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Table
+ // ------------------------------------------------------------------------
+
+ /**
+ *
+ */
+ private void initialize() {
+
+ // Instantiate the table
+// fTable = new Table(this, fTableStyle);
+
+ // Instantiate the slider
+ fSlider = new Slider(this, SWT.VERTICAL);
+ fSlider.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ setSelection();
+ }
+ });
+
+ // Fill the control placeholder
+ fControl = new Control[2];
+ fControl[0] = fTable;
+ fControl[1] = fSlider;
+
+ // Set the initial layout
+ Rectangle bounds = getClientArea();
+ fTable.setSize(bounds.width - 24, bounds.height);
+ fSlider.setSize(24, bounds.height);
+
+ // Add the widget-level listeners
+ addControlListener(new ControlAdapter() {
+ @Override
+ public void controlResized(ControlEvent e) {
+ resize();
+ }
+ });
+
+ addMouseWheelListener(new MouseWheelListener() {
+ public void mouseScrolled(MouseEvent event) {
+ fFirstRowOffset -= event.count;
+ if (fFirstRowOffset > fSliderMax) {
+ fFirstRowOffset = fSliderMax;
+ } else if (fFirstRowOffset < 0) {
+ fFirstRowOffset = 0;
+ }
+ fSlider.setSelection(fFirstRowOffset);
+ setSelection();
+ }
+ });
+ }
+
+ private void setSelection() {
+ if ((fAbsoluteRow > fFirstRowOffset)
+ && (fAbsoluteRow < (fFirstRowOffset + fNumberOfVisibleRows))) {
+ fRelativeRow = fAbsoluteRow - fFirstRowOffset;
+ fTable.setSelection(fRelativeRow);
+
+ } else {
+ fTable.deselect(fRelativeRow);
+ }
+
+ for (int i = 0; i < fNumberOfVisibleRows; i++) {
+ setDataItem(fTableItems[i]);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Control event handlers
+ // ------------------------------------------------------------------------
+
+
+
+
+ // ------------------------------------------------------------------------
+ // Composite
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Control[] getChildren() {
+ return fControl;
+ }
+
+ @Override
+ public boolean setFocus() {
+ boolean isVisible = isVisible();
+ if (isVisible) {
+ for (int i = 0; i < fControl.length; i++) {
+ fControl[i].setFocus();
+ }
+ }
+ return isVisible;
+ }
+
+ // ------------------------------------------------------------------------
+ // Table API
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ //
+ // ------------------------------------------------------------------------
+
+ /*
+ *
+ */
+ public TableItem[] getSelection()
+ {
+ return fSelectedItem;
+ }
+
+ public void setLinesVisible( boolean b)
+ {
+ fTable.setLinesVisible(b);
+ }
+
+ public void addSelectionListener( SelectionAdapter sa)
+ {
+ fTable.addSelectionListener(sa);
+ }
+
+
+
+
+ /*
+ *
+ */
+ public void setHeaderVisible(boolean b) {
+ fTable.setHeaderVisible(b);
+ }
+ /*
+ *
+ */
+ public void resize()
+ {
+ Rectangle bounds = this.getClientArea();
+ int sl_width = fSlider.getBounds().width;
+ int tab_width = bounds.width - sl_width;
+ int tab_height = bounds.height - 10;
+ int item_height = fTable.getItemHeight();
+ fNumberOfVisibleRows = tab_height/item_height;
+ if( fItemCount == 0)
+ fNumberOfVisibleRows = 0;
+ if( fNumberOfVisibleRows > 0 )
+ {
+ if( fTable.getItemCount() != fNumberOfVisibleRows)
+ {
+ int delta = fTable.getItemCount() - fNumberOfVisibleRows;
+ if(delta != 0)
+ {
+ fTable.removeAll();
+ if(fTableItems != null)
+ {
+ for( int i = fTableItems.length-1 ; i > 0 ; i-- )
+ {
+ if( fTableItems[i] != null )
+ {
+ fTableItems[i].dispose();
+ }
+ fTableItems[i] = null;
+ }
+ }
+ fTableItems = new TableItem[fNumberOfVisibleRows];
+ for( int i = 0 ; i < fTableItems.length; i++ )
+ {
+ fTableItems[i]= new TableItem(fTable, i);
+ }
+ }
+ }
+ if( fItemCount < fNumberOfVisibleRows )
+ {
+ fTable.setBounds(bounds);
+ fTable.setSize(bounds.width, bounds.height+6);
+ fSlider.setVisible(false);
+ }
+ else
+ {
+ fTable.setBounds(0, 0, tab_width, bounds.height);
+ fTable.setSize(tab_width,bounds.height+6);
+ fSlider.setBounds(tab_width, 0, sl_width, bounds.height);
+ fSlider.setSize(sl_width, bounds.height);
+ fSlider.setVisible(true);
+ fSliderMax = fItemCount - fNumberOfVisibleRows;
+ fSlider.setMaximum( fSliderMax);
+ fSlider.setMinimum(0);
+ }
+ }
+ else
+ {
+ fTable.setBounds(bounds);
+ fTable.setSize(bounds.width, bounds.height+6);
+ fSlider.setVisible(false);
+ }
+ }
+
+
+
+ public int getTopIndex() {
+
+ return fFirstRowOffset;
+ }
+
+ public void setTopIndex( int i){
+ fSlider.setSelection(i);
+ }
+
+ public int indexOf(TableItem ti)
+ {
+ return fTable.indexOf(ti) + getTopIndex();
+ }
+
+ public int removeAll()
+ {
+ fSlider.setMaximum(0);
+ fTable.removeAll();
+ return 0;
+ }
+
+ public void setSelection(int i)
+ {
+ if (fTableItems != null)
+ {
+ i = Math.min(i, fItemCount);
+ i = Math.max(i, 0);
+ fSlider.setSelection(i);
+ setSelection();
+ }
+ }
+
+// public void createColumnHeaders(ColumnData[] columnData, boolean b) {
+// for (int i = 0; i < columnData.length; i++) {
+// final TableColumn column = new TableColumn(this.fTable, columnData[i].alignment, i);
+// column.setText(columnData[i].header);
+// column.setWidth(columnData[i].width);
+// // TODO: Investigate why the column resizing doesn't work by default
+// // Anything to do with SWT_VIRTUAL?
+// column.addSelectionListener(new SelectionListener() {
+// public void widgetDefaultSelected(SelectionEvent e) {
+// // TODO Auto-generated method stub
+// }
+// public void widgetSelected(SelectionEvent e) {
+// column.pack();
+// }
+// });
+// }
+//
+// }
+
+} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java
new file mode 100644
index 0000000000..24a5401d36
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java
@@ -0,0 +1,451 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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:
+ * Matthew Khouzam - Initial API and implementation
+ * Francois Chouinard - Refactoring, slider support, bug fixing
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseWheelListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * <b><u>TmfVirtualTable</u></b>
+ * <p>
+ * TmfVirtualTable allows for the tabular display of arbitrarily large data sets
+ * (well, up to Integer.MAX_VALUE or ~2G rows).
+ *
+ * It is essentially a Composite of Table and Slider, where the number of rows
+ * in the table is set to fill the table display area. The slider is rank-based.
+ *
+ * It differs from Table with the VIRTUAL style flag where an empty entry is
+ * created for each virtual row. This does not scale well for very large data sets.
+ */
+public class TmfVirtualTable extends Composite {
+
+ // The table
+ private Table fTable;
+ private int fFirstRowOffset = 0;
+ private int fTableRow = 0;
+ private int fEffectiveRow = 0;
+
+ private TableItem fSelectedItems[] = null;
+ private int fTableItemCount = 0;
+ private int fRowsDisplayed;
+ private TableItem fTableItems[];
+
+ // The slider
+ private Slider fSlider;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public TmfVirtualTable(Composite parent, int style) {
+ super(parent, style | SWT.BORDER & (~SWT.H_SCROLL) & (~SWT.V_SCROLL));
+
+ // Create the controls
+ createTable();
+ createSlider();
+
+ // Set the layout
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 0;
+ gridLayout.marginWidth = 0;
+ setLayout(gridLayout);
+
+ GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ fTable.setLayoutData(tableGridData);
+
+ GridData sliderGridData = new GridData(SWT.FILL, SWT.FILL, false, true);
+ fSlider.setLayoutData(sliderGridData);
+
+ // Add the listeners
+ addMouseWheelListener(new MouseWheelListener() {
+ public void mouseScrolled(MouseEvent event) {
+ fFirstRowOffset -= event.count;
+ int lastFirstRowOffset = fTableItemCount - fRowsDisplayed - 1;
+ if (fFirstRowOffset > lastFirstRowOffset) {
+ fFirstRowOffset = lastFirstRowOffset;
+ } else if (fFirstRowOffset < 0) {
+ fFirstRowOffset = 0;
+ }
+ fSlider.setSelection(fFirstRowOffset);
+ setSelection();
+ }
+ });
+
+ addControlListener(new ControlAdapter() {
+ @Override
+ public void controlResized(ControlEvent event) {
+ resize();
+ }
+ });
+
+ // And display
+ refresh();
+ }
+
+ // ------------------------------------------------------------------------
+ // Table handling
+ // ------------------------------------------------------------------------
+
+ /**
+ * Create the table and add listeners
+ */
+ private void createTable() {
+
+ int tableStyle = SWT.NO_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION;
+ fTable = new Table(this, tableStyle);
+
+ fTable.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ handleTableSelection();
+ }
+ });
+
+ fTable.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent event) {
+ handleTableKeyEvent(event);
+ }
+ public void keyReleased(KeyEvent event) {
+ }
+ });
+ }
+
+ /**
+ * Update the rows and selected item
+ */
+ private void handleTableSelection() {
+ fTableRow = fTable.getSelectionIndices()[0];
+ fEffectiveRow = fFirstRowOffset + fTableRow;
+ fSelectedItems = new TableItem[1];
+ fSelectedItems[0] = fTable.getSelection()[0];
+ }
+
+ /**
+ * Handle key-based navigation in table.
+ *
+ * The key variables are:
+ * - fFirstRowOffset: the absolute index (in the data set) of the first row displayed
+ * - fTableRow: the index of the selected event in the table window
+ * - fEffectiveRow: the absolute index of the selected event (in the data set)
+ *
+ * At all times, the following relation should hold true:
+ * fEffectiveRow = fFirstRowOffset + fTableRow
+ *
+ * @param event
+ */
+ private void handleTableKeyEvent(KeyEvent event) {
+
+ boolean needsUpdate = false;
+ final int lastTableRow = fTableItemCount - 1;
+ int lastRowDisplayed = ((fTableItemCount < fRowsDisplayed) ? fTableItemCount : fRowsDisplayed) - 1;
+
+ // We are handling things
+ event.doit = false;
+
+ switch (event.keyCode) {
+
+ case SWT.ARROW_DOWN: {
+ if (fEffectiveRow < lastTableRow) {
+ fEffectiveRow++;
+ if (fTableRow < lastRowDisplayed) {
+ fTableRow++;
+ } else if (fTableRow < fEffectiveRow) {
+ fFirstRowOffset++;
+ needsUpdate = true;
+ }
+ }
+ break;
+ }
+
+ case SWT.PAGE_DOWN: {
+ if (fEffectiveRow < lastTableRow) {
+ if ((lastTableRow - fEffectiveRow) >= fRowsDisplayed) {
+ fEffectiveRow += fRowsDisplayed;
+ fFirstRowOffset += fRowsDisplayed;
+ } else {
+ fEffectiveRow = lastTableRow;
+ fTableRow = lastRowDisplayed;
+ }
+ needsUpdate = true;
+ }
+ break;
+ }
+
+ case SWT.END: {
+ fEffectiveRow = lastTableRow;
+ fTableRow = lastRowDisplayed;
+ if (lastTableRow > lastRowDisplayed) {
+ fFirstRowOffset = fTableItemCount - fRowsDisplayed;
+ }
+ needsUpdate = true;
+ break;
+ }
+
+ case SWT.ARROW_UP: {
+ if (fEffectiveRow > 0) {
+ fEffectiveRow--;
+ if (fTableRow > 0) {
+ fTableRow--;
+ } else {
+ fFirstRowOffset--;
+ needsUpdate = true;
+ }
+ }
+ break;
+ }
+
+ case SWT.PAGE_UP: {
+ if (fEffectiveRow > 0) {
+ if (fEffectiveRow > fRowsDisplayed - 1) {
+ fEffectiveRow -= fRowsDisplayed;
+ fFirstRowOffset -= fRowsDisplayed;
+ } else {
+ fEffectiveRow = 0;
+ fTableRow = 0;
+ }
+ needsUpdate = true;
+ }
+ break;
+ }
+
+ case SWT.HOME: {
+ fEffectiveRow = 0;
+ fTableRow = 0;
+ fFirstRowOffset = 0;
+ needsUpdate = true;
+ break;
+ }
+ }
+
+ if (needsUpdate) {
+ for (int i = 0; i < fTableItems.length; i++) {
+ setDataItem(fTableItems[i]);
+ }
+ }
+
+ fTable.setSelection(fTableRow);
+ fSlider.setSelection(fEffectiveRow);
+
+// System.out.println("1st: " + fFirstRowOffset + ", TR: " + fTableRow + ", ER: " + fEffectiveRow +
+// ", Valid: " + ((fFirstRowOffset >= 0) && (fEffectiveRow == (fFirstRowOffset + fTableRow))));
+ }
+
+ private void setDataItem(TableItem item) {
+ int index = fTable.indexOf(item);
+ if( index != -1) {
+ Event event = new Event();
+ event.item = item;
+ event.index = index + fFirstRowOffset;
+ event.doit = true;
+ notifyListeners(SWT.SetData, event);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Slider handling
+ // ------------------------------------------------------------------------
+
+ private void createSlider() {
+ fSlider = new Slider(this, SWT.VERTICAL);
+ fSlider.setMinimum(0);
+ fSlider.setMaximum(0);
+
+ fSlider.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ setSelection();
+ }
+ });
+
+ fSlider.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.detail) {
+ case SWT.ARROW_DOWN:
+ case SWT.ARROW_UP:
+ case SWT.NONE:
+ case SWT.END:
+ case SWT.HOME:
+ case SWT.PAGE_DOWN:
+ case SWT.PAGE_UP: {
+ fFirstRowOffset = fSlider.getSelection();
+ setSelection();
+ break;
+ }
+ }
+ }
+ });
+ }
+
+ // ------------------------------------------------------------------------
+ // Simulated Table API
+ // ------------------------------------------------------------------------
+
+ public void setHeaderVisible(boolean b) {
+ fTable.setHeaderVisible(b);
+ }
+
+ public void setLinesVisible(boolean b) {
+ fTable.setLinesVisible(b);
+ }
+
+ public TableItem[] getSelection() {
+ return fSelectedItems;
+ }
+
+ public void addSelectionListener(SelectionAdapter sa) {
+ fTable.addSelectionListener(sa);
+ }
+
+ public void setItemCount(int nbItems) {
+ nbItems = Math.max(0, nbItems);
+ if (nbItems != fTableItemCount) {
+ fTableItemCount = nbItems;
+ fSlider.setMaximum(nbItems);
+ resize();
+ }
+ }
+
+ public int getItemHeight() {
+ return fTable.getItemHeight();
+ }
+
+ public int getTopIndex() {
+ return fFirstRowOffset;
+ }
+
+ public void setTopIndex(int i) {
+ fSlider.setSelection(i);
+ }
+
+ public int indexOf(TableItem ti) {
+ return fTable.indexOf(ti) + getTopIndex();
+ }
+
+ public TableColumn[] getColumns() {
+ return fTable.getColumns();
+ }
+
+ private void resize() {
+
+ // Compute the numbers of rows that fit the new area
+ Rectangle clientArea = getClientArea();
+ int tableHeight = clientArea.height - fTable.getHeaderHeight();
+ int itemHeight = fTable.getItemHeight();
+ fRowsDisplayed = tableHeight / itemHeight + 1; // For partial rows
+ if (fTableItemCount == 0) {
+ fRowsDisplayed = 0;
+ }
+
+ // Re-size and re-create the virtual table if needed
+ int delta = fTable.getItemCount() - fRowsDisplayed;
+ if (delta != 0) {
+ fTable.removeAll();
+ if (fTableItems != null) {
+ for (int i = 0; i < fTableItems.length; i++) {
+ if (fTableItems[i] != null) {
+ fTableItems[i].dispose();
+ }
+ fTableItems[i] = null;
+ }
+ }
+ fTableItems = new TableItem[fRowsDisplayed];
+ for (int i = 0; i < fTableItems.length; i++) {
+ fTableItems[i] = new TableItem(fTable, i);
+ }
+ }
+
+ refresh();
+ }
+
+ // ------------------------------------------------------------------------
+ // Controls interactions
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean setFocus() {
+ boolean isVisible = isVisible();
+ if (isVisible) {
+ fTable.setFocus();
+ }
+ return isVisible;
+ }
+
+ public void refresh() {
+ setSelection();
+ }
+
+ public void setColumnHeaders(ColumnData columnData[]) {
+ for (int i = 0; i < columnData.length; i++) {
+ TableColumn column = new TableColumn(fTable, columnData[i].alignment, i);
+ column.setText(columnData[i].header);
+ if (columnData[i].width > 0) {
+ column.setWidth(columnData[i].width);
+ } else {
+ column.pack();
+ }
+ }
+ }
+
+ public int removeAll() {
+ fSlider.setMaximum(0);
+ fTable.removeAll();
+ return 0;
+ }
+
+ private void setSelection() {
+ if ((fEffectiveRow >= fFirstRowOffset) && (fEffectiveRow < (fFirstRowOffset + fRowsDisplayed))) {
+ fTableRow = fEffectiveRow - fFirstRowOffset;
+ fTable.setSelection(fTableRow);
+ } else {
+ fTable.deselect(fTableRow);
+ }
+
+ for (int i = 0; i < fRowsDisplayed; i++) {
+ setDataItem(fTableItems[i]);
+ }
+ }
+
+ public void setSelection(int i) {
+ if (fTableItems != null) {
+ i = Math.min(i, fTableItemCount);
+ i = Math.max(i, 0);
+ fSlider.setSelection(i);
+ setSelection();
+ }
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf/ChangeLog b/lttng/org.eclipse.linuxtools.tmf/ChangeLog
index 9df424b2d5..b3ccd84e6c 100644
--- a/lttng/org.eclipse.linuxtools.tmf/ChangeLog
+++ b/lttng/org.eclipse.linuxtools.tmf/ChangeLog
@@ -1,3 +1,36 @@
+2010-07-28 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java: Added getRank() to API
+ * src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java: Provide a default implementation of getRank() + minor changes
+
+2010-07-20 Francois Chouinard <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java:
+ - Use a specific lock object (instead of this) for synchronization
+ - Fix executor exception when request comes in immediately after dispose
+ * src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java:
+ - Fix constructor ignoring index page size
+ - Update saved context on parse to avoid unnecessary seeks
+
+2010-07-08 francois <fchouinard@gmail.com>
+
+ * src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java: Added clone()
+ * src/org/eclipse/linuxtools/tmf/trace/ITmfContext.java: Changed constant value
+ * src/org/eclipse/linuxtools/tmf/signal/TmfExperimentUpdatedSignal.java: Removed trace from signal
+ * src/org/eclipse/linuxtools/tmf/request/TmfRequestExecutor.java: Added priority queue and tracing
+ * src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java: Fix handleCompleted() handling
+ * src/org/eclipse/linuxtools/tmf/request/TmfCoalescedEventRequest.java: Added request merging based on time range
+ * src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentLocation.java: Added toString()
+ * src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentContext.java: Fix for equals()
+ * src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java: Partitionning of background requests
+ * src/org/eclipse/linuxtools/tmf/component/TmfThread.java: New file. Handles thread priorities
+ * src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java: Added tracing statements
+ * src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java: Added support for prioritized requests
+ * src/org/eclipse/linuxtools/tmf/component/TmfComponent.java: Added tracing statements
+ * src/org/eclipse/linuxtools/tmf/component/ITmfDataProvider.java: Cosmetic change
+ * src/org/eclipse/linuxtools/tmf/Tracer.java: Added support to stop tracing
+ * src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java: Added Tracer handling
+
2009-06-16 Andrew Overholt <overholt@redhat.com>
* META-INF/MANIFEST.MF: Change provider from Ericsson to Eclipse. \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java
index 16378a895b..7fd06bf75a 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java
@@ -75,6 +75,7 @@ public class TmfCorePlugin extends Plugin {
@Override
public void stop(BundleContext context) throws Exception {
+ Tracer.stop();
setDefault(null);
super.stop(context);
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java
index 7a58ee356b..02e1623bbb 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/Tracer.java
@@ -23,6 +23,7 @@ public class Tracer {
static Boolean SIGNAL = Boolean.FALSE;
static Boolean EVENT = Boolean.FALSE;
+ private static String LOGNAME = "trace.log";
private static BufferedWriter fTraceLog = null;
private static BufferedWriter openLogFile(String filename) {
@@ -84,7 +85,19 @@ public class Tracer {
// Create trace log file if needed
if (isTracing) {
- fTraceLog = openLogFile("trace.log");
+ fTraceLog = openLogFile(LOGNAME);
+ }
+ }
+
+ public static void stop() {
+ if (fTraceLog == null)
+ return;
+
+ try {
+ fTraceLog.close();
+ fTraceLog = null;
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
@@ -114,15 +127,16 @@ public class Tracer {
message.append(currentTime % 1000);
message.append("] ");
message.append(msg);
- System.out.println(message);
- try {
- if (fTraceLog != null) {
+// System.out.println(message);
+
+ if (fTraceLog != null) {
+ try {
fTraceLog.write(message.toString());
fTraceLog.newLine();
fTraceLog.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- } catch (IOException e) {
- e.printStackTrace();
}
}
@@ -149,4 +163,9 @@ public class Tracer {
trace(message);
}
+ public static void traceInfo(String msg) {
+ String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg);
+ trace(message);
+ }
+
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/ITmfDataProvider.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/ITmfDataProvider.java
index 73a306cbd4..735c1674ad 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/ITmfDataProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/ITmfDataProvider.java
@@ -31,5 +31,4 @@ public interface ITmfDataProvider<T extends TmfData> {
*/
public void sendRequest(ITmfDataRequest<T> request);
public void fireRequests();
-
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java
index 4a6082bff8..2f0badc6f2 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfComponent.java
@@ -12,7 +12,6 @@
package org.eclipse.linuxtools.tmf.component;
-import org.eclipse.linuxtools.tmf.Tracer;
import org.eclipse.linuxtools.tmf.signal.TmfSignal;
import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
@@ -33,7 +32,7 @@ public abstract class TmfComponent implements ITmfComponent {
public TmfComponent(String name) {
fName = name;
- if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "created");
+// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "created");
TmfSignalManager.register(this);
}
@@ -67,7 +66,7 @@ public abstract class TmfComponent implements ITmfComponent {
*/
public void dispose() {
TmfSignalManager.deregister(this);
- if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "terminated");
+// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "terminated");
}
/* (non-Javadoc)
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java
index eca340e5e9..48423b6439 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfDataProvider.java
@@ -16,11 +16,12 @@ import java.lang.reflect.Array;
import java.util.Vector;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.SynchronousQueue;
import org.eclipse.linuxtools.tmf.Tracer;
import org.eclipse.linuxtools.tmf.event.TmfData;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.request.TmfCoalescedDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfRequestExecutor;
@@ -48,7 +49,7 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
// Constants
// ------------------------------------------------------------------------
- private static final ITmfDataRequest.ExecutionType SHORT = ITmfDataRequest.ExecutionType.SHORT;
+// private static final ITmfDataRequest.ExecutionType SHORT = ITmfDataRequest.ExecutionType.SHORT;
// private static final ITmfDataRequest.ExecutionType LONG = ITmfDataRequest.ExecutionType.LONG;
// ------------------------------------------------------------------------
@@ -65,6 +66,7 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
protected final TmfRequestExecutor fExecutor;
private int fSignalDepth = 0;
+ private final Object fLock = new Object();
// ------------------------------------------------------------------------
// Constructors
@@ -78,8 +80,7 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
super(name);
fType = type;
fQueueSize = queueSize;
-// fDataQueue = (queueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
- fDataQueue = new LinkedBlockingQueue<T>(fQueueSize);
+ fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
fExecutor = new TmfRequestExecutor();
fSignalDepth = 0;
@@ -88,15 +89,14 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
fLogError = Tracer.isErrorTraced();
TmfProviderManager.register(fType, this);
- if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "started");
+// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "started");
}
public TmfDataProvider(TmfDataProvider<T> other) {
super(other);
fType = other.fType;
fQueueSize = other.fQueueSize;
-// fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
- fDataQueue = new LinkedBlockingQueue<T>(fQueueSize);
+ fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
fExecutor = new TmfRequestExecutor();
fSignalDepth = 0;
@@ -109,11 +109,8 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
public void dispose() {
TmfProviderManager.deregister(fType, this);
fExecutor.stop();
-
- if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped");
-
- if (fClone != null) fClone.dispose();
super.dispose();
+// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped");
}
public int getQueueSize() {
@@ -128,18 +125,12 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
// ITmfRequestHandler
// ------------------------------------------------------------------------
- protected TmfDataProvider<T> fClone;
public void sendRequest(final ITmfDataRequest<T> request) {
- synchronized(this) {
- if (fClone == null || request.getExecType() == SHORT) {
- if (fSignalDepth > 0) {
- coalesceDataRequest(request);
- } else {
- queueRequest(request);
- }
- }
- else {
- fClone.sendRequest(request);
+ synchronized(fLock) {
+ if (fSignalDepth > 0) {
+ coalesceDataRequest(request);
+ } else {
+ dispatchRequest(request);
}
}
}
@@ -150,14 +141,11 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
* @param thread
*/
public void fireRequests() {
- synchronized(this) {
+ synchronized(fLock) {
for (TmfDataRequest<T> request : fPendingCoalescedRequests) {
- queueRequest(request);
+ dispatchRequest(request);
}
fPendingCoalescedRequests.clear();
-
- if (fClone != null)
- fClone.fireRequests();
}
}
@@ -168,19 +156,27 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
protected Vector<TmfCoalescedDataRequest<T>> fPendingCoalescedRequests = new Vector<TmfCoalescedDataRequest<T>>();
protected void newCoalescedDataRequest(ITmfDataRequest<T> request) {
- synchronized(this) {
+ synchronized(fLock) {
TmfCoalescedDataRequest<T> coalescedRequest =
new TmfCoalescedDataRequest<T>(fType, request.getIndex(), request.getNbRequested(), request.getBlockize(), request.getExecType());
coalescedRequest.addRequest(request);
+ if (Tracer.isRequestTraced()) {
+ Tracer.traceRequest(request, "coalesced with " + coalescedRequest.getRequestId());
+ Tracer.traceRequest(coalescedRequest, "added " + request.getRequestId());
+ }
fPendingCoalescedRequests.add(coalescedRequest);
}
}
- protected synchronized void coalesceDataRequest(ITmfDataRequest<T> request) {
- synchronized(this) {
+ protected void coalesceDataRequest(ITmfDataRequest<T> request) {
+ synchronized(fLock) {
for (TmfCoalescedDataRequest<T> req : fPendingCoalescedRequests) {
if (req.isCompatible(request)) {
req.addRequest(request);
+ if (Tracer.isRequestTraced()) {
+ Tracer.traceRequest(request, "coalesced with " + req.getRequestId());
+ Tracer.traceRequest(req, "added " + request.getRequestId());
+ }
return;
}
}
@@ -192,17 +188,30 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
// Request processing
// ------------------------------------------------------------------------
+ private void dispatchRequest(final ITmfDataRequest<T> request) {
+ if (request.getExecType() == ExecutionType.SHORT)
+ queueRequest(request);
+ else
+ queueLongRequest(request);
+ }
+
protected void queueRequest(final ITmfDataRequest<T> request) {
- final ITmfDataProvider<T> provider = this;
- final ITmfComponent component = this;
+ if (fExecutor.isShutdown()) {
+ request.cancel();
+ return;
+ }
+
+ final TmfDataProvider<T> provider = this;
// Process the request
- Thread thread = new Thread() {
+ TmfThread thread = new TmfThread(request.getExecType()) {
@Override
public void run() {
+ if (Tracer.isRequestTraced()) Tracer.traceRequest(request, "started");
+
// Extract the generic information
request.start();
int blockSize = request.getBlockize();
@@ -221,7 +230,7 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
try {
// Get the ordered events
- if (Tracer.isRequestTraced()) Tracer.trace("Request #" + request.getRequestId() + " is being serviced by " + component.getName());
+ if (Tracer.isRequestTraced()) Tracer.trace("Request #" + request.getRequestId() + " is being serviced by " + provider.getName());
T data = getNext(context);
if (Tracer.isRequestTraced()) Tracer.trace("Request #" + request.getRequestId() + " read first event");
while (data != null && !isCompleted(request, data, nbRead))
@@ -234,8 +243,8 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
// To avoid an unnecessary read passed the last data requested
if (nbRead < nbRequested) {
data = getNext(context);
- if (data == null || data.isNullRef()) {
- if (Tracer.isRequestTraced()) Tracer.trace("Request #" + request.getRequestId() + " end of data");
+ if (Tracer.isRequestTraced() && (data == null || data.isNullRef())) {
+ Tracer.trace("Request #" + request.getRequestId() + " end of data");
}
}
}
@@ -243,17 +252,27 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
pushData(request, result);
}
request.done();
+
+ if (Tracer.isRequestTraced()) Tracer.traceRequest(request, "completed");
}
catch (Exception e) {
+ if (Tracer.isRequestTraced()) Tracer.traceRequest(request, "exception (failed)");
request.fail();
// e.printStackTrace();
}
}
};
+
fExecutor.execute(thread);
+
if (Tracer.isRequestTraced()) Tracer.traceRequest(request, "queued");
}
+ // By default, same behavior as a short request
+ protected void queueLongRequest(final ITmfDataRequest<T> request) {
+ queueRequest(request);
+ }
+
/**
* Format the result data and forwards it to the requester.
* Note: after handling, the data is *removed*.
@@ -282,7 +301,10 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
* @return an application specific context; null if request can't be serviced
*/
public abstract ITmfContext armRequest(ITmfDataRequest<T> request);
-
+ public abstract T getNext(ITmfContext context);
+
+// public abstract void queueResult(T data);
+
/**
* Return the next piece of data based on the context supplied. The context
* would typically be updated for the subsequent read.
@@ -290,40 +312,40 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
* @param context
* @return
*/
- private static final int TIMEOUT = 1000;
-// public abstract T getNext(ITmfContext context) throws InterruptedException;
-// private int getLevel = 0;
- public T getNext(ITmfContext context) throws InterruptedException {
-// String name = Thread.currentThread().getName(); getLevel++;
-// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (getLevel) + " getNext() - entering");
- T data = fDataQueue.poll(TIMEOUT, TimeUnit.MILLISECONDS);
- if (data == null) {
- if (Tracer.isErrorTraced()) Tracer.traceError(getName() + ": Request timeout on read");
- throw new InterruptedException();
- }
-// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (getLevel) + " getNext() - leaving");
-// getLevel--;
- return data;
- }
-
- /**
- * Makes the generated result data available for getNext()
- *
- * @param data
- */
-// public abstract void queueResult(T data) throws InterruptedException;
-// private int putLevel = 0;
- public void queueResult(T data) throws InterruptedException {
-// String name = Thread.currentThread().getName(); putLevel++;
-// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (putLevel) + " queueResult() - entering");
- boolean ok = fDataQueue.offer(data, TIMEOUT, TimeUnit.MILLISECONDS);
- if (!ok) {
- if (Tracer.isErrorTraced()) Tracer.traceError(getName() + ": Request timeout on write");
- throw new InterruptedException();
- }
-// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (putLevel) + " queueResult() - leaving");
-// putLevel--;
- }
+// private static final int TIMEOUT = 10000;
+//// public abstract T getNext(ITmfContext context) throws InterruptedException;
+//// private int getLevel = 0;
+// public T getNext(ITmfContext context) throws InterruptedException {
+//// String name = Thread.currentThread().getName(); getLevel++;
+//// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (getLevel) + " getNext() - entering");
+// T data = fDataQueue.poll(TIMEOUT, TimeUnit.MILLISECONDS);
+// if (data == null) {
+//// if (Tracer.isErrorTraced()) Tracer.traceError(getName() + ": Request timeout on read");
+// throw new InterruptedException();
+// }
+//// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (getLevel) + " getNext() - leaving");
+//// getLevel--;
+// return data;
+// }
+//
+// /**
+// * Makes the generated result data available for getNext()
+// *
+// * @param data
+// */
+//// public abstract void queueResult(T data) throws InterruptedException;
+//// private int putLevel = 0;
+// public void queueResult(T data) throws InterruptedException {
+//// String name = Thread.currentThread().getName(); putLevel++;
+//// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (putLevel) + " queueResult() - entering");
+// boolean ok = fDataQueue.offer(data, TIMEOUT, TimeUnit.MILLISECONDS);
+// if (!ok) {
+//// if (Tracer.isErrorTraced()) Tracer.traceError(getName() + ": Request timeout on write");
+// throw new InterruptedException();
+// }
+//// System.out.println("[" + System.currentTimeMillis() + "] " + name + " " + (putLevel) + " queueResult() - leaving");
+//// putLevel--;
+// }
/**
* Checks if the data meets the request completion criteria.
@@ -341,16 +363,20 @@ public abstract class TmfDataProvider<T extends TmfData> extends TmfComponent im
// ------------------------------------------------------------------------
@TmfSignalHandler
- public synchronized void startSynch(TmfStartSynchSignal signal) {
- fSignalDepth++;
+ public void startSynch(TmfStartSynchSignal signal) {
+ synchronized (fLock) {
+ fSignalDepth++;
+ }
}
@TmfSignalHandler
- public synchronized void endSynch(TmfEndSynchSignal signal) {
- fSignalDepth--;
- if (fSignalDepth == 0) {
- fireRequests();
- }
+ public void endSynch(TmfEndSynchSignal signal) {
+ synchronized (fLock) {
+ fSignalDepth--;
+ if (fSignalDepth == 0) {
+ fireRequests();
+ }
+ }
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java
index 63247f963b..6a14a5889e 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfEventProvider.java
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.tmf.component;
+import org.eclipse.linuxtools.tmf.Tracer;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
@@ -54,6 +55,10 @@ public abstract class TmfEventProvider<T extends TmfEvent> extends TmfDataProvid
TmfCoalescedEventRequest<T> coalescedRequest =
new TmfCoalescedEventRequest<T>(fType, eventRequest.getRange(), eventRequest.getNbRequested(), eventRequest.getBlockize(), eventRequest.getExecType());
coalescedRequest.addRequest(eventRequest);
+ if (Tracer.isRequestTraced()) {
+ Tracer.traceRequest(request, "coalesced with " + coalescedRequest.getRequestId());
+ Tracer.traceRequest(coalescedRequest, "added " + request.getRequestId());
+ }
fPendingCoalescedRequests.add(coalescedRequest);
}
else {
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfThread.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfThread.java
new file mode 100644
index 0000000000..43242723c5
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/component/TmfThread.java
@@ -0,0 +1,25 @@
+package org.eclipse.linuxtools.tmf.component;
+
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
+
+public class TmfThread extends Thread { // implements Comparator<ITmfDataRequest<?>> {
+
+ private final ExecutionType fExecType;
+
+ public TmfThread(ExecutionType execType) {
+ fExecType = execType;
+ }
+
+ public ExecutionType getExecType() {
+ return fExecType;
+ }
+//
+// public int compare(ITmfDataRequest<?> o1, ITmfDataRequest<?> o2) {
+// if (o1.getExecType() == o2.getExecType())
+// return 0;
+// if (o1.getExecType() == ExecutionType.SHORT)
+// return -1;
+// return 1;
+// }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java
index cbe8854f1d..75611dcff1 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java
@@ -20,6 +20,7 @@ import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
@@ -38,7 +39,7 @@ import org.eclipse.linuxtools.tmf.trace.TmfContext;
* <b><u>TmfExperiment</u></b>
* <p>
* TmfExperiment presents a time-ordered, unified view of a set of TmfTraces
- * that are part of a tracing experiment.
+ * that are part of a tracing experiment.
* <p>
*/
public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> implements ITmfTrace {
@@ -59,12 +60,14 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
// The experiment time range
private TmfTimeRange fTimeRange;
- // The experiment reference timestamp (default: BigBang)
+ // The experiment reference timestamp (default: Zero)
private TmfTimestamp fEpoch;
// The experiment index
private Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
+ private TmfExperimentContext fSavedContext;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -77,18 +80,17 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
* @param indexPageSize
*/
public TmfExperiment(Class<T> type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) {
- this(type, id, traces, TmfTimestamp.Zero, DEFAULT_INDEX_PAGE_SIZE, false);
+ this(type, id, traces, TmfTimestamp.Zero, indexPageSize, false);
}
- public TmfExperiment(Class<T> type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean waitForCompletion) {
+ public TmfExperiment(Class<T> type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean preIndexExperiment) {
super(id, type);
fTraces = traces;
fEpoch = epoch;
fIndexPageSize = indexPageSize;
- fClone = createTraceCopy();
- if (waitForCompletion) indexExperiment(true);
+ if (preIndexExperiment) indexExperiment(true);
updateTimeRange();
}
@@ -125,7 +127,6 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
fNbEvents = other.fNbEvents;
fTimeRange = other.fTimeRange;
- fClone = null;
}
public TmfExperiment<T> createTraceCopy() {
@@ -267,10 +268,12 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
@Override
public ITmfContext armRequest(ITmfDataRequest<T> request) {
+// Tracer.trace("Ctx: Arming request - start");
TmfTimestamp timestamp = (request instanceof ITmfEventRequest<?>) ?
- ((ITmfEventRequest<T>) request).getRange().getStartTime() : null;
+ ((ITmfEventRequest<T>) request).getRange().getStartTime() : null;
TmfExperimentContext context = (timestamp != null) ?
seekEvent(timestamp) : seekEvent(request.getIndex());
+// Tracer.trace("Ctx: Arming request - done");
return context;
}
@@ -289,7 +292,7 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
// Returns a brand new context based on the location provided
// and initializes the event queues
- public TmfExperimentContext seekLocation(ITmfLocation<?> location) {
+ public synchronized TmfExperimentContext seekLocation(ITmfLocation<?> location) {
// Validate the location
if (location != null && !(location instanceof TmfExperimentLocation)) {
@@ -303,6 +306,8 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
// Create and populate the context's traces contexts
TmfExperimentContext context = new TmfExperimentContext(fTraces, new TmfContext[fTraces.length]);
+// Tracer.trace("Ctx: SeekLocation - start");
+
long rank = 0;
for (int i = 0; i < fTraces.length; i++) {
// Get the relevant trace attributes
@@ -316,20 +321,27 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
// Set the trace location and read the corresponding event
expLocation.getLocation()[i] = context.getContexts()[i].getLocation();
- context.getEvents()[i] = fTraces[i].getNextEvent(context.getContexts()[i]);
+ context.getEvents()[i] = fTraces[i].parseEvent(context.getContexts()[i]);
}
+// Tracer.trace("Ctx: SeekLocation - done");
+
// Finalize context
context.setLocation(expLocation);
- context.setRank(rank);
context.setLastTrace(TmfExperimentContext.NO_TRACE);
+ context.setRank(rank);
+
+ fSavedContext = new TmfExperimentContext(context);
+
return context;
}
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.event.TmfTimestamp)
*/
- public TmfExperimentContext seekEvent(TmfTimestamp timestamp) {
+ public synchronized TmfExperimentContext seekEvent(TmfTimestamp timestamp) {
+
+// Tracer.trace("Ctx: seekEvent(TS) - start");
if (timestamp == null) {
timestamp = TmfTimestamp.BigBang;
@@ -362,22 +374,34 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
TmfExperimentContext context = seekLocation(location);
context.setRank((long) index * fIndexPageSize);
- // And locate the event
+ // And locate the event
TmfExperimentContext nextEventContext = new TmfExperimentContext(context);
- TmfEvent event = getNextEvent(nextEventContext);
+ TmfEvent event = parseEvent(nextEventContext);
while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
context = new TmfExperimentContext(nextEventContext);
event = getNextEvent(nextEventContext);
}
- context.setLastTrace(TmfExperimentContext.NO_TRACE);
- return context;
+ if (event != null) {
+ if (nextEventContext.getLastTrace() != TmfExperimentContext.NO_TRACE) {
+ nextEventContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+ nextEventContext.updateRank(-1);
+ }
+ fSavedContext = new TmfExperimentContext(nextEventContext);
+ }
+ else {
+ nextEventContext.setLocation(null);
+ nextEventContext.setRank(ITmfContext.UNKNOWN_RANK);
+ }
+ return nextEventContext;
}
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(long)
*/
- public TmfExperimentContext seekEvent(long rank) {
+ public synchronized TmfExperimentContext seekEvent(long rank) {
+
+// Tracer.trace("Ctx: seekEvent(rank) - start");
// Position the stream at the previous checkpoint
int index = (int) rank / fIndexPageSize;
@@ -395,20 +419,52 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
}
TmfExperimentContext context = seekLocation(location);
- long pos = (long) index * fIndexPageSize;
- context.setRank(pos);
+ context.setRank((long) index * fIndexPageSize);
- // And locate the event
+ // And locate the event
TmfExperimentContext nextEventContext = new TmfExperimentContext(context);
- TmfEvent event = getNextEvent(nextEventContext);
- while (event != null && pos++ < rank) {
+ TmfEvent event = parseEvent(nextEventContext);
+ long pos = context.getRank();
+ while (event != null && pos++ <= rank) {
+ context = new TmfExperimentContext(nextEventContext);
event = getNextEvent(nextEventContext);
- context = new TmfExperimentContext(nextEventContext);
- if (event != null) context.updateRank(-1);
}
- context.setLastTrace(TmfExperimentContext.NO_TRACE);
- return context;
+ if (event != null) {
+ if (nextEventContext.getLastTrace() != TmfExperimentContext.NO_TRACE) {
+ nextEventContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+ nextEventContext.updateRank(-1);
+ }
+ fSavedContext = new TmfExperimentContext(nextEventContext);
+ }
+ else {
+ nextEventContext.setLocation(null);
+ nextEventContext.setRank(ITmfContext.UNKNOWN_RANK);
+ }
+ return nextEventContext;
+
+// // And locate the event
+// TmfExperimentContext nextEventContext = new TmfExperimentContext(context);
+// TmfEvent event = parseEvent(nextEventContext);
+// long pos = context.getRank();
+// while (event != null && pos < rank) {
+// event = getNextEvent(nextEventContext);
+// context = new TmfExperimentContext(nextEventContext);
+// pos++;
+// }
+//
+// if (event != null) {
+// if (context.getLastTrace() != TmfExperimentContext.NO_TRACE) {
+// context.setLastTrace(TmfExperimentContext.NO_TRACE);
+// context.updateRank(-1);
+// }
+// fSavedContext = new TmfExperimentContext(context);
+// }
+// else {
+// context.setLocation(null);
+// context.setRank(ITmfContext.UNKNOWN_RANK);
+// }
+// return context;
}
/**
@@ -418,6 +474,24 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
* @param context
* @return
*/
+
+// private void dumpContext(TmfExperimentContext context, boolean isBefore) {
+
+// TmfContext context0 = context.getContexts()[0];
+// TmfEvent event0 = context.getEvents()[0];
+// TmfExperimentLocation location0 = (TmfExperimentLocation) context.getLocation();
+// long rank0 = context.getRank();
+// int trace = context.getLastTrace();
+//
+// StringBuffer result = new StringBuffer("Ctx: " + (isBefore ? "B " : "A "));
+//
+// result.append("[Ctx: fLoc= " + context0.getLocation().toString() + ", fRnk= " + context0.getRank() + "] ");
+// result.append("[Evt: " + event0.getTimestamp().toString() + "] ");
+// result.append("[Loc: fLoc= " + location0.getLocation()[0].toString() + ", fRnk= " + location0.getRanks()[0] + "] ");
+// result.append("[Rnk: " + rank0 + "], [Trc: " + trace + "]");
+// Tracer.trace(result.toString());
+// }
+
public synchronized TmfEvent getNextEvent(TmfContext context) {
// Validate the context
@@ -425,13 +499,26 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
return null; // Throw an exception?
}
+ if (!fSavedContext.equals(context)) {
+// Tracer.trace("Ctx: Restoring context");
+ seekLocation(context.getLocation());
+ }
+
TmfExperimentContext expContext = (TmfExperimentContext) context;
+// dumpContext(expContext, true);
+
// If an event was consumed previously, get the next one from that trace
int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
TmfContext traceContext = expContext.getContexts()[lastTrace];
expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+ expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].parseEvent(traceContext);
+
+ TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
+ traceContext = expContext.getContexts()[lastTrace];
+ expLocation.getLocation()[lastTrace] = traceContext.getLocation().clone();
+ expLocation.getRanks()[lastTrace] = traceContext.getRank();
}
// Scan the candidate events and identify the "next" trace to read from
@@ -451,26 +538,29 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
// Update the experiment context and set the "next" event
TmfEvent event = null;
if (trace >= 0) {
- long savedRank = expContext.getRank();
- updateIndex(expContext, savedRank, timestamp);
+ updateIndex(expContext, timestamp);
expContext.setLastTrace(trace);
expContext.updateRank(1);
- TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
- TmfContext traceContext = expContext.getContexts()[trace];
- expLocation.getLocation()[trace] = traceContext.getLocation().clone();
- expLocation.getRanks()[trace] = traceContext.getRank();
event = expContext.getEvents()[trace];
-// updateIndex(expContext, savedRank, timestamp);
}
+// if (event != null) {
+// Tracer.trace("Exp: " + (expContext.getRank() - 1) + ": " + event.getTimestamp().toString());
+// dumpContext(expContext, false);
+// Tracer.trace("Ctx: Event returned= " + event.getTimestamp().toString());
+// }
+
+ fSavedContext = new TmfExperimentContext(expContext);
+
return event;
}
- public synchronized void updateIndex(ITmfContext context, long rank, TmfTimestamp timestamp) {
+ public synchronized void updateIndex(ITmfContext context, TmfTimestamp timestamp) {
// Build the index as we go along
+ long rank = context.getRank();
if (context.isValidRank() && (rank % fIndexPageSize) == 0) {
// Determine the table position
- long position = context.getRank() / fIndexPageSize;
+ long position = rank / fIndexPageSize;
// Add new entry at proper location (if empty)
if (fCheckpoints.size() == position) {
ITmfLocation<?> location = context.getLocation().clone();
@@ -485,37 +575,46 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
*/
public TmfEvent parseEvent(TmfContext context) {
- if (context instanceof TmfExperimentContext) {
- TmfExperimentContext expContext = (TmfExperimentContext) context;
- int lastTrace = expContext.getLastTrace();
- if (lastTrace != -1) {
- TmfContext traceContext = expContext.getContexts()[lastTrace];
- expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
- expContext.updateRank(1);
- TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
- expLocation.getLocation()[lastTrace] = traceContext.getLocation().clone();
- }
+ // Validate the context
+ if (!(context instanceof TmfExperimentContext)) {
+ return null; // Throw an exception?
+ }
- int trace = -1;
- TmfTimestamp timestamp = TmfTimestamp.BigCrunch;
- for (int i = 0; i < expContext.getTraces().length; i++) {
- if (expContext.getEvents()[i] != null) {
- if (expContext.getEvents()[i].getTimestamp() != null) {
- TmfTimestamp otherTS = expContext.getEvents()[i].getTimestamp();
- if (otherTS.compareTo(timestamp, true) < 0) {
- trace = i;
- timestamp = otherTS;
- }
- }
+ if (!fSavedContext.equals(context)) {
+// Tracer.trace("Ctx: Restoring context");
+ seekLocation(context.getLocation());
+ }
+
+ TmfExperimentContext expContext = (TmfExperimentContext) context;
+
+ // If an event was consumed previously, get the next one from that trace
+ int lastTrace = expContext.getLastTrace();
+ if (lastTrace != TmfExperimentContext.NO_TRACE) {
+ TmfContext traceContext = expContext.getContexts()[lastTrace];
+ expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+ expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].parseEvent(traceContext);
+ fSavedContext = new TmfExperimentContext(expContext);
+ }
+
+ // Scan the candidate events and identify the "next" trace to read from
+ int trace = TmfExperimentContext.NO_TRACE;
+ TmfTimestamp timestamp = TmfTimestamp.BigCrunch;
+ for (int i = 0; i < expContext.getTraces().length; i++) {
+ TmfEvent event = expContext.getEvents()[i];
+ if (event != null && event.getTimestamp() != null) {
+ TmfTimestamp otherTS = event.getTimestamp();
+ if (otherTS.compareTo(timestamp, true) < 0) {
+ trace = i;
+ timestamp = otherTS;
}
}
- if (trace >= 0) {
- expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
- return expContext.getEvents()[trace];
- }
}
- return null;
+ TmfEvent event = null;
+ if (trace >= 0) {
+ event = expContext.getEvents()[trace];
+ }
+ return event;
}
/* (non-Javadoc)
@@ -541,14 +640,26 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
*/
// The index page size
- private static final int DEFAULT_INDEX_PAGE_SIZE = 1000;
+ private static final int DEFAULT_INDEX_PAGE_SIZE = 5000;
private final int fIndexPageSize;
+// private static BufferedWriter fEventLog = null;
+// private static BufferedWriter openLogFile(String filename) {
+// BufferedWriter outfile = null;
+// try {
+// outfile = new BufferedWriter(new FileWriter(filename));
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// return outfile;
+// }
+
@SuppressWarnings("unchecked")
private void indexExperiment(boolean waitForCompletion) {
-// final TmfExperiment<?> experiment = getCurrentExperiment();
fCheckpoints.clear();
+
+// fEventLog = openLogFile("TraceEvent.log");
ITmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, TmfTimeRange.Eternity, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.LONG) {
@@ -556,13 +667,22 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
TmfTimestamp startTime = null;
TmfTimestamp lastTime = null;
-// int nbEvents = 0;
@Override
public void handleData() {
TmfEvent[] events = getData();
if (events.length > 0) {
-// nbEvents++;
+
+// try {
+// if (fEventLog != null) {
+// fEventLog.write(events[0].getTimestamp().toString());
+// fEventLog.newLine();
+// fEventLog.flush();
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+
TmfTimestamp ts = events[0].getTimestamp();
if (startTime == null)
startTime = new TmfTimestamp(ts);
@@ -576,12 +696,22 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
@Override
public void handleSuccess() {
-// long indexingEnd = System.nanoTime();
- updateExperiment();
+// try {
+// fEventLog.close();
+// fEventLog = null;
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+
+// long indexingEnd = System.nanoTime();
-// System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed=" + (indexingEnd*1.0 - indexingStart) / 1000000000);
-// System.out.println(getName() + ": nbEvents=" + fNbEvents + "(" + ((indexingEnd-indexingStart)/nbEvents)+ " ns/evt)");
+ updateExperiment();
+// System.out.println(System.currentTimeMillis() + ": Experiment indexing completed");
+
+// long average = (indexingEnd - indexingStart) / fNbEvents;
+// System.out.println(getName() + ": start=" + startTime + ", end=" + lastTime + ", elapsed=" + (indexingEnd * 1.0 - indexingStart) / 1000000000);
+// System.out.println(getName() + ": nbEvents=" + fNbEvents + " (" + (average / 1000) + "." + (average % 1000) + " us/evt)");
// for (int i = 0; i < fCheckpoints.size(); i++) {
// TmfCheckpoint checkpoint = fCheckpoints.get(i);
@@ -590,16 +720,8 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
}
private void updateExperiment() {
-// if (experiment == fCurrentExperiment) {
-// experiment.fTimeRange = new TmfTimeRange(startTime, new TmfTimestamp(lastTime));
-// experiment.fNbEvents = nbEvents;
-// experiment.fCheckpoints = ((TmfExperiment<T>) fClone).fCheckpoints;
-// notifyListeners();
-// }
-
- fTimeRange = new TmfTimeRange(startTime, new TmfTimestamp(lastTime));
- fNbEvents = fNbRead;
- fCheckpoints = ((TmfExperiment<T>) fClone).fCheckpoints;
+ fTimeRange = new TmfTimeRange(startTime, new TmfTimestamp(lastTime));
+ fNbEvents = fNbRead;
notifyListeners();
}
};
@@ -614,7 +736,7 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
}
protected void notifyListeners() {
- broadcast(new TmfExperimentUpdatedSignal(this, this, null));
+ broadcast(new TmfExperimentUpdatedSignal(this, this)); // , null));
}
// ------------------------------------------------------------------------
@@ -644,12 +766,110 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
updateNbEvents();
updateTimeRange();
}
- broadcast(new TmfExperimentUpdatedSignal(this, this, signal.getTrace()));
+ broadcast(new TmfExperimentUpdatedSignal(this, this)); // , signal.getTrace()));
}
+// @Override
+// public void queueResult(T data) {
+//// super.queueResult(data);
+// }
+
+ // ------------------------------------------------------------------------
+ // TmfDataProvider
+ // ------------------------------------------------------------------------
+
@Override
- public void queueResult(T data) throws InterruptedException {
- super.queueResult(data);
+ protected void queueLongRequest(final ITmfDataRequest<T> request) {
+
+ // TODO: Handle the data requests also...
+ if (!(request instanceof ITmfEventRequest<?>)) {
+ super.queueRequest(request);
+ return;
+ }
+
+ final TmfExperiment<T> experiment = this;
+
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+
+// final long requestStart = System.nanoTime();
+
+ final Integer[] CHUNK_SIZE = new Integer[1];
+ CHUNK_SIZE[0] = fIndexPageSize + 1;
+
+ final ITmfEventRequest<T> req = (ITmfEventRequest<T>) request;
+
+ final Integer[] nbRead = new Integer[1];
+ nbRead[0] = 0;
+
+// final TmfTimestamp[] timestamp = new TmfTimestamp[1];
+// timestamp[0] = new TmfTimestamp(req.getRange().getStartTime());
+// final TmfTimestamp endTS = req.getRange().getEndTime();
+
+ final Boolean[] isFinished = new Boolean[1];
+ isFinished[0] = Boolean.FALSE;
+
+ while (!isFinished[0]) {
+
+// TmfEventRequest<T> subRequest = new TmfEventRequest<T>(req.getDataType(), new TmfTimeRange(timestamp[0], endTS),
+// requestedSize, req.getBlockize(), ExecutionType.LONG)
+ TmfDataRequest<T> subRequest = new TmfDataRequest<T>(req.getDataType(), nbRead[0], CHUNK_SIZE[0],
+ req.getBlockize(), ExecutionType.LONG)
+ {
+// int count = 0;
+ @Override
+ public void handleData() {
+ T[] data = getData();
+// if (count == 0) {
+// System.out.println("First event of the block: " + data[0].getTimestamp());
+// }
+// count++;
+// Tracer.trace("Ndx: " + ((TmfEvent) data[0]).getTimestamp());
+ req.setData(data);
+ req.handleData();
+ if (fNbRead == CHUNK_SIZE[0]) {
+ nbRead[0] += fNbRead;
+// System.out.println("fNbRead=" + fNbRead + ", count=" + count +", total=" + nbRead[0] + ", TS=" + data[0].getTimestamp());
+ }
+ if (fNbRead > CHUNK_SIZE[0]) {
+ System.out.println("ERROR - Read too many events");
+ }
+ }
+ @Override
+ public void handleCompleted() {
+// System.out.println("Request completed at: " + timestamp[0]);
+ if (fNbRead < CHUNK_SIZE[0]) {
+ req.done();
+ isFinished[0] = Boolean.TRUE;
+ nbRead[0] += fNbRead;
+// System.out.println("fNbRead=" + fNbRead + ", count=" + count +", total=" + nbRead[0]);
+ }
+ super.handleCompleted();
+ }
+ };
+
+ if (!isFinished[0]) {
+ experiment.queueRequest(subRequest);
+
+ try {
+ subRequest.waitForCompletion();
+// System.out.println("Finished at " + timestamp[0]);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+// TmfTimestamp newTS = new TmfTimestamp(timestamp[0].getValue() + 1, timestamp[0].getScale(), timestamp[0].getPrecision());
+// timestamp[0] = newTS;
+ CHUNK_SIZE[0] = fIndexPageSize;
+// System.out.println("New timestamp: " + timestamp[0]);
+ }
+ }
+// final long requestEnded = System.nanoTime();
+// System.out.println("Background request completed. Elapsed= " + (requestEnded * 1.0 - requestStart) / 1000000000);
+ }
+ };
+ thread.start();
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentContext.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentContext.java
index d43fa6a7e5..66c2336ade 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentContext.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentContext.java
@@ -46,7 +46,7 @@ public class TmfExperimentContext extends TmfContext {
private ITmfTrace[] fTraces = new ITmfTrace[0];
private TmfContext[] fContexts;
private TmfEvent[] fEvents;
- private int lastTrace;
+ private int lastTraceRead;
// ------------------------------------------------------------------------
// Constructors
@@ -71,7 +71,7 @@ public class TmfExperimentContext extends TmfContext {
setLocation(new TmfExperimentLocation(locations, ranks));
setRank(rank);
- lastTrace = NO_TRACE;
+ lastTraceRead = NO_TRACE;
}
public TmfExperimentContext(ITmfTrace[] traces) {
@@ -81,9 +81,10 @@ public class TmfExperimentContext extends TmfContext {
public TmfExperimentContext(TmfExperimentContext other) {
this(other.fTraces, other.cloneContexts());
fEvents = other.fEvents;
- setLocation(other.getLocation().clone());
+ if (other.getLocation() != null)
+ setLocation(other.getLocation().clone());
setRank(other.getRank());
- setLastTrace(other.lastTrace);
+ setLastTrace(other.lastTraceRead);
}
private TmfContext[] cloneContexts() {
@@ -110,11 +111,11 @@ public class TmfExperimentContext extends TmfContext {
}
public int getLastTrace() {
- return lastTrace;
+ return lastTraceRead;
}
public void setLastTrace(int newIndex) {
- lastTrace = newIndex;
+ lastTraceRead = newIndex;
}
// ------------------------------------------------------------------------
@@ -142,6 +143,7 @@ public class TmfExperimentContext extends TmfContext {
while (isEqual && i < fTraces.length) {
isEqual &= fTraces[i].equals(o.fTraces[i]);
isEqual &= fContexts[i].equals(o.fContexts[i]);
+ i++;
}
return isEqual;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentLocation.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentLocation.java
index 712cc08bcf..887e9d0c42 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentLocation.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperimentLocation.java
@@ -40,6 +40,17 @@ public class TmfExperimentLocation extends TmfLocation<ITmfLocation<?>[]> {
return new TmfExperimentLocation(clones, fRanks.clone());
}
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder("[TmfExperimentLocation");
+ ITmfLocation<?>[] locations = (ITmfLocation<?>[]) getLocation();
+ for (int i = 0; i < locations.length; i++) {
+ result.append("[" + locations[i].toString() + "," + fRanks[i] + "]");
+ }
+ result.append("]");
+ return result.toString();
+ }
+
public long[] getRanks() {
return fRanks;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfCoalescedEventRequest.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfCoalescedEventRequest.java
index c4c7cd67fc..4868d10402 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfCoalescedEventRequest.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfCoalescedEventRequest.java
@@ -91,6 +91,7 @@ public class TmfCoalescedEventRequest<T extends TmfEvent> extends TmfCoalescedDa
if (request instanceof ITmfEventRequest<?>) {
boolean ok = getNbRequested() == request.getNbRequested();
ok &= getBlockize() == request.getBlockize();
+ ok &= getExecType() == request.getExecType();
if (ok) {
TmfTimestamp startTime = ((ITmfEventRequest<T>) request).getRange().getStartTime();
TmfTimestamp endTime = ((ITmfEventRequest<T>) request).getRange().getEndTime();
@@ -113,8 +114,9 @@ public class TmfCoalescedEventRequest<T extends TmfEvent> extends TmfCoalescedDa
for (ITmfDataRequest<T> request : fRequests) {
if (request instanceof TmfEventRequest<?>) {
TmfEventRequest<T> req = (TmfEventRequest<T>) request;
- T[] data = getData();
- if (data.length > 0 && req.getRange().contains(data[0].getTimestamp())) {
+ T[] data = getData();
+ TmfTimestamp ts = data[0].getTimestamp();
+ if (data.length > 0 && req.getRange().contains(ts)) {
req.setData(data);
req.handleData();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java
index 362c694666..d5d868da4c 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfDataRequest.java
@@ -93,7 +93,7 @@ public abstract class TmfDataRequest<T extends TmfData> implements ITmfDataReque
private final int fBlockSize; // The maximum number of events per chunk
protected int fNbRead; // The number of reads so far
- private final Object lock;
+ private final Object lock;
private boolean fRequestRunning = false;
private boolean fRequestCompleted = false;
private boolean fRequestFailed = false;
@@ -359,7 +359,7 @@ public abstract class TmfDataRequest<T extends TmfData> implements ITmfDataReque
lock.notify();
}
handleStarted();
- if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "started");
+ if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "started");
}
/**
@@ -368,11 +368,13 @@ public abstract class TmfDataRequest<T extends TmfData> implements ITmfDataReque
public void done() {
if (Tracer.isRequestTraced()) Tracer.traceRequest(this, "completing");
synchronized(lock) {
- fRequestRunning = false;
- fRequestCompleted = true;
+ if (!fRequestCompleted) {
+ fRequestRunning = false;
+ fRequestCompleted = true;
+ }
+ handleCompleted();
lock.notify();
}
- handleCompleted();
}
/**
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfRequestExecutor.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfRequestExecutor.java
index 3dc7aa595c..26c3416cd6 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfRequestExecutor.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/request/TmfRequestExecutor.java
@@ -12,11 +12,15 @@
package org.eclipse.linuxtools.tmf.request;
-import java.util.Queue;
+import java.util.Comparator;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.PriorityBlockingQueue;
+
+import org.eclipse.linuxtools.tmf.Tracer;
+import org.eclipse.linuxtools.tmf.component.TmfThread;
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
/**
* <b><u>TmfRequestExecutor</u></b>
@@ -27,7 +31,15 @@ public class TmfRequestExecutor implements Executor {
private final ExecutorService fExecutor;
private final String fExecutorName;
- private final Queue<Runnable> fRequestQueue = new LinkedBlockingQueue<Runnable>();
+ private final PriorityBlockingQueue<TmfThread> fRequestQueue = new PriorityBlockingQueue<TmfThread>(100, new Comparator<TmfThread>() {
+ public int compare(TmfThread o1, TmfThread o2) {
+ if (o1.getExecType() == o2.getExecType())
+ return 0;
+ if (o1.getExecType() == ExecutionType.SHORT)
+ return 1;
+ return -1;
+ }
+ });
private Runnable fCurrentRequest;
// ------------------------------------------------------------------------
@@ -42,7 +54,7 @@ public class TmfRequestExecutor implements Executor {
fExecutor = executor;
String canonicalName = fExecutor.getClass().getCanonicalName();
fExecutorName = canonicalName.substring(canonicalName.lastIndexOf('.') + 1);
-// if (Tracer.COMPONENTS) Tracer.trace(fExecutor + " created");
+ if (Tracer.isComponentTraced()) Tracer.trace(fExecutor + " created");
}
/**
@@ -71,7 +83,7 @@ public class TmfRequestExecutor implements Executor {
*/
public void stop() {
fExecutor.shutdown();
-// if (Tracer.COMPONENTS) Tracer.trace(fExecutor + " terminated");
+ if (Tracer.isComponentTraced()) Tracer.trace(fExecutor + " terminated");
}
// ------------------------------------------------------------------------
@@ -81,11 +93,13 @@ public class TmfRequestExecutor implements Executor {
/* (non-Javadoc)
* @see java.util.concurrent.Executor#execute(java.lang.Runnable)
*/
- public synchronized void execute(final Runnable request) {
- fRequestQueue.offer(new Runnable() {
+ public synchronized void execute(final Runnable requestThread) {
+ fRequestQueue.offer(new TmfThread(((TmfThread) requestThread).getExecType()) {
+ @Override
public void run() {
try {
- request.run();
+ requestThread.run();
+ if (Tracer.isRequestTraced()) Tracer.trace("[REQ] Request finished");
} finally {
scheduleNext();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentUpdatedSignal.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentUpdatedSignal.java
index c8ede36950..49556b5c99 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentUpdatedSignal.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentUpdatedSignal.java
@@ -14,7 +14,6 @@ package org.eclipse.linuxtools.tmf.signal;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
/**
* <b><u>TmfExperimentUpdatedSignal</u></b>
@@ -24,28 +23,28 @@ import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
public class TmfExperimentUpdatedSignal extends TmfSignal {
private final TmfExperiment<? extends TmfEvent> fExperiment;
- private final ITmfTrace fTrace;
+// private final ITmfTrace fTrace;
- public TmfExperimentUpdatedSignal(Object source, TmfExperiment<? extends TmfEvent> experiment, ITmfTrace trace) {
+ public TmfExperimentUpdatedSignal(Object source, TmfExperiment<? extends TmfEvent> experiment) { // , ITmfTrace trace) {
super(source);
fExperiment = experiment;
- fTrace = trace;
+// fTrace = trace;
}
public TmfExperiment<? extends TmfEvent> getExperiment() {
return fExperiment;
}
- public ITmfTrace getTrace() {
- return fTrace;
- }
+// public ITmfTrace getTrace() {
+// return fTrace;
+// }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
- return "[TmfExperimentUpdatedSignal (" + fExperiment.toString() + ", " + fTrace.toString() + ")]";
+ return "[TmfExperimentUpdatedSignal (" + fExperiment.toString() /*+ ", " + fTrace.toString()*/ + ")]";
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfContext.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfContext.java
index 76a2fd3264..66fa11a93e 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfContext.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfContext.java
@@ -19,7 +19,7 @@ package org.eclipse.linuxtools.tmf.trace;
*/
public interface ITmfContext {
- public long UNKNOWN_RANK = -1L;
+ public long UNKNOWN_RANK = -2L;
public void setLocation(ITmfLocation<?> location);
public ITmfLocation<?> getLocation();
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java
index 5b349515a2..f524dbb2a4 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java
@@ -35,6 +35,11 @@ public interface ITmfTrace extends ITmfComponent {
*/
public String getName();
+ /**
+ * @return the cache size
+ */
+ public int getCacheSize();
+
/**
* @return the number of events in the trace
*/
@@ -62,6 +67,15 @@ public interface ITmfTrace extends ITmfComponent {
public TmfContext seekEvent(long rank);
/**
+ * Returns the rank of the first event with the requested timestamp.
+ * If none, returns the index of the next event (if any).
+ *
+ * @param timestamp
+ * @return
+ */
+ public long getRank(TmfTimestamp timestamp);
+
+ /**
* Return the event pointed by the supplied context (or null if
* no event left) and updates the context to the next event.
*
diff --git a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java
index f7f1db7353..13c552ace6 100644
--- a/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java
@@ -22,7 +22,11 @@ import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal;
/**
* <b><u>TmfTrace</u></b>
@@ -52,7 +56,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
// The default number of events to cache
// TODO: Make the DEFAULT_CACHE_SIZE a preference
- public static final int DEFAULT_CACHE_SIZE = 1000;
+ public static final int DEFAULT_INDEX_PAGE_SIZE = 1000;
// ------------------------------------------------------------------------
// Attributes
@@ -83,7 +87,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
* @throws FileNotFoundException
*/
protected TmfTrace(String name, Class<T> type, String path) throws FileNotFoundException {
- this(name, type, path, DEFAULT_CACHE_SIZE);
+ this(name, type, path, DEFAULT_INDEX_PAGE_SIZE);
}
/**
@@ -97,13 +101,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
String simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
setName(simpleName);
fPath = path;
- fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE;
-
- try {
- fClone = clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
+ fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
}
/* (non-Javadoc)
@@ -170,6 +168,18 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
return (Vector<TmfCheckpoint>) fCheckpoints.clone();
}
+ /**
+ * Returns the rank of the first event with the requested timestamp.
+ * If none, returns the index of the next event (if any).
+ *
+ * @param timestamp
+ * @return
+ */
+ public long getRank(TmfTimestamp timestamp) {
+ TmfContext context = seekEvent(timestamp);
+ return context.getRank();
+ }
+
// ------------------------------------------------------------------------
// Operators
// ------------------------------------------------------------------------
@@ -364,4 +374,166 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
return "[TmfTrace (" + getName() + ")]";
}
+ // ------------------------------------------------------------------------
+ // Indexing
+ // ------------------------------------------------------------------------
+
+ /*
+ * The purpose of the index is to keep the information needed to rapidly
+ * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE
+ * event).
+ */
+
+ @SuppressWarnings({ "unchecked", "unused" })
+ private void indexTrace(boolean waitForCompletion) {
+
+ fCheckpoints.clear();
+
+ ITmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, TmfTimeRange.Eternity, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.LONG) {
+
+ TmfTimestamp startTime = null;
+ TmfTimestamp lastTime = null;
+
+ @Override
+ public void handleData() {
+ TmfEvent[] events = getData();
+ if (events.length > 0) {
+ TmfTimestamp ts = events[0].getTimestamp();
+ if (startTime == null) {
+ startTime = new TmfTimestamp(ts);
+ fStartTime = startTime;
+ }
+ lastTime = new TmfTimestamp(ts);
+
+ if ((fNbRead % DEFAULT_INDEX_PAGE_SIZE) == 0) {
+ updateTraceData();
+ }
+ }
+ }
+
+ @Override
+ public void handleSuccess() {
+ updateTraceData();
+ }
+
+ private void updateTraceData() {
+ if (fNbRead != 0) {
+ fEndTime = new TmfTimestamp(lastTime);
+ fNbEvents = fNbRead;
+ notifyListeners();
+ }
+ }
+ };
+
+ sendRequest((ITmfDataRequest<T>) request);
+ if (waitForCompletion)
+ try {
+ request.waitForCompletion();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void notifyListeners() {
+ broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime)));
+ }
+
+ // ------------------------------------------------------------------------
+ // TmfDataProvider
+ // ------------------------------------------------------------------------
+
+ @Override
+ protected void queueLongRequest(final ITmfDataRequest<T> request) {
+
+ // TODO: Handle the data requests also...
+ if (!(request instanceof ITmfEventRequest<?>)) {
+ super.queueRequest(request);
+ return;
+ }
+
+ final TmfTrace<T> trace = this;
+
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+
+// final long requestStart = System.nanoTime();
+
+ final Integer[] CHUNK_SIZE = new Integer[1];
+ CHUNK_SIZE[0] = fIndexPageSize + 1;
+
+ final ITmfEventRequest<T> req = (ITmfEventRequest<T>) request;
+
+ final Integer[] nbRead = new Integer[1];
+ nbRead[0] = 0;
+
+// final TmfTimestamp[] timestamp = new TmfTimestamp[1];
+// timestamp[0] = new TmfTimestamp(req.getRange().getStartTime());
+// final TmfTimestamp endTS = req.getRange().getEndTime();
+
+ final Boolean[] isFinished = new Boolean[1];
+ isFinished[0] = Boolean.FALSE;
+
+ while (!isFinished[0]) {
+
+// TmfEventRequest<T> subRequest = new TmfEventRequest<T>(req.getDataType(), new TmfTimeRange(timestamp[0], endTS),
+// requestedSize, req.getBlockize(), ExecutionType.LONG)
+ TmfDataRequest<T> subRequest = new TmfDataRequest<T>(req.getDataType(), nbRead[0], CHUNK_SIZE[0],
+ req.getBlockize(), ExecutionType.LONG)
+ {
+// int count = 0;
+ @Override
+ public void handleData() {
+ T[] data = getData();
+// if (count == 0) {
+// System.out.println("First event of the block: " + data[0].getTimestamp());
+// }
+// count++;
+// Tracer.trace("Ndx: " + ((TmfEvent) data[0]).getTimestamp());
+ req.setData(data);
+ req.handleData();
+ if (fNbRead == CHUNK_SIZE[0]) {
+ nbRead[0] += fNbRead;
+// System.out.println("fNbRead=" + fNbRead + ", count=" + count +", total=" + nbRead[0] + ", TS=" + data[0].getTimestamp());
+ }
+ if (fNbRead > CHUNK_SIZE[0]) {
+ System.out.println("ERROR - Read too many events");
+ }
+ }
+ @Override
+ public void handleCompleted() {
+// System.out.println("Request completed at: " + timestamp[0]);
+ if (fNbRead < CHUNK_SIZE[0]) {
+ req.done();
+ isFinished[0] = Boolean.TRUE;
+ nbRead[0] += fNbRead;
+// System.out.println("fNbRead=" + fNbRead + ", count=" + count +", total=" + nbRead[0]);
+ }
+ super.handleCompleted();
+ }
+ };
+
+ if (!isFinished[0]) {
+ trace.queueRequest(subRequest);
+
+ try {
+ subRequest.waitForCompletion();
+// System.out.println("Finished at " + timestamp[0]);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+// TmfTimestamp newTS = new TmfTimestamp(timestamp[0].getValue() + 1, timestamp[0].getScale(), timestamp[0].getPrecision());
+// timestamp[0] = newTS;
+ CHUNK_SIZE[0] = fIndexPageSize;
+// System.out.println("New timestamp: " + timestamp[0]);
+ }
+ }
+// final long requestEnded = System.nanoTime();
+// System.out.println("Background request completed. Elapsed= " + (requestEnded * 1.0 - requestStart) / 1000000000);
+ }
+ };
+ thread.start();
+ }
+
}

Back to the top