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 if (isSnapshotSession() && getSnapshotInfo() != null) {
189 return getSnapshotInfo().isStreamedSnapshot();
191 return fIsStreamedTrace
;
195 public void setStreamedTrace(boolean isStreamedTrace
) {
196 fIsStreamedTrace
= isStreamedTrace
;
200 public boolean isSnapshotSession() {
201 return fIsSnapshot
|| fSnapshotInfo
!= null;
205 public void setSnapshot(boolean isSnapshot
) {
206 fIsSnapshot
= isSnapshot
;
210 public ISnapshotInfo
getSnapshotInfo() {
211 return fSnapshotInfo
;
215 public void setSnapshotInfo(ISnapshotInfo info
) {
216 fSnapshotInfo
= info
;
220 public boolean isLive() {
225 public void setLive(boolean isLive
) {
230 public int getLiveDelay() {
235 public void setLiveDelay(int liveDelay
) {
236 fLiveDelay
= liveDelay
;
239 // ------------------------------------------------------------------------
241 // ------------------------------------------------------------------------
244 public void addDomain(IDomainInfo domainInfo
) {
245 fDomains
.add(domainInfo
);
248 @SuppressWarnings("nls")
250 public String
toString() {
251 StringBuffer output
= new StringBuffer();
252 output
.append("[SessionInfo(");
253 output
.append(super.toString());
254 output
.append(",Path=");
255 output
.append(getSessionPath());
256 output
.append(",State=");
257 output
.append(fState
);
258 output
.append(",isStreamedTrace=");
259 output
.append(fIsStreamedTrace
);
260 output
.append(",isSnapshot=");
261 output
.append(fIsSnapshot
);
263 if (fSnapshotInfo
!= null) {
264 output
.append(",snapshotInfo=");
265 output
.append(fSnapshotInfo
.toString());
267 output
.append(",Domains=");
268 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
269 IDomainInfo domain
= iterator
.next();
270 output
.append(domain
.toString());
273 output
.append(",NetworkUrl=");
274 output
.append(getNetworkUrl());
275 output
.append(",ControlUrl=");
276 output
.append(getControlUrl());
277 output
.append(",DataUrl=");
278 output
.append(getDataUrl());
281 return output
.toString();
285 public String
getNetworkUrl() {
290 public void setNetworkUrl(String networkUrl
) {
291 fNetworkUrl
= networkUrl
;
295 public String
getControlUrl() {
300 public void setControlUrl(String controlUrl
) {
301 fControlUrl
= controlUrl
;
305 public void setDataUrl(String datalUrl
) {
310 public String
getDataUrl() {
315 public void setLiveUrl(String liveUrl
) {
320 public void setLivePort(Integer livePort
) {
321 fLivePort
= livePort
;
325 public String
getLiveUrl() {
330 public Integer
getLivePort() {