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 **********************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Iterator
;
17 import java
.util
.List
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISnapshotInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
26 * Implementation of the trace session interface (ISessionInfo) to store session
30 * @author Bernd Hufmann
32 public class SessionInfo
extends TraceInfo
implements ISessionInfo
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
38 * The trace session state.
40 private TraceSessionState fState
= TraceSessionState
.INACTIVE
;
42 * The trace session path for storing traces.
44 private String fSessionPath
= ""; //$NON-NLS-1$
46 * The domains information of this session.
48 private final List
<IDomainInfo
> fDomains
= new ArrayList
<>();
50 * Flag to indicate whether trace is streamed over network or not.
52 private boolean fIsStreamedTrace
= false;
54 * Flag to indicate whether the session is a snapshot session or not.
56 private boolean fIsSnapshot
= false;
58 * The snapshot information of the session
60 private ISnapshotInfo fSnapshotInfo
= null;
62 * The network URL for the session (-U)
64 private String fNetworkUrl
= null;
66 * The control URL for the session (-C)
68 private String fControlUrl
= null;
70 * The data URL for the session (-D)
72 private String fDataUrl
= null;
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 * @param name - name of base event
82 public SessionInfo(String name
) {
88 * @param other - the instance to copy
90 public SessionInfo(SessionInfo other
) {
92 fState
= other
.fState
;
93 fSessionPath
= other
.fSessionPath
;
94 fIsStreamedTrace
= other
.fIsStreamedTrace
;
95 fIsSnapshot
= other
.fIsSnapshot
;
96 fSnapshotInfo
= other
.fSnapshotInfo
;
97 fNetworkUrl
= other
.fNetworkUrl
;
98 fControlUrl
= other
.fControlUrl
;
99 fDataUrl
= other
.fDataUrl
;
101 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
102 IDomainInfo domain
= iterator
.next();
103 if (domain
instanceof DomainInfo
) {
104 fDomains
.add(new DomainInfo((DomainInfo
)domain
));
106 fDomains
.add(domain
);
111 // ------------------------------------------------------------------------
113 // ------------------------------------------------------------------------
116 public TraceSessionState
getSessionState() {
121 public void setSessionState(TraceSessionState state
) {
126 public void setSessionState(String stateName
) {
127 if (TraceSessionState
.INACTIVE
.getInName().equals(stateName
)) {
128 fState
= TraceSessionState
.INACTIVE
;
129 } else if (TraceSessionState
.ACTIVE
.getInName().equals(stateName
)) {
130 fState
= TraceSessionState
.ACTIVE
;
135 public String
getSessionPath() {
136 if (isSnapshotSession() && fSnapshotInfo
!= null) {
137 return fSnapshotInfo
.getSnapshotPath();
143 public void setSessionPath(String path
) {
148 public IDomainInfo
[] getDomains() {
149 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
153 public void setDomains(List
<IDomainInfo
> domains
) {
155 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
156 IDomainInfo domainInfo
= iterator
.next();
157 fDomains
.add(domainInfo
);
162 public boolean isStreamedTrace() {
163 return fIsStreamedTrace
;
167 public void setStreamedTrace(boolean isStreamedTrace
) {
168 fIsStreamedTrace
= isStreamedTrace
;
172 public boolean isSnapshotSession() {
173 return fIsSnapshot
|| fSnapshotInfo
!= null;
177 public void setSnapshot(boolean isSnapshot
) {
178 fIsSnapshot
= isSnapshot
;
182 public ISnapshotInfo
getSnapshotInfo() {
183 return fSnapshotInfo
;
187 public void setSnapshotInfo(ISnapshotInfo info
) {
188 fSnapshotInfo
= info
;
191 // ------------------------------------------------------------------------
193 // ------------------------------------------------------------------------
196 public void addDomain(IDomainInfo domainInfo
) {
197 fDomains
.add(domainInfo
);
201 @SuppressWarnings("nls")
203 public String
toString() {
204 StringBuffer output
= new StringBuffer();
205 output
.append("[SessionInfo(");
206 output
.append(super.toString());
207 output
.append(",Path=");
208 output
.append(getSessionPath());
209 output
.append(",State=");
210 output
.append(fState
);
211 output
.append(",isStreamedTrace=");
212 output
.append(fIsStreamedTrace
);
213 output
.append(",isSnapshot=");
214 output
.append(fIsSnapshot
);
216 if (fSnapshotInfo
!= null) {
217 output
.append(",snapshotInfo=");
218 output
.append(fSnapshotInfo
.toString());
220 output
.append(",Domains=");
221 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
222 IDomainInfo domain
= iterator
.next();
223 output
.append(domain
.toString());
226 output
.append(",NetworkUrl=");
227 output
.append(getNetworkUrl());
228 output
.append(",ControlUrl=");
229 output
.append(getControlUrl());
230 output
.append(",DataUrl=");
231 output
.append(getDataUrl());
234 return output
.toString();
238 public String
getNetworkUrl() {
243 public void setNetworkUrl(String networkUrl
) {
244 fNetworkUrl
= networkUrl
;
248 public String
getControlUrl() {
253 public void setControlUrl(String controlUrl
) {
254 fControlUrl
= controlUrl
;
258 public void setDataUrl(String datalUrl
) {
263 public String
getDataUrl() {