diff options
author | Marc-Andre Laperle | 2014-03-19 07:11:17 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2014-07-24 15:30:51 +0000 |
commit | abf232b1e18889c0b8b0b87a3ba323a13cf1143a (patch) | |
tree | a611e5a7cbeeaeb386b73df721ba078dc745a28f | |
parent | 8c6ba5368d6d1d32ac65c61f6680f7bddab2ced0 (diff) | |
download | org.eclipse.linuxtools-abf232b1e18889c0b8b0b87a3ba323a13cf1143a.tar.gz org.eclipse.linuxtools-abf232b1e18889c0b8b0b87a3ba323a13cf1143a.tar.xz org.eclipse.linuxtools-abf232b1e18889c0b8b0b87a3ba323a13cf1143a.zip |
lttng: Add support for creating a live session in Control view
Change-Id: Ifb31933f8a93437cf976cef71b53cfa5d1f4ec8f
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/23593
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
17 files changed, 589 insertions, 113 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki b/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki index 30a5c98f09..ec16a7147c 100644 --- a/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki +++ b/lttng/org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki @@ -997,10 +997,21 @@ LTTng Tools version v2.3.0 introduces the possibility to create snapshot tracing [[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. +Fill in all necessary information, select the radio button 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. +=== Creating a Live Tracing Session ==== +LTTng Tools version v2.4.0 introduces the possibility to create live tracing sessions. The live mode allows you to stream the trace and view it while it's being recorded. To create such a live session, open the trace session dialog as described in chapter [[#Creating a Tracing Session | Creating a Tracing Session]]. + +[[Image:images/LTTng2CreateSessionDialog_Live.png]] + +In the advanced options, it is possible to set the '''Live Delay'''. The '''Live Delay''' is the delay in micro seconds before the data is flushed and streamed. + +[[Image:images/LTTng2CreateSessionDialog_Live_Advanced.png]] + +Fill in all necessary information, select the radio button for '''Live Mode''' and press '''Ok'''. + === 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. diff --git a/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Live.png b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Live.png Binary files differnew file mode 100644 index 0000000000..9705f2ccf4 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Live.png diff --git a/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Live_Advanced.png b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Live_Advanced.png Binary files differnew file mode 100644 index 0000000000..1433649ddf --- /dev/null +++ b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Live_Advanced.png diff --git a/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png Binary files differindex 3d5ee221c3..53add22481 100644 --- a/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png +++ b/lttng/org.eclipse.linuxtools.lttng.help/doc/images/LTTng2CreateSessionDialog_Snapshot.png diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/ISessionInfo.java b/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/ISessionInfo.java index 74a8636820..2241e29713 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/ISessionInfo.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/ISessionInfo.java @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation * Bernd Hufmann - Updated for support of LTTng Tools 2.1 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.control.core.model; @@ -107,6 +108,38 @@ public interface ISessionInfo extends ITraceInfo { void setSnapshotInfo(ISnapshotInfo setSnapshotInfo); /** + * Get whether or not the session should be in Live mode + * + * @return <code>true</code> if is a live session else <code>false</code> + */ + public boolean isLive(); + + /** + * Set whether or not the session should be in Live mode + * + * @param isLive + * true for Live mode, false otherwise + */ + public void setLive(boolean isLive); + + /** + * Get the live delay which is the delay in micro seconds before the data is + * flushed and streamed. + * + * @return the live delay or -1 if the default value should be used + */ + public int getLiveDelay(); + + /** + * Set the live delay which is the delay in micro seconds before the data is + * flushed and streamed. + * + * @param liveDelay + * the live delay + */ + public void setLiveDelay(int liveDelay); + + /** * Get the network URL in case control and data is configured together * otherwise null If it returns a non-null value, getControlUrl() and * getDataUrl() have to return null. diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/SessionInfo.java b/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/SessionInfo.java index c5dd8a2bb4..c5c7d2408f 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/SessionInfo.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/SessionInfo.java @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation * Bernd Hufmann - Updated for support of LTTng Tools 2.1 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl; @@ -31,6 +32,11 @@ import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceSessionSta */ public class SessionInfo extends TraceInfo implements ISessionInfo { + /** + * The default network URL when creating a live session + */ + public static final String DEFAULT_LIVE_NETWORK_URK = "net://127.0.0.1"; //$NON-NLS-1$ + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ @@ -71,6 +77,15 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { */ private String fDataUrl = null; + /** + * Flag to indicate whether trace is live or not. + */ + private boolean fIsLive = false; + + /** + * The delay in micro seconds before the data is flushed and streamed. + */ + private int fLiveDelay = -1; // ------------------------------------------------------------------------ // Constructors @@ -188,6 +203,26 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { fSnapshotInfo = info; } + @Override + public boolean isLive() { + return fIsLive; + } + + @Override + public void setLive(boolean isLive) { + fIsLive = isLive; + } + + @Override + public int getLiveDelay() { + return fLiveDelay; + } + + @Override + public void setLiveDelay(int liveDelay) { + fLiveDelay = liveDelay; + } + // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/service/LTTngControlServiceTest.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/service/LTTngControlServiceTest.java index 4df5f9c561..e73bbba84a 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/service/LTTngControlServiceTest.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/src/org/eclipse/linuxtools/lttng2/control/ui/tests/service/LTTngControlServiceTest.java @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation * Alexandre Montplaisir - Port to JUnit4 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.lttng2.control.ui.tests.service; @@ -105,6 +106,8 @@ public class LTTngControlServiceTest { 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"; + private static final String SCEN_CREATE_LIVE_SESSION = "CreateSessionLive"; + private static final String SCEN_CREATE_LIVE_SESSION_ERRORS = "CreateSessionLiveErrors"; // ------------------------------------------------------------------------ // Test data @@ -1318,7 +1321,6 @@ public class LTTngControlServiceTest { String[] names = fService.getSessionNames(new NullProgressMonitor()); assertEquals(names[0], "mysession"); - ISnapshotInfo snapshotInfo = sessionInfo.getSnapshotInfo(); assertNotNull(sessionInfo); assertEquals("snapshot-2", snapshotInfo.getName()); @@ -1339,7 +1341,6 @@ public class LTTngControlServiceTest { } } - @Test public void testCreateSnapshotSessionErrors() { try { @@ -1373,6 +1374,61 @@ public class LTTngControlServiceTest { } } + @Test + public void testCreateLiveSession() throws ExecutionException { + fShell.setScenario(SCEN_CREATE_LIVE_SESSION); + + ISessionInfo params = new SessionInfo("mysession"); + params.setLive(true); + params.setStreamedTrace(true); + params.setNetworkUrl("net://127.0.0.1"); + ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); + assertNotNull(sessionInfo); + assertEquals("mysession", sessionInfo.getName()); + assertEquals(TraceSessionState.INACTIVE, sessionInfo.getSessionState()); + assertTrue(sessionInfo.isStreamedTrace()); + assertTrue(sessionInfo.isLive()); + assertEquals("net://127.0.0.1", sessionInfo.getSessionPath()); + String[] names = fService.getSessionNames(new NullProgressMonitor()); + assertEquals(names[0], "mysession"); + fService.destroySession("mysession", new NullProgressMonitor()); + } + + @Test + public void testCreateLiveSessionErrors() { + try { + fShell.setScenario(SCEN_CREATE_LIVE_SESSION_ERRORS); + + ISessionInfo parameters = new SessionInfo("mysession"); + parameters.setLive(true); + parameters.setSnapshot(true); + fService.createSession(parameters, new NullProgressMonitor()); + fail("createSession() didn't fail"); + } catch (ExecutionException e) { + // successful + } + + try { + ISessionInfo parameters = new SessionInfo("mysession"); + parameters.setNetworkUrl("blah"); + parameters.setLive(true); + fService.createSession(parameters, new NullProgressMonitor()); + fail("createSession() didn't fail"); + } catch (ExecutionException e) { + // successful + } + + try { + ISessionInfo parameters = new SessionInfo("mysession"); + parameters.setControlUrl("net://127.0.0.1"); + parameters.setLive(true); + fService.createSession(parameters, new NullProgressMonitor()); + fail("createSession() didn't fail"); + } catch (ExecutionException e) { + // successful + } + } + private static void enableVerbose() { // verbose ControlCommandLogger.init(ControlPreferences.getInstance().getLogfilePath(), false); diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/dialogs/CreateSessionDialogStub.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/dialogs/CreateSessionDialogStub.java index 44cca482f8..a3f7be4abc 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/dialogs/CreateSessionDialogStub.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/control/stubs/dialogs/CreateSessionDialogStub.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation * Bernd Hufmann - Updated for support of LTTng Tools 2.1 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.control.stubs.dialogs; @@ -30,6 +31,8 @@ public class CreateSessionDialogStub implements ICreateSessionDialog { private String fControlUrl = null; private String fDataUrl = null; private boolean fIsSnapshot; + private boolean fIsLive = false; + private int fLiveDelay = 0; @Override public void initialize(TraceSessionGroup group) { @@ -68,6 +71,14 @@ public class CreateSessionDialogStub implements ICreateSessionDialog { fIsSnapshot = isSnapshot; } + public void setLive(boolean isLive) { + fIsLive = isLive; + } + + public void setLiveDelay(int liveDelay) { + fLiveDelay = liveDelay; + } + @Override public ISessionInfo getParameters() { ISessionInfo sessionInfo = new SessionInfo(fName); @@ -81,6 +92,8 @@ public class CreateSessionDialogStub implements ICreateSessionDialog { sessionInfo.setSessionPath(fPath); } + sessionInfo.setLive(fIsLive); + sessionInfo.setLiveDelay(fLiveDelay); sessionInfo.setSnapshot(fIsSnapshot); return sessionInfo; diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg index 1775717198..22a69e988c 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg @@ -1259,9 +1259,6 @@ Session mysession destroyed. </COMMAND_OUTPUT> </SCENARIO> - - - #################################################################### # Scenario: Test "lttng create <session> --snapshot (LTTng 2.3) #################################################################### @@ -1309,4 +1306,85 @@ lttng snapshot record -s mysession Error: Session needs to be started once </COMMAND_OUTPUT> +</SCENARIO> + +#################################################################### +# Scenario: Test "lttng create <session> --live [USEC] (LTTng 2.4) +#################################################################### +<SCENARIO> +CreateSessionLive +<COMMAND_INPUT> +lttng create mysession --live -U net://127.0.0.1 +</COMMAND_INPUT> +<COMMAND_RESULT> +0 +</COMMAND_RESULT> +<COMMAND_OUTPUT> +Session mysession created. +Traces will be written in net://127.0.0.1 +Live timer set to 1000000 usec +</COMMAND_OUTPUT> +#------------------------------------------------------------------------------ +<COMMAND_INPUT> +lttng list +</COMMAND_INPUT> +<COMMAND_RESULT> +0 +</COMMAND_RESULT> +<COMMAND_OUTPUT> +Available tracing sessions: + 1) mysession (net4://127.0.0.1:5342/ [data: 5343]) [inactive] + +Use lttng list <session_name> for more details +</COMMAND_OUTPUT> +#------------------------------------------------------------------------------ +<COMMAND_INPUT> +lttng destroy mysession +</COMMAND_INPUT> +<COMMAND_RESULT> +0 +</COMMAND_RESULT> +<COMMAND_OUTPUT> +Session mysession destroyed. +</COMMAND_OUTPUT> +</SCENARIO> + +#################################################################### +# Scenario: Test errors for "lttng create <session> --live [USEC] (LTTng 2.4) +#################################################################### +<SCENARIO> +CreateSessionLiveErrors +<COMMAND_INPUT> +lttng create mysession --live --snapshot +</COMMAND_INPUT> +<COMMAND_RESULT> +1 +</COMMAND_RESULT> +<COMMAND_OUTPUT> +Error: Snapshot and live modes are mutually exclusive. +Error: Command error +</COMMAND_OUTPUT> +#------------------------------------------------------------------------------ +<COMMAND_INPUT> +lttng create mysession --live -U blah +</COMMAND_INPUT> +<COMMAND_RESULT> +1 +</COMMAND_RESULT> +<COMMAND_OUTPUT> +Error: URI parse unknown protocol blah +Error: Unable to parse the URL blah +Error: Invalid parameter +</COMMAND_OUTPUT> +#------------------------------------------------------------------------------ +<COMMAND_INPUT> +lttng create mysession --live -C net://127.0.0.1 +</COMMAND_INPUT> +<COMMAND_RESULT> +1 +</COMMAND_RESULT> +<COMMAND_OUTPUT> +Error: You need both control and data URL. +Error: Command error +</COMMAND_OUTPUT> </SCENARIO>
\ No newline at end of file diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/CreateSessionDialog.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/CreateSessionDialog.java index 50d4625773..4d21a3978c 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/CreateSessionDialog.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/CreateSessionDialog.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -9,6 +9,7 @@ * Contributors: * Bernd Hufmann - Initial API and implementation * Bernd Hufmann - Updated for support of LTTng Tools 2.1 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs; @@ -23,15 +24,20 @@ import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup; import org.eclipse.linuxtools.internal.lttng2.control.ui.views.remote.IRemoteSystemProxy; +import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -60,6 +66,11 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$ /** + * To indicate that the default value will be used for this field + */ + private static final String DEFAULT_TEXT = "<" + Messages.EnableChannelDialog_DefaultMessage + ">"; //$NON-NLS-1$ //$NON-NLS-2$ + + /** * Supported network protocols for streaming */ private enum StreamingProtocol { @@ -71,6 +82,16 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi file, } + /** + * Supported network protocols for Live tracing + */ + private enum LiveProtocol { + /** Default network protocol for IPv4 (TCP)*/ + net, + /** Default network protocol for IPv6 (TCP)*/ + net6 + } + private enum StreamingProtocol2 { /** Default network protocol for IPv4 (TCP)*/ net, @@ -110,17 +131,34 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi */ private Text fSessionPathText = null; /** + * The button widget to select a normal session + */ + private Button fNormalModeButton = null; + /** * The button widget to select a snapshot session */ private Button fSnapshotButton = null; /** - * The Group for stream configuration. + * The group that contains the mutually exclusive mode buttons + */ + private Group fModeButtonGroup = null; + /** + * The button widget to select a live session */ - private Group fMainStreamingGroup = null; + private Button fLiveButton = null; + + /** + * The text widget to set a live delay + */ + private Text fLiveDelayText = null; /** - * The button to show streaming options. + * The Group for advanced configuration. */ - private Button fConfigureStreamingButton = null; + private Group fAdvancedGroup = null; + /** + * The button to show advanced options. + */ + private Button fAdvancedButton = null; /** * The composite with streaming configuration parameter. */ @@ -194,13 +232,21 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi */ private boolean fIsSnapshot = false; /** + * Flag whether the session is live or not + */ + private boolean fIsLive = false; + /** + * The live delay + */ + private Integer fLiveDelay = 0; + /** * Flag whether default location (path) shall be used or not */ private boolean fIsDefaultPath = true; /** - * Flag whether the trace is streamed or not + * Flag whether the advanced options are enabled or not */ - private boolean fIsStreamedTrace = false; + private boolean fIsAdvancedEnabled = false; /** * The network URL in case control and data is configured together. * If set, fControlUrl and fDataUrl will be null. @@ -220,6 +266,10 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi * The trace path string. */ private String fTracePath = null; + /** + * The Group for advanced configuration of Live mode. + */ + private Group fLiveGroup = null; // ------------------------------------------------------------------------ // Constructors @@ -241,11 +291,15 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi public void initialize(TraceSessionGroup group) { fParent = group; fStreamingComposite = null; + fLiveGroup = null; + fLiveButton = null; + fIsLive = false; + fSnapshotButton = null; fSessionName = ""; //$NON-NLS-1$ fSessionPath = null; fIsSnapshot = false; fIsDefaultPath = true; - fIsStreamedTrace = false; + fIsAdvancedEnabled = false; fNetworkUrl = null; fControlUrl = null; fDataUrl = null; @@ -284,39 +338,66 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fSessionNameText = new Text(sessionGroup, SWT.NONE); fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip); fSessionNameText.addModifyListener(fUpdateEnablementModifyListener); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 3; + fSessionNameText.setLayoutData(data); fSessionPathLabel = new Label(sessionGroup, SWT.RIGHT); fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); fSessionPathText = new Text(sessionGroup, SWT.NONE); fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 3; + fSessionPathText.setLayoutData(data); fSessionPathText.addModifyListener(fUpdateEnablementModifyListener); - 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); + if (fParent.isSnapshotSupported() || fParent.isLiveSupported()) { + fModeButtonGroup = new Group(sessionGroup, SWT.NONE); + data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; - fSnapshotButton.setLayoutData(data); - fSnapshotButton.addSelectionListener(new SelectionAdapter() { + fModeButtonGroup.setLayoutData(data); + fModeButtonGroup.setLayout(new GridLayout(3, true)); + + SelectionAdapter modeChangedListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + if (fLiveButton != null) { + if (fLiveButton.getSelection()) { + createAdvancedLiveGroup(); + updateSessionPathEnablement(); + updateProtocolComboItems(); + } else { + disposeLiveGroup(); + updateSessionPathEnablement(); + updateProtocolComboItems(); + } + } updateEnablement(); } - }); - } - - // layout widgets - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - - fSessionNameText.setLayoutData(data); + }; + + fNormalModeButton = new Button(fModeButtonGroup, SWT.RADIO); + fNormalModeButton.setText(Messages.TraceControl_CreateSessionNormalLabel); + fNormalModeButton.setToolTipText(Messages.TraceControl_CreateSessionNormalTooltip); + fNormalModeButton.setSelection(true); + fNormalModeButton.addSelectionListener(modeChangedListener); + + if (fParent.isSnapshotSupported()) { + fSnapshotButton = new Button(fModeButtonGroup, SWT.RADIO); + fSnapshotButton.setText(Messages.TraceControl_CreateSessionSnapshotLabel); + fSnapshotButton.setToolTipText(Messages.TraceControl_CreateSessionSnapshotTooltip); + fSnapshotButton.addSelectionListener(modeChangedListener); + } - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - fSessionPathText.setLayoutData(data); + if (fParent.isLiveSupported()) { + fLiveButton = new Button(fModeButtonGroup, SWT.RADIO); + fLiveButton.setText(Messages.TraceControl_CreateSessionLiveLabel); + fLiveButton.setToolTipText(Messages.TraceControl_CreateSessionLiveTooltip); + fLiveButton.addSelectionListener(modeChangedListener); + } + } - if (fParent.isNetworkStreamingSupported()) { + if (fParent.isNetworkStreamingSupported() || fParent.isLiveSupported()) { createAdvancedOptionsComposite(); } @@ -325,31 +406,41 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi private void createAdvancedOptionsComposite() { - fMainStreamingGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); - fMainStreamingGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - fMainStreamingGroup.setLayout(new GridLayout(1, true)); + fAdvancedGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); + fAdvancedGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); + fAdvancedGroup.setLayout(new GridLayout(1, true)); - fConfigureStreamingButton = new Button(fMainStreamingGroup, SWT.PUSH); - fConfigureStreamingButton.setText(Messages.TraceControl_CreateSessionConfigureStreamingButtonText + " >>>"); //$NON-NLS-1$ - fConfigureStreamingButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); - fConfigureStreamingButton.addSelectionListener(new SelectionAdapter() { + fAdvancedButton = new Button(fAdvancedGroup, SWT.PUSH); + fAdvancedButton.setText(Messages.TraceControl_CreateSessionConfigureStreamingButtonText + " >>>"); //$NON-NLS-1$ + fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); + fAdvancedButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (fIsStreamedTrace) { - fIsStreamedTrace = false; - fConfigureStreamingButton.setText(">>> " + Messages.TraceControl_CreateSessionConfigureStreamingButtonText); //$NON-NLS-1$ - fConfigureStreamingButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); - fSessionPathText.setEnabled(true); - fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); - disposeConfigureStreamingComposite(); + if (fIsAdvancedEnabled) { + fIsAdvancedEnabled = false; + fAdvancedButton.setText(">>> " + Messages.TraceControl_CreateSessionConfigureStreamingButtonText); //$NON-NLS-1$ + fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); + + if (fParent.isNetworkStreamingSupported()) { + updateSessionPathEnablement(); + disposeConfigureStreamingComposite(); + } + + if (fParent.isLiveSupported()) { + disposeLiveGroup(); + } } else { - fIsStreamedTrace = true; - fConfigureStreamingButton.setText("<<< " + Messages.TraceControl_CreateSessionNoStreamingButtonText); //$NON-NLS-1$ - fConfigureStreamingButton.setToolTipText(Messages.TraceControl_CreateSessionNoStreamingButtonTooltip); - fSessionPathText.setEnabled(false); - fSessionPathText.setText(""); //$NON-NLS-1$ - fSessionPathLabel.setText(""); //$NON-NLS-1$ - createConfigureStreamingComposite(); + fIsAdvancedEnabled = true; + fAdvancedButton.setText("<<< " + Messages.TraceControl_CreateSessionNoStreamingButtonText); //$NON-NLS-1$ + fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionNoStreamingButtonTooltip); + + if (fParent.isNetworkStreamingSupported()) { + updateSessionPathEnablement(); + createConfigureStreamingComposite(); + } + if (fLiveButton != null && fLiveButton.getSelection()) { + createAdvancedLiveGroup(); + } } updateEnablement(); @@ -358,21 +449,63 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi }); } + private void updateSessionPathEnablement() { + if (fIsAdvancedEnabled || fIsLive) { + fSessionPathText.setEnabled(false); + fSessionPathText.setText(""); //$NON-NLS-1$ + fSessionPathLabel.setText(""); //$NON-NLS-1$ + } else { + fSessionPathText.setEnabled(true); + fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); + } + } + + private void updateProtocolComboItems() { + if (fControlProtocolCombo == null || fControlProtocolCombo.isDisposed()) { + return; + } + + int currentSelection = fControlProtocolCombo.getSelectionIndex() <= COMMON_URL_LAST_INDEX ? + fControlProtocolCombo.getSelectionIndex() : DEFAULT_URL_INDEX; + + fControlProtocolCombo.removeAll(); + Enum<? extends Enum<?>>[] values; + if (fIsLive) { + values = LiveProtocol.values(); + } else if (fLinkDataWithControlButton.getSelection()) { + values = StreamingProtocol.values(); + } else { + values = StreamingProtocol2.values(); + } + + String[] controlItems = new String[values.length]; + for (int i = 0; i < controlItems.length; i++) { + controlItems[i] = values[i].name(); + } + fControlProtocolCombo.setItems(controlItems); + fDataProtocolCombo.setItems(controlItems); + + // Set selection + if (currentSelection != -1) { + fControlProtocolCombo.select(currentSelection); + fDataProtocolCombo.select(currentSelection); + } + } + private void createConfigureStreamingComposite() { if (fStreamingComposite == null) { - fStreamingComposite = new Composite(fMainStreamingGroup, SWT.NONE); + fStreamingComposite = new Group(fAdvancedGroup, SWT.SHADOW_NONE); GridLayout layout = new GridLayout(1, true); fStreamingComposite.setLayout(layout); fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - Group urlGroup = new Group(fStreamingComposite, SWT.SHADOW_NONE); layout = new GridLayout(7, true); - urlGroup.setLayout(layout); - urlGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); + fStreamingComposite.setLayout(layout); + fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - Label tracePathLabel = new Label(urlGroup, SWT.RIGHT); + Label tracePathLabel = new Label(fStreamingComposite, SWT.RIGHT); tracePathLabel.setText(Messages.TraceControl_CreateSessionTracePathText); - fTracePathText = new Text(urlGroup, SWT.NONE); + fTracePathText = new Text(fStreamingComposite, SWT.NONE); fTracePathText.setToolTipText(Messages.TraceControl_CreateSessionTracePathTooltip); // layout widgets @@ -381,7 +514,7 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fTracePathText.setLayoutData(data); fTracePathText.addModifyListener(fUpdateEnablementModifyListener); - fLinkDataWithControlButton = new Button(urlGroup, SWT.CHECK); + fLinkDataWithControlButton = new Button(fStreamingComposite, SWT.CHECK); fLinkDataWithControlButton.setText(Messages.TraceControl_CreateSessionLinkButtonText); fLinkDataWithControlButton.setToolTipText(Messages.TraceControl_CreateSessionLinkButtonTooltip); data = new GridData(GridData.FILL_HORIZONTAL); @@ -389,63 +522,63 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fLinkDataWithControlButton.setLayoutData(data); fLinkDataWithControlButton.setSelection(true); - Label label = new Label(urlGroup, SWT.NONE); + Label label = new Label(fStreamingComposite, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; label.setLayoutData(data); - label = new Label(urlGroup, SWT.NONE); + label = new Label(fStreamingComposite, SWT.NONE); label.setText(Messages.TraceControl_CreateSessionProtocolLabelText); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; label.setLayoutData(data); - label = new Label(urlGroup, SWT.NONE); + label = new Label(fStreamingComposite, SWT.NONE); label.setText(Messages.TraceControl_CreateSessionAddressLabelText); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; label.setLayoutData(data); - label = new Label(urlGroup, SWT.NONE); + label = new Label(fStreamingComposite, SWT.NONE); label.setText(Messages.TraceControl_CreateSessionPortLabelText); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; label.setLayoutData(data); - label = new Label(urlGroup, SWT.RIGHT); + label = new Label(fStreamingComposite, SWT.RIGHT); label.setText(Messages.TraceControl_CreateSessionControlUrlLabel); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; label.setLayoutData(data); - fControlProtocolCombo = new CCombo(urlGroup, SWT.READ_ONLY); + fControlProtocolCombo = new CCombo(fStreamingComposite, SWT.READ_ONLY); fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; fControlProtocolCombo.setLayoutData(data); fControlProtocolCombo.addModifyListener(fUpdateEnablementModifyListener); - fControlHostAddressText = new Text(urlGroup, SWT.NONE); + fControlHostAddressText = new Text(fStreamingComposite, SWT.NONE); fControlHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionControlAddressTooltip); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; fControlHostAddressText.setLayoutData(data); fControlHostAddressText.addModifyListener(fUpdateEnablementModifyListener); - fControlPortText = new Text(urlGroup, SWT.NONE); + fControlPortText = new Text(fStreamingComposite, SWT.NONE); fControlPortText.setToolTipText(Messages.TraceControl_CreateSessionControlPortTooltip); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; fControlPortText.setLayoutData(data); fControlPortText.addModifyListener(fUpdateEnablementModifyListener); - label = new Label(urlGroup, SWT.RIGHT); + label = new Label(fStreamingComposite, SWT.RIGHT); label.setText(Messages.TraceControl_CreateSessionDataUrlLabel); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; label.setLayoutData(data); - fDataProtocolCombo = new CCombo(urlGroup, SWT.READ_ONLY); + fDataProtocolCombo = new CCombo(fStreamingComposite, SWT.READ_ONLY); fDataProtocolCombo.setEnabled(false); fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); data = new GridData(GridData.FILL_HORIZONTAL); @@ -453,14 +586,9 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fDataProtocolCombo.setLayoutData(data); fDataProtocolCombo.addModifyListener(fUpdateEnablementModifyListener); - String items[] = new String[StreamingProtocol.values().length]; - for (int i = 0; i < items.length; i++) { - items[i] = StreamingProtocol.values()[i].name(); - } - fControlProtocolCombo.setItems(items); - fDataProtocolCombo.setItems(items); + updateProtocolComboItems(); - fDataHostAddressText = new Text(urlGroup, SWT.NONE); + fDataHostAddressText = new Text(fStreamingComposite, SWT.NONE); fDataHostAddressText.setEnabled(false); fDataHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionDataAddressTooltip); data = new GridData(GridData.FILL_HORIZONTAL); @@ -468,7 +596,7 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fDataHostAddressText.setLayoutData(data); fDataHostAddressText.addModifyListener(fUpdateEnablementModifyListener); - fDataPortText = new Text(urlGroup, SWT.NONE); + fDataPortText = new Text(fStreamingComposite, SWT.NONE); fDataPortText.setEnabled(true); fDataPortText.setToolTipText(Messages.TraceControl_CreateSessionDataPortTooltip); data = new GridData(GridData.FILL_HORIZONTAL); @@ -504,22 +632,8 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); fControlHostAddressText.addModifyListener(fControlUrlKeyListener); - // Get previous selection and validate - int currentSelection = fControlProtocolCombo.getSelectionIndex() <= COMMON_URL_LAST_INDEX ? - fControlProtocolCombo.getSelectionIndex() : DEFAULT_URL_INDEX; + updateProtocolComboItems(); - // Update combo box items - fControlProtocolCombo.removeAll(); - String[] controlItems = new String[StreamingProtocol.values().length]; - for (int i = 0; i < controlItems.length; i++) { - controlItems[i] = StreamingProtocol.values()[i].name(); - } - fControlProtocolCombo.setItems(controlItems); - fDataProtocolCombo.setItems(controlItems); - - // Set selection - fControlProtocolCombo.select(currentSelection); - fDataProtocolCombo.select(currentSelection); fDataHostAddressText.setText(fControlHostAddressText.getText()); // Update tool tips @@ -535,19 +649,7 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fDataProtocolCombo.addSelectionListener(fDataProtocolSelectionListener); fControlHostAddressText.removeModifyListener(fControlUrlKeyListener); - // Update combo box items - int currentSelection = fControlProtocolCombo.getSelectionIndex(); - fControlProtocolCombo.removeAll(); - String[] controlItems = new String[StreamingProtocol2.values().length]; - for (int i = 0; i < controlItems.length; i++) { - controlItems[i] = StreamingProtocol2.values()[i].name(); - } - fControlProtocolCombo.setItems(controlItems); - fDataProtocolCombo.setItems(controlItems); - - // Set selection - fControlProtocolCombo.select(currentSelection); - fDataProtocolCombo.select(currentSelection); + updateProtocolComboItems(); // Update tool tips fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); @@ -575,6 +677,74 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi } } + private void createAdvancedLiveGroup() { + if (fLiveGroup == null && fIsAdvancedEnabled) { + GridLayout layout = new GridLayout(7, true); + fLiveGroup = new Group(fAdvancedGroup, SWT.NONE); + fLiveGroup.setLayout(layout); + GridData layoutData = new GridData(GridData.FILL_BOTH); + fLiveGroup.setLayoutData(layoutData); + + Label liveDelayLabel = new Label(fLiveGroup, SWT.RIGHT); + layoutData = new GridData(GridData.FILL_HORIZONTAL); + liveDelayLabel.setText(Messages.TraceControl_CreateSessionLiveDelayLabel); + liveDelayLabel.setLayoutData(layoutData); + fLiveDelayText = new Text(fLiveGroup, SWT.NONE); + fLiveDelayText.setText(DEFAULT_TEXT); + fLiveDelayText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); + fLiveDelayText.setToolTipText(Messages.TraceControl_CreateSessionLiveDelayTooltip); + fLiveDelayText.addVerifyListener(new VerifyListener() { + @Override + public void verifyText(VerifyEvent e) { + // only numbers and default are allowed. + e.doit = e.text.matches("[0-9]*") || e.text.matches(DEFAULT_TEXT); //$NON-NLS-1$ + updateEnablement(); + } + }); + fLiveDelayText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent event) { + updateEnablement(); + } + }); + + fLiveDelayText.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + Text focusLostWidget = (Text) e.widget; + if (focusLostWidget.getText().isEmpty()) { + focusLostWidget.setText(DEFAULT_TEXT); + focusLostWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); + } + } + + @Override + public void focusGained(FocusEvent e) { + Text focusGainedWidget = (Text) e.widget; + if (focusGainedWidget.getText().equals(DEFAULT_TEXT)) { + focusGainedWidget.setText(""); //$NON-NLS-1$ + focusGainedWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); + } + } + }); + + layoutData = new GridData(GridData.FILL_HORIZONTAL); + layoutData.grabExcessHorizontalSpace = true; + layoutData.horizontalSpan = 6; + fLiveDelayText.setLayoutData(layoutData); + getShell().pack(); + } + } + + private void disposeLiveGroup() { + if (fLiveGroup != null) { + fLiveGroup.dispose(); + fLiveGroup = null; + getShell().pack(); + } + } + private void disposeConfigureStreamingComposite() { if (fStreamingComposite != null) { fStreamingComposite.dispose(); @@ -599,9 +769,14 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fSessionPath = fSessionPathText.getText(); setErrorMessage(null); + if (fParent.isLiveSupported() && fLiveButton != null) { + fIsLive = fLiveButton.getSelection(); + fLiveDelay = LTTngControlServiceConstants.UNUSED_VALUE; + } + if (!"".equals(fSessionPath)) { //$NON-NLS-1$ // validate sessionPath - if (!fIsStreamedTrace) { + if (!fIsAdvancedEnabled && !fIsLive) { TargetNodeComponent node = (TargetNodeComponent)fParent.getParent(); IRemoteSystemProxy proxy = node.getRemoteSystemProxy(); IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem(); @@ -635,8 +810,19 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi fControlUrl = null; fDataUrl = null; - if (fIsStreamedTrace && fStreamingComposite != null) { + if (fIsAdvancedEnabled && fStreamingComposite != null) { // Validate input data + + if (fIsLive && fLiveGroup != null) { + String liveDelayText = fLiveDelayText.getText(); + try { + fLiveDelay = liveDelayText.equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.valueOf(liveDelayText); + } catch (NumberFormatException e) { + setErrorMessage(Messages.TraceControl_InvalidLiveDelayError); + return; + } + } + fTracePath = fTracePathText.getText(); if (fControlProtocolCombo.getSelectionIndex() < 0) { @@ -680,6 +866,10 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi } } + if (fIsLive && fNetworkUrl == null && fControlUrl == null && fDataUrl == null) { + fNetworkUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URK; + } + // Check for invalid names if (!"".equals(fSessionName) && !fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$ setErrorMessage(Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -775,7 +965,8 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi public ISessionInfo getParameters() { ISessionInfo sessionInfo = new SessionInfo(fSessionName); - if (fIsStreamedTrace) { + boolean isStreaming = (fIsAdvancedEnabled && fStreamingComposite != null) || fIsLive; + if (isStreaming) { sessionInfo.setNetworkUrl(fNetworkUrl); sessionInfo.setControlUrl(fControlUrl); sessionInfo.setDataUrl(fDataUrl); @@ -784,6 +975,8 @@ public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessi sessionInfo.setSessionPath(fSessionPath); } + sessionInfo.setLive(fIsLive); + sessionInfo.setLiveDelay(fLiveDelay); sessionInfo.setSnapshot(fIsSnapshot); return sessionInfo; diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ImportHandler.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ImportHandler.java index 6c9967d498..b5eda2736f 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ImportHandler.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ImportHandler.java @@ -33,6 +33,8 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.URIUtil; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.MessageDialogWithToggle; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; @@ -78,6 +80,9 @@ public class ImportHandler extends BaseControlViewHandler { /** Name of default project to import traces to */ public static final String DEFAULT_REMOTE_PROJECT_NAME = "Remote"; //$NON-NLS-1$ + /** The preference key to remeber whether or not the user wants the notification shown next time **/ + private static final String NOTIFY_IMPORT_STREAMED_PREF_KEY = "NOTIFY_IMPORT_STREAMED"; //$NON-NLS-1$ + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ @@ -108,6 +113,13 @@ public class ImportHandler extends BaseControlViewHandler { IProject project = TmfProjectRegistry.createProject(DEFAULT_REMOTE_PROJECT_NAME, null, null); if (param.getSession().isStreamedTrace()) { + + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + String notify = store.getString(NOTIFY_IMPORT_STREAMED_PREF_KEY); + if (!MessageDialogWithToggle.ALWAYS.equals(notify)) { + MessageDialogWithToggle.openInformation(window.getShell(), null, Messages.TraceControl_ImportDialogStreamedTraceNotification, Messages.TraceControl_ImportDialogStreamedTraceNotificationToggle, false, store, NOTIFY_IMPORT_STREAMED_PREF_KEY); + } + // Streamed trace TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true); TmfTraceFolder traceFolder = projectElement.getTracesFolder(); diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java index 893d1905c8..948bd16e84 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java @@ -110,8 +110,12 @@ public final class Messages extends NLS { public static String TraceControl_CreateSessionNameTooltip; public static String TraceControl_CreateSessionPathLabel; public static String TraceControl_CreateSessionPathTooltip; + public static String TraceControl_CreateSessionNormalLabel; + public static String TraceControl_CreateSessionNormalTooltip; public static String TraceControl_CreateSessionSnapshotLabel; public static String TraceControl_CreateSessionSnapshotTooltip; + public static String TraceControl_CreateSessionLiveLabel; + public static String TraceControl_CreateSessionLiveTooltip; public static String TraceControl_CreateSessionConfigureStreamingButtonText; public static String TraceControl_CreateSessionConfigureStreamingButtonTooltip; @@ -136,11 +140,14 @@ public final class Messages extends NLS { public static String TraceControl_CreateSessionNoConsumertTooltip; public static String TraceControl_CreateSessionDisableConsumertText; public static String TraceControl_CreateSessionDisableConsumertTooltip; + public static String TraceControl_CreateSessionLiveDelayLabel; + public static String TraceControl_CreateSessionLiveDelayTooltip; public static String TraceControl_InvalidSessionNameError; public static String TraceControl_SessionAlreadyExistsError; public static String TraceControl_SessionPathAlreadyExistsError; public static String TraceControl_InvalidSessionPathError; + public static String TraceControl_InvalidLiveDelayError; public static String TraceControl_FileSubSystemError; public static String TraceControl_EnableChannelDialogTitle; @@ -208,6 +215,8 @@ public final class Messages extends NLS { public static String TraceControl_AddContextAvailableContextsTooltip; public static String TraceControl_AddContextAllLabel; + public static String TraceControl_ImportDialogStreamedTraceNotification; + public static String TraceControl_ImportDialogStreamedTraceNotificationToggle; public static String TraceControl_ImportDialogTitle; public static String TraceControl_ImportDialogTracesGroupName; public static String TraceControl_ImportDialogTracesTooltip; diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties index 7fbf077abe..a196b4c333 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties @@ -91,8 +91,12 @@ 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_CreateSessionNormalLabel=Normal Mode +TraceControl_CreateSessionNormalTooltip=Configure session in normal mode TraceControl_CreateSessionSnapshotLabel=Snapshot Mode TraceControl_CreateSessionSnapshotTooltip=Configure session in snapshot mode +TraceControl_CreateSessionLiveLabel=Live Mode +TraceControl_CreateSessionLiveTooltip=Configure session in live mode TraceControl_CreateSessionConfigureStreamingButtonText=Advanced @@ -123,11 +127,14 @@ TraceControl_CreateSessionNoConsumertText=No Consumer TraceControl_CreateSessionNoConsumertTooltip=Don't activate a consumer for this session. TraceControl_CreateSessionDisableConsumertText=Disable Consumer TraceControl_CreateSessionDisableConsumertTooltip=Disable consumer for this session. +TraceControl_CreateSessionLiveDelayLabel=Live Delay +TraceControl_CreateSessionLiveDelayTooltip=The delay in micro seconds before the data is flushed and streamed TraceControl_InvalidSessionNameError=The session name is invalid TraceControl_SessionAlreadyExistsError=The session name already exists TraceControl_SessionPathAlreadyExistsError=Session path already exists TraceControl_InvalidSessionPathError=The session path is invalid +TraceControl_InvalidLiveDelayError=Live Delay must be a valid positive number TraceControl_FileSubSystemError=File subsystem error in session creation dialog. TraceControl_EnableChannelDialogTitle=Enable Channel @@ -195,6 +202,8 @@ TraceControl_AddContextAvailableContextsLabel=Contexts TraceControl_AddContextAvailableContextsTooltip=Available Contexts TraceControl_AddContextAllLabel=All Contexts +TraceControl_ImportDialogStreamedTraceNotification=You are importing a trace generated by a streamed session. By default the traces will be outputed to ~/lttng-traces/hostname/sessionname but the location can vary. +TraceControl_ImportDialogStreamedTraceNotificationToggle=Do not warn me again TraceControl_ImportDialogTitle=Import Traces TraceControl_ImportDialogTracesGroupName=Available Traces TraceControl_ImportDialogTracesTooltip=The available traces of current session to import diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TargetNodeComponent.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TargetNodeComponent.java index a8df138e10..309fcba35e 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TargetNodeComponent.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TargetNodeComponent.java @@ -264,7 +264,14 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu public boolean isSnapshotSupported() { return getControlService().isVersionSupported("2.3.0"); //$NON-NLS-1$ } - + /** + * Returns if node supports live or not + * @return <code>true</code> if it supports live else <code>false</code> + * + */ + public boolean isLiveSupported() { + return getControlService().isVersionSupported("2.4.0"); //$NON-NLS-1$; + } /** * Returns if node supports adding contexts on event * @return <code>true</code> if it supports adding contexts on events else <code>false</code> diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java index 90c0ca31be..8592c0415d 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java @@ -79,6 +79,15 @@ public class TraceSessionGroup extends TraceControlComponent { return getTargetNode().isSnapshotSupported(); } + /** + * Returns if node supports live or not + * + * @return <code>true</code> if it supports live else <code>false</code> + */ + public boolean isLiveSupported() { + return getTargetNode().isLiveSupported(); + } + // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java index 52e11c76d2..9af28be07a 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java @@ -10,6 +10,7 @@ * Bernd Hufmann - Initial API and implementation * Bernd Hufmann - Updated for support of LTTng Tools 2.1 * Simon Delisle - Updated for support of LTTng Tools 2.2 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.control.ui.views.service; @@ -489,6 +490,11 @@ public class LTTngControlService implements ILttngControlService { if (sessionInfo.isSnapshotSession()) { command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT); + } else if (sessionInfo.isLive()) { + command.append(LTTngControlServiceConstants.OPTION_LIVE); + if (sessionInfo.getLiveDelay() != LTTngControlServiceConstants.UNUSED_VALUE) { + command.append(sessionInfo.getLiveDelay()); + } } if (sessionInfo.getNetworkUrl() != null) { diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java index f30d5fb8d0..83e6c58114 100644 --- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java +++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2014 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -10,6 +10,7 @@ * Bernd Hufmann - Initial API and implementation * Bernd Hufmann - Updated for support of LTTng Tools 2.1 * Simon Delisle - Updated for support of LTTng Tools 2.2 + * Marc-Andre Laperle - Support for creating a live session **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.control.ui.views.service; @@ -140,6 +141,10 @@ public interface LTTngControlServiceConstants { */ static final String OPTION_SNAPSHOT = " --snapshot "; //$NON-NLS-1$ /** + * Command line option for live + */ + static final String OPTION_LIVE = " --live "; //$NON-NLS-1$ + /** * Command line option for kernel tracer. */ static final String OPTION_KERNEL = " -k "; //$NON-NLS-1$ |