From f7d4d450ccdd8fbf5c523a3e4471e8ab969bb8a6 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Wed, 19 Mar 2014 00:56:33 -0400 Subject: [PATCH] lttng: Move createSession parameters into SessionInfo class Change-Id: Iaa45647fcfa69fd3e62fdb56baf68070b27cad27 Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/23591 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann --- .../control/model/impl/SessionInfoTest.java | 19 +++-- .../core/control/model/ISessionInfo.java | 59 +++++++++++++++ .../core/control/model/impl/SessionInfo.java | 73 +++++++++++++++++-- .../service/LTTngControlServiceTest.java | 64 +++++++++++----- .../dialogs/CreateSessionDialogStub.java | 61 +++++----------- .../control/dialogs/CreateSessionDialog.java | 55 +++++--------- .../control/dialogs/ICreateSessionDialog.java | 56 ++------------ .../handlers/CreateSessionHandler.java | 8 +- .../control/model/impl/TraceSessionGroup.java | 41 +---------- .../control/service/ILttngControlService.java | 31 +------- .../control/service/LTTngControlService.java | 49 +++++++------ 11 files changed, 268 insertions(+), 248 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java index 6a6b164e3b..5112069991 100644 --- a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java +++ b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/SessionInfoTest.java @@ -81,6 +81,10 @@ public class SessionInfoTest { assertEquals("INACTIVE", state.toString()); assertEquals(0, state.ordinal()); assertEquals(0, result.getDomains().length); + assertFalse(result.isSnapshotSession()); + assertNull(result.getNetworkUrl()); + assertNull(result.getControlUrl()); + assertNull(result.getDataUrl()); } /** @@ -99,6 +103,10 @@ public class SessionInfoTest { for (int i = 0; i < orignalDomains.length; i++) { assertEquals(orignalDomains[i], resultDomains[i]); } + + assertEquals(sessionInfo.getNetworkUrl(), fSessionInfo1.getNetworkUrl()); + assertEquals(sessionInfo.getControlUrl(), fSessionInfo1.getControlUrl()); + assertEquals(sessionInfo.getDataUrl(), fSessionInfo1.getDataUrl()); } /** @@ -189,7 +197,7 @@ public class SessionInfoTest { String result = fixture.toString(); // add additional test code here - assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],Path=,State=INACTIVE,isStreamedTrace=false,Domains=)]", result); + assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],Path=,State=INACTIVE,isStreamedTrace=false,isSnapshot=false,Domains=,NetworkUrl=null,ControlUrl=null,DataUrl=null)]", result); } /** @@ -200,12 +208,12 @@ public class SessionInfoTest { String result = fSessionInfo1.toString(); // add additional test code here - assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,snapshotInfo=" + assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,isSnapshot=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); + + "isKernel=false)],NetworkUrl=null,ControlUrl=null,DataUrl=null)]", result); } /** @@ -214,17 +222,18 @@ public class SessionInfoTest { @Test public void testToString_3() { SessionInfo info = new SessionInfo((SessionInfo)fSessionInfo1); + info.setSnapshot(false); 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," + assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,isSnapshot=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); + + "isKernel=false)],NetworkUrl=null,ControlUrl=null,DataUrl=null)]", result); } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISessionInfo.java b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISessionInfo.java index 3fff6a2d56..e5ffd56ee7 100644 --- a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISessionInfo.java +++ b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/ISessionInfo.java @@ -85,6 +85,14 @@ public interface ISessionInfo extends ITraceInfo { */ boolean isSnapshotSession(); + /** + * Set whether or not the session should be in snapshot mode + * + * @param isSnapshot + * true for snapshot mode, false otherwise + */ + void setSnapshot(boolean isSnapshot); + /** * Gets the snapshot information the session or null if it is not a * snapshot session. @@ -97,4 +105,55 @@ public interface ISessionInfo extends ITraceInfo { * @param setSnapshotInfo - the snapshot data to set. */ void setSnapshotInfo(ISnapshotInfo setSnapshotInfo); + + /** + * 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. + * + * @return The network URL or null. + */ + String getNetworkUrl(); + + /** + * Set the network URL + * + * @param networkUrl + * the network URL + */ + void setNetworkUrl(String networkUrl); + + /** + * Get the control URL in case control and data is configured separately. If + * it returns a non-null value, getDataUrl() has to return a valid value too + * and getNetworkUrl() has to return null. + * + * @return The control URL or null. + */ + String getControlUrl(); + + /** + * Set the control URL + * + * @param controlUrl + * the control URL + */ + void setControlUrl(String controlUrl); + + /** + * Get the data URL in case control and data is configured separately. If it + * returns a non-null value, getControlUrl() has to return a valid value too + * and getNetworkUrl() has to return null. + * + * @return The data URL or null. + */ + String getDataUrl(); + + /** + * Set the data URL + * + * @param datalUrl + * the data URL + */ + void setDataUrl(String datalUrl); } diff --git a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SessionInfo.java b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SessionInfo.java index 84dff097e7..519955bfbf 100644 --- a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SessionInfo.java +++ b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/SessionInfo.java @@ -53,7 +53,23 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { /** * Flag to indicate whether the session is a snapshot session or not. */ + private boolean fIsSnapshot = false; + /** + * The snapshot information of the session + */ private ISnapshotInfo fSnapshotInfo = null; + /** + * The network URL for the session (-U) + */ + private String fNetworkUrl = null; + /** + * The control URL for the session (-C) + */ + private String fControlUrl = null; + /** + * The data URL for the session (-D) + */ + private String fDataUrl = null; // ------------------------------------------------------------------------ @@ -76,7 +92,11 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { fState = other.fState; fSessionPath = other.fSessionPath; fIsStreamedTrace = other.fIsStreamedTrace; + fIsSnapshot = other.fIsSnapshot; fSnapshotInfo = other.fSnapshotInfo; + fNetworkUrl = other.fNetworkUrl; + fControlUrl = other.fControlUrl; + fDataUrl = other.fDataUrl; for (Iterator iterator = other.fDomains.iterator(); iterator.hasNext();) { IDomainInfo domain = iterator.next(); @@ -113,7 +133,7 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { @Override public String getSessionPath() { - if(isSnapshotSession()) { + if (isSnapshotSession() && fSnapshotInfo != null) { return fSnapshotInfo.getSnapshotPath(); } return fSessionPath; @@ -140,9 +160,6 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { @Override public boolean isStreamedTrace() { - if (isSnapshotSession()) { - return fSnapshotInfo.isStreamedSnapshot(); - } return fIsStreamedTrace; } @@ -153,7 +170,12 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { @Override public boolean isSnapshotSession() { - return fSnapshotInfo != null; + return fIsSnapshot || fSnapshotInfo != null; + } + + @Override + public void setSnapshot(boolean isSnapshot) { + fIsSnapshot = isSnapshot; } @Override @@ -188,6 +210,9 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { output.append(fState); output.append(",isStreamedTrace="); output.append(fIsStreamedTrace); + output.append(",isSnapshot="); + output.append(fIsSnapshot); + if (fSnapshotInfo != null) { output.append(",snapshotInfo="); output.append(fSnapshotInfo.toString()); @@ -197,7 +222,45 @@ public class SessionInfo extends TraceInfo implements ISessionInfo { IDomainInfo domain = iterator.next(); output.append(domain.toString()); } + + output.append(",NetworkUrl="); + output.append(getNetworkUrl()); + output.append(",ControlUrl="); + output.append(getControlUrl()); + output.append(",DataUrl="); + output.append(getDataUrl()); + output.append(")]"); return output.toString(); } + + @Override + public String getNetworkUrl() { + return fNetworkUrl; + } + + @Override + public void setNetworkUrl(String networkUrl) { + fNetworkUrl = networkUrl; + } + + @Override + public String getControlUrl() { + return fControlUrl; + } + + @Override + public void setControlUrl(String controlUrl) { + fControlUrl = controlUrl; + } + + @Override + public void setDataUrl(String datalUrl) { + fDataUrl = datalUrl; + } + + @Override + public String getDataUrl() { + return fDataUrl; + } } diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java index bc64520e7a..aebad3bc56 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java @@ -44,6 +44,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType; import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; +import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo; import org.eclipse.linuxtools.internal.lttng2.stubs.service.CommandShellFactory; import org.eclipse.linuxtools.internal.lttng2.stubs.shells.LTTngToolsFileShell; import org.eclipse.linuxtools.internal.lttng2.ui.Activator; @@ -711,7 +712,7 @@ public class LTTngControlServiceTest { try { fShell.setScenario(SCEN_CREATE_SESSION1); - ISessionInfo info = fService.createSession("mysession2", null, false, new NullProgressMonitor()); + ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); assertNotNull(info); assertEquals("mysession2", info.getName()); assertNotNull(info.getSessionPath()); @@ -730,7 +731,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, false, new NullProgressMonitor()); + ISessionInfo info = fService.createSession(new SessionInfo("mysession2"), new NullProgressMonitor()); assertNotNull(info); assertEquals("mysession2", info.getName()); assertNotNull(info.getSessionPath()); @@ -747,28 +748,30 @@ public class LTTngControlServiceTest { fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS); try { - fService.createSession("alreadyExist", null, false, new NullProgressMonitor()); + fService.createSession(new SessionInfo("alreadyExist"), new NullProgressMonitor()); fail("No exeption thrown"); } catch (ExecutionException e) { // success } try { - fService.createSession("wrongName", null, false, new NullProgressMonitor()); + fService.createSession(new SessionInfo("wrongName"), new NullProgressMonitor()); fail("No exeption thrown"); } catch (ExecutionException e) { // success } try { - fService.createSession("withPath", "/home/user/hallo", false, new NullProgressMonitor()); + ISessionInfo sessionInfo = new SessionInfo("withPath"); + sessionInfo.setSessionPath("/home/user/hallo"); + fService.createSession(sessionInfo, new NullProgressMonitor()); fail("No exeption thrown"); } catch (ExecutionException e) { // success } try { - ISessionInfo info = fService.createSession("session with spaces", null, false, new NullProgressMonitor()); + ISessionInfo info = fService.createSession(new SessionInfo("session with spaces"), new NullProgressMonitor()); assertNotNull(info); assertEquals("session with spaces", info.getName()); assertNotNull(info.getSessionPath()); @@ -780,7 +783,9 @@ public class LTTngControlServiceTest { } try { - ISessionInfo info = fService.createSession("pathWithSpaces", "/home/user/hallo user/here", false, new NullProgressMonitor()); + ISessionInfo sessionInfo = new SessionInfo("pathWithSpaces"); + sessionInfo.setSessionPath("/home/user/hallo user/here"); + ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); assertNotNull(info); assertEquals("pathWithSpaces", info.getName()); assertNotNull(info.getSessionPath()); @@ -1166,35 +1171,51 @@ public class LTTngControlServiceTest { try { fShell.setScenario(SCEN_CREATE_SESSION_2_1); - ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor()); + ISessionInfo sessionInfo = new SessionInfo("mysession"); + sessionInfo.setNetworkUrl("net://172.0.0.1"); + sessionInfo.setStreamedTrace(true); + ISessionInfo info = fService.createSession(sessionInfo, 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, false, new NullProgressMonitor()); + sessionInfo = new SessionInfo("mysession"); + sessionInfo.setStreamedTrace(true); + sessionInfo.setNetworkUrl("file:///tmp"); + info = fService.createSession(sessionInfo, 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, false, new NullProgressMonitor()); + sessionInfo = new SessionInfo("mysession"); + sessionInfo.setStreamedTrace(true); + sessionInfo.setNetworkUrl("file:///tmp"); + info = fService.createSession(sessionInfo, 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", false, new NullProgressMonitor()); + sessionInfo = new SessionInfo("mysession"); + sessionInfo.setStreamedTrace(true); + sessionInfo.setControlUrl("tcp://172.0.0.1"); + sessionInfo.setDataUrl("tcp://172.0.0.1:5343"); + info = fService.createSession(sessionInfo, 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, false, new NullProgressMonitor()); + sessionInfo = new SessionInfo("mysession"); + sessionInfo.setStreamedTrace(true); + sessionInfo.setNetworkUrl("net://172.0.0.1:1234:2345"); + info = fService.createSession(sessionInfo, new NullProgressMonitor()); assertNotNull(info); assertEquals("mysession", info.getName()); assertEquals("net://172.0.0.1:1234:2345", info.getSessionPath()); @@ -1203,7 +1224,10 @@ public class LTTngControlServiceTest { // verbose enableVerbose(); - info = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor()); + sessionInfo = new SessionInfo("mysession"); + sessionInfo.setStreamedTrace(true); + sessionInfo.setNetworkUrl("net://172.0.0.1"); + info = fService.createSession(sessionInfo, new NullProgressMonitor()); assertNotNull(info); assertEquals("mysession", info.getName()); assertEquals("net://172.0.0.1", info.getSessionPath()); @@ -1223,7 +1247,10 @@ public class LTTngControlServiceTest { fShell.setScenario(SCEN_CREATE_SESSION_VERBOSE_2_1); enableVerbose(); - ISessionInfo info = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor()); + ISessionInfo sessionInfo = new SessionInfo("mysession"); + sessionInfo.setStreamedTrace(true); + sessionInfo.setNetworkUrl("net://172.0.0.1"); + ISessionInfo info = fService.createSession(sessionInfo, new NullProgressMonitor()); assertNotNull(info); assertEquals("mysession", info.getName()); assertEquals("net://172.0.0.1", info.getSessionPath()); @@ -1240,8 +1267,9 @@ public class LTTngControlServiceTest { public void testCreateSnapshotSession() { try { fShell.setScenario(SCEN_CREATE_SNAPSHOT_SESSION); - - ISessionInfo sessionInfo = fService.createSession("mysession", null, true, new NullProgressMonitor()); + ISessionInfo params = new SessionInfo("mysession"); + params.setSnapshot(true); + ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); assertNotNull(sessionInfo); assertEquals("mysession", sessionInfo.getName()); assertTrue(sessionInfo.isSnapshotSession()); @@ -1277,7 +1305,9 @@ public class LTTngControlServiceTest { try { fShell.setScenario(SCEN_CREATE_STREAMED_SNAPSHOT_SESSION); - ISessionInfo sessionInfo = fService.createSession("mysession", "net://172.0.0.1", null, null, false, new NullProgressMonitor()); + ISessionInfo params = new SessionInfo("mysession"); + params.setNetworkUrl("net://172.0.0.1"); + ISessionInfo sessionInfo = fService.createSession(params, new NullProgressMonitor()); assertNotNull(sessionInfo); assertEquals("mysession", sessionInfo.getName()); assertTrue(sessionInfo.isSnapshotSession()); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateSessionDialogStub.java b/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateSessionDialogStub.java index 599e24a61c..15950c870d 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateSessionDialogStub.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateSessionDialogStub.java @@ -12,6 +12,8 @@ **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.stubs.dialogs; +import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; +import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup; @@ -29,21 +31,6 @@ public class CreateSessionDialogStub implements ICreateSessionDialog { private String fDataUrl = null; private boolean fIsSnapshot; - @Override - public String getSessionName() { - return fName; - } - - @Override - public String getSessionPath() { - return fPath; - } - - @Override - public boolean isDefaultSessionPath() { - return fPath == null; - } - @Override public void initialize(TraceSessionGroup group) { } @@ -61,49 +48,41 @@ public class CreateSessionDialogStub implements ICreateSessionDialog { fName = name; } - @Override - public boolean isStreamedTrace() { - return fIsStreamedTrace; - } - public void setStreamedTrace(boolean isStreamedTrace) { fIsStreamedTrace = isStreamedTrace; } - @Override - public String getNetworkUrl() { - return fNetworkUrl; - } - public void setNetworkUrl(String fNetworkUrl) { this.fNetworkUrl = fNetworkUrl; } - - @Override - public String getControlUrl() { - return fControlUrl; - } - public void setControlUrl(String fControlUrl) { this.fControlUrl = fControlUrl; } - @Override - public String getDataUrl() { - return fDataUrl; - } - public void setDataUrl(String fDataUrl) { this.fDataUrl = fDataUrl; } - @Override - public boolean isSnapshot() { - return fIsSnapshot; - } - public void setSnapshot(boolean isSnapshot) { fIsSnapshot = isSnapshot; } + + @Override + public ISessionInfo getParameters() { + ISessionInfo sessionInfo = new SessionInfo(fName); + + if (fIsStreamedTrace) { + sessionInfo.setNetworkUrl(fNetworkUrl); + sessionInfo.setControlUrl(fControlUrl); + sessionInfo.setDataUrl(fDataUrl); + sessionInfo.setStreamedTrace(true); + } else if (fPath != null) { + sessionInfo.setSessionPath(fPath); + } + + sessionInfo.setSnapshot(fIsSnapshot); + + return sessionInfo; + } } diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateSessionDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateSessionDialog.java index 18b8dde513..ff79a0976c 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateSessionDialog.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateSessionDialog.java @@ -16,6 +16,8 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; +import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo; import org.eclipse.linuxtools.internal.lttng2.ui.Activator; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent; @@ -235,21 +237,6 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog // Accessors // ------------------------------------------------------------------------ - @Override - public String getSessionName() { - return fSessionName; - } - - @Override - public String getSessionPath() { - return fSessionPath; - } - - @Override - public boolean isDefaultSessionPath() { - return fIsDefaultPath; - } - @Override public void initialize(TraceSessionGroup group) { fParent = group; @@ -263,27 +250,6 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog fControlUrl = null; fDataUrl = null; } - - @Override - public boolean isStreamedTrace() { - return fIsStreamedTrace; - } - @Override - public String getNetworkUrl() { - return fNetworkUrl; - } - @Override - public String getControlUrl() { - return fControlUrl; - } - @Override - public String getDataUrl() { - return fDataUrl; - } - @Override - public boolean isSnapshot() { - return fIsSnapshot; - } // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ @@ -816,4 +782,21 @@ public class CreateSessionDialog extends Dialog implements ICreateSessionDialog } } + @Override + public ISessionInfo getParameters() { + ISessionInfo sessionInfo = new SessionInfo(fSessionName); + + if (fIsStreamedTrace) { + sessionInfo.setNetworkUrl(fNetworkUrl); + sessionInfo.setControlUrl(fControlUrl); + sessionInfo.setDataUrl(fDataUrl); + sessionInfo.setStreamedTrace(true); + } else if (!fIsDefaultPath) { + sessionInfo.setSessionPath(fSessionPath); + } + + sessionInfo.setSnapshot(fIsSnapshot); + + return sessionInfo; + } } diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateSessionDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateSessionDialog.java index d73de0abe4..872d0f573e 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateSessionDialog.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateSessionDialog.java @@ -12,6 +12,7 @@ **********************************************************************/ package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs; +import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup; /** @@ -26,65 +27,24 @@ public interface ICreateSessionDialog { // ------------------------------------------------------------------------ // Accessors // ------------------------------------------------------------------------ - /** - * @return the session name. - */ - String getSessionName(); /** - * @return the session path (null for default path) + * Get the parameters necessary for the creation of a LTTng session + * + * @return the parameters */ - String getSessionPath(); + ISessionInfo getParameters(); - /** - * @return true for default location else false - */ - boolean isDefaultSessionPath(); + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ /** * Initializes the dialog box. * @param group - the session group */ void initialize(TraceSessionGroup group); - /** - * @return true if traces is to be streamed else false. - */ - boolean isStreamedTrace(); - - /** - * 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. - * @return The network URL or null. - */ - String getNetworkUrl(); - - /** - * Get the control URL in case control and data is configured separately. - * If it returns a non-null value, getDataUrl() has to return a valid value too - * and getNetworkUrl() has to return null. - * - * @return The control URL or null. - */ - String getControlUrl(); - - /** - * Get the data URL in case control and data is configured separately. - * If it returns a non-null value, getControlUrl() has to return a valid value too - * and getNetworkUrl() has to return null. - * - * @return The data URL or null. - */ - String getDataUrl(); - - /** - * @return true if is a snapshot session else false - */ - boolean isSnapshot(); - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ /** * @return the open return value */ diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateSessionHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateSessionHandler.java index 327f901c57..88366bacf2 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateSessionHandler.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateSessionHandler.java @@ -70,13 +70,7 @@ public class CreateSessionHandler extends BaseControlViewHandler { @Override protected IStatus run(IProgressMonitor monitor) { try { - if (dialog.isStreamedTrace()) { - sessionGroup.createSession(dialog.getSessionName(), dialog.getNetworkUrl(), dialog.getControlUrl(), - dialog.getDataUrl(), dialog.isSnapshot(), monitor); - } else { - String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath(); - sessionGroup.createSession(dialog.getSessionName(), sessionPath, dialog.isSnapshot(), monitor); - } + sessionGroup.createSession(dialog.getParameters(), monitor); } catch (ExecutionException e) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e); } diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionGroup.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionGroup.java index 66c151edbf..b0563f8f4a 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionGroup.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionGroup.java @@ -112,49 +112,16 @@ public class TraceSessionGroup extends TraceControlComponent { /** * Creates a session with given session name and location. * - * @param sessionName - * - 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, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException { - ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, isSnapshot, monitor); - - if (sessionInfo != null) { - TraceSessionComponent session = new TraceSessionComponent( - sessionInfo.getName(), TraceSessionGroup.this); - addChild(session); - session.getConfigurationFromNode(monitor); - } - } - - /** - * Creates a session with given session name and location. + * @param sessionInf + * the session information used to create the session * - * @param sessionName - * - a session name to create - * @param networkUrl - * - a network URL for common definition of data and control channel - * or null if separate definition of data and control channel - * @param controlUrl - * - 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, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException { - ISessionInfo sessionInfo = getControlService().createSession(sessionName, networkUrl, controlUrl, dataUrl, isSnapshot, monitor); + public void createSession(ISessionInfo sessionInf, IProgressMonitor monitor) throws ExecutionException { + ISessionInfo sessionInfo = getControlService().createSession(sessionInf, monitor); if (sessionInfo != null) { TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this); diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/ILttngControlService.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/ILttngControlService.java index b24bbf91db..c1e3c601bb 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/ILttngControlService.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/ILttngControlService.java @@ -122,41 +122,16 @@ public interface ILttngControlService { /** * Creates a session with given session name and location. * - * @param sessionName - * - 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 sessionInfo + * the session information used to create the session * @param monitor * - a progress monitor - * @return the session information - * @throws ExecutionException - * If the command fails - */ - ISessionInfo createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException; - - /** - * Creates a session with given session name and location. * - * @param sessionName - * - a session name to create - * @param networkUrl - * - a network URL for common definition of data and control channel - * or null if separate definition of data and control channel - * @param controlUrl - * - 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, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException; + ISessionInfo createSession(ISessionInfo sessionInfo, IProgressMonitor monitor) throws ExecutionException; /** * Destroys a session with given session name. diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java index ecb62ca237..1a2bc84a13 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java @@ -412,10 +412,13 @@ public class LTTngControlService implements ILttngControlService { } @Override - public ISessionInfo createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException { + public ISessionInfo createSession(ISessionInfo sessionInfo, IProgressMonitor monitor) throws ExecutionException { + if (sessionInfo.isStreamedTrace()) { + return createStreamedSession(sessionInfo, monitor); + } - String newName = formatParameter(sessionName); - String newPath = formatParameter(sessionPath); + String newName = formatParameter(sessionInfo.getName()); + String newPath = formatParameter(sessionInfo.getSessionPath()); StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION, newName); @@ -424,7 +427,7 @@ public class LTTngControlService implements ILttngControlService { command.append(newPath); } - if (isSnapshot) { + if (sessionInfo.isSnapshotSession()) { command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT); } @@ -452,23 +455,22 @@ public class LTTngControlService implements ILttngControlService { } // Verify session name - if ((name == null) || (!"".equals(sessionName) && !name.equals(sessionName))) { //$NON-NLS-1$ + if ((name == null) || (!"".equals(sessionInfo.getName()) && !name.equals(sessionInfo.getName()))) { //$NON-NLS-1$ // Unexpected name returned throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$ } - SessionInfo sessionInfo = new SessionInfo(name); - + sessionInfo.setName(name); // Verify session path - if (!isSnapshot && - ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath))))) { + if (!sessionInfo.isSnapshotSession() && + ((path == null) || ((sessionInfo.getSessionPath() != null) && (!path.contains(sessionInfo.getSessionPath()))))) { // Unexpected path throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$ } - if (isSnapshot) { + if (sessionInfo.isSnapshotSession()) { // Make it a snapshot session - content of snapshot info need to // set afterwards using getSession() or getSnapshotInfo() sessionInfo.setSnapshotInfo(new SnapshotInfo("")); //$NON-NLS-1$ @@ -480,25 +482,24 @@ public class LTTngControlService implements ILttngControlService { } - @Override - public ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException { + private ISessionInfo createStreamedSession(ISessionInfo sessionInfo, IProgressMonitor monitor) throws ExecutionException { - String newName = formatParameter(sessionName); + String newName = formatParameter(sessionInfo.getName()); StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION, newName); - if (isSnapshot) { + if (sessionInfo.isSnapshotSession()) { command.append(LTTngControlServiceConstants.OPTION_SNAPSHOT); } - if (networkUrl != null) { + if (sessionInfo.getNetworkUrl() != null) { command.append(LTTngControlServiceConstants.OPTION_NETWORK_URL); - command.append(networkUrl); + command.append(sessionInfo.getNetworkUrl()); } else { command.append(LTTngControlServiceConstants.OPTION_CONTROL_URL); - command.append(controlUrl); + command.append(sessionInfo.getControlUrl()); command.append(LTTngControlServiceConstants.OPTION_DATA_URL); - command.append(dataUrl); + command.append(sessionInfo.getDataUrl()); } ICommandResult result = executeCommand(command.toString(), monitor); @@ -518,32 +519,32 @@ public class LTTngControlService implements ILttngControlService { if (nameMatcher.matches()) { name = String.valueOf(nameMatcher.group(1).trim()); - } else if (pathMatcher.matches() && (networkUrl != null)) { + } else if (pathMatcher.matches() && (sessionInfo.getNetworkUrl() != null)) { path = String.valueOf(pathMatcher.group(1).trim()); } index++; } // Verify session name - if ((name == null) || (!"".equals(sessionName) && !name.equals(sessionName))) { //$NON-NLS-1$ + if ((name == null) || (!"".equals(sessionInfo.getName()) && !name.equals(sessionInfo.getName()))) { //$NON-NLS-1$ // Unexpected name returned throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$ } - SessionInfo sessionInfo = new SessionInfo(name); + sessionInfo.setName(name); sessionInfo.setStreamedTrace(true); // Verify session path - if (networkUrl != null) { - if (!isSnapshot && (path == null)) { + if (sessionInfo.getNetworkUrl() != null) { + if (!sessionInfo.isSnapshotSession() && (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$ } - if (isSnapshot) { + if (sessionInfo.isSnapshotSession()) { sessionInfo.setStreamedTrace(false); } else { sessionInfo.setSessionPath(path); -- 2.34.1