summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBernd Hufmann2012-11-28 07:58:53 (EST)
committer Bernd Hufmann2012-11-28 11:01:44 (EST)
commitcf2667737f384ad72f98b7dc84029c128b3e5646 (patch)
tree9e2923f991f5bedd3a64b87a7d14dec05d0e593c
parent87a43b7c150eda36f21ddf79caa370f365be8441 (diff)
downloadorg.eclipse.linuxtools-cf2667737f384ad72f98b7dc84029c128b3e5646.zip
org.eclipse.linuxtools-cf2667737f384ad72f98b7dc84029c128b3e5646.tar.gz
org.eclipse.linuxtools-cf2667737f384ad72f98b7dc84029c128b3e5646.tar.bz2
Add handling of initial range offset in experimentsrefs/changes/14/8914/2
Change-Id: I3eb8353c183747eaac3e1b39816efcfe29bd3864 Reviewed-on: https://git.eclipse.org/r/8914 Tested-by: Hudson CI Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java33
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java38
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java14
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java8
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java22
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java10
6 files changed, 119 insertions, 6 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java
index a49a684..cbeb459 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
@@ -47,7 +48,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
-
+ private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM1 = "O-Test-10K";
private static final String TEST_STREAM2 = "E-Test-10K";
@@ -71,10 +72,13 @@ public class TmfMultiTraceExperimentTest extends TestCase {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
File test = new File(FileLocator.toFileURL(location).toURI());
final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
+ trace1.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
+
fTraces[0] = trace1;
location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
test = new File(FileLocator.toFileURL(location).toURI());
final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
+ trace2.setInitialRangeOffset(new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE));
fTraces[1] = trace2;
} catch (final TmfTraceException e) {
e.printStackTrace();
@@ -121,6 +125,16 @@ public class TmfMultiTraceExperimentTest extends TestCase {
final TmfTimeRange timeRange = fExperiment.getTimeRange();
assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
+
+ TmfTimestamp initRange = new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset());
+ assertEquals("getCurrentTime", fExperiment.getTimeRange().getStartTime(), fExperiment.getCurrentTime());
+
+ ITmfTimestamp startTimestamp = fExperiment.getTimeRange().getStartTime();
+ long endValue = startTimestamp.getValue() + initRange.normalize(0, startTimestamp.getScale()).getValue();
+ ITmfTimestamp endTimestamp = new TmfTimestamp(endValue, startTimestamp.getScale());
+ TmfTimeRange expectedRange = new TmfTimeRange(startTimestamp, endTimestamp);
+ assertEquals("getCurrentRange", expectedRange, fExperiment.getCurrentRange());
}
// ------------------------------------------------------------------------
@@ -806,4 +820,21 @@ public class TmfMultiTraceExperimentTest extends TestCase {
assertNull("getTimestamp", fExperiment.getTimestamp(20000));
}
+ // ------------------------------------------------------------------------
+ // getInitialRangeOffset, getCurrentRange, getCurrentTime
+ // ------------------------------------------------------------------------
+ public void testDefaultCurrentTimeValues() {
+ // reset to default initial range offset
+ ((TmfTraceStub)fTraces[0]).setInitialRangeOffset(null);
+ ((TmfTraceStub)fTraces[1]).setInitialRangeOffset(null);
+
+ TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, fTraces, BLOCK_SIZE);
+
+ // verify initial values
+ TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset());
+ assertEquals("getCurrentTime", TmfTimestamp.ZERO, exp.getCurrentTime());
+ assertEquals("getCurrentRange", TmfTimeRange.NULL_RANGE, exp.getCurrentRange());
+
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
index 8258ebc..b104fdd 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
@@ -50,7 +50,7 @@ public class TmfTraceTest extends TestCase {
// ------------------------------------------------------------------------
// Variables
// ------------------------------------------------------------------------
-
+ private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "A-Test-10K";
private static final int BLOCK_SIZE = 500;
@@ -1394,4 +1394,40 @@ public class TmfTraceTest extends TestCase {
assertEquals("toString", expected, fTrace.toString());
}
+ // ------------------------------------------------------------------------
+ // getInitialRangeOffset, getCurrentRange, getCurrentTime
+ // ------------------------------------------------------------------------
+ @SuppressWarnings("null")
+ public void testCurrentTimeValues() throws TmfTraceException {
+
+ TmfTraceStub trace = null;
+ File testfile = null;
+ try {
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
+ testfile = new File(FileLocator.toFileURL(location).toURI());
+ trace = new TmfTraceStub(testfile.toURI().getPath());
+ // verify initial values
+ TmfTimestamp defaultInitRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ assertEquals("getInitialRangeOffset", defaultInitRange, trace.getInitialRangeOffset());
+ assertEquals("getCurrentTime", TmfTimestamp.ZERO, trace.getCurrentTime());
+ assertEquals("getCurrentRange", TmfTimeRange.NULL_RANGE, trace.getCurrentRange());
+ trace.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
+ trace.indexTrace();
+ } catch (final URISyntaxException e) {
+ fail("URISyntaxException");
+ } catch (final IOException e) {
+ fail("IOException");
+ }
+ assertFalse ("Open trace", trace == null);
+
+ TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
+ assertEquals("getCurrentTime", trace.getTimeRange().getStartTime(), trace.getCurrentTime());
+
+ ITmfTimestamp startTimestamp = trace.getTimeRange().getStartTime();
+ long endValue = startTimestamp.getValue() + initRange.normalize(0, startTimestamp.getScale()).getValue();
+ ITmfTimestamp endTimestamp = new TmfTimestamp(endValue, startTimestamp.getScale());
+ TmfTimeRange expectedRange = new TmfTimeRange(startTimestamp, endTimestamp);
+ assertEquals("getCurrentRange", expectedRange, trace.getCurrentRange());
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
index e0be954..2a16a2e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
@@ -54,6 +54,8 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
// The synchronization lock
private final ReentrantLock fLock = new ReentrantLock();
+ private ITmfTimestamp fInitialRangeOffset = null;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -207,6 +209,18 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
return fTrace;
}
+ public void setInitialRangeOffset(ITmfTimestamp initOffset) {
+ fInitialRangeOffset = initOffset;
+ }
+
+ @Override
+ public ITmfTimestamp getInitialRangeOffset() {
+ if (fInitialRangeOffset != null) {
+ return fInitialRangeOffset;
+ }
+ return super.getInitialRangeOffset();
+ }
+
// ------------------------------------------------------------------------
// Operators
// ------------------------------------------------------------------------
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
index 5cdf5d1..b42a9d9 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
@@ -293,6 +293,14 @@ public interface ITmfTrace extends ITmfDataProvider {
public ITmfContext seekEvent(double ratio);
/**
+ * Returns the initial range offset
+ *
+ * @return the initial range offset
+ * @since 2.0
+ */
+ public ITmfTimestamp getInitialRangeOffset();
+
+ /**
* Return the current selected time.
*
* @return the current time stamp
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
index 2a25b96..eda777e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
@@ -385,6 +385,28 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser {
}
/* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#getInitialRangeOffset()
+ */
+ /**
+ * @since 2.0
+ */
+ @Override
+ public ITmfTimestamp getInitialRangeOffset() {
+ if ((fTraces == null) || (fTraces.length == 0)) {
+ return super.getInitialRangeOffset();
+ }
+
+ ITmfTimestamp initTs = TmfTimestamp.BIG_CRUNCH;
+ for (int i = 0; i < fTraces.length; i++) {
+ ITmfTimestamp ts = fTraces[i].getInitialRangeOffset();
+ if (ts.compareTo(initTs) < 0) {
+ initTs = ts;
+ }
+ }
+ return initTs;
+ }
+
+ /* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
index 0c317c4..6f77649 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
@@ -451,13 +451,15 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
return fCurrentRange;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getInitialRangeOffset()
+ */
/**
- * Returns the initial range offset
- *
- * @return the initial range offset
* @since 2.0
*/
- protected TmfTimestamp getInitialRangeOffset() {
+ @Override
+ public ITmfTimestamp getInitialRangeOffset() {
final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
}