1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 * Marc-Andre Laperle - Support for creating a live session
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
;
16 import java
.util
.ArrayList
;
17 import java
.util
.Iterator
;
18 import java
.util
.List
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISnapshotInfo
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
27 * 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;
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
95 * @param name - name of base event
97 public SessionInfo(String name
) {
103 * @param other - the instance to copy
105 public SessionInfo(SessionInfo other
) {
107 fState
= other
.fState
;
108 fSessionPath
= other
.fSessionPath
;
109 fIsStreamedTrace
= other
.fIsStreamedTrace
;
110 fIsSnapshot
= other
.fIsSnapshot
;
111 fSnapshotInfo
= other
.fSnapshotInfo
;
112 fNetworkUrl
= other
.fNetworkUrl
;
113 fControlUrl
= other
.fControlUrl
;
114 fDataUrl
= other
.fDataUrl
;
116 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
117 IDomainInfo domain
= iterator
.next();
118 if (domain
instanceof DomainInfo
) {
119 fDomains
.add(new DomainInfo((DomainInfo
)domain
));
121 fDomains
.add(domain
);
126 // ------------------------------------------------------------------------
128 // ------------------------------------------------------------------------
131 public TraceSessionState
getSessionState() {
136 public void setSessionState(TraceSessionState state
) {
141 public void setSessionState(String stateName
) {
142 if (TraceSessionState
.INACTIVE
.getInName().equals(stateName
)) {
143 fState
= TraceSessionState
.INACTIVE
;
144 } else if (TraceSessionState
.ACTIVE
.getInName().equals(stateName
)) {
145 fState
= TraceSessionState
.ACTIVE
;
150 public String
getSessionPath() {
151 if (isSnapshotSession() && fSnapshotInfo
!= null) {
152 return fSnapshotInfo
.getSnapshotPath();
158 public void setSessionPath(String path
) {
163 public IDomainInfo
[] getDomains() {
164 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
168 public void setDomains(List
<IDomainInfo
> domains
) {
170 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
171 IDomainInfo domainInfo
= iterator
.next();
172 fDomains
.add(domainInfo
);
177 public boolean isStreamedTrace() {
178 return fIsStreamedTrace
;
182 public void setStreamedTrace(boolean isStreamedTrace
) {
183 fIsStreamedTrace
= isStreamedTrace
;
187 public boolean isSnapshotSession() {
188 return fIsSnapshot
|| fSnapshotInfo
!= null;
192 public void setSnapshot(boolean isSnapshot
) {
193 fIsSnapshot
= isSnapshot
;
197 public ISnapshotInfo
getSnapshotInfo() {
198 return fSnapshotInfo
;
202 public void setSnapshotInfo(ISnapshotInfo info
) {
203 fSnapshotInfo
= info
;
207 public boolean isLive() {
212 public void setLive(boolean isLive
) {
217 public int getLiveDelay() {
222 public void setLiveDelay(int liveDelay
) {
223 fLiveDelay
= liveDelay
;
226 // ------------------------------------------------------------------------
228 // ------------------------------------------------------------------------
231 public void addDomain(IDomainInfo domainInfo
) {
232 fDomains
.add(domainInfo
);
236 @SuppressWarnings("nls")
238 public String
toString() {
239 StringBuffer output
= new StringBuffer();
240 output
.append("[SessionInfo(");
241 output
.append(super.toString());
242 output
.append(",Path=");
243 output
.append(getSessionPath());
244 output
.append(",State=");
245 output
.append(fState
);
246 output
.append(",isStreamedTrace=");
247 output
.append(fIsStreamedTrace
);
248 output
.append(",isSnapshot=");
249 output
.append(fIsSnapshot
);
251 if (fSnapshotInfo
!= null) {
252 output
.append(",snapshotInfo=");
253 output
.append(fSnapshotInfo
.toString());
255 output
.append(",Domains=");
256 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
257 IDomainInfo domain
= iterator
.next();
258 output
.append(domain
.toString());
261 output
.append(",NetworkUrl=");
262 output
.append(getNetworkUrl());
263 output
.append(",ControlUrl=");
264 output
.append(getControlUrl());
265 output
.append(",DataUrl=");
266 output
.append(getDataUrl());
269 return output
.toString();
273 public String
getNetworkUrl() {
278 public void setNetworkUrl(String networkUrl
) {
279 fNetworkUrl
= networkUrl
;
283 public String
getControlUrl() {
288 public void setControlUrl(String controlUrl
) {
289 fControlUrl
= controlUrl
;
293 public void setDataUrl(String datalUrl
) {
298 public String
getDataUrl() {