tmf: lttngControl: mi: support snapshot information
authorJonathan Rajotte Julien <jonathan.rajotte-julien@ericsson.com>
Mon, 11 Aug 2014 14:55:50 +0000 (10:55 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Wed, 27 Aug 2014 15:34:35 +0000 (11:34 -0400)
Change-Id: Idac3ad8e3b4166734d6580c7e791e312cd0d6ca0
Signed-off-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/31394
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java
org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/MIStrings.java

index 1e8d8335736c52dedd162bfd85ca151eaf13eb49..9a85d2fe2b550cf4e88935d39a0dcab5734196b2 100644 (file)
@@ -501,8 +501,11 @@ public class LTTngControlService implements ILttngControlService {
     }
 
     /**
+     * Basic generation of command for session creation
+     *
      * @param sessionInfo
-     * @return
+     *            the session to create
+     * @return the basic command for command creation
      */
     protected StringBuffer prepareSessionCreationCommand(ISessionInfo sessionInfo) {
         String newName = formatParameter(sessionInfo.getName());
@@ -586,8 +589,11 @@ public class LTTngControlService implements ILttngControlService {
     }
 
     /**
+     * Basic generation of command for streamed session creation
+     *
      * @param sessionInfo
-     * @return
+     *            the session to create
+     * @return the basic command for command creation
      */
     protected StringBuffer prepareStreamedSessionCreationCommand(ISessionInfo sessionInfo) {
         String newName = formatParameter(sessionInfo.getName());
index 1583b1c36ce9456297a3e2255b898b9122a18150..9d115426efcd744fa0a7ae3fc31a16d7216ef0a3 100644 (file)
@@ -447,8 +447,50 @@ public class LTTngControlServiceMI extends LTTngControlService {
 
     @Override
     public ISnapshotInfo getSnapshotInfo(String sessionName, IProgressMonitor monitor) throws ExecutionException {
-        // TODO JRJ - STUB
-        return null;
+        // TODO A session can have multiple snapshot output. This need to be
+        // supported in the future.
+        // Currently the SessionInfo object does not support multiple snashot
+        // output.
+        // For now only keep the last one.
+        StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_SNAPSHOT_OUTPUT, LTTngControlServiceConstants.OPTION_SESSION, sessionName);
+        ICommandResult result = executeCommand(command.toString(), monitor);
+        Document doc = getDocumentFromStrings(result.getOutput());
+        NodeList rawSnapshotsOutputs = doc.getElementsByTagName(MIStrings.SNAPSHOT_OUTPUTS);
+
+        ISnapshotInfo snapshotInfo = new SnapshotInfo(""); //$NON-NLS-1$
+
+        // TODO: tmf does not have a notion of a ctrl url.
+        for (int i = 0; i < rawSnapshotsOutputs.getLength(); i++) {
+            NodeList rawSnapshotOutput = rawSnapshotsOutputs.item(i).getChildNodes();
+            for (int j = 0; j < rawSnapshotOutput.getLength(); j++) {
+                Node rawInfo = rawSnapshotOutput.item(j);
+                switch (rawInfo.getNodeName()) {
+                case MIStrings.ID:
+                    snapshotInfo.setId(Integer.parseInt(rawInfo.getTextContent()));
+                    break;
+                case MIStrings.NAME:
+                    snapshotInfo.setName(rawInfo.getTextContent());
+                    break;
+                case MIStrings.SNAPSHOT_CTRL_URL:
+                    // The use of the ctrl_url for the snapshot path is to assure
+                    // basic support. Refactoring is necessary in lttng and
+                    // tmf side.
+                    // See http://bugs.lttng.org/issues/828 (+comment)
+                    snapshotInfo.setSnapshotPath(rawInfo.getTextContent());
+                    break;
+                default:
+                    break;
+                }
+            }
+        }
+
+        // Check if the snapshot output is Streamed
+        Matcher matcher2 = LTTngControlServiceConstants.TRACE_NETWORK_PATTERN.matcher(snapshotInfo.getSnapshotPath());
+        if (matcher2.matches()) {
+            snapshotInfo.setStreamedSnapshot(true);
+        }
+
+        return snapshotInfo;
     }
 
     @Override
index 61b352a57dbe8e977dc867fac200be72016fe94a..3d79248ec75486422f445d4325be109dddb17922 100644 (file)
@@ -537,7 +537,7 @@ public interface MIStrings {
     /**
      * Represent the snapshot_outputs xml element
      */
-     String SNAPSHOT_OUTPUTS = "snapshot_outputs";
+     String SNAPSHOT_OUTPUTS = "snapshot";
 
     /**
      * Represent the consumer_output xml element
This page took 0.028134 seconds and 5 git commands to generate.