1 /*******************************************************************************
2 * Copyright (c) 2011 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 * Polytechnique Montréal - Initial API and implementation
11 * Bernd Hufmann - Productification, enhancements and fixes
13 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.subsystems
;
17 import java
.util
.ArrayList
;
18 import java
.util
.Arrays
;
19 import java
.util
.Vector
;
20 import java
.util
.concurrent
.TimeUnit
;
22 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
23 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
24 import org
.eclipse
.linuxtools
.lttng
.core
.LttngConstants
;
25 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.model
.ProviderResource
;
26 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.model
.TargetResource
;
27 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.model
.TraceResource
;
28 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.model
.TraceResource
.TraceState
;
29 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.model
.config
.TraceConfig
;
30 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.service
.ILttControllerService
;
31 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.service
.LttControllerServiceProxy
;
32 import org
.eclipse
.linuxtools
.lttng
.core
.tracecontrol
.utility
.LiveTraceManager
;
33 import org
.eclipse
.linuxtools
.lttng
.ui
.LTTngUiPlugin
;
34 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.Messages
;
35 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.TraceControlConstants
;
36 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.actions
.ImportToProject
;
37 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.actions
.PauseTrace
;
38 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.connectorservice
.TraceConnectorService
;
39 import org
.eclipse
.rse
.core
.events
.ISystemResourceChangeEvents
;
40 import org
.eclipse
.rse
.core
.events
.SystemResourceChangeEvent
;
41 import org
.eclipse
.rse
.core
.filters
.ISystemFilter
;
42 import org
.eclipse
.rse
.core
.filters
.ISystemFilterPoolReference
;
43 import org
.eclipse
.rse
.core
.model
.IHost
;
44 import org
.eclipse
.rse
.core
.model
.ISystemMessageObject
;
45 import org
.eclipse
.rse
.core
.model
.ISystemRegistry
;
46 import org
.eclipse
.rse
.core
.model
.SystemMessageObject
;
47 import org
.eclipse
.rse
.core
.model
.SystemStartHere
;
48 import org
.eclipse
.rse
.core
.subsystems
.CommunicationsEvent
;
49 import org
.eclipse
.rse
.core
.subsystems
.ICommunicationsListener
;
50 import org
.eclipse
.rse
.core
.subsystems
.IConnectorService
;
51 import org
.eclipse
.rse
.core
.subsystems
.SubSystem
;
52 import org
.eclipse
.rse
.services
.clientserver
.NamePatternMatcher
;
53 import org
.eclipse
.rse
.services
.clientserver
.messages
.SystemMessageException
;
54 import org
.eclipse
.rse
.ui
.SystemBasePlugin
;
55 import org
.eclipse
.swt
.widgets
.Display
;
56 import org
.eclipse
.tm
.tcf
.protocol
.IToken
;
57 import org
.eclipse
.tm
.tcf
.util
.TCFTask
;
60 * <b><u>TraceSubSystem</u></b>
62 * Implementation of the trace subsystem. Provides methods to initialize connections
63 * to the remote system, connection handling, filtering and retrival of remote
64 * system configuration.
67 public class TraceSubSystem
extends SubSystem
implements ICommunicationsListener
{
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
72 private ProviderResource
[] fProviders
; // master list of Providers
74 // ------------------------------------------------------------------------
76 // ------------------------------------------------------------------------
79 * @param connectorService
81 public TraceSubSystem(IHost host
, IConnectorService connectorService
) {
82 super(host
, connectorService
);
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
91 * @see org.eclipse.rse.core.subsystems.SubSystem#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor)
94 public void initializeSubSystem(IProgressMonitor monitor
) {
95 getConnectorService().addCommunicationsListener(this);
100 * @see org.eclipse.rse.core.subsystems.SubSystem#uninitializeSubSystem(org.eclipse.core.runtime.IProgressMonitor)
103 public void uninitializeSubSystem(IProgressMonitor monitor
) {
108 * @see org.eclipse.rse.core.subsystems.SubSystem#getObjectWithAbsoluteName(java.lang.String)
110 * For drag and drop, and clipboard support of remote objects.
112 * Return the remote object within the subsystem that corresponds to the specified unique ID. Because each subsystem maintains it's own objects, it's the responsability of the subsystem to determine how an ID (or key) for a given object maps to
113 * the real object. By default this returns null.
116 public Object
getObjectWithAbsoluteName(String key
) {
122 * @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
125 protected Object
[] internalResolveFilterString(String filterString
, IProgressMonitor monitor
) throws java
.lang
.reflect
.InvocationTargetException
, java
.lang
.InterruptedException
{
127 ProviderResource
[] allProviders
;
130 allProviders
= getAllProviders();
131 } catch (SystemMessageException e
) {
132 SystemBasePlugin
.logError("TraceSubSystem", e
); //$NON-NLS-1$
133 Object
[] children
= new SystemMessageObject
[1];
134 children
[0] = new SystemMessageObject(e
.getSystemMessage(), ISystemMessageObject
.MSGTYPE_ERROR
, null);
138 // Now, subset master list, based on filter string...
139 NamePatternMatcher subsetter
= new NamePatternMatcher(filterString
);
140 Vector
<ProviderResource
> v
= new Vector
<ProviderResource
>();
141 for (int idx
= 0; idx
< allProviders
.length
; idx
++) {
142 if (subsetter
.matches(allProviders
[idx
].getName())) {
143 v
.addElement(allProviders
[idx
]);
150 * @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(java.lang.Object, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
153 protected Object
[] internalResolveFilterString(Object parent
, String filterString
, IProgressMonitor monitor
) throws java
.lang
.reflect
.InvocationTargetException
, java
.lang
.InterruptedException
{
158 * @see org.eclipse.rse.core.subsystems.SubSystem#filterEventFilterCreated(java.lang.Object, org.eclipse.rse.core.filters.ISystemFilter)
161 public void filterEventFilterCreated(Object selectedObject
, ISystemFilter newFilter
) {
162 super.filterEventFilterCreated(selectedObject
, newFilter
);
163 ISystemRegistry registry
= SystemStartHere
.getSystemRegistry();
164 registry
.fireEvent(new SystemResourceChangeEvent(this, ISystemResourceChangeEvents
.EVENT_REFRESH
, null));
168 * @see org.eclipse.rse.core.subsystems.SubSystem#filterEventFilterPoolReferenceCreated(org.eclipse.rse.core.filters.ISystemFilterPoolReference)
171 public void filterEventFilterPoolReferenceCreated(ISystemFilterPoolReference newPoolRef
) {
172 super.filterEventFilterPoolReferenceCreated(newPoolRef
);
173 if (getSystemFilterPoolReferenceManager().getSystemFilterPoolReferenceCount() == 1) {
174 ISystemRegistry registry
= SystemStartHere
.getSystemRegistry();
175 registry
.fireEvent(new SystemResourceChangeEvent(this, ISystemResourceChangeEvents
.EVENT_REFRESH
, null));
180 * Retrieves all provider resources from the remote system and updates local references.
182 * @return provider resources
183 * @throws SystemMessageException
184 * @throws InterruptedException
186 public ProviderResource
[] getAllProviders() throws SystemMessageException
, InterruptedException
{
187 ProviderResource
[] providers
= createProviders();
188 if (fProviders
== null) {
189 fProviders
= providers
;
192 for (int i
= 0; i
< fProviders
.length
; i
++) {
193 for (int j
= 0; j
< providers
.length
; j
++) {
194 if(fProviders
[i
].getName().equals(providers
[j
].getName())) {
195 // Check if all targets already exist
196 fProviders
[i
].refreshTargets(providers
[j
].getTargets());
205 * Get the list of all targets.
207 * @return targets The list of targets.
208 * @throws SystemMessageException
210 public TargetResource
[] getAllTargets() throws SystemMessageException
{
211 ArrayList
<TargetResource
> targets
= new ArrayList
<TargetResource
>();
212 if (fProviders
!= null) {
213 for (int i
= 0; i
< fProviders
.length
; i
++) {
214 targets
.addAll(Arrays
.asList(fProviders
[i
].getTargets()));
217 return targets
.toArray(new TargetResource
[0]);
221 * Get the list of all traces.
223 * @return traces The list of traces.
224 * @throws SystemMessageException
226 public TraceResource
[] getAllTraces() throws SystemMessageException
{
227 ArrayList
<TraceResource
> traces
= new ArrayList
<TraceResource
>();
228 if (fProviders
!= null) {
229 for (int i
= 0; i
< fProviders
.length
; i
++) {
230 ProviderResource provider
= fProviders
[i
];
231 int numTargets
= provider
.getTargets().length
;
232 for (int j
= 0; j
< numTargets
; j
++) {
233 TargetResource target
= provider
.getTargets()[j
];
234 if (provider
.getName().equals(LttngConstants
.Lttng_Provider_Kernel
)) {
235 traces
.addAll(Arrays
.asList(target
.getTraces()));
240 return traces
.toArray(new TraceResource
[0]);
244 * Get the list of all traces for given provider and target.
248 * @returns trace resources
250 public TraceResource
[] getAllTraces(String providerName
, String targetName
) throws SystemMessageException
{
251 ArrayList
<TraceResource
> traces
= new ArrayList
<TraceResource
>();
252 ProviderResource selectedProvider
= null;
253 if (fProviders
!= null) {
254 for (int i
= 0; i
< fProviders
.length
; i
++) {
255 ProviderResource provider
= fProviders
[i
];
256 if (provider
.getName().equals(providerName
)) {
257 selectedProvider
= fProviders
[i
];
262 if (selectedProvider
!= null) {
263 int numTargets
= selectedProvider
.getTargets().length
;
264 for (int j
= 0; j
< numTargets
; j
++) {
265 TargetResource target
= selectedProvider
.getTargets()[j
];
266 if (target
.getName().equals(targetName
)) {
267 traces
.addAll(Arrays
.asList(target
.getTraces()));
273 return traces
.toArray(new TraceResource
[0]);
277 * Finds a trace resource within a given provider and target for a given trace name
279 * @param targetName - target name to be searched
280 * @param traceName - trace name to be searched
281 * @return trace resource or null (if not found)
283 public TraceResource
findTrace(String providerName
, String targetName
, String traceName
) {
284 TraceResource trace
= null;
285 TraceResource
[] traces
;
287 traces
= getAllTraces(providerName
, targetName
);
288 for (int i
= 0; i
< traces
.length
; i
++) {
289 if (traces
[i
].getName().equals(traceName
)) {
294 } catch (SystemMessageException e
) {
295 SystemBasePlugin
.logError("TraceSubSystem", e
); //$NON-NLS-1$
302 * Retrieves the providers from the remote system.
304 private ProviderResource
[] createProviders() throws SystemMessageException
{
305 ProviderResource
[] providers
= null;
308 final ILttControllerService service
= getControllerService();
310 // Create future task
311 providers
= new TCFTask
<ProviderResource
[]>() {
315 // Get provider using Lttng controller service proxy
316 service
.getProviders(new ILttControllerService
.DoneGetProviders() {
319 public void doneGetProviders(IToken token
, Exception error
, String
[] str
) {
326 // Create provider list
327 ProviderResource
[] providers
= new ProviderResource
[str
.length
];
329 for (int i
= 0; i
< str
.length
; i
++) {
330 ProviderResource tempProvider
= new ProviderResource(TraceSubSystem
.this);
331 tempProvider
.setName(str
[i
]);
332 providers
[i
] = tempProvider
;
335 // Notify with provider list
339 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
340 } catch (Exception e
) {
341 if (e
instanceof SystemMessageException
) throw (SystemMessageException
)e
;
342 throw new SystemMessageException(LTTngUiPlugin
.getDefault().getMessage(e
));
345 for (int i
= 0; i
< providers
.length
; i
++) {
346 createTargets(providers
[i
]);
353 * Retrieves the targets for given provider from the remote system.
355 private TargetResource
[] createTargets(final ProviderResource provider
) throws SystemMessageException
{
356 TargetResource
[] targets
;
358 final ILttControllerService service
= getControllerService();
360 // Create future task
361 targets
= new TCFTask
<TargetResource
[]>() {
365 // Get targets using Lttng controller service proxy
366 service
.getTargets(provider
.getName(), new ILttControllerService
.DoneGetTargets() {
369 public void doneGetTargets(IToken token
, Exception error
, String
[] str
) {
377 TargetResource
[] targets
= new TargetResource
[str
.length
];
378 for (int i
= 0; i
< str
.length
; i
++) {
379 TargetResource tempTarget
= new TargetResource(TraceSubSystem
.this);
380 tempTarget
.setName(str
[i
]);
381 tempTarget
.setParent(provider
);
382 targets
[i
] = tempTarget
;
384 // Notify with target list
388 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
389 } catch (Exception e
) {
390 provider
.setTargets(new TargetResource
[0]);
391 if (e
instanceof SystemMessageException
) throw (SystemMessageException
)e
;
392 throw new SystemMessageException(LTTngUiPlugin
.getDefault().getMessage(e
));
395 provider
.setTargets(targets
);
396 for (int i
= 0; i
< targets
.length
; i
++) {
397 if (targets
[i
].getParent().getName().equals(LttngConstants
.Lttng_Provider_Kernel
)) {
398 createTraces(targets
[i
]);
406 * Retrieves the trace instances for a given target from the remote system.
408 private TraceResource
[] createTraces(final TargetResource target
) throws SystemMessageException
{
409 TraceResource
[] traces
;
411 final ILttControllerService service
= getControllerService();
413 // Create future task
414 traces
= new TCFTask
<TraceResource
[]>() {
417 // Get targets using Lttng controller service proxy
418 service
.getTraces(target
.getParent().getName(), target
.getName(), new ILttControllerService
.DoneGetTraces() {
421 public void doneGetTraces(IToken token
, Exception error
, String
[] str
) {
429 TraceResource
[] traces
= new TraceResource
[str
.length
];
430 for (int i
= 0; i
< str
.length
; i
++) {
431 TraceResource trace
= new TraceResource(TraceSubSystem
.this, service
);
432 trace
.setName(str
[i
]);
433 trace
.setParent(target
);
434 trace
.setTraceState(TraceState
.CREATED
);
438 // Notify with trace list
442 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
443 } catch (Exception e
) {
444 target
.setTraces(new TraceResource
[0]);
445 if (e
instanceof SystemMessageException
) throw (SystemMessageException
)e
;
446 throw new SystemMessageException(LTTngUiPlugin
.getDefault().getMessage(e
));
449 target
.setTraces(traces
);
451 // get active trace information (is only supported for kernel traces)
452 createTraceConfigurations(target
, traces
);
457 * Retrieves the trace configurations for the given trace from the remote system.
459 private void createTraceConfigurations(final TargetResource target
, TraceResource
[] traces
) throws SystemMessageException
{
460 if (!target
.isUst() && (traces
.length
> 0)) {
462 String
[] activeTraceNames
;
464 final ILttControllerService service
= getControllerService();
465 activeTraceNames
= new TCFTask
<String
[]>() {
468 // Get targets using Lttng controller service proxy
469 service
.getActiveTraces(target
.getParent().getName(), target
.getName(), new ILttControllerService
.DoneGetActiveTraces() {
472 public void doneGetActiveTraces(IToken token
, Exception error
, String
[] str
) {
479 // Notify with active trace list
483 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
484 } catch (Exception e
) {
485 if (e
instanceof SystemMessageException
) throw (SystemMessageException
)e
;
486 throw new SystemMessageException(LTTngUiPlugin
.getDefault().getMessage(e
));
489 // get active trace information
490 for (int j
= 0; j
< activeTraceNames
.length
; j
++) {
491 final TraceResource trace
= target
.getTrace(activeTraceNames
[j
]);
494 TraceConfig traceConfig
;
497 final ILttControllerService service
= getControllerService();
498 traceConfig
= new TCFTask
<TraceConfig
>() {
501 // Get targets using Lttng controller service proxy
502 service
.getActiveTraceInfo(target
.getParent().getName(), target
.getName(), trace
.getName(), new ILttControllerService
.DoneGetActiveTraceInfo() {
505 public void doneGetActiveTraceInfo(IToken token
, Exception error
, String
[] strArray
) {
512 TraceConfig config
= new TraceConfig();
513 config
.setTraceName(trace
.getName());
514 config
.setTraceTransport(TraceControlConstants
.Lttng_Trace_Transport_Relay
);
515 config
.setIsAppend(false);
516 for (String pair
: strArray
) {
517 String
[] pairArray
= pair
.split(LttngConstants
.Lttng_Control_GetActiveTraceInfoSeparator
);
518 if (pairArray
.length
!= 2) {
521 String param
= pairArray
[0];
522 String value
= pairArray
[1];
523 if (param
.equals(TraceControlConstants
.ACTIVE_TRACE_INFO_PARAM_DESTINATION
)) {
524 if (value
.startsWith(TraceControlConstants
.ACTIVE_TRACE_INFO_DESTINATION_PREFIX_LOCAL
)) {
525 config
.setNetworkTrace(false);
526 config
.setTracePath(value
.substring(TraceControlConstants
.ACTIVE_TRACE_INFO_DESTINATION_PREFIX_LOCAL
.length()));
527 } else if (value
.startsWith(TraceControlConstants
.ACTIVE_TRACE_INFO_DESTINATION_PREFIX_NETWORK
)) {
528 config
.setNetworkTrace(true);
529 config
.setTracePath(value
.substring(TraceControlConstants
.ACTIVE_TRACE_INFO_DESTINATION_PREFIX_NETWORK
.length()));
531 } else if (param
.equals(TraceControlConstants
.ACTIVE_TRACE_INFO_PARAM_NUM_THREAD
)) {
532 config
.setNumChannel(Integer
.valueOf(value
));
533 } else if (param
.equals(TraceControlConstants
.ACTIVE_TRACE_INFO_PARAM_NORMAL_ONLY
)) {
534 if (value
.equals(Boolean
.toString(true))) {
535 config
.setMode(TraceConfig
.NORMAL_MODE
);
537 } else if (param
.equals(TraceControlConstants
.ACTIVE_TRACE_INFO_PARAM_FLIGHT_ONLY
)) {
538 if (value
.equals(Boolean
.toString(true))) {
539 config
.setMode(TraceConfig
.FLIGHT_RECORDER_MODE
);
541 } else if (param
.equals(TraceControlConstants
.ACTIVE_TRACE_INFO_PARAM_ENABLED
)) {
542 if (value
.equals(Boolean
.toString(true))) {
543 trace
.setTraceState(TraceState
.STARTED
);
545 trace
.setTraceState(TraceState
.PAUSED
);
550 // Notify with active trace list
554 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
555 trace
.setTraceConfig(traceConfig
);
556 if (traceConfig
!= null) {
557 if (traceConfig
.isNetworkTrace()) {
558 // stop and restart the network transfer since TCF channel may be different
559 if (fProviders
== null) { // do this only on startup, not on refresh
560 restartTraceNetwork(service
, trace
, traceConfig
);
562 LiveTraceManager
.setLiveTrace(traceConfig
.getTracePath(), true);
565 } catch (Exception e
) {
566 if (e
instanceof SystemMessageException
) throw (SystemMessageException
)e
;
567 throw new SystemMessageException(LTTngUiPlugin
.getDefault().getMessage(e
));
576 * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#communicationsStateChange(org.eclipse.rse.core.subsystems.CommunicationsEvent)
579 public void communicationsStateChange(CommunicationsEvent e
) {
580 switch (e
.getState())
582 case CommunicationsEvent
.BEFORE_CONNECT
:
584 case CommunicationsEvent
.AFTER_CONNECT
:
586 case CommunicationsEvent
.BEFORE_DISCONNECT
:
589 final TraceResource
[] traces
= getAllTraces();
591 StringBuffer traceNames
= new StringBuffer(""); //$NON-NLS-1$
592 String filler
= ""; //$NON-NLS-1$
593 for (int j
= 0; j
< traces
.length
; j
++) {
594 // For network traces, ask user to pause tracing
595 if (traces
[j
].isNetworkTraceAndStarted()) {
596 traceNames
.append(filler
);
597 traceNames
.append(traces
[j
].getName());
599 filler
= ", "; //$NON-NLS-1$
601 if (!"".equals(traceNames
.toString())) { //$NON-NLS-1$
602 final String finalTraceNames
= traceNames
.toString();
603 Display
.getDefault().syncExec(new Runnable() {
607 MessageDialog
.openWarning(Display
.getDefault().getActiveShell(), Messages
.Ltt_ShutdownWarning
, Messages
.Ltt_NetworkTraceRunningWarning
+ ":\n" + finalTraceNames
); //$NON-NLS-1$
610 PauseTrace pauseAction
= new PauseTrace();
611 pauseAction
.setSelectedTraces(new ArrayList
<TraceResource
>(Arrays
.asList(traces
)));
612 pauseAction
.run(null);
614 Thread
.sleep(2000); // allow time for target to pause traces before disconnecting the channel
615 } catch (InterruptedException e
) {
622 if (fProviders
!= null) {
623 // reset all providers and it's children
624 for (int i
= 0; i
< fProviders
.length
; i
++) {
625 fProviders
[i
].removeAllTargets();
630 } catch (SystemMessageException ex
) {
631 SystemBasePlugin
.logError("TraceSubSystem", ex
); //$NON-NLS-1$
634 case CommunicationsEvent
.AFTER_DISCONNECT
:
635 getConnectorService().removeCommunicationsListener(this);
637 case CommunicationsEvent
.CONNECTION_ERROR
:
638 // TODO notify user about the lost connection ?!
639 getConnectorService().removeCommunicationsListener(this);
642 } catch (Exception e1
) {
653 * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#isPassiveCommunicationsListener()
656 public boolean isPassiveCommunicationsListener() {
661 * Returns the trace controller service.
663 * @return trace controller service
666 public LttControllerServiceProxy
getControllerService() throws Exception
{
667 return ((TraceConnectorService
)getConnectorService()).getControllerService();
671 * Stop and restart the network transfer. Only normal channels are written while trace is started.
673 private void restartTraceNetwork(final ILttControllerService service
, final TraceResource trace
, final TraceConfig traceConfig
) throws Exception
{
674 File newDir
= new File(traceConfig
.getTracePath());
675 if (!newDir
.exists()) {
676 boolean created
= newDir
.mkdirs();
678 throw new Exception(Messages
.Lttng_Control_ErrorCreateTracePath
+ ": " + traceConfig
.getTracePath()); //$NON-NLS-1$
680 if (traceConfig
.getProject() != null) {
681 ImportToProject
.linkTrace(getShell(), trace
, traceConfig
.getProject(), traceConfig
.getTraceName());
685 // stop the previous lttd
686 boolean ok
= new TCFTask
<Boolean
>() {
690 // Setup trace transport using Lttng controller service proxy
691 service
.stopWriteTraceNetwork(trace
.getParent().getParent().getName(),
692 trace
.getParent().getName(),
693 traceConfig
.getTraceName(),
694 new ILttControllerService
.DoneStopWriteTraceNetwork() {
697 public void doneStopWriteTraceNetwork(IToken token
, Exception error
, Object str
) {
704 // Notify about success
708 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
714 // lttd will only perform the shutdown after stopWriteTraceNetwork
715 // when it receives the next on_read_subbuffer callback
717 if (trace
.getTraceState() == TraceState
.PAUSED
) {
718 // we need to start the trace to make sure that the network transfer is stopped
719 ok
= new TCFTask
<Boolean
>() {
724 service
.startTrace(trace
.getParent().getParent().getName(),
725 trace
.getParent().getName(),
726 traceConfig
.getTraceName(),
727 new ILttControllerService
.DoneStartTrace() {
730 public void doneStartTrace(IToken token
, Exception error
, Object str
) {
737 // Notify about success
741 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
747 trace
.setTraceState(TraceState
.STARTED
);
749 // wait for the lttd shutdown
752 // return to paused state
753 ok
= new TCFTask
<Boolean
>() {
758 service
.pauseTrace(trace
.getParent().getParent().getName(),
759 trace
.getParent().getName(),
760 traceConfig
.getTraceName(),
761 new ILttControllerService
.DonePauseTrace() {
764 public void donePauseTrace(IToken token
, Exception error
, Object str
) {
771 // Notify about success
775 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);
781 trace
.setTraceState(TraceState
.PAUSED
);
784 // wait for the lttd shutdown
789 new TCFTask
<Boolean
>() {
793 // Setup trace transport using Lttng controller service proxy
794 service
.writeTraceNetwork(trace
.getParent().getParent().getName(),
795 trace
.getParent().getName(),
796 traceConfig
.getTraceName(),
797 traceConfig
.getTracePath(),
798 traceConfig
.getNumChannel(),
799 traceConfig
.getIsAppend(),
801 true, // write only normal channels
802 new ILttControllerService
.DoneWriteTraceNetwork() {
805 public void doneWriteTraceNetwork(IToken token
, Exception error
, Object str
) {
812 // Notify about success
816 }}.get(TraceControlConstants
.DEFAULT_TCF_TASK_TIMEOUT
, TimeUnit
.SECONDS
);