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