Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
6f40b641 | 2 | * Copyright (c) 2012, 2015 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 | **********************************************************************/ |
9bc60be7 | 13 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl; |
eb1bab5b | 14 | |
b957fb8c | 15 | import java.util.ArrayList; |
6503ae0f BH |
16 | import java.util.List; |
17 | ||
18 | import org.eclipse.core.commands.ExecutionException; | |
19 | import org.eclipse.core.runtime.IProgressMonitor; | |
eb1bab5b | 20 | import org.eclipse.swt.graphics.Image; |
1bc37054 | 21 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
9bc60be7 AM |
22 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo; |
23 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo; | |
a20452b1 | 24 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel; |
9bc60be7 AM |
25 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType; |
26 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType; | |
27 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement; | |
9bc60be7 AM |
28 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ChannelInfo; |
29 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ProbeEventInfo; | |
30 | import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; | |
31 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages; | |
32 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
33 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceChannelPropertySource; | |
06b9339e | 34 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
35 | |
36 | ||
37 | /** | |
eb1bab5b BH |
38 | * <p> |
39 | * Implementation of the trace channel component. | |
40 | * </p> | |
cfdb727a | 41 | * |
dbd4432d | 42 | * @author Bernd Hufmann |
eb1bab5b BH |
43 | */ |
44 | public class TraceChannelComponent extends TraceControlComponent { | |
11252342 | 45 | |
eb1bab5b BH |
46 | // ------------------------------------------------------------------------ |
47 | // Constants | |
48 | // ------------------------------------------------------------------------ | |
11252342 | 49 | |
eb1bab5b BH |
50 | /** |
51 | * Path to icon file for this component (state enabled). | |
52 | */ | |
53 | public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$ | |
54 | /** | |
55 | * Path to icon file for this component (state disabled). | |
56 | */ | |
57 | public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$ | |
cfdb727a | 58 | |
eb1bab5b BH |
59 | // ------------------------------------------------------------------------ |
60 | // Attributes | |
61 | // ------------------------------------------------------------------------ | |
11252342 | 62 | |
eb1bab5b BH |
63 | /** |
64 | * The channel information. | |
65 | */ | |
66 | private IChannelInfo fChannelInfo = null; | |
67 | /** | |
68 | * The image to be displayed in disabled state. | |
69 | */ | |
70 | private Image fDisabledImage = null; | |
cfdb727a | 71 | |
eb1bab5b BH |
72 | // ------------------------------------------------------------------------ |
73 | // Constructors | |
74 | // ------------------------------------------------------------------------ | |
11252342 | 75 | |
eb1bab5b | 76 | /** |
cfdb727a | 77 | * Constructor |
eb1bab5b BH |
78 | * @param name - the name of the component. |
79 | * @param parent - the parent of this component. | |
80 | */ | |
81 | public TraceChannelComponent(String name, ITraceControlComponent parent) { | |
82 | super(name, parent); | |
83 | setImage(TRACE_CHANNEL_ICON_FILE_ENABLED); | |
84 | setToolTip(Messages.TraceControl_ChannelDisplayName); | |
85 | fChannelInfo = new ChannelInfo(name); | |
31a6a4e4 | 86 | fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED); |
eb1bab5b | 87 | } |
cfdb727a | 88 | |
eb1bab5b BH |
89 | // ------------------------------------------------------------------------ |
90 | // Accessors | |
91 | // ------------------------------------------------------------------------ | |
11252342 | 92 | |
eb1bab5b BH |
93 | @Override |
94 | public Image getImage() { | |
95 | if (fChannelInfo.getState() == TraceEnablement.DISABLED) { | |
96 | return fDisabledImage; | |
97 | } | |
98 | return super.getImage(); | |
99 | } | |
100 | ||
101 | /** | |
102 | * Sets the channel information. | |
cfdb727a | 103 | * |
eb1bab5b | 104 | * @param channelInfo |
cfdb727a | 105 | * The channel info to assign to this component |
eb1bab5b BH |
106 | */ |
107 | public void setChannelInfo(IChannelInfo channelInfo) { | |
108 | fChannelInfo = channelInfo; | |
109 | IEventInfo[] events = fChannelInfo.getEvents(); | |
e0838ca1 | 110 | List<ITraceControlComponent> eventComponents = new ArrayList<>(); |
eb1bab5b | 111 | for (int i = 0; i < events.length; i++) { |
d132bcc7 BH |
112 | TraceEventComponent event = null; |
113 | if (events[i].getClass() == ProbeEventInfo.class) { | |
114 | event = new TraceProbeEventComponent(events[i].getName(), this); | |
115 | } else { | |
116 | event = new TraceEventComponent(events[i].getName(), this); | |
117 | } | |
118 | ||
b957fb8c | 119 | eventComponents.add(event); |
eb1bab5b | 120 | event.setEventInfo(events[i]); |
b957fb8c BH |
121 | } |
122 | if (!eventComponents.isEmpty()) { | |
123 | setChildren(eventComponents); | |
eb1bab5b BH |
124 | } |
125 | } | |
126 | ||
127 | /** | |
128 | * @return the overwrite mode value. | |
129 | */ | |
130 | public boolean isOverwriteMode() { | |
131 | return fChannelInfo.isOverwriteMode(); | |
132 | } | |
133 | /** | |
134 | * Sets the overwrite mode value to the given mode. | |
135 | * @param mode - mode to set. | |
136 | */ | |
137 | public void setOverwriteMode(boolean mode){ | |
138 | fChannelInfo.setOverwriteMode(mode); | |
139 | } | |
140 | /** | |
141 | * @return the sub-buffer size. | |
142 | */ | |
143 | public long getSubBufferSize() { | |
144 | return fChannelInfo.getSubBufferSize(); | |
145 | } | |
146 | /** | |
147 | * Sets the sub-buffer size to the given value. | |
148 | * @param bufferSize - size to set to set. | |
149 | */ | |
150 | public void setSubBufferSize(long bufferSize) { | |
151 | fChannelInfo.setSubBufferSize(bufferSize); | |
152 | } | |
153 | /** | |
154 | * @return the number of sub-buffers. | |
155 | */ | |
156 | public int getNumberOfSubBuffers() { | |
157 | return fChannelInfo.getNumberOfSubBuffers(); | |
158 | } | |
159 | /** | |
160 | * Sets the number of sub-buffers to the given value. | |
161 | * @param numberOfSubBuffers - value to set. | |
162 | */ | |
163 | public void setNumberOfSubBuffers(int numberOfSubBuffers) { | |
164 | fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers); | |
165 | } | |
166 | /** | |
167 | * @return the switch timer interval. | |
168 | */ | |
169 | public long getSwitchTimer() { | |
170 | return fChannelInfo.getSwitchTimer(); | |
171 | } | |
172 | /** | |
173 | * Sets the switch timer interval to the given value. | |
174 | * @param timer - timer value to set. | |
175 | */ | |
176 | public void setSwitchTimer(long timer) { | |
177 | fChannelInfo.setSwitchTimer(timer); | |
178 | } | |
179 | /** | |
180 | * @return the read timer interval. | |
181 | */ | |
182 | public long getReadTimer() { | |
cfdb727a | 183 | return fChannelInfo.getReadTimer(); |
eb1bab5b BH |
184 | } |
185 | /** | |
186 | * Sets the read timer interval to the given value. | |
187 | * @param timer - timer value to set.. | |
188 | */ | |
189 | public void setReadTimer(long timer) { | |
190 | fChannelInfo.setReadTimer(timer); | |
191 | } | |
192 | /** | |
193 | * @return the output type. | |
194 | */ | |
0ad9fc89 | 195 | public TraceChannelOutputType getOutputType() { |
eb1bab5b BH |
196 | return fChannelInfo.getOutputType(); |
197 | } | |
0ad9fc89 JRJ |
198 | /** |
199 | * Sets the output type to the given value. | |
200 | * @param type - type to set. | |
201 | */ | |
202 | public void setOutputType(TraceChannelOutputType type) { | |
203 | fChannelInfo.setOutputType(type); | |
204 | } | |
eb1bab5b BH |
205 | /** |
206 | * Sets the output type to the given value. | |
207 | * @param type - type to set. | |
208 | */ | |
209 | public void setOutputType(String type) { | |
210 | fChannelInfo.setOutputType(type); | |
211 | } | |
0ad9fc89 | 212 | |
eb1bab5b BH |
213 | /** |
214 | * @return the channel state (enabled or disabled). | |
215 | */ | |
216 | public TraceEnablement getState() { | |
217 | return fChannelInfo.getState(); | |
218 | } | |
219 | /** | |
220 | * Sets the channel state (enablement) to the given value. | |
221 | * @param state - state to set. | |
222 | */ | |
223 | public void setState(TraceEnablement state) { | |
224 | fChannelInfo.setState(state); | |
225 | } | |
226 | /** | |
227 | * Sets the channel state (enablement) to the value specified by the given name. | |
228 | * @param stateName - state to set. | |
229 | */ | |
230 | public void setState(String stateName) { | |
231 | fChannelInfo.setState(stateName); | |
232 | } | |
11252342 | 233 | |
79175662 BR |
234 | /** |
235 | * @return number of discarded events | |
236 | */ | |
237 | public long getNumberOfDiscardedEvents() { | |
238 | return fChannelInfo.getNumberOfDiscardedEvents(); | |
239 | } | |
240 | /** | |
241 | * @return number of lost packets | |
242 | */ | |
243 | public long getNumberOfLostPackets() { | |
244 | return fChannelInfo.getNumberOfLostPackets(); | |
245 | } | |
246 | ||
6f40b641 BH |
247 | /** |
248 | * @return maximum size of trace files | |
249 | */ | |
250 | public long getMaxSizeTraceFiles() { | |
251 | return fChannelInfo.getMaxSizeTraceFiles(); | |
252 | } | |
253 | /** | |
254 | * @return maximum number of trace files | |
255 | */ | |
256 | public int getMaxNumberTraceFiles() { | |
257 | return fChannelInfo.getMaxNumberTraceFiles(); | |
258 | } | |
259 | ||
06b9339e | 260 | @Override |
e58fe1d5 | 261 | public <T> T getAdapter(Class<T> adapter) { |
06b9339e | 262 | if (adapter == IPropertySource.class) { |
e58fe1d5 | 263 | return adapter.cast(new TraceChannelPropertySource(this)); |
06b9339e BH |
264 | } |
265 | return null; | |
cfdb727a | 266 | } |
bbb3538a BH |
267 | |
268 | /** | |
269 | * @return session name from parent | |
270 | */ | |
271 | public String getSessionName() { | |
cfdb727a | 272 | return ((TraceDomainComponent)getParent()).getSessionName(); |
bbb3538a BH |
273 | } |
274 | ||
6503ae0f BH |
275 | /** |
276 | * @return session from parent | |
277 | */ | |
278 | public TraceSessionComponent getSession() { | |
cfdb727a | 279 | return ((TraceDomainComponent)getParent()).getSession(); |
6503ae0f BH |
280 | } |
281 | ||
bbb3538a | 282 | /** |
1bc37054 | 283 | * @return the domain type ({@link TraceDomainType}) |
bbb3538a | 284 | */ |
1bc37054 BR |
285 | public TraceDomainType getDomain() { |
286 | return ((TraceDomainComponent)getParent()).getDomain(); | |
bbb3538a | 287 | } |
cfdb727a | 288 | |
498704b3 BH |
289 | /** |
290 | * @return the parent target node | |
291 | */ | |
292 | public TargetNodeComponent getTargetNode() { | |
293 | return ((TraceDomainComponent)getParent()).getTargetNode(); | |
294 | } | |
cfdb727a | 295 | |
eb1bab5b BH |
296 | // ------------------------------------------------------------------------ |
297 | // Operations | |
298 | // ------------------------------------------------------------------------ | |
6503ae0f BH |
299 | |
300 | /** | |
301 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
302 | * |
303 | * @param eventNames | |
304 | * - a list of event names to enabled. | |
305 | * @param monitor | |
306 | * - a progress monitor | |
6503ae0f | 307 | * @throws ExecutionException |
cfdb727a | 308 | * If the command fails |
6503ae0f | 309 | */ |
498704b3 | 310 | public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException { |
91dc1c3e | 311 | enableEvents(eventNames, null, null, monitor); |
d4514365 BH |
312 | } |
313 | ||
314 | /** | |
315 | * Enables a list of events with no additional parameters. | |
316 | * | |
317 | * @param eventNames | |
318 | * - a list of event names to enabled. | |
319 | * @param filterExpression | |
320 | * - a filter expression | |
91dc1c3e BR |
321 | * @param excludedEvents |
322 | * - a list of events to exclude. | |
d4514365 BH |
323 | * @param monitor |
324 | * - a progress monitor | |
325 | * @throws ExecutionException | |
326 | * If the command fails | |
327 | */ | |
91dc1c3e | 328 | public void enableEvents(List<String> eventNames, String filterExpression, List<String> excludedEvents, IProgressMonitor monitor) throws ExecutionException { |
1bc37054 | 329 | getControlService().enableEvents(getSessionName(), getName(), eventNames, getDomain(), filterExpression, excludedEvents, monitor); |
498704b3 | 330 | } |
cfdb727a | 331 | |
498704b3 BH |
332 | /** |
333 | * Enables all syscalls (for kernel domain) | |
cfdb727a | 334 | * |
207ff523 BR |
335 | * @param syscallNames |
336 | * - a list of syscall to enable | |
cfdb727a AM |
337 | * @param monitor |
338 | * - a progress monitor | |
498704b3 | 339 | * @throws ExecutionException |
cfdb727a | 340 | * If the command fails |
498704b3 | 341 | */ |
207ff523 BR |
342 | public void enableSyscalls(List<String> syscallNames, IProgressMonitor monitor) throws ExecutionException { |
343 | getControlService().enableSyscalls(getSessionName(), getName(), syscallNames, monitor); | |
498704b3 BH |
344 | } |
345 | ||
498704b3 BH |
346 | /** |
347 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
348 | * |
349 | * @param eventName | |
350 | * - event name for probe | |
351 | * @param isFunction | |
352 | * - true for dynamic function entry/return probe else false | |
353 | * @param probe | |
354 | * - the actual probe | |
355 | * @param monitor | |
356 | * - a progress monitor | |
498704b3 | 357 | * @throws ExecutionException |
cfdb727a | 358 | * If the command fails |
498704b3 | 359 | */ |
cfdb727a AM |
360 | public void enableProbe(String eventName, boolean isFunction, String probe, |
361 | IProgressMonitor monitor) throws ExecutionException { | |
d132bcc7 | 362 | getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor); |
498704b3 BH |
363 | } |
364 | ||
ccc66d01 BH |
365 | /** |
366 | * Enables events using log level. | |
cfdb727a | 367 | * |
a20452b1 BR |
368 | * @param eventNames |
369 | * - a list of event names | |
cfdb727a AM |
370 | * @param logLevelType |
371 | * - a log level type | |
372 | * @param level | |
373 | * - a log level | |
d4514365 BH |
374 | * @param filterExpression |
375 | * - a filter expression | |
a20452b1 BR |
376 | * @param domain |
377 | * - the domain type ({@link TraceDomainType}) | |
cfdb727a AM |
378 | * @param monitor |
379 | * - a progress monitor | |
ccc66d01 | 380 | * @throws ExecutionException |
cfdb727a | 381 | * If the command fails |
ccc66d01 | 382 | */ |
a20452b1 BR |
383 | public void enableLogLevel(List<String> eventNames, LogLevelType logLevelType, |
384 | ITraceLogLevel level, String filterExpression, TraceDomainType domain, IProgressMonitor monitor) | |
cfdb727a | 385 | throws ExecutionException { |
a20452b1 | 386 | getControlService().enableLogLevel(getSessionName(), getName(), eventNames, logLevelType, level, filterExpression, domain, monitor); |
ccc66d01 BH |
387 | } |
388 | ||
6503ae0f BH |
389 | /** |
390 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
391 | * |
392 | * @param eventNames | |
393 | * - a list of event names to enabled. | |
394 | * @param monitor | |
395 | * - a progress monitor | |
6503ae0f | 396 | * @throws ExecutionException |
cfdb727a | 397 | * If the command fails |
6503ae0f | 398 | */ |
cfdb727a AM |
399 | public void disableEvent(List<String> eventNames, IProgressMonitor monitor) |
400 | throws ExecutionException { | |
401 | getControlService().disableEvent(getParent().getParent().getName(), | |
1bc37054 | 402 | getName(), eventNames, getDomain(), monitor); |
6503ae0f | 403 | } |
cfdb727a | 404 | |
b793fbe1 BH |
405 | /** |
406 | * Add contexts to given channels and or events | |
cfdb727a AM |
407 | * |
408 | * @param contexts | |
409 | * - a list of contexts to add | |
410 | * @param monitor | |
411 | * - a progress monitor | |
b793fbe1 | 412 | * @throws ExecutionException |
cfdb727a | 413 | * If the command fails |
b793fbe1 | 414 | */ |
cfdb727a AM |
415 | public void addContexts(List<String> contexts, IProgressMonitor monitor) |
416 | throws ExecutionException { | |
417 | getControlService().addContexts(getSessionName(), getName(), null, | |
1bc37054 | 418 | getDomain(), contexts, monitor); |
b793fbe1 | 419 | } |
eb1bab5b | 420 | } |