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
CommitLineData
eb1bab5b 1/**********************************************************************
0df4af5f 2
60ae41e1 3 * Copyright (c) 2012, 2014 Ericsson
b0318660 4 *
eb1bab5b
BH
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
b0318660
AM
9 *
10 * Contributors:
eb1bab5b 11 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 12 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
81d5dc3a 13 * Marc-Andre Laperle - Support for creating a live session
eb1bab5b 14 **********************************************************************/
0df4af5f 15
9bc60be7 16package org.eclipse.tracecompass.internal.lttng2.control.core.model.impl;
eb1bab5b
BH
17
18import java.util.ArrayList;
19import java.util.Iterator;
20import java.util.List;
21
9bc60be7
AM
22import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
23import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
24import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISnapshotInfo;
25import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
eb1bab5b
BH
26
27/**
eb1bab5b 28 * Implementation of the trace session interface (ISessionInfo) to store session
b0318660 29 * related data.
b0318660 30 *
dbd4432d 31 * @author Bernd Hufmann
eb1bab5b
BH
32 */
33public class SessionInfo extends TraceInfo implements ISessionInfo {
34
81d5dc3a 35 /**
6fd3c6e9 36 * The default network URL when creating a live session.
81d5dc3a 37 */
92fe6900
MAL
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;
81d5dc3a 44
eb1bab5b
BH
45 // ------------------------------------------------------------------------
46 // Attributes
47 // ------------------------------------------------------------------------
48 /**
49 * The trace session state.
50 */
51 private TraceSessionState fState = TraceSessionState.INACTIVE;
b0318660 52 /**
eb1bab5b
BH
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 */
e0838ca1 59 private final List<IDomainInfo> fDomains = new ArrayList<>();
f3b33d40
BH
60 /**
61 * Flag to indicate whether trace is streamed over network or not.
62 */
63 private boolean fIsStreamedTrace = false;
589d0d33
BH
64 /**
65 * Flag to indicate whether the session is a snapshot session or not.
66 */
f7d4d450
MAL
67 private boolean fIsSnapshot = false;
68 /**
69 * The snapshot information of the session
70 */
589d0d33 71 private ISnapshotInfo fSnapshotInfo = null;
f7d4d450
MAL
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;
589d0d33 84
81d5dc3a
MAL
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 */
8634587a 93 private long fLiveDelay = -1;
eb1bab5b 94
6fd3c6e9
MAL
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
eb1bab5b
BH
105 // ------------------------------------------------------------------------
106 // Constructors
107 // ------------------------------------------------------------------------
108 /**
109 * Constructor
0df4af5f
JRJ
110 *
111 * @param name
112 * - name of base event
eb1bab5b
BH
113 */
114 public SessionInfo(String name) {
115 super(name);
116 }
117
118 /**
119 * Copy constructor
0df4af5f
JRJ
120 *
121 * @param other
122 * - the instance to copy
eb1bab5b
BH
123 */
124 public SessionInfo(SessionInfo other) {
125 super(other);
126 fState = other.fState;
127 fSessionPath = other.fSessionPath;
f3b33d40 128 fIsStreamedTrace = other.fIsStreamedTrace;
f7d4d450 129 fIsSnapshot = other.fIsSnapshot;
589d0d33 130 fSnapshotInfo = other.fSnapshotInfo;
f7d4d450
MAL
131 fNetworkUrl = other.fNetworkUrl;
132 fControlUrl = other.fControlUrl;
133 fDataUrl = other.fDataUrl;
b0318660 134
eb1bab5b
BH
135 for (Iterator<IDomainInfo> iterator = other.fDomains.iterator(); iterator.hasNext();) {
136 IDomainInfo domain = iterator.next();
137 if (domain instanceof DomainInfo) {
0df4af5f 138 fDomains.add(new DomainInfo((DomainInfo) domain));
eb1bab5b
BH
139 } else {
140 fDomains.add(domain);
141 }
142 }
143 }
b0318660 144
eb1bab5b
BH
145 // ------------------------------------------------------------------------
146 // Accessors
147 // ------------------------------------------------------------------------
11252342 148
eb1bab5b
BH
149 @Override
150 public TraceSessionState getSessionState() {
151 return fState;
152 }
153
eb1bab5b
BH
154 @Override
155 public void setSessionState(TraceSessionState state) {
156 fState = state;
157 }
158
eb1bab5b
BH
159 @Override
160 public void setSessionState(String stateName) {
0df4af5f 161 fState = TraceSessionState.valueOfString(stateName);
eb1bab5b 162 }
b0318660 163
eb1bab5b
BH
164 @Override
165 public String getSessionPath() {
f7d4d450 166 if (isSnapshotSession() && fSnapshotInfo != null) {
589d0d33
BH
167 return fSnapshotInfo.getSnapshotPath();
168 }
eb1bab5b
BH
169 return fSessionPath;
170 }
171
eb1bab5b
BH
172 @Override
173 public void setSessionPath(String path) {
174 fSessionPath = path;
175 }
176
eb1bab5b
BH
177 @Override
178 public IDomainInfo[] getDomains() {
179 return fDomains.toArray(new IDomainInfo[fDomains.size()]);
180 }
181
eb1bab5b
BH
182 @Override
183 public void setDomains(List<IDomainInfo> domains) {
a6702bfa 184 fDomains.clear();
eb1bab5b 185 for (Iterator<IDomainInfo> iterator = domains.iterator(); iterator.hasNext();) {
b0318660 186 IDomainInfo domainInfo = iterator.next();
eb1bab5b
BH
187 fDomains.add(domainInfo);
188 }
189 }
190
f3b33d40
BH
191 @Override
192 public boolean isStreamedTrace() {
80169942
JRJ
193 if (isSnapshotSession() && getSnapshotInfo() != null) {
194 return getSnapshotInfo().isStreamedSnapshot();
195 }
f3b33d40
BH
196 return fIsStreamedTrace;
197 }
198
f3b33d40
BH
199 @Override
200 public void setStreamedTrace(boolean isStreamedTrace) {
201 fIsStreamedTrace = isStreamedTrace;
202 }
203
589d0d33
BH
204 @Override
205 public boolean isSnapshotSession() {
f7d4d450
MAL
206 return fIsSnapshot || fSnapshotInfo != null;
207 }
208
209 @Override
210 public void setSnapshot(boolean isSnapshot) {
211 fIsSnapshot = isSnapshot;
589d0d33 212 }
11252342 213
eb1bab5b 214 @Override
589d0d33
BH
215 public ISnapshotInfo getSnapshotInfo() {
216 return fSnapshotInfo;
eb1bab5b 217 }
b0318660 218
d132bcc7 219 @Override
589d0d33
BH
220 public void setSnapshotInfo(ISnapshotInfo info) {
221 fSnapshotInfo = info;
eb1bab5b
BH
222 }
223
81d5dc3a
MAL
224 @Override
225 public boolean isLive() {
ee8d0c40
MAL
226 // FIXME: Disable Live support until we have a better implementation
227 return fIsLive && false;
81d5dc3a
MAL
228 }
229
230 @Override
231 public void setLive(boolean isLive) {
232 fIsLive = isLive;
233 }
234
235 @Override
8634587a 236 public long getLiveDelay() {
81d5dc3a
MAL
237 return fLiveDelay;
238 }
239
240 @Override
8634587a 241 public void setLiveDelay(long liveDelay) {
81d5dc3a
MAL
242 fLiveDelay = liveDelay;
243 }
244
589d0d33
BH
245 // ------------------------------------------------------------------------
246 // Operations
247 // ------------------------------------------------------------------------
248
eb1bab5b 249 @Override
589d0d33
BH
250 public void addDomain(IDomainInfo domainInfo) {
251 fDomains.add(domainInfo);
eb1bab5b 252 }
d132bcc7 253
eb1bab5b
BH
254 @SuppressWarnings("nls")
255 @Override
256 public String toString() {
257 StringBuffer output = new StringBuffer();
0df4af5f
JRJ
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 }
f7d4d450 278
0df4af5f
JRJ
279 output.append(",NetworkUrl=");
280 output.append(getNetworkUrl());
281 output.append(",ControlUrl=");
282 output.append(getControlUrl());
283 output.append(",DataUrl=");
284 output.append(getDataUrl());
f7d4d450 285
0df4af5f
JRJ
286 output.append(")]");
287 return output.toString();
eb1bab5b 288 }
f7d4d450
MAL
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 }
6fd3c6e9
MAL
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 }
eb1bab5b 339}
This page took 0.088591 seconds and 5 git commands to generate.