Commit | Line | Data |
---|---|---|
e8d771d5 BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2011 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Polytechnique Montréal - Initial API and implementation | |
11 | * Bernd Hufmann - Productification, enhancements and fixes | |
12 | * | |
13 | *******************************************************************************/ | |
6c13869b | 14 | package org.eclipse.linuxtools.lttng.core.tracecontrol.service; |
e8d771d5 | 15 | |
6c13869b | 16 | import org.eclipse.linuxtools.lttng.core.LttngConstants; |
e8d771d5 BH |
17 | import org.eclipse.tm.tcf.core.Command; |
18 | import org.eclipse.tm.tcf.core.ErrorReport; | |
19 | import org.eclipse.tm.tcf.protocol.IChannel; | |
20 | import org.eclipse.tm.tcf.protocol.IToken; | |
21 | ||
22 | /** | |
23 | * <b><u>LttControllerServiceProxy</u></b> | |
24 | * <p> | |
25 | * Provides the mplementation of the ILttControllerService interface for | |
26 | * sending of commands to the remote system. | |
27 | * </p> | |
28 | */ | |
29 | public class LttControllerServiceProxy implements ILttControllerService { | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Attributes | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | private static final short INVALID_ARG_LENGTH = 2; | |
36 | ||
37 | private IChannel fProxychannel; | |
38 | ||
39 | // ------------------------------------------------------------------------ | |
40 | // Constructors | |
41 | // ------------------------------------------------------------------------ | |
42 | public LttControllerServiceProxy(IChannel chan) { | |
43 | fProxychannel = chan; | |
44 | } | |
45 | ||
46 | // ------------------------------------------------------------------------ | |
47 | // Operations | |
48 | // ------------------------------------------------------------------------ | |
49 | ||
50 | /* | |
51 | * (non-Javadoc) | |
52 | * @see org.eclipse.tm.tcf.protocol.IService#getName() | |
53 | * | |
54 | * Return service name, as it appears on the wire - a TCF name of the service. | |
55 | */ | |
56 | @Override | |
57 | public String getName() { | |
58 | return NAME; | |
59 | } | |
60 | ||
61 | /** | |
62 | * Sets the service channel. | |
63 | * @param channel | |
64 | */ | |
65 | public void setChannel(IChannel channel) { | |
66 | fProxychannel = channel; | |
67 | } | |
68 | ||
69 | /* | |
70 | * (non-Javadoc) | |
71 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getProviders(org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetProviders) | |
72 | */ | |
73 | @Override | |
74 | public IToken getProviders(final DoneGetProviders done) { | |
75 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetProviders, new Object[] {}) { | |
76 | @Override | |
77 | public void done(Exception error, Object[] args) { | |
78 | String[] strArray = new String[0]; | |
79 | Object str = null; | |
80 | if (error == null) { | |
81 | assert args.length == INVALID_ARG_LENGTH; | |
82 | error = toDetailedError(toError(args[0]), args[1]); | |
83 | str = args[1]; | |
84 | strArray = toStringArray(str.toString()); | |
85 | } | |
86 | done.doneGetProviders(token, error, strArray); | |
87 | } | |
88 | }.token; | |
89 | } | |
90 | ||
91 | /* | |
92 | * (non-Javadoc) | |
93 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getTargets(java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetTargets) | |
94 | */ | |
95 | @Override | |
96 | public IToken getTargets(String provider, final DoneGetTargets done) { | |
97 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetTargets, new Object[] { provider }) { | |
98 | @Override | |
99 | public void done(Exception error, Object[] args) { | |
100 | String[] strArray = new String[0]; | |
101 | Object str = null; | |
102 | if (error == null) { | |
103 | assert args.length == INVALID_ARG_LENGTH; | |
104 | error = toDetailedError(toError(args[0]), args[1]); | |
105 | str = args[1]; | |
106 | strArray = toStringArray(str.toString()); | |
107 | } | |
108 | done.doneGetTargets(token, error, strArray); | |
109 | } | |
110 | }.token; | |
111 | } | |
112 | ||
113 | /* | |
114 | * (non-Javadoc) | |
115 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getMarkers(java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetMarkers) | |
116 | */ | |
117 | @Override | |
118 | public IToken getMarkers(String provider, String target, final DoneGetMarkers done) { | |
119 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetMarkers, new Object[] { provider, target }) { | |
120 | @Override | |
121 | public void done(Exception error, Object[] args) { | |
122 | String[] strArray = new String[0]; | |
123 | Object str = null; | |
124 | if (error == null) { | |
125 | assert args.length == INVALID_ARG_LENGTH; | |
126 | error = toDetailedError(toError(args[0]), args[1]); | |
127 | str = args[1]; | |
128 | strArray = toStringArray(str.toString()); | |
129 | } | |
130 | done.doneGetMarkers(token, error, strArray); | |
131 | } | |
132 | }.token; | |
133 | } | |
134 | ||
135 | /* | |
136 | * (non-Javadoc) | |
137 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getTraces(java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetTraces) | |
138 | */ | |
139 | @Override | |
140 | public IToken getTraces(String provider, String target, final DoneGetTraces done) { | |
141 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetTraces, new Object[] { provider, target }) { | |
142 | @Override | |
143 | public void done(Exception error, Object[] args) { | |
144 | String[] strArray = new String[0]; | |
145 | Object str = null; | |
146 | if (error == null) { | |
147 | assert args.length == INVALID_ARG_LENGTH; | |
148 | error = toDetailedError(toError(args[0]), args[1]); | |
149 | str = args[1]; | |
150 | strArray = toStringArray(str.toString()); | |
151 | } | |
152 | done.doneGetTraces(token, error, strArray); | |
153 | } | |
154 | }.token; | |
155 | } | |
156 | ||
157 | /* | |
158 | * (non-Javadoc) | |
159 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getActiveTraces(java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetActiveTraces) | |
160 | */ | |
161 | @Override | |
162 | public IToken getActiveTraces(String provider, String target, final DoneGetActiveTraces done) { | |
163 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetActiveTraces, new Object[] { provider, target }) { | |
164 | @Override | |
165 | public void done(Exception error, Object[] args) { | |
166 | String[] strArray = new String[0]; | |
167 | Object str = null; | |
168 | if (error == null) { | |
169 | assert args.length == INVALID_ARG_LENGTH; | |
170 | error = toDetailedError(toError(args[0]), args[1]); | |
171 | str = args[1]; | |
172 | strArray = toStringArray(str.toString()); | |
173 | } | |
174 | done.doneGetActiveTraces(token, error, strArray); | |
175 | } | |
176 | }.token; | |
177 | } | |
178 | ||
179 | /* | |
180 | * (non-Javadoc) | |
181 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getActiveTraceInfo(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetActiveTraceInfo) | |
182 | */ | |
183 | @Override | |
184 | public IToken getActiveTraceInfo(String provider, String target, String trace, final DoneGetActiveTraceInfo done) { | |
185 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetActiveTraceInfo, new Object[] { provider, target, trace }) { | |
186 | @Override | |
187 | public void done(Exception error, Object[] args) { | |
1b70b6dc | 188 | String[] strArray = new String[0]; |
e8d771d5 BH |
189 | Object str = null; |
190 | if (error == null) { | |
191 | assert args.length == INVALID_ARG_LENGTH; | |
192 | error = toDetailedError(toError(args[0]), args[1]); | |
193 | str = args[1]; | |
1b70b6dc | 194 | strArray = toStringArray(str.toString()); |
e8d771d5 | 195 | } |
1b70b6dc | 196 | done.doneGetActiveTraceInfo(token, error, strArray); |
e8d771d5 BH |
197 | } |
198 | }.token; | |
199 | } | |
200 | ||
201 | /* | |
202 | * (non-Javadoc) | |
203 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getChannels(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetChannels) | |
204 | */ | |
205 | @Override | |
206 | public IToken getChannels(String provider, String target, String trace, final DoneGetChannels done) { | |
207 | ||
208 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetChannels, new Object[] { provider, target, trace }) { | |
209 | @Override | |
210 | public void done(Exception error, Object[] args) { | |
211 | String[] strArray = new String[0]; | |
212 | Object str = null; | |
213 | if (error == null) { | |
214 | assert args.length == INVALID_ARG_LENGTH; | |
215 | error = toDetailedError(toError(args[0]), args[1]); | |
216 | str = args[1]; | |
217 | strArray = toStringArray(str.toString()); | |
218 | } | |
219 | done.doneGetChannels(token, error, strArray); | |
220 | } | |
221 | }.token; | |
222 | } | |
223 | ||
224 | /* | |
225 | * (non-Javadoc) | |
226 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setupTrace(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetupTrace) | |
227 | */ | |
228 | @Override | |
229 | public IToken setupTrace(String provider, String target, String trace, final DoneSetupTrace done) { | |
230 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetupTrace, new Object[] { provider, target, trace }) { | |
231 | @Override | |
232 | public void done(Exception error, Object[] args) { | |
233 | Object str = null; | |
234 | if (error == null) { | |
235 | assert args.length == INVALID_ARG_LENGTH; | |
236 | error = toDetailedError(toError(args[0]), args[1]); | |
237 | str = args[1]; | |
238 | } | |
239 | done.doneSetupTrace(token, error, str); | |
240 | } | |
241 | }.token; | |
242 | } | |
243 | ||
244 | /* | |
245 | * (non-Javadoc) | |
246 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setTraceTransport(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetTraceTransport) | |
247 | */ | |
248 | @Override | |
249 | public IToken setTraceTransport(String provider, String target, String trace, String transport, final DoneSetTraceTransport done) { | |
250 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetupTraceTransport, new Object[] { provider, target, trace, transport }) { | |
251 | @Override | |
252 | public void done(Exception error, Object[] args) { | |
253 | Object str = null; | |
254 | if (error == null) { | |
255 | assert args.length == INVALID_ARG_LENGTH; | |
256 | error = toDetailedError(toError(args[0]), args[1]); | |
257 | str = args[1]; | |
258 | } | |
259 | done.doneSetTraceTransport(token, error, str); | |
260 | } | |
261 | }.token; | |
262 | } | |
263 | ||
264 | /* | |
265 | * (non-Javadoc) | |
266 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#getMarkerInfo(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneGetMarkerInfo) | |
267 | */ | |
268 | @Override | |
269 | public IToken getMarkerInfo(String provider, String target, String marker, final DoneGetMarkerInfo done) { | |
270 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_GetMarkerInfo, new Object[] { provider, target, marker }) { | |
271 | @Override | |
272 | public void done(Exception error, Object[] args) { | |
273 | Object str = null; | |
274 | String result = ""; //$NON-NLS-1$ | |
275 | if (error == null) { | |
276 | assert args.length == INVALID_ARG_LENGTH; | |
277 | error = toDetailedError(toError(args[0]), args[1]); | |
278 | str = args[1]; | |
279 | result = str.toString(); | |
280 | if (result.length() > 2) { | |
281 | result = result.substring(1, result.length() - 1); | |
282 | } | |
283 | } | |
284 | done.doneGetMarkerInfo(token, error, result); | |
285 | } | |
286 | }.token; | |
287 | } | |
288 | ||
289 | /* | |
290 | * (non-Javadoc) | |
291 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setMarkerEnable(java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetMarkerEnable) | |
292 | */ | |
293 | @Override | |
294 | public IToken setMarkerEnable(String provider, String target, String marker, Boolean enable, final DoneSetMarkerEnable done) { | |
295 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetMarkerEnable, new Object[] { provider, target, marker, enable }) { | |
296 | @Override | |
297 | public void done(Exception error, Object[] args) { | |
298 | Object str = null; | |
299 | if (error == null) { | |
300 | assert args.length == INVALID_ARG_LENGTH; | |
301 | error = toDetailedError(toError(args[0]), args[1]); | |
302 | str = args[1]; | |
303 | } | |
304 | done.doneSetMarkerEnable(token, error, str); | |
305 | } | |
306 | }.token; | |
307 | } | |
308 | ||
309 | /* | |
310 | * (non-Javadoc) | |
311 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setChannelEnable(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetChannelEnable) | |
312 | */ | |
313 | @Override | |
314 | public IToken setChannelEnable(String provider, String target, String trace, String channel, Boolean enable, final DoneSetChannelEnable done) { | |
315 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetChannelEnable, new Object[] { provider, target, trace, channel, enable }) { | |
316 | @Override | |
317 | public void done(Exception error, Object[] args) { | |
318 | Object str = null; | |
319 | if (error == null) { | |
320 | assert args.length == INVALID_ARG_LENGTH; | |
321 | error = toDetailedError(toError(args[0]), args[1]); | |
322 | str = args[1]; | |
323 | } | |
324 | done.doneSetChannelEnable(token, error, str); | |
325 | } | |
326 | }.token; | |
327 | } | |
328 | ||
329 | /* | |
330 | * (non-Javadoc) | |
331 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setChannelOverwrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetChannelOverwrite) | |
332 | */ | |
333 | @Override | |
334 | public IToken setChannelOverwrite(String provider, String target, String trace, String channel, Boolean overwrite, final DoneSetChannelOverwrite done) { | |
335 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetChannelOverwrite, new Object[] { provider, target, trace, channel, overwrite }) { | |
336 | @Override | |
337 | public void done(Exception error, Object[] args) { | |
338 | Object str = null; | |
339 | if (error == null) { | |
340 | assert args.length == INVALID_ARG_LENGTH; | |
341 | error = toDetailedError(toError(args[0]), args[1]); | |
342 | str = args[1]; | |
343 | } | |
344 | done.doneSetChannelOverwrite(token, error, str); | |
345 | } | |
346 | }.token; | |
347 | } | |
348 | ||
349 | /* | |
350 | * (non-Javadoc) | |
351 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setChannelTimer(java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetChannelTimer) | |
352 | */ | |
353 | @Override | |
354 | public IToken setChannelTimer(String provider, String target, String trace, String channel, long period, final DoneSetChannelTimer done) { | |
355 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetChannelTimer, new Object[] { provider, target, trace, channel, period }) { | |
356 | @Override | |
357 | public void done(Exception error, Object[] args) { | |
358 | Object str = null; | |
359 | if (error == null) { | |
360 | assert args.length == INVALID_ARG_LENGTH; | |
361 | error = toDetailedError(toError(args[0]), args[1]); | |
362 | str = args[1]; | |
363 | } | |
364 | done.doneSetChannelTimer(token, error, str); | |
365 | } | |
366 | }.token; | |
367 | } | |
368 | ||
369 | /* | |
370 | * (non-Javadoc) | |
371 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setChannelSubbufNum(java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetChannelSubbufNum) | |
372 | */ | |
373 | @Override | |
374 | public IToken setChannelSubbufNum(String provider, String target, String trace, String channel, long subbufNum, final DoneSetChannelSubbufNum done) { | |
375 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetChannelSubbufNum, new Object[] { provider, target, trace, channel, subbufNum }) { | |
376 | @Override | |
377 | public void done(Exception error, Object[] args) { | |
378 | Object str = null; | |
379 | if (error == null) { | |
380 | assert args.length == INVALID_ARG_LENGTH; | |
381 | error = toDetailedError(toError(args[0]), args[1]); | |
382 | str = args[1]; | |
383 | } | |
384 | done.doneSetChannelSubbufNum(token, error, str); | |
385 | } | |
386 | }.token; | |
387 | } | |
388 | ||
389 | /* | |
390 | * (non-Javadoc) | |
391 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#setChannelSubbufSize(java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneSetChannelSubbufSize) | |
392 | */ | |
393 | @Override | |
394 | public IToken setChannelSubbufSize(String provider, String target, String trace, String channel, long subbufSize, final DoneSetChannelSubbufSize done) { | |
395 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_SetChannelSubbufSize, new Object[] { provider, target, trace, channel, subbufSize }) { | |
396 | @Override | |
397 | public void done(Exception error, Object[] args) { | |
398 | Object str = null; | |
399 | if (error == null) { | |
400 | assert args.length == INVALID_ARG_LENGTH; | |
401 | error = toDetailedError(toError(args[0]), args[1]); | |
402 | str = args[1]; | |
403 | } | |
404 | done.doneSetChannelSubbufSize(token, error, str); | |
405 | } | |
406 | }.token; | |
407 | } | |
408 | ||
409 | /* | |
410 | * (non-Javadoc) | |
411 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#allocTrace(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneAllocTrace) | |
412 | */ | |
413 | @Override | |
414 | public IToken allocTrace(String provider, String target, String trace, final DoneAllocTrace done) { | |
415 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_AllocTrace, new Object[] { provider, target, trace }) { | |
416 | @Override | |
417 | public void done(Exception error, Object[] args) { | |
418 | Object str = null; | |
419 | if (error == null) { | |
420 | assert args.length == INVALID_ARG_LENGTH; | |
421 | error = toDetailedError(toError(args[0]), args[1]); | |
422 | str = args[1]; | |
423 | } | |
424 | done.doneAllocTrace(token, error, str); | |
425 | } | |
426 | }.token; | |
427 | } | |
428 | ||
429 | /* | |
430 | * (non-Javadoc) | |
431 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#writeTraceLocal(java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, java.lang.Boolean, java.lang.Boolean, java.lang.Boolean, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneWriteTraceLocal) | |
432 | */ | |
433 | @Override | |
434 | public IToken writeTraceLocal(String provider, String target, String trace, String path, int numChannel, Boolean isAppend, Boolean isFlightRecorder, Boolean isNormalOnly, final DoneWriteTraceLocal done) { | |
435 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_WriteTraceLocal, new Object[] { provider, target, trace, path, numChannel, isAppend, isFlightRecorder, isNormalOnly }) { | |
436 | @Override | |
437 | public void done(Exception error, Object[] args) { | |
438 | Object str = null; | |
439 | if (error == null) { | |
440 | assert args.length == INVALID_ARG_LENGTH; | |
441 | error = toDetailedError(toError(args[0]), args[1]); | |
442 | str = args[1]; | |
443 | } | |
444 | done.doneWriteTraceLocal(token, error, str); | |
445 | } | |
446 | }.token; | |
447 | } | |
448 | ||
449 | /* | |
450 | * (non-Javadoc) | |
451 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#writeTraceNetwork(java.lang.String, java.lang.String, java.lang.String, int, java.lang.Boolean, java.lang.Boolean, java.lang.Boolean, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneWriteTraceNetwork) | |
452 | */ | |
453 | @Override | |
1b70b6dc PT |
454 | public IToken writeTraceNetwork(String provider, String target, String trace, String path, int numChannel, Boolean isAppend, Boolean isFlightRecorder, Boolean isNormalOnly, final DoneWriteTraceNetwork done) { |
455 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_WriteTraceNetwork, new Object[] { provider, target, trace, path, numChannel, isAppend, isFlightRecorder, isNormalOnly }) { | |
e8d771d5 BH |
456 | @Override |
457 | public void done(Exception error, Object[] args) { | |
458 | Object str = null; | |
459 | if (error == null) { | |
460 | assert args.length == INVALID_ARG_LENGTH; | |
461 | error = toDetailedError(toError(args[0]), args[1]); | |
462 | str = args[1]; | |
463 | } | |
464 | done.doneWriteTraceNetwork(token, error, str); | |
465 | } | |
466 | }.token; | |
467 | } | |
468 | ||
1b70b6dc PT |
469 | /* |
470 | * (non-Javadoc) | |
471 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#stopWriteTraceNetwork(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneWriteTraceNetwork) | |
472 | */ | |
473 | @Override | |
474 | public IToken stopWriteTraceNetwork(String provider, String target, String trace, final DoneStopWriteTraceNetwork done) { | |
475 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_StopWriteTraceNetwork, new Object[] { provider, target, trace }) { | |
476 | @Override | |
477 | public void done(Exception error, Object[] args) { | |
478 | Object str = null; | |
479 | if (error == null) { | |
480 | assert args.length == INVALID_ARG_LENGTH; | |
481 | error = toDetailedError(toError(args[0]), args[1]); | |
482 | str = args[1]; | |
483 | } | |
484 | done.doneStopWriteTraceNetwork(token, error, str); | |
485 | } | |
486 | }.token; | |
487 | } | |
488 | ||
e8d771d5 BH |
489 | /* |
490 | * (non-Javadoc) | |
491 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#startTrace(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneStartTrace) | |
492 | */ | |
493 | @Override | |
494 | public IToken startTrace(String provider, String target, String trace, final DoneStartTrace done) { | |
495 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_StartTrace, new Object[] { provider, target, trace }) { | |
496 | @Override | |
497 | public void done(Exception error, Object[] args) { | |
498 | Object str = null; | |
499 | if (error == null) { | |
500 | assert args.length == INVALID_ARG_LENGTH; | |
501 | error = toDetailedError(toError(args[0]), args[1]); | |
502 | str = args[1]; | |
503 | } | |
504 | done.doneStartTrace(token, error, str); | |
505 | } | |
506 | }.token; | |
507 | } | |
508 | ||
509 | /* | |
510 | * (non-Javadoc) | |
511 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#pauseTrace(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DonePauseTrace) | |
512 | */ | |
513 | @Override | |
514 | public IToken pauseTrace(String provider, String target, String trace, final DonePauseTrace done) { | |
515 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_PauseTrace, new Object[] { provider, target, trace }) { | |
516 | @Override | |
517 | public void done(Exception error, Object[] args) { | |
518 | Object str = null; | |
519 | if (error == null) { | |
520 | assert args.length == INVALID_ARG_LENGTH; | |
521 | error = toDetailedError(toError(args[0]), args[1]); | |
522 | str = args[1]; | |
523 | } | |
524 | done.donePauseTrace(token, error, str); | |
525 | } | |
526 | }.token; | |
527 | } | |
528 | ||
529 | /* | |
530 | * (non-Javadoc) | |
531 | * @see org.eclipse.linuxtools.lttng.rse.service.ILttControllerService#destroyTrace(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.rse.service.ILttControllerService.DoneDestroyTrace) | |
532 | */ | |
533 | @Override | |
534 | public IToken destroyTrace(String provider, String target, String trace, final DoneDestroyTrace done) { | |
535 | return new Command(fProxychannel, this, LttngConstants.Lttng_Control_DestroyTrace, new Object[] { provider, target, trace }) { | |
536 | @Override | |
537 | public void done(Exception error, Object[] args) { | |
538 | Object str = null; | |
539 | if (error == null) { | |
540 | assert args.length == INVALID_ARG_LENGTH; | |
541 | error = toDetailedError(toError(args[0]), args[1]); | |
542 | str = args[1]; | |
543 | } | |
544 | done.doneDestroyTrace(token, error, str); | |
545 | } | |
546 | }.token; | |
547 | } | |
548 | ||
549 | /* | |
550 | * Converts comma separated string to String array. | |
551 | */ | |
552 | private String[] toStringArray(String list) { | |
553 | if (list.length() > 2) { | |
554 | String temp = list.substring(1, list.length() - 1); | |
555 | String[] str = temp.split(LttngConstants.Lttng_Control_Separator); | |
556 | for (int i = 0; i < str.length; i++) { | |
557 | str[i] = str[i].trim(); | |
558 | } | |
559 | return str; | |
560 | } | |
561 | return new String[0]; | |
562 | } | |
563 | ||
564 | /* | |
565 | * Creates new error report using a given error and a detailed message. | |
566 | */ | |
567 | private Exception toDetailedError(Exception error, Object detail) { | |
568 | if ((error != null) && (error instanceof ErrorReport) && (detail != null)) { | |
569 | error = new ErrorReport(error.getMessage() + "\nDetail: " + detail.toString(), ((ErrorReport) error).getAttributes()); //$NON-NLS-1$ | |
570 | } | |
571 | return error; | |
572 | } | |
573 | } |