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