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
.tracecompass
.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
.tracecompass
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
25 import org
.eclipse
.tracecompass
.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_URL
= "net://127.0.0.1"; //$NON-NLS-1$
41 * The default live port for a live session.
43 public static final int DEFAULT_LIVE_PORT
= 5344;
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
49 * The trace session state.
51 private TraceSessionState fState
= TraceSessionState
.INACTIVE
;
53 * The trace session path for storing traces.
55 private String fSessionPath
= ""; //$NON-NLS-1$
57 * The domains information of this session.
59 private final List
<IDomainInfo
> fDomains
= new ArrayList
<>();
61 * Flag to indicate whether trace is streamed over network or not.
63 private boolean fIsStreamedTrace
= false;
65 * Flag to indicate whether the session is a snapshot session or not.
67 private boolean fIsSnapshot
= false;
69 * The snapshot information of the session
71 private ISnapshotInfo fSnapshotInfo
= null;
73 * The network URL for the session (-U)
75 private String fNetworkUrl
= null;
77 * The control URL for the session (-C)
79 private String fControlUrl
= null;
81 * The data URL for the session (-D)
83 private String fDataUrl
= null;
86 * Flag to indicate whether trace is live or not.
88 private boolean fIsLive
= false;
91 * The delay in micro seconds before the data is flushed and streamed.
93 private long fLiveDelay
= -1;
96 * The live connection url (Relayd).
98 private String fLiveUrl
;
101 * The live connection port (Relayd).
103 private Integer fLivePort
;
105 // ------------------------------------------------------------------------
107 // ------------------------------------------------------------------------
112 * - name of base event
114 public SessionInfo(String name
) {
122 * - the instance to copy
124 public SessionInfo(SessionInfo other
) {
126 fState
= other
.fState
;
127 fSessionPath
= other
.fSessionPath
;
128 fIsStreamedTrace
= other
.fIsStreamedTrace
;
129 fIsSnapshot
= other
.fIsSnapshot
;
130 fSnapshotInfo
= other
.fSnapshotInfo
;
131 fNetworkUrl
= other
.fNetworkUrl
;
132 fControlUrl
= other
.fControlUrl
;
133 fDataUrl
= other
.fDataUrl
;
135 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
136 IDomainInfo domain
= iterator
.next();
137 if (domain
instanceof DomainInfo
) {
138 fDomains
.add(new DomainInfo((DomainInfo
) domain
));
140 fDomains
.add(domain
);
145 // ------------------------------------------------------------------------
147 // ------------------------------------------------------------------------
150 public TraceSessionState
getSessionState() {
155 public void setSessionState(TraceSessionState state
) {
160 public void setSessionState(String stateName
) {
161 fState
= TraceSessionState
.valueOfString(stateName
);
165 public String
getSessionPath() {
166 if (isSnapshotSession() && fSnapshotInfo
!= null) {
167 return fSnapshotInfo
.getSnapshotPath();
173 public void setSessionPath(String path
) {
178 public IDomainInfo
[] getDomains() {
179 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
183 public void setDomains(List
<IDomainInfo
> domains
) {
185 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
186 IDomainInfo domainInfo
= iterator
.next();
187 fDomains
.add(domainInfo
);
192 public boolean isStreamedTrace() {
193 if (isSnapshotSession() && getSnapshotInfo() != null) {
194 return getSnapshotInfo().isStreamedSnapshot();
196 return fIsStreamedTrace
;
200 public void setStreamedTrace(boolean isStreamedTrace
) {
201 fIsStreamedTrace
= isStreamedTrace
;
205 public boolean isSnapshotSession() {
206 return fIsSnapshot
|| fSnapshotInfo
!= null;
210 public void setSnapshot(boolean isSnapshot
) {
211 fIsSnapshot
= isSnapshot
;
215 public ISnapshotInfo
getSnapshotInfo() {
216 return fSnapshotInfo
;
220 public void setSnapshotInfo(ISnapshotInfo info
) {
221 fSnapshotInfo
= info
;
225 public boolean isLive() {
226 // FIXME: Disable Live support until we have a better implementation
227 return fIsLive
&& false;
231 public void setLive(boolean isLive
) {
236 public long getLiveDelay() {
241 public void setLiveDelay(long liveDelay
) {
242 fLiveDelay
= liveDelay
;
245 // ------------------------------------------------------------------------
247 // ------------------------------------------------------------------------
250 public void addDomain(IDomainInfo domainInfo
) {
251 fDomains
.add(domainInfo
);
254 @SuppressWarnings("nls")
256 public String
toString() {
257 StringBuffer output
= new StringBuffer();
258 output
.append("[SessionInfo(");
259 output
.append(super.toString());
260 output
.append(",Path=");
261 output
.append(getSessionPath());
262 output
.append(",State=");
263 output
.append(fState
);
264 output
.append(",isStreamedTrace=");
265 output
.append(fIsStreamedTrace
);
266 output
.append(",isSnapshot=");
267 output
.append(fIsSnapshot
);
269 if (fSnapshotInfo
!= null) {
270 output
.append(",snapshotInfo=");
271 output
.append(fSnapshotInfo
.toString());
273 output
.append(",Domains=");
274 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
275 IDomainInfo domain
= iterator
.next();
276 output
.append(domain
.toString());
279 output
.append(",NetworkUrl=");
280 output
.append(getNetworkUrl());
281 output
.append(",ControlUrl=");
282 output
.append(getControlUrl());
283 output
.append(",DataUrl=");
284 output
.append(getDataUrl());
287 return output
.toString();
291 public String
getNetworkUrl() {
296 public void setNetworkUrl(String networkUrl
) {
297 fNetworkUrl
= networkUrl
;
301 public String
getControlUrl() {
306 public void setControlUrl(String controlUrl
) {
307 fControlUrl
= controlUrl
;
311 public void setDataUrl(String datalUrl
) {
316 public String
getDataUrl() {
321 public void setLiveUrl(String liveUrl
) {
326 public void setLivePort(Integer livePort
) {
327 fLivePort
= livePort
;
331 public String
getLiveUrl() {
336 public Integer
getLivePort() {