1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
<IDomainInfo
>();
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 ISnapshotInfo fSnapshotInfo
= null;
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
64 * @param name - name of base event
66 public SessionInfo(String name
) {
72 * @param other - the instance to copy
74 public SessionInfo(SessionInfo other
) {
76 fState
= other
.fState
;
77 fSessionPath
= other
.fSessionPath
;
78 fIsStreamedTrace
= other
.fIsStreamedTrace
;
79 fSnapshotInfo
= other
.fSnapshotInfo
;
81 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
82 IDomainInfo domain
= iterator
.next();
83 if (domain
instanceof DomainInfo
) {
84 fDomains
.add(new DomainInfo((DomainInfo
)domain
));
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 public TraceSessionState
getSessionState() {
101 public void setSessionState(TraceSessionState state
) {
106 public void setSessionState(String stateName
) {
107 if (TraceSessionState
.INACTIVE
.getInName().equals(stateName
)) {
108 fState
= TraceSessionState
.INACTIVE
;
109 } else if (TraceSessionState
.ACTIVE
.getInName().equals(stateName
)) {
110 fState
= TraceSessionState
.ACTIVE
;
115 public String
getSessionPath() {
116 if(isSnapshotSession()) {
117 return fSnapshotInfo
.getSnapshotPath();
123 public void setSessionPath(String path
) {
128 public IDomainInfo
[] getDomains() {
129 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
133 public void setDomains(List
<IDomainInfo
> domains
) {
135 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
136 IDomainInfo domainInfo
= iterator
.next();
137 fDomains
.add(domainInfo
);
142 public boolean isStreamedTrace() {
143 if (isSnapshotSession()) {
144 return fSnapshotInfo
.isStreamedSnapshot();
146 return fIsStreamedTrace
;
150 public void setStreamedTrace(boolean isStreamedTrace
) {
151 fIsStreamedTrace
= isStreamedTrace
;
155 public boolean isSnapshotSession() {
156 return fSnapshotInfo
!= null;
160 public ISnapshotInfo
getSnapshotInfo() {
161 return fSnapshotInfo
;
165 public void setSnapshotInfo(ISnapshotInfo info
) {
166 fSnapshotInfo
= info
;
169 // ------------------------------------------------------------------------
171 // ------------------------------------------------------------------------
174 public void addDomain(IDomainInfo domainInfo
) {
175 fDomains
.add(domainInfo
);
179 @SuppressWarnings("nls")
181 public String
toString() {
182 StringBuffer output
= new StringBuffer();
183 output
.append("[SessionInfo(");
184 output
.append(super.toString());
185 output
.append(",Path=");
186 output
.append(getSessionPath());
187 output
.append(",State=");
188 output
.append(fState
);
189 output
.append(",isStreamedTrace=");
190 output
.append(fIsStreamedTrace
);
191 if (fSnapshotInfo
!= null) {
192 output
.append(",snapshotInfo=");
193 output
.append(fSnapshotInfo
.toString());
195 output
.append(",Domains=");
196 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
197 IDomainInfo domain
= iterator
.next();
198 output
.append(domain
.toString());
201 return output
.toString();