Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfTrace.java
index e26d535c509d0c68291e0a4881eed766401cba54..648550d54333ea4cc2c5b1100f4bf5023d34eb5f 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;
@@ -32,9 +33,9 @@ import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
 
 /**
  * The CTf trace handler
@@ -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
     // -------------------------------------------
@@ -164,12 +170,16 @@ public class CtfTmfTrace extends TmfTrace
      *
      * @return null, since the trace has no knowledge of the current location
      * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation()
+     * @since 3.0
      */
     @Override
     public ITmfLocation getCurrentLocation() {
         return null;
     }
 
+    /**
+     * @since 3.0
+     */
     @Override
     public double getLocationRatio(ITmfLocation location) {
         final CtfLocation curLocation = (CtfLocation) location;
@@ -189,6 +199,7 @@ public class CtfTmfTrace extends TmfTrace
      * @param location
      *            ITmfLocation<?>
      * @return ITmfContext
+     * @since 3.0
      */
     @Override
     public synchronized ITmfContext seekEvent(final ITmfLocation location) {
@@ -281,6 +292,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
     // -------------------------------------------
@@ -317,7 +347,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);
@@ -337,7 +367,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) {
@@ -355,7 +385,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.02738 seconds and 5 git commands to generate.