1 /**********************************************************************
3 * Copyright (c) 2012, 2014 Ericsson
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * Bernd Hufmann - Initial API and implementation
12 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
13 * Marc-Andre Laperle - Support for creating a live session
14 **********************************************************************/
16 package org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
;
18 import java
.util
.ArrayList
;
19 import java
.util
.Iterator
;
20 import java
.util
.List
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
28 * Implementation of the trace session interface (ISessionInfo) to store session
31 * @author Bernd Hufmann
33 public class SessionInfo
extends TraceInfo
implements ISessionInfo
{
36 * The default network URL when creating a live session.
38 public static final String DEFAULT_LIVE_NETWORK_URK
= "net://127.0.0.1"; //$NON-NLS-1$
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 * The trace session state.
46 private TraceSessionState fState
= TraceSessionState
.INACTIVE
;
48 * The trace session path for storing traces.
50 private String fSessionPath
= ""; //$NON-NLS-1$
52 * The domains information of this session.
54 private final List
<IDomainInfo
> fDomains
= new ArrayList
<>();
56 * Flag to indicate whether trace is streamed over network or not.
58 private boolean fIsStreamedTrace
= false;
60 * Flag to indicate whether the session is a snapshot session or not.
62 private boolean fIsSnapshot
= false;
64 * The snapshot information of the session
66 private ISnapshotInfo fSnapshotInfo
= null;
68 * The network URL for the session (-U)
70 private String fNetworkUrl
= null;
72 * The control URL for the session (-C)
74 private String fControlUrl
= null;
76 * The data URL for the session (-D)
78 private String fDataUrl
= null;
81 * Flag to indicate whether trace is live or not.
83 private boolean fIsLive
= false;
86 * The delay in micro seconds before the data is flushed and streamed.
88 private int fLiveDelay
= -1;
91 * The live connection url (Relayd).
93 private String fLiveUrl
;
96 * The live connection port (Relayd).
98 private Integer fLivePort
;
100 // ------------------------------------------------------------------------
102 // ------------------------------------------------------------------------
107 * - name of base event
109 public SessionInfo(String name
) {
117 * - the instance to copy
119 public SessionInfo(SessionInfo other
) {
121 fState
= other
.fState
;
122 fSessionPath
= other
.fSessionPath
;
123 fIsStreamedTrace
= other
.fIsStreamedTrace
;
124 fIsSnapshot
= other
.fIsSnapshot
;
125 fSnapshotInfo
= other
.fSnapshotInfo
;
126 fNetworkUrl
= other
.fNetworkUrl
;
127 fControlUrl
= other
.fControlUrl
;
128 fDataUrl
= other
.fDataUrl
;
130 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
131 IDomainInfo domain
= iterator
.next();
132 if (domain
instanceof DomainInfo
) {
133 fDomains
.add(new DomainInfo((DomainInfo
) domain
));
135 fDomains
.add(domain
);
140 // ------------------------------------------------------------------------
142 // ------------------------------------------------------------------------
145 public TraceSessionState
getSessionState() {
150 public void setSessionState(TraceSessionState state
) {
155 public void setSessionState(String stateName
) {
156 fState
= TraceSessionState
.valueOfString(stateName
);
160 public String
getSessionPath() {
161 if (isSnapshotSession() && fSnapshotInfo
!= null) {
162 return fSnapshotInfo
.getSnapshotPath();
168 public void setSessionPath(String path
) {
173 public IDomainInfo
[] getDomains() {
174 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
178 public void setDomains(List
<IDomainInfo
> domains
) {
180 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
181 IDomainInfo domainInfo
= iterator
.next();
182 fDomains
.add(domainInfo
);
187 public boolean isStreamedTrace() {
188 return fIsStreamedTrace
;
192 public void setStreamedTrace(boolean isStreamedTrace
) {
193 fIsStreamedTrace
= isStreamedTrace
;
197 public boolean isSnapshotSession() {
198 return fIsSnapshot
|| fSnapshotInfo
!= null;
202 public void setSnapshot(boolean isSnapshot
) {
203 fIsSnapshot
= isSnapshot
;
207 public ISnapshotInfo
getSnapshotInfo() {
208 return fSnapshotInfo
;
212 public void setSnapshotInfo(ISnapshotInfo info
) {
213 fSnapshotInfo
= info
;
217 public boolean isLive() {
222 public void setLive(boolean isLive
) {
227 public int getLiveDelay() {
232 public void setLiveDelay(int liveDelay
) {
233 fLiveDelay
= liveDelay
;
236 // ------------------------------------------------------------------------
238 // ------------------------------------------------------------------------
241 public void addDomain(IDomainInfo domainInfo
) {
242 fDomains
.add(domainInfo
);
245 @SuppressWarnings("nls")
247 public String
toString() {
248 StringBuffer output
= new StringBuffer();
249 output
.append("[SessionInfo(");
250 output
.append(super.toString());
251 output
.append(",Path=");
252 output
.append(getSessionPath());
253 output
.append(",State=");
254 output
.append(fState
);
255 output
.append(",isStreamedTrace=");
256 output
.append(fIsStreamedTrace
);
257 output
.append(",isSnapshot=");
258 output
.append(fIsSnapshot
);
260 if (fSnapshotInfo
!= null) {
261 output
.append(",snapshotInfo=");
262 output
.append(fSnapshotInfo
.toString());
264 output
.append(",Domains=");
265 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
266 IDomainInfo domain
= iterator
.next();
267 output
.append(domain
.toString());
270 output
.append(",NetworkUrl=");
271 output
.append(getNetworkUrl());
272 output
.append(",ControlUrl=");
273 output
.append(getControlUrl());
274 output
.append(",DataUrl=");
275 output
.append(getDataUrl());
278 return output
.toString();
282 public String
getNetworkUrl() {
287 public void setNetworkUrl(String networkUrl
) {
288 fNetworkUrl
= networkUrl
;
292 public String
getControlUrl() {
297 public void setControlUrl(String controlUrl
) {
298 fControlUrl
= controlUrl
;
302 public void setDataUrl(String datalUrl
) {
307 public String
getDataUrl() {
312 public void setLiveUrl(String liveUrl
) {
317 public void setLivePort(Integer livePort
) {
318 fLivePort
= livePort
;
322 public String
getLiveUrl() {
327 public Integer
getLivePort() {