xml: Add the Host ID as event field
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 11 May 2017 21:12:05 +0000 (17:12 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 12 May 2017 19:15:08 +0000 (15:15 -0400)
This is useful for analyses on experiment, to divide the resulting state
system per trace if necessary.

Change-Id: Ic4f25964a78df8cdd7688cbac743047bf0c2c6e1
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/96903
Reviewed-by: Hudson CI
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/model/TmfStateValueTest.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_state_values.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlStateValue.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/TmfXmlStrings.java

index 3c6cacb04a9806345364f8d85557cc6260c356c8..4a3a6290ca9a556c72ef8b80fb66d134ee2c597c 100644 (file)
@@ -169,4 +169,28 @@ public class TmfStateValueTest {
         XmlUtilsTest.verifyStateIntervals("testMappingGroups", ss, quark, expectedStarts, expectedValues);
 
     }
+
+    /**
+     * Test using the HostID event field. It should give the host ID for value
+     *
+     * @throws StateSystemDisposedException
+     *             Exceptions thrown during state system verification
+     * @throws AttributeNotFoundException
+     *             Exceptions thrown during state system verification
+     */
+    @Test
+    public void testStateValueHostId() throws AttributeNotFoundException, StateSystemDisposedException {
+        XmlStateSystemModule module = fModule;
+        assertNotNull(module);
+
+        ITmfStateSystem ss = module.getStateSystem();
+        assertNotNull(ss);
+
+        int quark = ss.getQuarkAbsolute("hostID");
+
+        final int[] expectedStarts = { 1, 7 };
+        ITmfStateValue[] expectedValues = { TmfStateValue.newValueString("testTrace4.xml") };
+        XmlUtilsTest.verifyStateIntervals("testHostId", ss, quark, expectedStarts, expectedValues);
+
+    }
 }
index 08a76c4682e17dadafe614b78a389d53597af59f..3629410c1d9afd0d1fa7f9c2a03a4dd5774a4a99 100644 (file)
                                <stateAttribute type="eventField" value="cpu" />
                                <stateValue type="string" value="UNKNOWN" />
                        </stateChange>
+                       <stateChange>
+                               <stateAttribute type="constant" value="hostID" />
+                               <stateValue type="eventField" value="hostID" />
+                       </stateChange>
                        <stateChange>
                                <stateAttribute type="constant" value="stack"/>
                                <stateValue stack="push" type="eventField" value="timestamp" />
index 3cc7ed37b62b4481941ae2dd88ac5770e77ca303..250911b7ab340481a42e14a85920240cb2957cff 100644 (file)
@@ -237,6 +237,9 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute {
                             return getQuarkRelativeAndAdd(startQuark, cpu.toString());
                         }
                         return IXmlStateSystemContainer.ERROR_QUARK;
+                    } else if (name.equalsIgnoreCase(TmfXmlStrings.HOSTID)) {
+                        /* Return the host ID of the trace containing the event */
+                        return getQuarkRelativeAndAdd(startQuark, event.getTrace().getHostId());
                     }
                     /* Search between the trace event aspects */
                     fieldValue = TmfTraceUtils.resolveAspectOfNameForEvent(event.getTrace(), name, event);
index 8edaaab63dfc0a074d4d8efa032a1f0b51109c97..1c2f8e39f0aa90b2bcc64508f09ab702a2cae52f 100644 (file)
@@ -313,6 +313,9 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
                  * event
                  */
                 return TmfStateValue.newValueLong(event.getTimestamp().getValue());
+            } else if (fieldName.equalsIgnoreCase(TmfXmlStrings.HOSTID)) {
+                /* Return the host ID of the trace containing the event */
+                return TmfStateValue.newValueString(event.getTrace().getHostId());
             }
             // This will allow to use any column as input
             fieldValue = TmfTraceUtils.resolveAspectOfNameForEvent(event.getTrace(), fieldName, event);
index 2edb570b91793e78ee1d3499e803ef870c292937..4e7fb64af7b8c4c43cdf0a6763941c826bad845c 100644 (file)
@@ -85,6 +85,7 @@ public interface TmfXmlStrings {
     String STACK_PUSH = "push";
     String STACK_PEEK = "peek";
     String CPU = "cpu";
+    String HOSTID = "hostId";
 
     String TIMESTAMP = "timestamp";
 
This page took 0.027657 seconds and 5 git commands to generate.