lttng: Add snapshot support - LTTng Tools v2.3
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Mon, 19 Aug 2013 16:59:04 +0000 (12:59 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 30 Sep 2013 20:15:50 +0000 (16:15 -0400)
Support for commands
- lttng create <session> --snapshot OPTIONS
- lttng snapshot list-output
- lttng snapshot record

Not supported
- lttng snapshot del-output
- lttng snapshot add-output
- lttng snapshot record OPTIONS

Change-Id: Id8b8a6bc487c0fe792ffe74981f42dbc1d42a81c
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/16644
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Hudson CI
35 files changed:
org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki
org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png [new file with mode: 0644]
org.eclipse.linuxtools.lttng.help/doc/images/LTTng2RecordSnapshotAction.png [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/AllTests.java
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ModelImplFactory.java
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SnapshotInfoTest.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISessionInfo.java
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISnapshotInfo.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SessionInfo.java
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SnapshotInfo.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/AllTests.java
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlSnapshotSessionTests.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java
org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateSessionDialogStub.java
org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateSessionTest2.cfg [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg
org.eclipse.linuxtools.lttng2.ui/icons/elcl16/snapshot.gif [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ui/plugin.properties
org.eclipse.linuxtools.lttng2.ui/plugin.xml
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateSessionDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateSessionDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ImportDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateSessionHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/ImportHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/SnaphshotHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionGroup.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceSessionPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/ILttngControlService.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java

index ccc5d485b1c4486c2cd0e286473c63b40496bf48..215e8a0bf12e3bd4394ec496f33a8348e8a254b7 100644 (file)
@@ -938,6 +938,15 @@ The text field '''Trace Path''' allows for specifying the path relative to the l
 
 To create a session with advanced options, fill in the relevant parameters and press '''Ok'''. Upon successful operation a new session will be created and added under the tree node '''Sessions'''.
 
+==== Creating a Snapshot Tracing Session ====
+LTTng Tools version v2.3.0 introduces the possibility to create snapshot tracing sessions. After starting tracing the trace events are not stored on disk or over the network. They are only transfered to disk or over the network when the user records a snapshot. To create such a snapshot session, open the trace session dialog as described in chapter [[#Creating a Tracing Session | Creating a Tracing Session]].
+
+[[Image:images/LTTng2CreateSessionDialog_Snapshot.png]]
+
+Fill in all necessary information, select checkbox for '''Snapshot Mode''' and press '''Ok'''. By default, the location for the snapshot output will be on the host where the host is located.
+
+Refer to chapter [[#Recording a Snapshot | Recording a Snapshot]] for how to create a snapshot.
+
 ==== Enabling Channels - General ====
 
 Enabling channels can be done using a session tree node when the domain hasn't be created in the session or, alternatively on a domain tree node of a session in case the domain is already available.
@@ -1199,9 +1208,17 @@ To start tracing, select one or more sessions to start in the Control View and p
 
 Upon successful operation, the tracing session will be '''ACTIVE''' and the icon of the session will be updated.
 
+==== Recording a Snapshot ====
+
+LTTng Tools version v2.3.0 introduces the possibility to create snapshot tracing sessions. After creating a snapshot session (see [[#Creating a Snapshot Tracing Session | Creating a Snapshot Tracing Session]]) and starting tracing (see [[#Start Tracing | Start Tracing]]) it possible to record snapshots. To record a snapshot select one or more sessions and press the '''Record Snapshot''' button. Alternatively, press the right mouse button on the session tree nodes. A context-sensitive menu will show. Then select the '''Recored Snapshot''' menu item.
+
+[[Image:images/LTTng2RecordSnapshotAction.png]]
+
+This action can be executed many times. It is possible to import the recorded snpshots to a tracing project. The trace session might be '''ACTIVE''' or '''INACTIVE''' for that. Refer to section [[#Importing Session Traces to a Tracing Project | Importing Session Traces to a Tracing Project]] on how to import a trace to a tracing project.
+
 ==== Stop Tracing ====
 
-To stop tracing, select one or more sessions to stop in the Control View and press the '''Stop''' button. Alternatively, click the right mouse button on the session tree nodes. A context-sensitive menu will show. Then select the '''Stop''' menu item.
+To stop tracing, select one or more sessions to stop in the Control View and press the '''Stop''' button. Alternatively, click the right mouse button on the session tree node. A context-sensitive menu will show. Then select the '''Stop''' menu item.
 
 [[Image:images/LTTng2StopTracingAction.png]]
 
@@ -1288,8 +1305,11 @@ The Control View provides property information of selected tree component. Depen
 ** '''Log Level''': The log level of the event.
 * '''Session''' Properties
 ** '''Session Name''': The name of the Session.
-** '''Session Path''': The path on the remote host where the traces will be stored.
+** '''Session Path''': The path on the remote host where the traces will be stored. (Not shown for snapshot sessions).
 ** '''State''': The state of the session ('''ACTIVE''' or '''INACTIVE''')
+** '''Snapshot ID''': The snapshot ID. (Only shown for snapshot sessions).
+** '''Snapshot Name''': The name of the snapshot output configuration. (Only shown for snapshot sessions).
+** '''Snapshot Path''': The path where the snapshot session is located. (Only shown for snapshot sessions).
 * '''Domain''' Properties
 ** '''Domain Name''': The name of the domain.
 ** '''Buffer Type''': The buffer type of the domain.
diff --git a/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png b/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png
new file mode 100644 (file)
index 0000000..7438ab4
Binary files /dev/null and b/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png differ
diff --git a/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2RecordSnapshotAction.png b/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2RecordSnapshotAction.png
new file mode 100644 (file)
index 0000000..8c8ae56
Binary files /dev/null and b/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2RecordSnapshotAction.png differ
index fdbf937756a3cb35d14a1abd305eb67d39da9c0b..ce0e6e1d8054deb01a4de701e08d8aafab88a573 100644 (file)
@@ -29,7 +29,8 @@ import org.junit.runners.Suite;
     ProbeEventInfoTest.class,
     SessionInfoTest.class,
     TraceInfoTest.class,
-    UstProviderInfoTest.class
+    UstProviderInfoTest.class,
+    SnapshotInfoTest.class
 })
 public class AllTests {
 
index a756060140d326e50620fa9155a8784af628db1f..76e340a796b88bf0ced251f1a9d64ae793d66419 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
@@ -31,6 +32,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo;
 
 /**
@@ -56,6 +58,8 @@ public class ModelImplFactory {
     private IUstProviderInfo fUstProviderInfo2 = null;
     private IProbeEventInfo fProbeEventInfo1 = null;
     private IProbeEventInfo fProbeEventInfo2 = null;
+    private ISnapshotInfo fSnapshotInfo1 = null;
+    private ISnapshotInfo fSnapshotInfo2 = null;
 
     public ModelImplFactory() {
 
@@ -146,6 +150,16 @@ public class ModelImplFactory {
         fProbeEventInfo2.setState(TraceEnablement.DISABLED);
         fProbeEventInfo2.setOffset("0x100");
         fProbeEventInfo2.setSymbol("init_post");
+
+        fSnapshotInfo1 = new SnapshotInfo("snapshot-1");
+        fSnapshotInfo1.setId(1);
+        fSnapshotInfo1.setSnapshotPath("/home/user/lttng-trace/mysession/");
+        fSnapshotInfo2 = new SnapshotInfo("other-snapshot");
+        fSnapshotInfo2.setId(1);
+        fSnapshotInfo2.setSnapshotPath("net4://172.0.0.1:1234/");
+        fSnapshotInfo2.setStreamedSnapshot(true);
+
+        fSessionInfo1.setSnapshotInfo(fSnapshotInfo1);
     }
 
     public ISessionInfo getSessionInfo1() {
@@ -215,4 +229,12 @@ public class ModelImplFactory {
     public IFieldInfo getFieldInfo2() {
         return fFieldInfo2;
     }
+
+    public ISnapshotInfo getSnapshotInfo1() {
+        return fSnapshotInfo1;
+    }
+
+    public ISnapshotInfo getSnapshotInfo2() {
+        return fSnapshotInfo2;
+    }
 }
index 3a8039c08aac016ab470d3028b5c31fc9334a113..f033772a0dbdeeb8a790a4757d1c712a5b7ec9a3 100644 (file)
@@ -189,7 +189,7 @@ public class SessionInfoTest {
         String result = fixture.toString();
 
         // add additional test code here
-        assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],State=INACTIVE,isStreamedTrace=false,Domains=)]", result);
+        assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],Path=,State=INACTIVE,isStreamedTrace=false,Domains=)]", result);
     }
 
     /**
@@ -200,7 +200,31 @@ public class SessionInfoTest {
         String result = fSessionInfo1.toString();
 
         // add additional test code here
-        assertEquals("[SessionInfo([TraceInfo(Name=session1)],State=ACTIVE,isStreamedTrace=false,Domains=[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)])]", result);
+        assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,snapshotInfo="
+                + "[SnapshotInfo([TraceInfo(Name=snapshot-1)],snapshotPath=/home/user/lttng-trace/mysession/,ID=1,isStreamedSnapshot=false)],"
+                    + "Domains=[DomainInfo([TraceInfo(Name=test1)],"
+                        + "Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),"
+                            + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],"
+                + "isKernel=false)])]", result);
+    }
+
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
+    public void testToString_3() {
+        SessionInfo info = new SessionInfo((SessionInfo)fSessionInfo1);
+        info.setSnapshotInfo(null);
+        info.setSessionPath("/home/user/lttng-trace/mysession/");
+
+        String result = info.toString();
+
+        // add additional test code here
+        assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,"
+                    + "Domains=[DomainInfo([TraceInfo(Name=test1)],"
+                        + "Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),"
+                            + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],"
+                + "isKernel=false)])]", result);
     }
 
     // ------------------------------------------------------------------------
diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SnapshotInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SnapshotInfoTest.java
new file mode 100644 (file)
index 0000000..75a285d
--- /dev/null
@@ -0,0 +1,229 @@
+/**********************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SnapshotInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * The class <code>SnapshotInfoTest</code> contains test for the class
+ * <code>{@link SnapshotInfo}</code>.
+ */
+public class SnapshotInfoTest {
+
+    // ------------------------------------------------------------------------
+    // Test data
+    // ------------------------------------------------------------------------
+
+    private ISnapshotInfo fSnapshotInfo1 = null;
+    private ISnapshotInfo fSnapshotInfo2 = null;
+
+
+    // ------------------------------------------------------------------------
+    // Housekeeping
+    // ------------------------------------------------------------------------
+
+    /**
+     * Perform pre-test initialization.
+     */
+    @Before
+    public void setUp() {
+        ModelImplFactory factory = new ModelImplFactory();
+        fSnapshotInfo1 = factory.getSnapshotInfo1();
+        fSnapshotInfo2 = factory.getSnapshotInfo2();
+    }
+
+    // ------------------------------------------------------------------------
+    // Tests
+    // ------------------------------------------------------------------------
+
+    /**
+     * Constructor test.
+     */
+    @Test
+    public void testSnapshotInfo() {
+        SnapshotInfo fixture = new SnapshotInfo("event");
+        assertNotNull(fixture);
+        assertEquals("event", fixture.getName());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testSnapshotInfo2() {
+        try {
+            String name = null;
+            new SnapshotInfo(name);
+            fail("null name in custructor");
+        }
+        catch (IllegalArgumentException e) {
+            // Success
+        }
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testSnapshotCopy() {
+        SnapshotInfo info = new SnapshotInfo((SnapshotInfo)fSnapshotInfo1);
+
+        assertEquals(fSnapshotInfo1.getName(), info.getName());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testTraceCopy2() {
+        try {
+            SnapshotInfo info = null;
+            new SnapshotInfo(info);
+            fail("null copy");
+        }
+        catch (IllegalArgumentException e) {
+            // Success
+        }
+    }
+
+    /**
+     * Run the void setEventType(String) method test.
+     */
+    @Test
+    public void testSetName() {
+        SnapshotInfo fixture = new SnapshotInfo("event");
+        fixture.setName("newName");
+        assertEquals("newName", fixture.getName());
+    }
+
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
+    public void testToString_1() {
+        String result = fSnapshotInfo1.toString();
+
+        // add additional test code here
+        assertEquals("[SnapshotInfo([TraceInfo(Name=snapshot-1)],snapshotPath=/home/user/lttng-trace/mysession/,ID=1,isStreamedSnapshot=false)]", result);
+    }
+
+    // ------------------------------------------------------------------------
+    // equals
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsReflexivity() {
+        assertTrue("equals", fSnapshotInfo1.equals(fSnapshotInfo1));
+        assertTrue("equals", fSnapshotInfo2.equals(fSnapshotInfo2));
+
+        assertTrue("equals", !fSnapshotInfo1.equals(fSnapshotInfo2));
+        assertTrue("equals", !fSnapshotInfo2.equals(fSnapshotInfo1));
+    }
+
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsSymmetry() {
+        SnapshotInfo info1 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo1);
+        SnapshotInfo info2 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo2);
+
+        assertTrue("equals", info1.equals(fSnapshotInfo1));
+        assertTrue("equals", fSnapshotInfo1.equals(info1));
+
+        assertTrue("equals", info2.equals(fSnapshotInfo2));
+        assertTrue("equals", fSnapshotInfo2.equals(info2));
+    }
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsTransivity() {
+        SnapshotInfo info1 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo1);
+        SnapshotInfo info2 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo1);
+        SnapshotInfo info3 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo1);
+
+        assertTrue("equals", info1.equals(info2));
+        assertTrue("equals", info2.equals(info3));
+        assertTrue("equals", info1.equals(info3));
+    }
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsNull() {
+        assertTrue("equals", !fSnapshotInfo1.equals(null));
+        assertTrue("equals", !fSnapshotInfo2.equals(null));
+
+        SnapshotInfo info = new SnapshotInfo("snapshot-1");
+        assertTrue("equals", !fSnapshotInfo1.equals(info));
+
+        info.setSnapshotPath(null);
+        assertTrue("equals", !fSnapshotInfo1.equals(info));
+
+        info.setId(fSnapshotInfo1.getId());
+        assertTrue("equals", !info.equals(fSnapshotInfo1));
+
+        info.setSnapshotPath("/home/user/lttng-trace/mysession/");
+        assertTrue("equals", fSnapshotInfo1.equals(info));
+        info.setId(2);
+        assertTrue("equals", !fSnapshotInfo1.equals(info));
+
+        info.setId(fSnapshotInfo1.getId());
+        info.setStreamedSnapshot(true);
+        assertTrue("equals", !fSnapshotInfo1.equals(info));
+
+        assertTrue("equals", !fSnapshotInfo1.equals(new TraceInfo(fSnapshotInfo1.getName())));
+    }
+
+    // ------------------------------------------------------------------------
+    // hashCode
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the hashCode() method test.
+     */
+    @Test
+    public void testHashCode() {
+        SnapshotInfo info1 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo1);
+        SnapshotInfo info2 = new SnapshotInfo((SnapshotInfo)fSnapshotInfo2);
+
+        assertTrue("hashCode", fSnapshotInfo1.hashCode() == info1.hashCode());
+        assertTrue("hashCode", fSnapshotInfo2.hashCode() == info2.hashCode());
+
+        assertTrue("hashCode", fSnapshotInfo1.hashCode() != info2.hashCode());
+        assertTrue("hashCode", fSnapshotInfo2.hashCode() != info1.hashCode());
+
+        // null values
+        SnapshotInfo info3 = new SnapshotInfo("snapshot-1");
+        assertTrue("hashCode", fSnapshotInfo1.hashCode() != info3.hashCode());
+
+        info3.setSnapshotPath(null);
+        assertTrue("hashCode", fSnapshotInfo1.hashCode() != info3.hashCode());
+
+        info3.setSnapshotPath("/home/user/lttng-trace/mysession/");
+        assertTrue("hashCode", fSnapshotInfo1.hashCode() != info3.hashCode());
+    }
+}
\ No newline at end of file
index cf9d4d9c88f2cc17ac3eb1ebd9b937f7fdea80c7..3fff6a2d56e70b66c15f80649e0d0a428b01b595 100644 (file)
@@ -78,4 +78,23 @@ public interface ISessionInfo extends ITraceInfo {
      * @param isStreamedTrace <code>true</code> if streamed over network else <code>false</code>
      */
     void setStreamedTrace(boolean isStreamedTrace);
+
+    /**
+     * Returns whether the session is snapshot session or not
+     * @return <code>true</code> if it is snapshot session else <code>false</code>
+     */
+    boolean isSnapshotSession();
+
+    /**
+     * Gets the snapshot information the session or null if it is not a
+     * snapshot session.
+     * @return snapshot information
+     */
+    ISnapshotInfo getSnapshotInfo();
+
+    /**
+     * Sets the snapshot information of the session
+     * @param setSnapshotInfo - the snapshot data to set.
+     */
+    void setSnapshotInfo(ISnapshotInfo setSnapshotInfo);
 }
diff --git a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISnapshotInfo.java b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISnapshotInfo.java
new file mode 100644 (file)
index 0000000..4f9c91f
--- /dev/null
@@ -0,0 +1,62 @@
+/**********************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.core.control.model;
+
+
+/**
+ * <p>
+ * Interface for retrieval of snapshot information of a session.
+ * </p>
+ *
+ * @author Bernd Hufmann
+ */
+public interface ISnapshotInfo extends ITraceInfo {
+
+    /**
+     * @return path string where snapshot is located.
+     */
+    String getSnapshotPath();
+
+    /**
+     * Sets the path string (where snapshot is located) to the given value.
+     * @param path - session path to set.
+     */
+    void setSnapshotPath(String path);
+
+    /**
+     * @return the snapshot ID.
+     */
+    int getId();
+
+    /**
+     * Sets the snapshot ID.
+     * @param id - the ID to set.
+     */
+    void setId(int id);
+
+    /**
+     * Sets whether snapshot is streamed over the network or stored locally
+     * at the tracers host.
+     *
+     * @param isStreamed - <code>true</code> if streamed else <code>false</code>
+     */
+    void setStreamedSnapshot(boolean isStreamed);
+
+    /**
+     * Gets whether snapshot is streamed over the network or stored locally
+     * at the tracers host.
+     *
+     * @return <code>true</code> if streamed else <code>false</code>
+     */
+    boolean isStreamedSnapshot();
+
+}
index ec6b95344281f2839ffb72b5b4947e3050da3d16..ac660757e32aae93250b31f46e6f22dc2622a17f 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
 
 /**
@@ -49,6 +50,11 @@ public class SessionInfo extends TraceInfo implements ISessionInfo {
      * Flag to indicate whether trace is streamed over network or not.
      */
     private boolean fIsStreamedTrace = false;
+    /**
+     * Flag to indicate whether the session is a snapshot session or not.
+     */
+    private ISnapshotInfo fSnapshotInfo = null;
+
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -70,6 +76,7 @@ public class SessionInfo extends TraceInfo implements ISessionInfo {
         fState = other.fState;
         fSessionPath = other.fSessionPath;
         fIsStreamedTrace = other.fIsStreamedTrace;
+        fSnapshotInfo = other.fSnapshotInfo;
 
         for (Iterator<IDomainInfo> iterator = other.fDomains.iterator(); iterator.hasNext();) {
             IDomainInfo domain = iterator.next();
@@ -106,6 +113,9 @@ public class SessionInfo extends TraceInfo implements ISessionInfo {
 
     @Override
     public String getSessionPath() {
+        if(isSnapshotSession()) {
+            return fSnapshotInfo.getSnapshotPath();
+        }
         return fSessionPath;
     }
 
@@ -130,6 +140,9 @@ public class SessionInfo extends TraceInfo implements ISessionInfo {
 
     @Override
     public boolean isStreamedTrace() {
+        if (isSnapshotSession()) {
+            return fSnapshotInfo.isStreamedSnapshot();
+        }
         return fIsStreamedTrace;
     }
 
@@ -138,67 +151,47 @@ public class SessionInfo extends TraceInfo implements ISessionInfo {
         fIsStreamedTrace = isStreamedTrace;
     }
 
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
+    @Override
+    public boolean isSnapshotSession() {
+        return fSnapshotInfo != null;
+    }
 
     @Override
-    public void addDomain(IDomainInfo domainInfo) {
-        fDomains.add(domainInfo);
+    public ISnapshotInfo getSnapshotInfo() {
+        return fSnapshotInfo;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + fDomains.hashCode();
-        result = prime * result + (fIsStreamedTrace ? 1231 : 1237);
-        result = prime * result + ((fSessionPath == null) ? 0 : fSessionPath.hashCode());
-        result = prime * result + ((fState == null) ? 0 : fState.hashCode());
-        return result;
+    public void setSnapshotInfo(ISnapshotInfo info) {
+        fSnapshotInfo = info;
     }
 
+    // ------------------------------------------------------------------------
+    // Operations
+    // ------------------------------------------------------------------------
+
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        SessionInfo other = (SessionInfo) obj;
-        if (!fDomains.equals(other.fDomains)) {
-            return false;
-        }
-        if (fIsStreamedTrace != other.fIsStreamedTrace) {
-            return false;
-        }
-        if (fSessionPath == null) {
-            if (other.fSessionPath != null) {
-                return false;
-            }
-        } else if (!fSessionPath.equals(other.fSessionPath)) {
-            return false;
-        }
-        if (fState != other.fState) {
-            return false;
-        }
-        return true;
+    public void addDomain(IDomainInfo domainInfo) {
+        fDomains.add(domainInfo);
     }
 
+
     @SuppressWarnings("nls")
     @Override
     public String toString() {
         StringBuffer output = new StringBuffer();
             output.append("[SessionInfo(");
             output.append(super.toString());
+            output.append(",Path=");
+            output.append(getSessionPath());
             output.append(",State=");
             output.append(fState);
             output.append(",isStreamedTrace=");
             output.append(fIsStreamedTrace);
+            if (fSnapshotInfo != null) {
+                output.append(",snapshotInfo=");
+                output.append(fSnapshotInfo.toString());
+            }
             output.append(",Domains=");
             for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
                 IDomainInfo domain = iterator.next();
diff --git a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SnapshotInfo.java b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SnapshotInfo.java
new file mode 100644 (file)
index 0000000..352e7f9
--- /dev/null
@@ -0,0 +1,150 @@
+/**********************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
+
+/**
+ * <p>
+ * Implementation of the snapshot interface (ISnapshotInfo) to store snapshot
+ * related data.
+ * </p>
+ *
+ * @author Bernd Hufmann
+ */
+public class SnapshotInfo extends TraceInfo implements ISnapshotInfo {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+    /** The snapshot path for storing traces. */
+    private String fPath = ""; //$NON-NLS-1$
+    /** The snapshot ID */
+    private int fId = -1;
+    /** Flag whether snapshot is stored over the network or locally */
+    private boolean fIsStreamed = false;
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+    /**
+     * Constructor
+     * @param name - name of base event
+     */
+    public SnapshotInfo(String name) {
+        super(name);
+    }
+
+    /**
+     * Copy constructor
+     * @param other - the instance to copy
+     */
+    public SnapshotInfo(SnapshotInfo other) {
+        super(other);
+        fPath = other.fPath;
+        fId = other.fId;
+        fIsStreamed = other.fIsStreamed;
+    }
+
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
+    @Override
+    public String getSnapshotPath() {
+        return fPath;
+    }
+
+    @Override
+    public void setSnapshotPath(String path) {
+        fPath = path;
+    }
+
+    @Override
+    public int getId() {
+        return fId;
+    }
+
+    @Override
+    public void setId(int id) {
+        fId = id;
+    }
+
+    @Override
+    public void setStreamedSnapshot(boolean isStreamed) {
+        fIsStreamed = isStreamed;
+    }
+
+    @Override
+    public boolean isStreamedSnapshot() {
+        return fIsStreamed;
+    }
+
+    // ------------------------------------------------------------------------
+    // Operations
+    // ------------------------------------------------------------------------
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + fId;
+        result = prime * result + (fIsStreamed ? 1231 : 1237);
+        result = prime * result + ((fPath == null) ? 0 : fPath.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        SnapshotInfo other = (SnapshotInfo) obj;
+        if (fId != other.fId) {
+            return false;
+        }
+        if (fIsStreamed != other.fIsStreamed) {
+            return false;
+        }
+        if (fPath == null) {
+            if (other.fPath != null) {
+                return false;
+            }
+        } else if (!fPath.equals(other.fPath)) {
+            return false;
+        }
+        return true;
+    }
+
+    @SuppressWarnings("nls")
+    @Override
+    public String toString() {
+        StringBuffer output = new StringBuffer();
+            output.append("[SnapshotInfo(");
+            output.append(super.toString());
+            output.append(",snapshotPath=");
+            output.append(fPath);
+            output.append(",ID=");
+            output.append(fId);
+            output.append(",isStreamedSnapshot=");
+            output.append(fIsStreamed);
+            output.append(")]");
+            return output.toString();
+    }
+
+}
index dcca208ac98001294988b7532e4caa9ebe14f2a0..86d433445aeea243893bd02ce2c1d473e654d316 100644 (file)
@@ -30,7 +30,8 @@ import org.junit.runners.Suite;
     TraceControlTreeModelTest.class,
     TraceControlUstProviderTests.class,
     TraceControlUstSessionTests.class,
-    TraceControlUstSessionTests2.class
+    TraceControlUstSessionTests2.class,
+    TraceControlSnapshotSessionTests.class
 })
 public class AllTests {
 
diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlSnapshotSessionTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlSnapshotSessionTests.java
new file mode 100644 (file)
index 0000000..e3a147e
--- /dev/null
@@ -0,0 +1,220 @@
+/**********************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub;
+import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub;
+import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.GetEventInfoDialogStub;
+import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceSessionPropertySource;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemProfile;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.FrameworkUtil;
+
+/**
+ * The class <code>TraceControlSnapshotSessionTests</code> contains Snapshot
+ * session test cases for support of LTTng Tools 2.3.
+ */
+public class TraceControlSnapshotSessionTests {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    private static final String TEST_STREAM = "CreateSessionTest2.cfg";
+    private static final String SCEN_CREATE_SESSION = "ScenCreateSession";
+
+    // ------------------------------------------------------------------------
+    // Test data
+    // ------------------------------------------------------------------------
+
+    private TraceControlTestFacility fFacility;
+    private TestRemoteSystemProxy fProxy;
+    private String fTestFile;
+
+    // ------------------------------------------------------------------------
+    // Housekeeping
+    // ------------------------------------------------------------------------
+
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception
+     *         if the initialization fails for some reason
+     */
+    @Before
+    public void setUp() throws Exception {
+        fFacility = TraceControlTestFacility.getInstance();
+        fFacility.init();
+        fProxy = new TestRemoteSystemProxy();
+        URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
+        File testfile = new File(FileLocator.toFileURL(location).toURI());
+        fTestFile = testfile.getAbsolutePath();
+    }
+
+    /**
+     * Perform post-test clean-up.
+     */
+    @After
+    public void tearDown() {
+        fFacility.waitForJobs();
+        fFacility.dispose();
+    }
+
+    /**
+     * Run the TraceControlComponent.
+     *
+     * @throws Exception
+     *             This will fail the test
+     */
+    @Test
+    public void testTraceSessionTree() throws Exception {
+
+        fProxy.setTestFile(fTestFile);
+        fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST);
+
+        ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
+
+        ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+        ISystemProfile profile =  registry.createSystemProfile("myProfile", true);
+        IHost host = registry.createLocalHost(profile, "myProfile", "user");
+
+        TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, fProxy);
+
+        root.addChild(node);
+        fFacility.waitForJobs();
+
+        fFacility.executeCommand(node, "connect");
+        int i = 0;
+        while ((i < 10) && (node.getTargetNodeState() != TargetNodeState.CONNECTED)) {
+            i++;
+            fFacility.delay(TraceControlTestFacility.GUI_REFESH_DELAY);
+        }
+
+        // Get provider groups
+        ITraceControlComponent[] groups = node.getChildren();
+        assertNotNull(groups);
+        assertEquals(2, groups.length);
+
+        // Initialize dialog implementations for command execution
+        // --- snapshot session ---
+        CreateSessionDialogStub sessionDialog = new CreateSessionDialogStub();
+        sessionDialog.setSnapshot(true);
+
+        TraceControlDialogFactory.getInstance().setCreateSessionDialog(sessionDialog);
+        TraceControlDialogFactory.getInstance().setGetEventInfoDialog(new GetEventInfoDialogStub());
+        TraceControlDialogFactory.getInstance().setConfirmDialog(new DestroyConfirmDialogStub());
+
+        // Initialize scenario
+        fProxy.setScenario(SCEN_CREATE_SESSION);
+
+        // ------------------------------------------------------------------------
+        // Create session
+        // ------------------------------------------------------------------------
+        TraceSessionComponent session = fFacility.createSession(groups[1]);
+
+        // Verify that session was created
+        assertNotNull(session);
+        assertEquals("mysession", session.getName());
+        assertTrue(session.isSnapshotSession());
+        assertNotNull(session.getSnapshotInfo());
+        assertEquals("snapshot-1", session.getSnapshotInfo().getName());
+        assertEquals("/home/user/lttng-traces/mysession-20130913-141651", session.getSnapshotInfo().getSnapshotPath());
+        assertEquals(1, session.getSnapshotInfo().getId());
+
+        // ------------------------------------------------------------------------
+        // Start session
+        // ------------------------------------------------------------------------
+        fFacility.startSession(session);
+        assertEquals(TraceSessionState.ACTIVE, session.getSessionState());
+
+        // verify properties
+        Object adapter = session.getAdapter(IPropertySource.class);
+        assertNotNull(adapter);
+        assertTrue(adapter instanceof TraceSessionPropertySource);
+
+        TraceSessionPropertySource sessionSource = (TraceSessionPropertySource)adapter;
+        IPropertyDescriptor[] descriptors = sessionSource.getPropertyDescriptors();
+        assertNotNull(descriptors);
+
+        Map<String,String> map = new HashMap<String,String>();
+        map.put(TraceSessionPropertySource.TRACE_SESSION_NAME_PROPERTY_ID, "mysession");
+        map.put(TraceSessionPropertySource.TRACE_SNAPSHOT_NAME_PROPERTY_ID, "snapshot-1");
+        map.put(TraceSessionPropertySource.TRACE_SNAPSHOT_PATH_PROPERTY_ID, "/home/user/lttng-traces/mysession-20130913-141651");
+        map.put(TraceSessionPropertySource.TRACE_SNAPSHOT_ID_PROPERTY_ID, "1");
+        map.put(TraceSessionPropertySource.TRACE_SESSION_STATE_PROPERTY_ID, TraceSessionState.ACTIVE.name());
+
+        for (int j = 0; j < descriptors.length; j++) {
+            String expected = map.get(descriptors[j].getId());
+            assertNotNull(expected);
+            assertEquals(expected, sessionSource.getPropertyValue(descriptors[j].getId()).toString());
+        }
+
+        // ------------------------------------------------------------------------
+        // Record snapshot
+        // ------------------------------------------------------------------------
+        fFacility.executeCommand(session, "snapshot");
+
+        // ------------------------------------------------------------------------
+        // Stop snapshot
+        // ------------------------------------------------------------------------
+        fFacility.stopSession(session);
+        assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
+
+        // ------------------------------------------------------------------------
+        // Destroy session
+        // ------------------------------------------------------------------------
+        fFacility.destroySession(session);
+
+        // Verify that no more session components exist
+        assertEquals(0, groups[1].getChildren().length);
+
+        //-------------------------------------------------------------------------
+        // Disconnect node
+        //-------------------------------------------------------------------------
+        fFacility.executeCommand(node, "disconnect");
+        assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
+
+        //-------------------------------------------------------------------------
+        // Delete node
+        //-------------------------------------------------------------------------
+
+        fFacility.executeCommand(node, "delete");
+
+        assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
+    }
+}
\ No newline at end of file
index d4fd95a874420c12ce0e98747c19df1dc2064561..ddf7ee811f90054bb1c31561f39e2f3e17cad091 100644 (file)
@@ -35,6 +35,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
@@ -100,6 +101,9 @@ public class LTTngControlServiceTest {
     private static final String SCEN_CALIBRATE_HANDLING = "CalibrateHandling";
     private static final String SCEN_CREATE_SESSION_2_1 = "CreateSessionLttng2.1";
     private static final String SCEN_CREATE_SESSION_VERBOSE_2_1 = "CreateSessionLttngVerbose2.1";
+    private static final String SCEN_CREATE_SNAPSHOT_SESSION = "CreateSessionSnapshot";
+    private static final String SCEN_CREATE_STREAMED_SNAPSHOT_SESSION = "CreateSessionStreamedSnapshot";
+    private static final String SCEN_CREATE_SNAPSHOT_SESSION_ERRORS = "CreateSessionSnapshotErrors";
 
     // ------------------------------------------------------------------------
     // Test data
@@ -707,7 +711,7 @@ public class LTTngControlServiceTest {
         try {
             fShell.setScenario(SCEN_CREATE_SESSION1);
 
-            ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
+            ISessionInfo info = fService.createSession("mysession2", null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession2", info.getName());
             assertNotNull(info.getSessionPath());
@@ -726,7 +730,7 @@ public class LTTngControlServiceTest {
             fShell.setScenario(SCEN_CREATE_SESSION_WITH_PROMPT);
 
             // First line has no shell prompt before the output
-            ISessionInfo info = fService.createSession("mysession2", null, new NullProgressMonitor());
+            ISessionInfo info = fService.createSession("mysession2", null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession2", info.getName());
             assertNotNull(info.getSessionPath());
@@ -743,28 +747,28 @@ public class LTTngControlServiceTest {
         fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
 
         try {
-            fService.createSession("alreadyExist", null, new NullProgressMonitor());
+            fService.createSession("alreadyExist", null, false, new NullProgressMonitor());
             fail("No exeption thrown");
         } catch (ExecutionException e) {
             // success
         }
 
         try {
-            fService.createSession("wrongName", null, new NullProgressMonitor());
+            fService.createSession("wrongName", null, false, new NullProgressMonitor());
             fail("No exeption thrown");
         } catch (ExecutionException e) {
             // success
         }
 
         try {
-            fService.createSession("withPath", "/home/user/hallo", new NullProgressMonitor());
+            fService.createSession("withPath", "/home/user/hallo", false, new NullProgressMonitor());
             fail("No exeption thrown");
         } catch (ExecutionException e) {
             // success
         }
 
         try {
-            ISessionInfo info = fService.createSession("session with spaces", null, new NullProgressMonitor());
+            ISessionInfo info = fService.createSession("session with spaces", null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("session with spaces", info.getName());
             assertNotNull(info.getSessionPath());
@@ -776,7 +780,7 @@ public class LTTngControlServiceTest {
         }
 
         try {
-            ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
+            ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("pathWithSpaces", info.getName());
             assertNotNull(info.getSessionPath());
@@ -1162,35 +1166,35 @@ public class LTTngControlServiceTest {
         try {
             fShell.setScenario(SCEN_CREATE_SESSION_2_1);
 
-            ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, new NullProgressMonitor());
+            ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("net://172.0.0.1", info.getSessionPath());
             assertTrue(info.isStreamedTrace());
             fService.destroySession("mysession", new NullProgressMonitor());
 
-            info = fService.createSession("mysession", "file:///tmp", null, null, new NullProgressMonitor());
+            info = fService.createSession("mysession", "file:///tmp", null, null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("file:///tmp", info.getSessionPath());
             assertTrue(!info.isStreamedTrace());
             fService.destroySession("mysession", new NullProgressMonitor());
 
-            info = fService.createSession("mysession", "file:///tmp", null, null, new NullProgressMonitor());
+            info = fService.createSession("mysession", "file:///tmp", null, null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("file:///tmp", info.getSessionPath());
             assertTrue(!info.isStreamedTrace());
             fService.destroySession("mysession", new NullProgressMonitor());
 
-            info = fService.createSession("mysession", null, "tcp://172.0.0.1", "tcp://172.0.0.1:5343", new NullProgressMonitor());
+            info = fService.createSession("mysession", null, "tcp://172.0.0.1", "tcp://172.0.0.1:5343", false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("", info.getSessionPath()); // the complete network path is not available at this point
             assertTrue(info.isStreamedTrace());
             fService.destroySession("mysession", new NullProgressMonitor());
 
-            info = fService.createSession("mysession", "net://172.0.0.1:1234:2345", null, null, new NullProgressMonitor());
+            info = fService.createSession("mysession", "net://172.0.0.1:1234:2345", null, null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("net://172.0.0.1:1234:2345", info.getSessionPath());
@@ -1199,7 +1203,7 @@ public class LTTngControlServiceTest {
 
             // verbose
             enableVerbose();
-            info = fService.createSession("mysession", "net://172.0.0.1", null, null, new NullProgressMonitor());
+            info = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("net://172.0.0.1", info.getSessionPath());
@@ -1219,7 +1223,7 @@ public class LTTngControlServiceTest {
             fShell.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1);
 
             enableVerbose();
-            ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, new NullProgressMonitor());
+            ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor());
             assertNotNull(info);
             assertEquals("mysession", info.getName());
             assertEquals("net://172.0.0.1", info.getSessionPath());
@@ -1232,6 +1236,113 @@ public class LTTngControlServiceTest {
         }
     }
 
+    @Test
+    public void testCreateSnapshotSession() {
+        try {
+            fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION);
+
+            ISessionInfo sessionInfo = fService.createSession("mysession", null, true, new NullProgressMonitor());
+            assertNotNull(sessionInfo);
+            assertEquals("mysession", sessionInfo.getName());
+            assertTrue(sessionInfo.isSnapshotSession());
+            assertEquals("", sessionInfo.getSessionPath());
+            assertTrue(!sessionInfo.isStreamedTrace());
+
+            assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState());
+
+            String[] names = fService.getSessionNames(new NullProgressMonitor());
+            assertEquals(names[0], "mysession");
+
+            ISnapshotInfo snapshotInfo = fService.getSnapshotInfo("mysession", new NullProgressMonitor());
+            assertNotNull(snapshotInfo);
+            assertEquals("snapshot-1", snapshotInfo.getName());
+            assertEquals("/home/user/lttng-traces/mysession-20130913-141651", snapshotInfo.getSnapshotPath());
+            assertEquals(1, snapshotInfo.getId());
+            assertTrue(!snapshotInfo.isStreamedSnapshot());
+
+            // we need to set the snapshotInfo to so that the session path is set correctly
+            sessionInfo.setSnapshotInfo(snapshotInfo);
+            assertEquals("/home/user/lttng-traces/mysession-20130913-141651", sessionInfo.getSessionPath());
+
+            fService.recordSnapshot("mysession", new NullProgressMonitor());
+
+            fService.destroySession("mysession", new NullProgressMonitor());
+
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+    }
+
+    public void testCreateStreamedSnapshotSession() {
+        try {
+            fShell.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION);
+
+            ISessionInfo sessionInfo = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor());
+            assertNotNull(sessionInfo);
+            assertEquals("mysession", sessionInfo.getName());
+            assertTrue(sessionInfo.isSnapshotSession());
+
+            assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState());
+            assertTrue(sessionInfo.isStreamedTrace());
+
+            String[] names = fService.getSessionNames(new NullProgressMonitor());
+            assertEquals(names[0], "mysession");
+
+
+            ISnapshotInfo snapshotInfo = sessionInfo.getSnapshotInfo();
+            assertNotNull(sessionInfo);
+            assertEquals("snapshot-2", snapshotInfo.getName());
+            assertEquals("net4://172.0.0.1:5342/", snapshotInfo.getSnapshotPath());
+            assertEquals(2, snapshotInfo.getId());
+            assertTrue(snapshotInfo.isStreamedSnapshot());
+
+            // we need to set the snapshotInfo to so that the session path is set correctly
+            sessionInfo.setSnapshotInfo(snapshotInfo);
+            assertEquals("net4://172.0.0.1:5342/", sessionInfo.getSessionPath());
+
+            fService.recordSnapshot("mysession", new NullProgressMonitor());
+
+            fService.destroySession("mysession", new NullProgressMonitor());
+
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+    }
+
+
+    @Test
+    public void testCreateSnapshotSessionErrors() {
+        try {
+            fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION_ERRORS);
+
+            String[] names = fService.getSessionNames(new NullProgressMonitor());
+            assertEquals(names[0], "mysession");
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+
+        try {
+            fService.getSnapshotInfo("blabla", new NullProgressMonitor());
+            fail("getSnapshoInfo() didn't fail");
+        } catch (ExecutionException e) {
+            // successful
+        }
+
+        try {
+            fService.recordSnapshot("blabla", new NullProgressMonitor());
+            fail("getSnapshoInfo() didn't fail");
+        } catch (ExecutionException e) {
+            // successful
+        }
+
+        try {
+            fService.recordSnapshot("mysession", new NullProgressMonitor());
+            fail("getSnapshoInfo() didn't fail");
+        } catch (ExecutionException e) {
+            // successful
+        }
+    }
+
     private static void enableVerbose() {
         // verbose
         ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false);
index 673021cd07badd8a65474e37560de0bd42d6a4c8..599e24a61cde1a340057c3299f3867c863c46e2d 100644 (file)
@@ -27,6 +27,7 @@ public class CreateSessionDialogStub implements ICreateSessionDialog {
     private String fNetworkUrl = null;
     private String fControlUrl = null;
     private String fDataUrl = null;
+    private boolean fIsSnapshot;
 
     @Override
     public String getSessionName() {
@@ -97,4 +98,12 @@ public class CreateSessionDialogStub implements ICreateSessionDialog {
         this.fDataUrl = fDataUrl;
     }
 
+    @Override
+    public boolean isSnapshot() {
+        return fIsSnapshot;
+    }
+
+    public void setSnapshot(boolean isSnapshot) {
+        fIsSnapshot = isSnapshot;
+    }
 }
diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateSessionTest2.cfg b/org.eclipse.linuxtools.lttng2.ui.tests/testfiles/CreateSessionTest2.cfg
new file mode 100644 (file)
index 0000000..808a51f
--- /dev/null
@@ -0,0 +1,158 @@
+####################################################################
+# Copyright (c) 2013 Ericsson
+#
+# All rights reserved. This program and the accompanying materials are
+# made available under the terms of the Eclipse Public License v1.0 which
+# accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors: 
+#    Bernd Hufmann - Initial API and implementation
+####################################################################
+####################################################################
+# Scenario: Initialize
+####################################################################
+<SCENARIO>
+Initialize
+<COMMAND_INPUT>
+lttng version 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+lttng version 2.3.0 - Dominus Vobiscum
+
+A very succulent line-up of beers brewed at Microbrasserie Charlevoix. Elaborated starting from special malts and fermented with a Belgian yeast. These beers are refermented in bottle and will make you discover the richness of wheat, amber and triple styles.
+
+Web site: http://lttng.org
+
+lttng is free software and under the GPL license and part LGPL
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Currently no available tracing session
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -k
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Kernel events
+-------------
+      sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+      sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+      sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+
+<COMMAND_INPUT>
+lttng list -u -f 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+    ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+    ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+    ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+    ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session> --snapshot" LTTng 2.3
+####################################################################
+<SCENARIO>
+ScenCreateSession
+<COMMAND_INPUT>
+lttng create mysession --snapshot 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Default snapshot output set to: /home/user/lttng-traces/mysession-20130913-141651
+Snapshot mode set. Every channel enabled for that session will be set in overwrite mode and mmap output.
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing session mysession: [inactive snapshot]
+    Trace path: 
+
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot list-output  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Snapshot output list for session mysession
+    [1] snapshot-1: /home/user/lttng-traces/mysession-20130913-141651
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng start mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing started for session mysession.
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot record  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+    Snapshot recorded successfully for session mysession
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng stop mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Tracing stopped for session mysession.
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+</SCENARIO>
index 58b65afdc7be538b3cac4ef3d65f6d83f7f96cd1..177571719812a1974596594fa08c34017bd533f4 100644 (file)
@@ -1137,5 +1137,176 @@ lttng -vvv  destroy mysession
 <COMMAND_OUTPUT>
 Session mysession destroyed.
 </COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session> --snapshot (LTTng 2.3)
+####################################################################
+<SCENARIO>
+CreateSessionSnapshot
+<COMMAND_INPUT>
+lttng create mysession --snapshot 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Default snapshot output set to: /home/user/lttng-traces/mysession-20130913-141651
+Snapshot mode set. Every channel enabled for that session will be set in overwrite mode and mmap output.
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot list-output  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Snapshot output list for session mysession
+    [1] snapshot-1: /home/user/lttng-traces/mysession-20130913-141651
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng list 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+  1) mysession () [inactive snapshot]
+
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot record  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+    Snapshot recorded successfully for session mysession
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+####################################################################
+# Scenario: Test "lttng create <session> --snapshot -U <URL> (LTTng 2.3)
+####################################################################
+<SCENARIO>
+CreateSessionStreamedSnapshot
+<COMMAND_INPUT>
+lttng create mysession --snapshot -U net://172.0.0.1
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession created.
+Default snapshot output set to: net://172.0.0.1
+Snapshot mode set. Every channel enabled for that session will be set in overwrite mode and mmap output.
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot list-output  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Snapshot output list for session mysession
+    [2] snapshot-2: net4://172.0.0.1:5342/
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng list 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+  1) mysession () [inactive snapshot]
+
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot record  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+    Snapshot recorded successfully for session mysession
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Session mysession destroyed.
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+
+
+
+####################################################################
+# Scenario: Test "lttng create <session> --snapshot (LTTng 2.3)
+####################################################################
+<SCENARIO>
+CreateSessionSnapshotErrors
+<COMMAND_INPUT>
+lttng snapshot list-output  -s blabla
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+Error: Session name not found
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+#next is not an error case but good to be tested
+<COMMAND_INPUT>
+lttng list 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+  1) mysession () [active snapshot]
+
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot record  -s blabla
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+    Error: Session name not found
+</COMMAND_OUTPUT>
+#------------------------------------------------------------------------------
+<COMMAND_INPUT>
+lttng snapshot record  -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+1
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+    Error: Session needs to be started once
+</COMMAND_OUTPUT>
 
 </SCENARIO>
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/snapshot.gif b/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/snapshot.gif
new file mode 100644 (file)
index 0000000..176830a
Binary files /dev/null and b/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/snapshot.gif differ
index 5769f0f07fa578fcd062ea54e5cf19c3d2bee5d3..8b85752b6d4633ceeb85bbd97ee208a3bd4cf1a0 100644 (file)
@@ -134,4 +134,7 @@ commands.control.import.description=Import Traces to LTTng Project
 commands.control.calibrate=Calibrate
 commands.control.calibrate.description=Quantify LTTng overhead
 
+commands.control.snapshot=Record Snapshot
+commands.control.snapshot.description=Record a snapshot
+
 preference.page.control.name=LTTng Tracer Control Preferences
\ No newline at end of file
index 6f4180f3d3e1e9ff7f062545ec5b7bbbdbbffaa0..3b03b07d04ad91fd39b659c5d489e78a4ba7e613 100644 (file)
             name="%commands.control.calibrate">
       </command>
 
+      <command
+            categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+            description="%commands.control.snapshot.description"
+            id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.snapshot"
+            name="%commands.control.snapshot">
+      </command>
+
    </extension>
    <extension
          point="org.eclipse.ui.menus">
                name="org.eclipse.linuxtools.internal.lttng2.ui.views.control.toolbar.separator2"
                visible="true">
          </separator>
+         <command
+               commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.snapshot"
+               icon="icons/elcl16/snapshot.gif"
+               label="%commands.control.snapshot"
+               style="push">
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.internal.lttng2.ui.views.control.toolbar.separator3"
+               visible="true">
+         </separator>
          <command
                commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.import"
                icon="icons/elcl16/import_trace.gif"
             </visibleWhen>
          </command>
 
+         <command
+               commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.snapshot"
+               icon="icons/elcl16/snapshot.gif"
+               label="%commands.control.snapshot"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="activeMenuSelection">
+                  <and>
+                     <iterate
+                           operator="or">
+                        <instanceof
+                              value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+                        </instanceof>
+                     </iterate>
+                     <count
+                           value="1">
+                     </count>
+                  </and>
+               </with>
+            </visibleWhen>
+         </command>
+
       </menuContribution>
       
    </extension>
          </activeWhen>
       </handler>
 
+      <handler
+            class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.SnaphshotHandler"
+            commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.snapshot">
+         <activeWhen>
+            <with
+                  variable="selection">
+               <iterate
+                     operator="or">
+                  <instanceof
+                        value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent">
+                  </instanceof>
+               </iterate>
+            </with>
+         </activeWhen>
+      </handler>
+
+
       <handler
             class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.AssignEventHandler"
             commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.assign.event">
index f6c1845f322be3a11a310c85e40045fcbe23a83b..c92a92da7d1f1236136a84bb1a3cd34a969a3c74 100644 (file)
@@ -111,6 +111,10 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog
      * The text widget for the session path.
      */
     private Text fSessionPathText = null;
+    /**
+     * The button widget to select a snapshot session
+     */
+    private Button fSnapshotButton = null;
     /**
      * The Group for stream configuration.
      */
@@ -183,6 +187,10 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog
      * The  session path string.
      */
     private String fSessionPath = null;
+    /**
+     * The  session path string.
+     */
+    private boolean fIsSnapshot = false;
     /**
      * Flag whether default location (path) shall be used or not
      */
@@ -248,6 +256,7 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog
        fStreamingComposite = null;
        fSessionName = null;
        fSessionPath = null;
+       fIsSnapshot = false;
        fIsDefaultPath = true;
        fIsStreamedTrace = false;
        fNetworkUrl = null;
@@ -271,7 +280,10 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog
     public String getDataUrl() {
         return fDataUrl;
     }
-
+    @Override
+    public boolean isSnapshot() {
+        return fIsSnapshot;
+    }
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -318,6 +330,15 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog
         fSessionPathText = new Text(sessionGroup, SWT.NONE);
         fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip);
 
+        if (fParent.isSnapshotSupported()) {
+            fSnapshotButton = new Button(sessionGroup, SWT.CHECK);
+            fSnapshotButton.setText(Messages.TraceControl_CreateSessionSnapshotLabel);
+            fSnapshotButton.setToolTipText(Messages.TraceControl_CreateSessionSnapshotTooltip);
+            GridData data = new GridData(GridData.FILL_HORIZONTAL);
+            data.horizontalSpan = 4;
+            fSnapshotButton.setData(data);
+        }
+
         // layout widgets
         GridData data = new GridData(GridData.FILL_HORIZONTAL);
         data.horizontalSpan = 3;
@@ -636,6 +657,10 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog
             fIsDefaultPath = false;
         }
 
+        if(fParent.isSnapshotSupported()) {
+            fIsSnapshot = fSnapshotButton.getSelection();
+        }
+
         fNetworkUrl = null;
         fControlUrl = null;
         fDataUrl = null;
index 141325fc9911ab95680ce7b2638588ddf3359572..d73de0abe4eeca274cb805ed0efa5e1ae5d3fde6 100644 (file)
@@ -77,6 +77,11 @@ public interface ICreateSessionDialog {
      */
     String getDataUrl();
 
+    /**
+     * @return <code>true</code> if is a snapshot session else <code>false</code>
+     */
+    boolean isSnapshot();
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
index 941dbf29f42f738df879807eaf0181d2aa5f184f..03eae31441cedd79f1a656fbacbb27acd75c76b6 100644 (file)
@@ -240,7 +240,9 @@ public class ImportDialog extends Dialog implements IImportDialog {
                     traceName.append(trace.getName());
                     traceName.insert(0, '-');
 
-                    while (!parent.getAbsolutePath().equals(fSession.getSessionPath())) {
+                    String path = fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : fSession.getSessionPath();
+
+                    while (!parent.getAbsolutePath().equals(path)) {
                         traceName.insert(0, parent.getName());
                         traceName.insert(0, '-');
                         parent = parent.getParentRemoteFile();
@@ -342,7 +344,10 @@ public class ImportDialog extends Dialog implements IImportDialog {
 
         IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem();
 
-        final IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSession.getSessionPath(), new NullProgressMonitor());
+        final String path = fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : fSession.getSessionPath();
+        final IRemoteFile remoteFolder = fsss.getRemoteFileObject(path, new NullProgressMonitor());
+        // make sure that remote directory is read and not cached
+        remoteFolder.markStale(true, true);
 
         fFolderViewer = new CheckboxTreeViewer(contextGroup, SWT.BORDER);
         GridData data = new GridData(GridData.FILL_BOTH);
@@ -375,10 +380,14 @@ public class ImportDialog extends Dialog implements IImportDialog {
         });
         fFolderViewer.setInput(remoteFolder);
 
-        // Select all traces by default
         Object[] children = remoteFolder.getContents(RemoteChildrenContentsType.getInstance());
-        for (int i = 0; i < children.length; i++) {
-            fFolderViewer.setSubtreeChecked(children[i], true);
+        // children can be null if there the path doesn't exist. This happens when a trace
+        // session hadn't been started and no output was created.
+        if (children != null) {
+            // Select all traces by default
+            for (int i = 0; i < children.length; i++) {
+                fFolderViewer.setSubtreeChecked(children[i], true);
+            }
         }
 
         Group projectGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
index ac0521d5336ec358438751723eea846d5ddb71c4..327f901c57d317e887636b7c1970332cacbdfec4 100644 (file)
@@ -72,10 +72,10 @@ public class CreateSessionHandler extends BaseControlViewHandler {
                     try {
                         if (dialog.isStreamedTrace()) {
                             sessionGroup.createSession(dialog.getSessionName(), dialog.getNetworkUrl(), dialog.getControlUrl(),
-                                    dialog.getDataUrl(), monitor);
+                                    dialog.getDataUrl(), dialog.isSnapshot(), monitor);
                         } else {
                             String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
-                            sessionGroup.createSession(dialog.getSessionName(), sessionPath, monitor);
+                            sessionGroup.createSession(dialog.getSessionName(), sessionPath, dialog.isSnapshot(), monitor);
                         }
                     } catch (ExecutionException e) {
                         return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e);
index db6b9a6d0ab05b0159e02bcbb003ca75fa8363d4..32b7a8b7bd661974513a4cfc15fb7e5210a0b726 100644 (file)
@@ -189,7 +189,7 @@ public class ImportHandler extends BaseControlViewHandler {
                 if (element instanceof TraceSessionComponent) {
                     // Add only TraceSessionComponents that are inactive and not destroyed
                     TraceSessionComponent tmpSession = (TraceSessionComponent) element;
-                    if ((tmpSession.getSessionState() == TraceSessionState.INACTIVE) && (!tmpSession.isDestroyed())) {
+                    if (((tmpSession.isSnapshotSession()) || (tmpSession.getSessionState() == TraceSessionState.INACTIVE)) && (!tmpSession.isDestroyed())) {
                         session = tmpSession;
                     }
                 }
diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/SnaphshotHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/SnaphshotHandler.java
new file mode 100644 (file)
index 0000000..40046a7
--- /dev/null
@@ -0,0 +1,130 @@
+/**********************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <p>
+ * Command handler implementation to record a snapshot.
+ * </p>
+ *
+ * @author Bernd Hufmann
+ */
+public class SnaphshotHandler extends BaseControlViewHandler {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+    /**
+     * The list of session components the command is to be executed on.
+     */
+    protected List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
+
+    // ------------------------------------------------------------------------
+    // Operations
+    // ------------------------------------------------------------------------
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        fLock.lock();
+        try {
+            // Make a copy for thread safety
+            final List<TraceSessionComponent> sessions = new ArrayList<TraceSessionComponent>();
+            sessions.addAll(fSessions);
+
+            Job job = new Job(Messages.TraceControl_RecordSnapshotJob) {
+                @Override
+                protected IStatus run(IProgressMonitor monitor) {
+                    MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
+                    for (Iterator<TraceSessionComponent> iterator = sessions.iterator(); iterator.hasNext();) {
+                        try {
+                            // record snapshot for all selected sessions sequentially
+                            TraceSessionComponent session = iterator.next();
+                            session.recordSnapshot(monitor);
+                            if (monitor.isCanceled()) {
+                                status.add(Status.CANCEL_STATUS);
+                                break;
+                            }
+                        } catch (ExecutionException e) {
+                            status.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_RecordSnapshotFailure, e));
+                        }
+                    }
+                    return status;
+                }
+            };
+            job.setUser(true);
+            job.schedule();
+        } finally {
+            fLock.unlock();
+        }
+        return null;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        // Get workbench page for the Control View
+        IWorkbenchPage page = getWorkbenchPage();
+        if (page == null) {
+            return false;
+        }
+
+        List<TraceSessionComponent> sessions = new ArrayList<TraceSessionComponent>(0);
+
+        // Check if one session is selected
+        ISelection selection = page.getSelection(ControlView.ID);
+        if (selection instanceof StructuredSelection) {
+            StructuredSelection structered = ((StructuredSelection) selection);
+            for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+                Object element = iterator.next();
+                if (element instanceof TraceSessionComponent) {
+                    // Add only if corresponding TraceSessionComponent is an active snapshot session and not destroyed
+                    TraceSessionComponent session = (TraceSessionComponent) element;
+                    if(session.isSnapshotSession() &&
+                            session.getSessionState() == TraceSessionState.ACTIVE &&
+                            !session.isDestroyed()) {
+                        sessions.add(session);
+                    }
+                }
+            }
+        }
+        boolean isEnabled = !sessions.isEmpty();
+        fLock.lock();
+        try {
+            fSessions = null;
+            if (isEnabled) {
+                fSessions = sessions;
+            }
+        } finally {
+            fLock.unlock();
+        }
+        return isEnabled;
+    }
+}
\ No newline at end of file
index 58de39318372a53bf2263f3a3708bd2e94ea64d1..1afd9894854d2fa19f93759c7eb86ca4be39fa11 100644 (file)
@@ -86,6 +86,9 @@ final public class Messages extends NLS {
     public static String TraceControl_AddCalibrateJob;
     public static String TraceControl_AddCalibrateFailure;
 
+    public static String TraceControl_RecordSnapshotJob;
+    public static String TraceControl_RecordSnapshotFailure;
+
     // Dialogs
     public static String TraceControl_NewDialogTitle;
     public static String TraceControl_NewNodeExistingConnectionGroupName;
@@ -104,6 +107,8 @@ final public class Messages extends NLS {
     public static String TraceControl_CreateSessionNameTooltip;
     public static String TraceControl_CreateSessionPathLabel;
     public static String TraceControl_CreateSessionPathTooltip;
+    public static String TraceControl_CreateSessionSnapshotLabel;
+    public static String TraceControl_CreateSessionSnapshotTooltip;
 
     public static String TraceControl_CreateSessionConfigureStreamingButtonText;
     public static String TraceControl_CreateSessionConfigureStreamingButtonTooltip;
@@ -257,6 +262,9 @@ final public class Messages extends NLS {
     public static String TraceControl_HostNamePropertyName;
     public static String TraceControl_HostAddressPropertyName;
     public static String TraceControl_SessionPathPropertyName;
+    public static String TraceControl_SnapshotPathPropertyName;
+    public static String TraceControl_SnapshotNamePropertyName;
+    public static String TraceControl_SnapshotIdPropertyName;
     public static String TraceControl_ProviderNamePropertyName;
     public static String TraceControl_ProcessIdPropertyName;
     public static String TraceControl_ProbeAddressPropertyName;
index 89de0b4eed06ee0599b6a24547b92df54feb533d..b6db6a98fb37dfcd0f668db48070a6eade2d05db 100644 (file)
@@ -68,6 +68,9 @@ TraceControl_AddContextFailure=Command to add contexts failed
 TraceControl_AddCalibrateJob=Calibrating...
 TraceControl_AddCalibrateFailure=Command to calibrate failed
 
+TraceControl_RecordSnapshotJob=Record snapshot...
+TraceControl_RecordSnapshotFailure=Command to snapshot record failed
+
 # Dialogs
 TraceControl_NewDialogTitle=New Connection
 TraceControl_NewNodeExistingConnectionGroupName=Existing Connections
@@ -86,6 +89,9 @@ TraceControl_CreateSessionNameLabel=Session Name
 TraceControl_CreateSessionNameTooltip=The name of the session to be created.
 TraceControl_CreateSessionPathLabel=Session Path
 TraceControl_CreateSessionPathTooltip=The session path (keep empty for default location)
+TraceControl_CreateSessionSnapshotLabel=Snapshot Mode
+TraceControl_CreateSessionSnapshotTooltip=Configure session in snapshot mode
+
 
 TraceControl_CreateSessionConfigureStreamingButtonText=Advanced
 TraceControl_CreateSessionConfigureStreamingButtonTooltip=Configure advanced options
@@ -244,6 +250,9 @@ TraceControl_OutputTypePropertyName=Output Type
 TraceControl_HostNamePropertyName=Connection Name
 TraceControl_HostAddressPropertyName=Host Name
 TraceControl_SessionPathPropertyName=Session Path
+TraceControl_SnapshotPathPropertyName=Snapshot Path
+TraceControl_SnapshotNamePropertyName=Snapshot Name
+TraceControl_SnapshotIdPropertyName=Snapshot ID
 TraceControl_ProviderNamePropertyName=Provider Name
 TraceControl_ProcessIdPropertyName=Process ID
 TraceControl_ProbeAddressPropertyName=Address
index 634bee6f25f96b09a580640ae4e340cc65f45f5d..964456b8c2a6cc2519b020e7e45f94a8281eb551 100644 (file)
@@ -256,6 +256,14 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu
     public boolean isPeriodicalMetadataFlushSupported() {
         return getControlService().isVersionSupported("2.2.0"); //$NON-NLS-1$
     }
+    /**
+     * Returns if node supports snapshots or not
+     * @return <code>true</code> if it supports snapshots else <code>false</code>
+     *
+     */
+    public boolean isSnapshotSupported() {
+        return getControlService().isVersionSupported("2.3.0"); //$NON-NLS-1$
+    }
 
     // ------------------------------------------------------------------------
     // Operations
index 86de1fa590a9e2c00e565fe5211a2036ee22562b..471c60cc5af287c10c3e62075ef863d34a741724 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
@@ -178,6 +179,22 @@ public class TraceSessionComponent extends TraceControlComponent {
         fSessionInfo.setStreamedTrace(isStreamedTrace);
     }
 
+    /**
+     * Returns whether the session is snapshot session or not
+     * @return <code>true</code> if it is snapshot session else <code>false</code>
+     */
+    public boolean isSnapshotSession() {
+        return fSessionInfo.isSnapshotSession();
+    }
+
+    /**
+     * Gets the snapshot information if available whether the session is a snapshot session or not
+     * @return the snapshot information or null if it is not a snapshot session
+     */
+    public ISnapshotInfo getSnapshotInfo() {
+        return fSessionInfo.getSnapshotInfo();
+    }
+
     @Override
     public Object getAdapter(Class adapter) {
         if (adapter == IPropertySource.class) {
@@ -218,6 +235,15 @@ public class TraceSessionComponent extends TraceControlComponent {
         return ((TargetNodeComponent)getParent().getParent()).isEventFilteringSupported();
     }
 
+    /**
+     * Returns if node supports snapshots or not
+     * @return <code>true</code> if it supports snapshots else <code>false</code>
+     *
+     */
+    public boolean isSnapshotSupported() {
+        return ((TargetNodeComponent)getParent().getParent()).isSnapshotSupported();
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -234,6 +260,7 @@ public class TraceSessionComponent extends TraceControlComponent {
             throws ExecutionException {
         removeAllChildren();
         fSessionInfo = getControlService().getSession(getName(), monitor);
+
         IDomainInfo[] domains = fSessionInfo.getDomains();
         for (int i = 0; i < domains.length; i++) {
             TraceDomainComponent domainComponent = new TraceDomainComponent(
@@ -381,4 +408,16 @@ public class TraceSessionComponent extends TraceControlComponent {
             throws ExecutionException {
         return getControlService().getContextList(monitor);
     }
+
+    /**
+     * Records a snapshot.
+     *
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public void recordSnapshot(IProgressMonitor monitor) throws ExecutionException {
+        getControlService().recordSnapshot(getName(), monitor);
+    }
 }
index e9d7f6a5b28c320a2f1724bb303df5e38faf19c5..66c151edbf2af59ff5cdb61d246a8da591a949a8 100644 (file)
@@ -69,6 +69,13 @@ public class TraceSessionGroup extends TraceControlComponent {
     public boolean isNetworkStreamingSupported() {
         return getTargetNode().isNetworkStreamingSupported();
     }
+    /**
+     * Returns if node supports snapshots or not
+     * @return <code>true</code> if it supports snapshots else <code>false</code>
+     *
+     */    public boolean isSnapshotSupported() {
+        return getTargetNode().isSnapshotSupported();
+    }
 
     // ------------------------------------------------------------------------
     // Operations
@@ -109,13 +116,15 @@ public class TraceSessionGroup extends TraceControlComponent {
      *            - a session name to create
      * @param sessionPath
      *            - a path for storing the traces (use null for default)
+     * @param isSnapshot
+     *            - true for snapshot session else false
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
-    public void createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
-        ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
+    public void createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException {
+        ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, isSnapshot, monitor);
 
         if (sessionInfo != null) {
             TraceSessionComponent session = new TraceSessionComponent(
@@ -137,13 +146,15 @@ public class TraceSessionGroup extends TraceControlComponent {
      *            - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
      * @param dataUrl
      *            - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
+     * @param isSnapshot
+     *            - true for snapshot session else false
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
-    public void createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, IProgressMonitor monitor) throws ExecutionException {
-        ISessionInfo sessionInfo = getControlService().createSession(sessionName, networkUrl, controlUrl, dataUrl, monitor);
+    public void createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException {
+        ISessionInfo sessionInfo = getControlService().createSession(sessionName, networkUrl, controlUrl, dataUrl, isSnapshot, monitor);
 
         if (sessionInfo != null) {
             TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
index 96c7e8f26db7825f68c23fb87175fab8c9e98735..283e6d4a11eb2b8f0810c1b8e8e3ac1543aba7ac 100644 (file)
@@ -11,6 +11,9 @@
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
 import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
@@ -40,6 +43,19 @@ public class TraceSessionPropertySource extends BasePropertySource {
      * The trace session state ID.
      */
     public static final String TRACE_SESSION_STATE_PROPERTY_ID = "trace.session.state"; //$NON-NLS-1$
+    /**
+     * The trace snapshot path property ID.
+     */
+    public static final String TRACE_SNAPSHOT_PATH_PROPERTY_ID = "trace.snapshot.path"; //$NON-NLS-1$
+    /**
+     * The snapshot name property.
+     */
+    public static final String TRACE_SNAPSHOT_NAME_PROPERTY_ID = "trace.snapshot.name"; //$NON-NLS-1$
+    /**
+     * The snapshot ID property.
+     */
+    public static final String TRACE_SNAPSHOT_ID_PROPERTY_ID = "trace.snapshot.id"; //$NON-NLS-1$
+
     /**
      *  The trace session name property name.
      */
@@ -52,6 +68,19 @@ public class TraceSessionPropertySource extends BasePropertySource {
      * The trace session state property name.
      */
     public static final String TRACE_SESSION_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
+    /**
+     *  The snapshot path property name.
+     */
+    public static final String TRACE_SNAPSHOT_PATH_PROPERTY_NAME = Messages.TraceControl_SnapshotPathPropertyName;
+    /**
+     * The trace snapshot name property name.
+     */
+    public static final String TRACE_SNAPSHOT_NAME_PROPERTY_NAME = Messages.TraceControl_SnapshotNamePropertyName;
+    /**
+     * The trace snapshot ID property name.
+     */
+    public static final String TRACE_SNAPSHOT_ID_PROPERTY_NAME = Messages.TraceControl_SnapshotIdPropertyName;
+
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -80,10 +109,17 @@ public class TraceSessionPropertySource extends BasePropertySource {
 
     @Override
     public IPropertyDescriptor[] getPropertyDescriptors() {
-        return new IPropertyDescriptor[] {
-                new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME),
-                new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME),
-                new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME)};
+        List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
+        list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME));
+        list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME));
+        if (fSession.isSnapshotSession()) {
+            list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SNAPSHOT_NAME_PROPERTY_ID, TRACE_SNAPSHOT_NAME_PROPERTY_NAME));
+            list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SNAPSHOT_PATH_PROPERTY_ID, TRACE_SNAPSHOT_PATH_PROPERTY_NAME));
+            list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SNAPSHOT_ID_PROPERTY_ID, TRACE_SNAPSHOT_ID_PROPERTY_NAME));
+        } else {
+            list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME));
+        }
+        return(list.toArray(new IPropertyDescriptor[list.size()]));
     }
 
     @Override
@@ -97,6 +133,15 @@ public class TraceSessionPropertySource extends BasePropertySource {
         if (TRACE_SESSION_STATE_PROPERTY_ID.equals(id)) {
             return fSession.getSessionState().name();
         }
+        if (TRACE_SNAPSHOT_PATH_PROPERTY_ID.equals(id)) {
+            return (fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : ""); //$NON-NLS-1$
+        }
+        if (TRACE_SNAPSHOT_NAME_PROPERTY_ID.equals(id)) {
+            return (fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getName() : ""); //$NON-NLS-1$
+        }
+        if (TRACE_SNAPSHOT_ID_PROPERTY_ID.equals(id)) {
+            return (fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getId() : ""); //$NON-NLS-1$
+        }
         return null;
     }
 }
index 96c41965601ad39a6d1327a4a2a970a292bd8c0b..b24bbf91dbcb40097f9c8b2ac621221f194bbed8 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
@@ -72,6 +73,19 @@ public interface ILttngControlService {
     ISessionInfo getSession(String sessionName, IProgressMonitor monitor)
             throws ExecutionException;
 
+    /**
+     * Retrieves the snapshot output information from the node
+     * @param sessionName
+     *            - the session name
+     * @param monitor
+     *            - a progress monitor
+     * @return snapshot output information
+     * @throws ExecutionException
+     *          if command fails
+     */
+    ISnapshotInfo getSnapshotInfo(String sessionName, IProgressMonitor monitor)
+            throws ExecutionException;
+
     /**
      * Retrieves the kernel provider information (i.e. the kernel events)
      *
@@ -112,13 +126,15 @@ public interface ILttngControlService {
      *            - a session name to create
      * @param sessionPath
      *            - a path for storing the traces (use null for default)
+     * @param isSnapshot
+     *            - true for snapshot session else false
      * @param monitor
      *            - a progress monitor
      * @return the session information
      * @throws ExecutionException
      *             If the command fails
      */
-    ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException;
+    ISessionInfo createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException;
 
     /**
      * Creates a session with given session name and location.
@@ -132,13 +148,15 @@ public interface ILttngControlService {
      *            - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
      * @param dataUrl
      *            - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
+     * @param isSnapshot
+     *            - true for snapshot session else false
      * @param monitor
      *            - a progress monitor
      * @return the session information
      * @throws ExecutionException
      *             If the command fails
      */
-    ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, IProgressMonitor monitor) throws ExecutionException;
+    ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException;
 
     /**
      * Destroys a session with given session name.
@@ -375,4 +393,17 @@ public interface ILttngControlService {
      */
     void calibrate(boolean isKernel, IProgressMonitor monitor)
             throws ExecutionException;
+
+    /**
+     * Records a snapshot.
+     *
+     * @param sessionName
+     *            - a session name
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    void recordSnapshot(String sessionName, IProgressMonitor monitor)
+            throws ExecutionException;
 }
index e06bae8093caf13cb650834073deb48882c3f16c..9d82dc9838a3c97b449638eef614e578b9763ac3 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
@@ -40,6 +41,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SnapshotInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.logging.ControlCommandLogger;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
@@ -174,18 +176,30 @@ public class LTTngControlService implements ILttngControlService {
                 continue;
             }
 
-            matcher = LTTngControlServiceConstants.TRACE_NETWORK_PATH_PATTERN.matcher(line);
+            matcher = LTTngControlServiceConstants.TRACE_SNAPSHOT_SESSION_PATTERN.matcher(line);
             if (matcher.matches()) {
-                sessionInfo.setStreamedTrace(true);
-            }
-
-            matcher = LTTngControlServiceConstants.TRACE_SESSION_PATH_PATTERN.matcher(line);
-            if (matcher.matches()) {
-                sessionInfo.setSessionPath(matcher.group(1).trim());
+                sessionInfo.setSessionState(matcher.group(2));
+                // real name will be set later
+                ISnapshotInfo snapshotInfo = new SnapshotInfo(""); //$NON-NLS-1$
+                sessionInfo.setSnapshotInfo(snapshotInfo);
                 index++;
                 continue;
             }
 
+            if (!sessionInfo.isSnapshotSession()) {
+                matcher = LTTngControlServiceConstants.TRACE_NETWORK_PATH_PATTERN.matcher(line);
+                if (matcher.matches()) {
+                    sessionInfo.setStreamedTrace(true);
+                }
+
+                matcher = LTTngControlServiceConstants.TRACE_SESSION_PATH_PATTERN.matcher(line);
+                if (matcher.matches()) {
+                    sessionInfo.setSessionPath(matcher.group(1).trim());
+                    index++;
+                    continue;
+                }
+            }
+
             matcher = LTTngControlServiceConstants.DOMAIN_KERNEL_PATTERN.matcher(line);
             if (matcher.matches()) {
                 // Create Domain
@@ -230,9 +244,50 @@ public class LTTngControlService implements ILttngControlService {
             }
             index++;
         }
+
+        if (sessionInfo.isSnapshotSession()) {
+            ISnapshotInfo snapshot = getSnapshotInfo(sessionName, monitor);
+            sessionInfo.setSnapshotInfo(snapshot);
+        }
+
         return sessionInfo;
     }
 
+    @Override
+    public ISnapshotInfo getSnapshotInfo(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+        StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_SNAPSHOT_OUTPUT, LTTngControlServiceConstants.OPTION_SESSION, sessionName);
+        ICommandResult result = executeCommand(command.toString(), monitor);
+
+        int index = 0;
+
+        // Output:
+        // [1] snapshot-1: /home/user/lttng-traces/my-20130909-114431
+        // or
+        // [3] snapshot-3: net4://172.0.0.1/
+        ISnapshotInfo snapshotInfo = new SnapshotInfo(""); //$NON-NLS-1$
+
+        while (index < result.getOutput().length) {
+            String line = result.getOutput()[index];
+            Matcher matcher = LTTngControlServiceConstants.LIST_SNAPSHOT_OUTPUT_PATTERN.matcher(line);
+            if (matcher.matches()) {
+                snapshotInfo.setId(Integer.valueOf(matcher.group(1)));
+                snapshotInfo.setName(matcher.group(2));
+                snapshotInfo.setSnapshotPath(matcher.group(3));
+
+                Matcher matcher2 = LTTngControlServiceConstants.SNAPSHOT_NETWORK_PATH_PATTERN.matcher(snapshotInfo.getSnapshotPath());
+                if (matcher2.matches()) {
+                    snapshotInfo.setStreamedSnapshot(true);
+                }
+
+                index++;
+                break;
+            }
+            index++;
+        }
+
+        return snapshotInfo;
+    }
+
     @Override
     public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_KERNEL);
@@ -357,7 +412,7 @@ public class LTTngControlService implements ILttngControlService {
     }
 
     @Override
-    public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+    public ISessionInfo createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException {
 
         String newName = formatParameter(sessionName);
         String newPath = formatParameter(sessionPath);
@@ -369,6 +424,10 @@ public class LTTngControlService implements ILttngControlService {
             command.append(newPath);
         }
 
+        if (isSnapshot) {
+            command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT);
+        }
+
         ICommandResult result = executeCommand(command.toString(), monitor);
 
         //Session myssession2 created.
@@ -402,24 +461,35 @@ public class LTTngControlService implements ILttngControlService {
         SessionInfo sessionInfo = new SessionInfo(name);
 
         // Verify session path
-        if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) {
+        if (!isSnapshot &&
+                ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath))))) {
             // Unexpected path
             throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
                     Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
         }
 
-        sessionInfo.setSessionPath(path);
+        if (isSnapshot) {
+            // Make it a snapshot session - content of snapshot info need to
+            // set afterwards using getSession() or getSnapshotInfo()
+            sessionInfo.setSnapshotInfo(new SnapshotInfo("")); //$NON-NLS-1$
+        } else {
+            sessionInfo.setSessionPath(path);
+        }
 
         return sessionInfo;
 
     }
 
     @Override
-    public ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, IProgressMonitor monitor) throws ExecutionException {
+    public ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException {
 
         String newName = formatParameter(sessionName);
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION, newName);
 
+        if (isSnapshot) {
+            command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT);
+        }
+
         if (networkUrl != null) {
             command.append(LTTngControlServiceConstants.OPTION_NETWORK_URL);
             command.append(networkUrl);
@@ -467,20 +537,24 @@ public class LTTngControlService implements ILttngControlService {
 
         // Verify session path
         if (networkUrl != null) {
-            if (path == null) {
+            if (!isSnapshot && (path == null)) {
                 // Unexpected path
                 throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
                         Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
             }
 
-            sessionInfo.setSessionPath(path);
-
-            // Check file protocol
-            Matcher matcher = LTTngControlServiceConstants.TRACE_FILE_PROTOCOL_PATTERN.matcher(path);
-            if (matcher.matches()) {
+            if (isSnapshot) {
                 sessionInfo.setStreamedTrace(false);
+            } else {
+                sessionInfo.setSessionPath(path);
+                // Check file protocol
+                Matcher matcher = LTTngControlServiceConstants.TRACE_FILE_PROTOCOL_PATTERN.matcher(path);
+                if (matcher.matches()) {
+                    sessionInfo.setStreamedTrace(false);
+                }
             }
         }
+
         // When using controlUrl and dataUrl the full session path is not known yet
         // and will be set later on when listing the session
 
@@ -912,6 +986,18 @@ public class LTTngControlService implements ILttngControlService {
         executeCommand(command.toString(), monitor);
     }
 
+    @Override
+    public void recordSnapshot(String sessionName, IProgressMonitor monitor)
+            throws ExecutionException {
+        StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_RECORD_SNAPSHOT);
+
+        String newSessionName = formatParameter(sessionName);
+        command.append(LTTngControlServiceConstants.OPTION_SESSION);
+        command.append(newSessionName);
+
+        executeCommand(command.toString(), monitor);
+    }
+
     // ------------------------------------------------------------------------
     // Helper methods
     // ------------------------------------------------------------------------
index 8b312bc2b45cc7ba8c5005975c228576c799d43e..7e844f1fb5beb7a65dadbd353997f3e8f7d7ced4 100644 (file)
@@ -103,6 +103,14 @@ public interface LTTngControlServiceConstants {
      * Command to execute calibrate command to quantify LTTng overhead
      */
     static final String COMMAND_CALIBRATE = " calibrate "; //$NON-NLS-1$
+    /**
+     * Command to execute calibrate command to quantify LTTng overhead
+     */
+    static final String COMMAND_LIST_SNAPSHOT_OUTPUT = " snapshot list-output "; //$NON-NLS-1$
+    /**
+     * Command to execute calibrate command to quantify LTTng overhead
+     */
+    static final String COMMAND_RECORD_SNAPSHOT = " snapshot record "; //$NON-NLS-1$
 
     // ------------------------------------------------------------------------
     // Command line options constants
@@ -127,6 +135,10 @@ public interface LTTngControlServiceConstants {
      * Command line option for output path.
      */
     static final String OPTION_OUTPUT_PATH = " -o "; //$NON-NLS-1$
+    /**
+     * Command line option for output path.
+     */
+    static final String OPTION_SNAPSHOT = " --snapshot "; //$NON-NLS-1$
     /**
      * Command line option for kernel tracer.
      */
@@ -254,11 +266,15 @@ public interface LTTngControlServiceConstants {
     /**
      * Pattern to match for session information (lttng list)
      */
-    static final Pattern SESSION_PATTERN = Pattern.compile("\\s+(\\d+)\\)\\s+(.*)\\s+\\((.*)\\)\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
+    static final Pattern SESSION_PATTERN = Pattern.compile("\\s+(\\d+)\\)\\s+(.*)\\s+\\((.*)\\)\\s+\\[(active|inactive).*\\].*"); //$NON-NLS-1$
     /**
      * Pattern to match for session information (lttng list <session>)
      */
     static final Pattern TRACE_SESSION_PATTERN = Pattern.compile("\\s*Tracing\\s+session\\s+(.*)\\:\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
+    /**
+     * Pattern to match for snapshot session information (lttng list <session>)
+     */
+    static final Pattern TRACE_SNAPSHOT_SESSION_PATTERN = Pattern.compile("\\s*Tracing\\s+session\\s+(.*)\\:\\s+\\[(active|inactive)\\s*snapshot\\].*"); //$NON-NLS-1$
     /**
      * Pattern to match for session path information (lttng list <session>)
      */
@@ -267,7 +283,7 @@ public interface LTTngControlServiceConstants {
      * Pattern to match session path for network tracing (lttng list <session>)
      * Note: file for protocol is not considered as network trace since local consumer will be used.
      */
-    static final Pattern TRACE_NETWORK_PATH_PATTERN = Pattern.compile("\\s*Trace\\s+path\\:\\s+(net|net6|tcp|tcp6)\\:\\/\\/(.*)(\\:(\\d*)\\/(.*)\\[data\\:\\s+(\\d*)\\]){0,1}"); //$NON-NLS-1$
+    static final Pattern TRACE_NETWORK_PATH_PATTERN = Pattern.compile("\\s*Trace\\s+path\\:\\s+(net|net4|net6|tcp|tcp6)\\:\\/\\/(.*)(\\:(\\d*)\\/(.*)\\[data\\:\\s+(\\d*)\\]){0,1}"); //$NON-NLS-1$
     /**
      * Sub-pattern to pattern TRACE_NETWORK_PATH_PATTERN to match file protocol
      */
@@ -392,4 +408,14 @@ public interface LTTngControlServiceConstants {
      * Pattern to match error line if no ust tracer is available or installed.
      */
     static final Pattern LIST_UST_NO_UST_PROVIDER_PATTERN = Pattern.compile(".*Unable\\s*to\\s*list\\s*UST\\s*event.*"); //$NON-NLS-1$;
+    /**
+     * Pattern to match for list snapshot information (lttng snapshot list-output)
+     */
+    static final Pattern LIST_SNAPSHOT_OUTPUT_PATTERN = Pattern.compile("\\s+\\[(\\d+)\\]\\s+(.*)\\:\\s+(.*)"); //$NON-NLS-1$
+    /**
+     * Pattern to match snapshot path for network tracing (lttng list <session>)
+     * Note: file for protocol is not considered as network trace since local consumer will be used.
+     */
+    static final Pattern SNAPSHOT_NETWORK_PATH_PATTERN = Pattern.compile("(net|net4|net6|tcp|tcp6)\\:\\/\\/(.*)(\\:(\\d*)\\/(.*)\\[data\\:\\s+(\\d*)\\]){0,1}"); //$NON-NLS-1$
+
 }
This page took 0.064665 seconds and 5 git commands to generate.