tmf: lttngControl: mi: basic listing support
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / model / impl / SessionInfo.java
1 /**********************************************************************
2
3 * Copyright (c) 2012, 2014 Ericsson
4 *
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
9 *
10 * Contributors:
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 **********************************************************************/
15
16 package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
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;
26
27 /**
28 * Implementation of the trace session interface (ISessionInfo) to store session
29 * related data.
30 *
31 * @author Bernd Hufmann
32 */
33 public class SessionInfo extends TraceInfo implements ISessionInfo {
34
35 /**
36 * The default network URL when creating a live session.
37 */
38 public static final String DEFAULT_LIVE_NETWORK_URK = "net://127.0.0.1"; //$NON-NLS-1$
39
40 // ------------------------------------------------------------------------
41 // Attributes
42 // ------------------------------------------------------------------------
43 /**
44 * The trace session state.
45 */
46 private TraceSessionState fState = TraceSessionState.INACTIVE;
47 /**
48 * The trace session path for storing traces.
49 */
50 private String fSessionPath = ""; //$NON-NLS-1$
51 /**
52 * The domains information of this session.
53 */
54 private final List<IDomainInfo> fDomains = new ArrayList<>();
55 /**
56 * Flag to indicate whether trace is streamed over network or not.
57 */
58 private boolean fIsStreamedTrace = false;
59 /**
60 * Flag to indicate whether the session is a snapshot session or not.
61 */
62 private boolean fIsSnapshot = false;
63 /**
64 * The snapshot information of the session
65 */
66 private ISnapshotInfo fSnapshotInfo = null;
67 /**
68 * The network URL for the session (-U)
69 */
70 private String fNetworkUrl = null;
71 /**
72 * The control URL for the session (-C)
73 */
74 private String fControlUrl = null;
75 /**
76 * The data URL for the session (-D)
77 */
78 private String fDataUrl = null;
79
80 /**
81 * Flag to indicate whether trace is live or not.
82 */
83 private boolean fIsLive = false;
84
85 /**
86 * The delay in micro seconds before the data is flushed and streamed.
87 */
88 private int fLiveDelay = -1;
89
90 /**
91 * The live connection url (Relayd).
92 */
93 private String fLiveUrl;
94
95 /**
96 * The live connection port (Relayd).
97 */
98 private Integer fLivePort;
99
100 // ------------------------------------------------------------------------
101 // Constructors
102 // ------------------------------------------------------------------------
103 /**
104 * Constructor
105 *
106 * @param name
107 * - name of base event
108 */
109 public SessionInfo(String name) {
110 super(name);
111 }
112
113 /**
114 * Copy constructor
115 *
116 * @param other
117 * - the instance to copy
118 */
119 public SessionInfo(SessionInfo other) {
120 super(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;
129
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));
134 } else {
135 fDomains.add(domain);
136 }
137 }
138 }
139
140 // ------------------------------------------------------------------------
141 // Accessors
142 // ------------------------------------------------------------------------
143
144 @Override
145 public TraceSessionState getSessionState() {
146 return fState;
147 }
148
149 @Override
150 public void setSessionState(TraceSessionState state) {
151 fState = state;
152 }
153
154 @Override
155 public void setSessionState(String stateName) {
156 fState = TraceSessionState.valueOfString(stateName);
157 }
158
159 @Override
160 public String getSessionPath() {
161 if (isSnapshotSession() && fSnapshotInfo != null) {
162 return fSnapshotInfo.getSnapshotPath();
163 }
164 return fSessionPath;
165 }
166
167 @Override
168 public void setSessionPath(String path) {
169 fSessionPath = path;
170 }
171
172 @Override
173 public IDomainInfo[] getDomains() {
174 return fDomains.toArray(new IDomainInfo[fDomains.size()]);
175 }
176
177 @Override
178 public void setDomains(List<IDomainInfo> domains) {
179 fDomains.clear();
180 for (Iterator<IDomainInfo> iterator = domains.iterator(); iterator.hasNext();) {
181 IDomainInfo domainInfo = iterator.next();
182 fDomains.add(domainInfo);
183 }
184 }
185
186 @Override
187 public boolean isStreamedTrace() {
188 return fIsStreamedTrace;
189 }
190
191 @Override
192 public void setStreamedTrace(boolean isStreamedTrace) {
193 fIsStreamedTrace = isStreamedTrace;
194 }
195
196 @Override
197 public boolean isSnapshotSession() {
198 return fIsSnapshot || fSnapshotInfo != null;
199 }
200
201 @Override
202 public void setSnapshot(boolean isSnapshot) {
203 fIsSnapshot = isSnapshot;
204 }
205
206 @Override
207 public ISnapshotInfo getSnapshotInfo() {
208 return fSnapshotInfo;
209 }
210
211 @Override
212 public void setSnapshotInfo(ISnapshotInfo info) {
213 fSnapshotInfo = info;
214 }
215
216 @Override
217 public boolean isLive() {
218 return fIsLive;
219 }
220
221 @Override
222 public void setLive(boolean isLive) {
223 fIsLive = isLive;
224 }
225
226 @Override
227 public int getLiveDelay() {
228 return fLiveDelay;
229 }
230
231 @Override
232 public void setLiveDelay(int liveDelay) {
233 fLiveDelay = liveDelay;
234 }
235
236 // ------------------------------------------------------------------------
237 // Operations
238 // ------------------------------------------------------------------------
239
240 @Override
241 public void addDomain(IDomainInfo domainInfo) {
242 fDomains.add(domainInfo);
243 }
244
245 @SuppressWarnings("nls")
246 @Override
247 public String toString() {
248 StringBuffer output = new StringBuffer();
249 output.append("[SessionInfo(");
250 output.append(super.toString());
251 output.append(",Path=");
252 output.append(getSessionPath());
253 output.append(",State=");
254 output.append(fState);
255 output.append(",isStreamedTrace=");
256 output.append(fIsStreamedTrace);
257 output.append(",isSnapshot=");
258 output.append(fIsSnapshot);
259
260 if (fSnapshotInfo != null) {
261 output.append(",snapshotInfo=");
262 output.append(fSnapshotInfo.toString());
263 }
264 output.append(",Domains=");
265 for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
266 IDomainInfo domain = iterator.next();
267 output.append(domain.toString());
268 }
269
270 output.append(",NetworkUrl=");
271 output.append(getNetworkUrl());
272 output.append(",ControlUrl=");
273 output.append(getControlUrl());
274 output.append(",DataUrl=");
275 output.append(getDataUrl());
276
277 output.append(")]");
278 return output.toString();
279 }
280
281 @Override
282 public String getNetworkUrl() {
283 return fNetworkUrl;
284 }
285
286 @Override
287 public void setNetworkUrl(String networkUrl) {
288 fNetworkUrl = networkUrl;
289 }
290
291 @Override
292 public String getControlUrl() {
293 return fControlUrl;
294 }
295
296 @Override
297 public void setControlUrl(String controlUrl) {
298 fControlUrl = controlUrl;
299 }
300
301 @Override
302 public void setDataUrl(String datalUrl) {
303 fDataUrl = datalUrl;
304 }
305
306 @Override
307 public String getDataUrl() {
308 return fDataUrl;
309 }
310
311 @Override
312 public void setLiveUrl(String liveUrl) {
313 fLiveUrl = liveUrl;
314 }
315
316 @Override
317 public void setLivePort(Integer livePort) {
318 fLivePort = livePort;
319 }
320
321 @Override
322 public String getLiveUrl() {
323 return fLiveUrl;
324 }
325
326 @Override
327 public Integer getLivePort() {
328 return fLivePort;
329 }
330 }
This page took 0.041966 seconds and 5 git commands to generate.