TMF: Add the concept of host id to a trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfTrace.java
index 5bdbfbbc7c2e5e176b1d86d432433e60582d1e98..4c9d9dd0b565f69d89e6ea42e06a916ba8ebcb61 100644 (file)
@@ -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
     // -------------------------------------------
This page took 0.024009 seconds and 5 git commands to generate.