Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfTrace.java
index 16ff7f5c7f47587fd68eb3ee8922e170f8ed5f12..89151ee3db21807fa199361ec698eb029d97d189 100644 (file)
@@ -22,6 +22,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;
@@ -53,6 +54,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
     // -------------------------------------------
@@ -284,6 +290,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
     // -------------------------------------------
@@ -320,7 +345,7 @@ public class CtfTmfTrace extends TmfTrace
      * @param eventName
      *            The name of the event to check
      * @return Whether the event is in the metadata or not
-     * @since 2.1
+     * @since 3.0
      */
     public boolean hasEvent(final String eventName) {
         Map<Long, IEventDeclaration> events = fTrace.getEvents(0L);
@@ -340,7 +365,7 @@ public class CtfTmfTrace extends TmfTrace
      * @param names
      *            The array of events to check for
      * @return Whether all events are in the metadata
-     * @since 2.1
+     * @since 3.0
      */
     public boolean hasAllEvents(String[] names) {
         for (String name : names) {
@@ -358,7 +383,7 @@ public class CtfTmfTrace extends TmfTrace
      * @param names
      *            The array of event names of check for
      * @return Whether one of the event is present in trace metadata
-     * @since 2.1
+     * @since 3.0
      */
     public boolean hasAtLeastOneOfEvents(String[] names) {
         for (String name : names) {
This page took 0.025415 seconds and 5 git commands to generate.