Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
cfdb727a | 3 | * |
eb1bab5b BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b | 13 | |
bbb3538a BH |
14 | import java.util.List; |
15 | ||
16 | import org.eclipse.core.commands.ExecutionException; | |
17 | import org.eclipse.core.runtime.IProgressMonitor; | |
18 | import org.eclipse.core.runtime.NullProgressMonitor; | |
9315aeee BH |
19 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; |
20 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo; | |
21 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType; | |
22 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
23 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo; | |
24 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; | |
115b4a01 | 25 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
115b4a01 | 26 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceDomainPropertySource; |
06b9339e | 27 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
28 | |
29 | /** | |
eb1bab5b BH |
30 | * <p> |
31 | * Implementation of the trace domain component. | |
32 | * </p> | |
cfdb727a | 33 | * |
dbd4432d | 34 | * @author Bernd Hufmann |
eb1bab5b BH |
35 | */ |
36 | public class TraceDomainComponent extends TraceControlComponent { | |
37 | // ------------------------------------------------------------------------ | |
38 | // Constants | |
39 | // ------------------------------------------------------------------------ | |
40 | /** | |
41 | * Path to icon file for this component. | |
42 | */ | |
43 | public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$ | |
44 | ||
45 | // ------------------------------------------------------------------------ | |
46 | // Attributes | |
47 | // ------------------------------------------------------------------------ | |
48 | /** | |
49 | * The domain information. | |
50 | */ | |
bbb3538a | 51 | private IDomainInfo fDomainInfo = null; |
eb1bab5b BH |
52 | |
53 | // ------------------------------------------------------------------------ | |
54 | // Constructors | |
55 | // ------------------------------------------------------------------------ | |
56 | /** | |
cfdb727a | 57 | * Constructor |
eb1bab5b BH |
58 | * @param name - the name of the component. |
59 | * @param parent - the parent of this component. | |
60 | */ | |
61 | public TraceDomainComponent(String name, ITraceControlComponent parent) { | |
62 | super(name, parent); | |
63 | setImage(TRACE_DOMAIN_ICON_FILE); | |
64 | setToolTip(Messages.TraceControl_DomainDisplayName); | |
65 | fDomainInfo = new DomainInfo(name); | |
66 | } | |
67 | ||
68 | // ------------------------------------------------------------------------ | |
69 | // Accessors | |
70 | // ------------------------------------------------------------------------ | |
71 | /** | |
72 | * Sets the domain information. | |
73 | * @param domainInfo - the domain information to set. | |
74 | */ | |
75 | public void setDomainInfo(IDomainInfo domainInfo) { | |
76 | fDomainInfo = domainInfo; | |
77 | IChannelInfo[] channels = fDomainInfo.getChannels(); | |
78 | for (int i = 0; i < channels.length; i++) { | |
79 | TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this); | |
80 | channel.setChannelInfo(channels[i]); | |
81 | addChild(channel); | |
82 | } | |
83 | } | |
84 | ||
06b9339e BH |
85 | /* |
86 | * (non-Javadoc) | |
115b4a01 | 87 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) |
06b9339e | 88 | */ |
06b9339e BH |
89 | @Override |
90 | public Object getAdapter(Class adapter) { | |
91 | if (adapter == IPropertySource.class) { | |
92 | return new TraceDomainPropertySource(this); | |
93 | } | |
94 | return null; | |
bbb3538a | 95 | } |
cfdb727a | 96 | |
bbb3538a BH |
97 | /** |
98 | * @return session name from parent | |
99 | */ | |
100 | public String getSessionName() { | |
101 | return ((TraceSessionComponent)getParent()).getName(); | |
102 | } | |
cfdb727a | 103 | |
6503ae0f BH |
104 | /** |
105 | * @return session from parent | |
106 | */ | |
107 | public TraceSessionComponent getSession() { | |
cfdb727a | 108 | return (TraceSessionComponent)getParent(); |
6503ae0f BH |
109 | } |
110 | ||
bbb3538a BH |
111 | /** |
112 | * @return true if domain is kernel, false for UST | |
113 | */ | |
114 | public boolean isKernel() { | |
115 | return fDomainInfo.isKernel(); | |
116 | } | |
cfdb727a | 117 | |
bbb3538a | 118 | /** |
cfdb727a | 119 | * Sets whether domain is Kernel domain or UST |
bbb3538a BH |
120 | * @param isKernel true for kernel, false for UST |
121 | */ | |
122 | public void setIsKernel(boolean isKernel) { | |
123 | fDomainInfo.setIsKernel(isKernel); | |
124 | } | |
cfdb727a | 125 | |
6503ae0f BH |
126 | /** |
127 | * @return returns all available channels for this domain. | |
128 | */ | |
129 | public TraceChannelComponent[] getChannels() { | |
130 | List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class); | |
cfdb727a | 131 | return channels.toArray(new TraceChannelComponent[channels.size()]); |
6503ae0f | 132 | } |
cfdb727a | 133 | |
498704b3 BH |
134 | /** |
135 | * @return the parent target node | |
136 | */ | |
137 | public TargetNodeComponent getTargetNode() { | |
138 | return ((TraceSessionComponent)getParent()).getTargetNode(); | |
139 | } | |
bbb3538a | 140 | |
eb1bab5b BH |
141 | // ------------------------------------------------------------------------ |
142 | // Operations | |
143 | // ------------------------------------------------------------------------ | |
cfdb727a | 144 | |
bbb3538a | 145 | /** |
cfdb727a AM |
146 | * Retrieves the session configuration from the node. |
147 | * | |
bbb3538a | 148 | * @throws ExecutionException |
cfdb727a | 149 | * If the command fails |
bbb3538a BH |
150 | */ |
151 | public void getConfigurationFromNode() throws ExecutionException { | |
152 | getConfigurationFromNode(new NullProgressMonitor()); | |
153 | } | |
cfdb727a | 154 | |
bbb3538a | 155 | /** |
cfdb727a AM |
156 | * Retrieves the session configuration from the node. |
157 | * | |
158 | * @param monitor | |
159 | * - a progress monitor | |
bbb3538a | 160 | * @throws ExecutionException |
cfdb727a | 161 | * If the command fails |
bbb3538a BH |
162 | */ |
163 | public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException { | |
164 | TraceSessionComponent session = (TraceSessionComponent) getParent(); | |
165 | session.getConfigurationFromNode(monitor); | |
166 | } | |
cfdb727a | 167 | |
bbb3538a | 168 | /** |
cfdb727a AM |
169 | * Enables channels with given names which are part of this domain. If a |
170 | * given channel doesn't exists it creates a new channel with the given | |
171 | * parameters (or default values if given parameter is null). | |
172 | * | |
173 | * @param channelNames | |
174 | * - a list of channel names to enable on this domain | |
175 | * @param info | |
176 | * - channel information to set for the channel (use null for | |
177 | * default) | |
bbb3538a | 178 | * @throws ExecutionException |
cfdb727a | 179 | * If the command fails |
bbb3538a BH |
180 | */ |
181 | public void enableChannels(List<String> channelNames, IChannelInfo info) throws ExecutionException { | |
182 | enableChannels(channelNames, info, new NullProgressMonitor()); | |
183 | } | |
cfdb727a | 184 | |
bbb3538a | 185 | /** |
cfdb727a AM |
186 | * Enables channels with given names which are part of this domain. If a |
187 | * given channel doesn't exists it creates a new channel with the given | |
188 | * parameters (or default values if given parameter is null). | |
189 | * | |
190 | * @param channelNames | |
191 | * - a list of channel names to enable on this domain | |
192 | * @param info | |
193 | * - channel information to set for the channel (use null for | |
194 | * default) | |
195 | * @param monitor | |
196 | * - a progress monitor | |
bbb3538a | 197 | * @throws ExecutionException |
cfdb727a | 198 | * If the command fails |
bbb3538a | 199 | */ |
cfdb727a AM |
200 | public void enableChannels(List<String> channelNames, IChannelInfo info, |
201 | IProgressMonitor monitor) throws ExecutionException { | |
202 | getControlService().enableChannels(getParent().getName(), channelNames, | |
203 | isKernel(), info, monitor); | |
bbb3538a | 204 | } |
cfdb727a | 205 | |
bbb3538a | 206 | /** |
cfdb727a AM |
207 | * Disables channels with given names which are part of this domain. |
208 | * | |
209 | * @param channelNames | |
210 | * - a list of channel names to enable on this domain | |
bbb3538a | 211 | * @throws ExecutionException |
cfdb727a | 212 | * If the command fails |
bbb3538a | 213 | */ |
cfdb727a AM |
214 | public void disableChannels(List<String> channelNames) |
215 | throws ExecutionException { | |
bbb3538a BH |
216 | disableChannels(channelNames, new NullProgressMonitor()); |
217 | } | |
cfdb727a | 218 | |
bbb3538a | 219 | /** |
cfdb727a AM |
220 | * Disables channels with given names which are part of this domain. |
221 | * | |
222 | * @param channelNames | |
223 | * - a list of channel names to enable on this domain | |
224 | * @param monitor | |
225 | * - a progress monitor | |
bbb3538a | 226 | * @throws ExecutionException |
cfdb727a | 227 | * If the command fails |
bbb3538a | 228 | */ |
cfdb727a AM |
229 | public void disableChannels(List<String> channelNames, |
230 | IProgressMonitor monitor) throws ExecutionException { | |
231 | getControlService().disableChannels(getParent().getName(), | |
232 | channelNames, isKernel(), monitor); | |
498704b3 BH |
233 | } |
234 | ||
235 | /** | |
236 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
237 | * |
238 | * @param eventNames | |
239 | * - a list of event names to enabled. | |
240 | * @param monitor | |
241 | * - a progress monitor | |
498704b3 | 242 | * @throws ExecutionException |
cfdb727a | 243 | * If the command fails |
498704b3 | 244 | */ |
cfdb727a AM |
245 | public void enableEvents(List<String> eventNames, IProgressMonitor monitor) |
246 | throws ExecutionException { | |
247 | getControlService().enableEvents(getSessionName(), null, eventNames, | |
d4514365 | 248 | isKernel(), null, monitor); |
498704b3 BH |
249 | } |
250 | ||
251 | /** | |
252 | * Enables all syscalls (for kernel domain) | |
cfdb727a | 253 | * |
498704b3 | 254 | * @throws ExecutionException |
cfdb727a | 255 | * If the command fails |
498704b3 | 256 | */ |
cfdb727a | 257 | public void enableSyscalls() throws ExecutionException { |
498704b3 BH |
258 | enableSyscalls(new NullProgressMonitor()); |
259 | } | |
260 | ||
cfdb727a AM |
261 | /** |
262 | * Enables all syscalls (for kernel domain) | |
263 | * | |
264 | * @param monitor | |
265 | * - a progress monitor | |
266 | * @throws ExecutionException | |
267 | * If the command fails | |
268 | */ | |
498704b3 | 269 | |
cfdb727a AM |
270 | public void enableSyscalls(IProgressMonitor monitor) |
271 | throws ExecutionException { | |
498704b3 BH |
272 | getControlService().enableSyscalls(getSessionName(), null, monitor); |
273 | } | |
274 | ||
275 | /** | |
276 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
277 | * |
278 | * @param eventName | |
279 | * - event name for probe | |
280 | * @param isFunction | |
281 | * - true for dynamic function entry/return probe else false | |
282 | * @param probe | |
283 | * - the actual probe | |
498704b3 | 284 | * @throws ExecutionException |
cfdb727a | 285 | * If the command fails |
498704b3 | 286 | */ |
cfdb727a AM |
287 | public void enableProbe(String eventName, boolean isFunction, String probe) |
288 | throws ExecutionException { | |
d132bcc7 | 289 | enableProbe(eventName, isFunction, probe, new NullProgressMonitor()); |
498704b3 | 290 | } |
cfdb727a | 291 | |
498704b3 BH |
292 | /** |
293 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
294 | * |
295 | * @param eventName | |
296 | * - event name for probe | |
297 | * @param isFunction | |
298 | * - true for dynamic function entry/return probe else false | |
299 | * @param probe | |
300 | * - the actual probe | |
301 | * @param monitor | |
302 | * - a progress monitor | |
498704b3 | 303 | * @throws ExecutionException |
cfdb727a | 304 | * If the command fails |
498704b3 | 305 | */ |
cfdb727a AM |
306 | public void enableProbe(String eventName, boolean isFunction, String probe, |
307 | IProgressMonitor monitor) throws ExecutionException { | |
308 | getControlService().enableProbe(getSessionName(), null, eventName, | |
309 | isFunction, probe, monitor); | |
498704b3 BH |
310 | } |
311 | ||
ccc66d01 BH |
312 | /** |
313 | * Enables events using log level. | |
cfdb727a AM |
314 | * |
315 | * @param eventName | |
316 | * - a event name | |
317 | * @param logLevelType | |
318 | * - a log level type | |
319 | * @param level | |
320 | * - a log level | |
d4514365 BH |
321 | * @param filterExpression |
322 | * - a filter expression | |
ccc66d01 | 323 | * @throws ExecutionException |
cfdb727a | 324 | * If the command fails |
ccc66d01 | 325 | */ |
cfdb727a | 326 | public void enableLogLevel(String eventName, LogLevelType logLevelType, |
d4514365 BH |
327 | TraceLogLevel level, String filterExpression) throws ExecutionException { |
328 | enableLogLevel(eventName, logLevelType, level, filterExpression, | |
cfdb727a | 329 | new NullProgressMonitor()); |
ccc66d01 BH |
330 | } |
331 | ||
332 | /** | |
333 | * Enables events using log level. | |
cfdb727a AM |
334 | * |
335 | * @param eventName | |
336 | * - a event name | |
337 | * @param logLevelType | |
338 | * - a log level type | |
339 | * @param level | |
340 | * - a log level | |
d4514365 BH |
341 | * @param filterExpression |
342 | * - a filter expression | |
cfdb727a AM |
343 | * @param monitor |
344 | * - a progress monitor | |
ccc66d01 | 345 | * @throws ExecutionException |
cfdb727a | 346 | * If the command fails |
ccc66d01 | 347 | */ |
cfdb727a | 348 | public void enableLogLevel(String eventName, LogLevelType logLevelType, |
d4514365 | 349 | TraceLogLevel level, String filterExpression, IProgressMonitor monitor) |
cfdb727a AM |
350 | throws ExecutionException { |
351 | getControlService().enableLogLevel(getSessionName(), null, eventName, | |
d4514365 | 352 | logLevelType, level, filterExpression, monitor); |
ccc66d01 BH |
353 | } |
354 | ||
b793fbe1 BH |
355 | /** |
356 | * Add contexts to given channels and or events | |
cfdb727a AM |
357 | * |
358 | * @param contexts | |
359 | * - a list of contexts to add | |
b793fbe1 | 360 | * @throws ExecutionException |
cfdb727a | 361 | * If the command fails |
b793fbe1 BH |
362 | */ |
363 | public void addContexts(List<String> contexts) throws ExecutionException { | |
364 | addContexts(contexts, new NullProgressMonitor()); | |
365 | } | |
366 | ||
367 | /** | |
368 | * Add contexts to given channels and or events | |
cfdb727a AM |
369 | * |
370 | * @param contexts | |
371 | * - a list of contexts to add | |
372 | * @param monitor | |
373 | * - a progress monitor | |
b793fbe1 | 374 | * @throws ExecutionException |
cfdb727a | 375 | * If the command fails |
b793fbe1 | 376 | */ |
cfdb727a AM |
377 | public void addContexts(List<String> contexts, IProgressMonitor monitor) |
378 | throws ExecutionException { | |
379 | getControlService().addContexts(getSessionName(), null, null, | |
380 | isKernel(), contexts, monitor); | |
b793fbe1 | 381 | } |
b720ac44 BH |
382 | |
383 | /** | |
384 | * Executes calibrate command to quantify LTTng overhead. | |
cfdb727a | 385 | * |
b720ac44 | 386 | * @throws ExecutionException |
cfdb727a | 387 | * If the command fails |
b720ac44 BH |
388 | */ |
389 | public void calibrate() throws ExecutionException { | |
390 | calibrate(new NullProgressMonitor()); | |
391 | } | |
392 | ||
393 | /** | |
394 | * Executes calibrate command to quantify LTTng overhead. | |
cfdb727a AM |
395 | * |
396 | * @param monitor | |
397 | * - a progress monitor | |
b720ac44 | 398 | * @throws ExecutionException |
cfdb727a | 399 | * If the command fails |
b720ac44 BH |
400 | */ |
401 | public void calibrate(IProgressMonitor monitor) throws ExecutionException { | |
402 | getControlService().calibrate(isKernel(), monitor); | |
403 | } | |
eb1bab5b | 404 | } |