aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGenevieve Bastien2013-06-14 12:22:24 (EDT)
committerGenevieve Bastien2013-07-18 09:35:48 (EDT)
commit8332fe6a84f1d2e3c9e84b52d5db1bc34f8dd0fc (patch)
treee75f48d25a282e50378d4d9d2a2f7c5604dae031
parent90bb242d92d45bf8a669a97a638f4e3f2dbee3ab (diff)
downloadorg.eclipse.linuxtools-8332fe6a84f1d2e3c9e84b52d5db1bc34f8dd0fc.zip
org.eclipse.linuxtools-8332fe6a84f1d2e3c9e84b52d5db1bc34f8dd0fc.tar.gz
org.eclipse.linuxtools-8332fe6a84f1d2e3c9e84b52d5db1bc34f8dd0fc.tar.bz2
TMF: Add the concept of host id to a tracerefs/changes/52/14052/6
This patch adds the concept of a host to a trace. By default, the host is the name of the trace itself (so 1 trace => 1 host). For CTF traces, the clock uuid is used to uniquely identify the host (boot session) the trace was taken from. Change-Id: Ie35725bc24be4ea5678c94d5ab5680e67892f4be Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net> Reviewed-on: https://git.eclipse.org/r/14052 Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java10
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java9
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java25
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java14
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java8
5 files changed, 66 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java
index 913e465..235be8b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java
@@ -364,4 +364,14 @@ public class CtfTmfTraceTest {
assertTrue(fixture.hasAtLeastOneOfEvents(names));
assertFalse(fixture.hasAllEvents(names));
}
+
+ /**
+ * Run the String getHostId() method test
+ */
+ @Test
+ public void testCtfHostId() {
+ String a = fixture.getHostId();
+ assertEquals("\"84db105b-b3f4-4821-b662-efc51455106a\"", a);
+ }
+
}
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 86e7c34..d20c677 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
@@ -1465,4 +1465,13 @@ public class TmfTraceTest {
TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
}
+
+ /**
+ * Run the String getHostId() method test
+ */
+ @Test
+ public void testTraceHostId() {
+ String a = fTrace.getHostId();
+ assertEquals("A-Test-10K", a);
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
index 5bdbfbb..4c9d9dd 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
+import org.eclipse.linuxtools.ctf.core.event.CTFClock;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
@@ -52,6 +53,11 @@ public class CtfTmfTrace extends TmfTrace
*/
protected static final int DEFAULT_CACHE_SIZE = 50000;
+ /*
+ * The Ctf clock unique identifier field
+ */
+ private static final String CLOCK_HOST_PROPERTY = "uuid"; //$NON-NLS-1$
+
// -------------------------------------------
// Fields
// -------------------------------------------
@@ -280,6 +286,25 @@ public class CtfTmfTrace extends TmfTrace
return fTrace;
}
+ /**
+ * Ctf traces have a clock with a unique uuid that will be used to identify
+ * the host. Traces with the same clock uuid will be known to have been made
+ * on the same machine.
+ *
+ * Note: uuid is an optional field, it may not be there for a clock.
+ */
+ @Override
+ public String getHostId() {
+ CTFClock clock = getCTFTrace().getClock();
+ if (clock != null) {
+ String clockHost = (String) clock.getProperty(CLOCK_HOST_PROPERTY);
+ if (clockHost != null) {
+ return clockHost;
+ }
+ }
+ return super.getHostId();
+ }
+
// -------------------------------------------
// ITmfTraceProperties
// -------------------------------------------
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 24ccaa1..1e680af 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
@@ -339,4 +339,18 @@ public interface ITmfTrace extends ITmfDataProvider {
* @since 2.0
*/
ITmfTimestamp getInitialRangeOffset();
+
+ /**
+ * Returns the ID of the host this trace is from. The host ID is not
+ * necessarily the hostname, but should be a unique identifier for the
+ * machine on which the trace was taken. It can be used to determine if two
+ * traces were taken on the exact same machine (timestamp are already
+ * synchronized, resources with same id are the same if taken at the same
+ * time, etc).
+ *
+ * @return The host id of this trace
+ * @since 3.0
+ */
+ String getHostId();
+
}
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 8543d66..d139af8 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
@@ -410,6 +410,14 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
}
+ /**
+ * @since 3.0
+ */
+ @Override
+ public String getHostId() {
+ return this.getName();
+ }
+
// ------------------------------------------------------------------------
// Convenience setters
// ------------------------------------------------------------------------