55eac043337abba5dc7a64bcbda2ac880b51b62c
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.ui / src / org / eclipse / tracecompass / internal / lttng2 / kernel / ui / criticalpath / CriticalPathParameterProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
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
10 package org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath;
11
12 import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule;
13 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
14 import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfThreadSelectedSignal;
15 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.LttngWorker;
16 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
17 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisParamProvider;
18 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
19 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
20 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
21
22 /**
23 * Class that provides parameters to the critical path analysis for lttng kernel
24 * traces
25 *
26 * @author Geneviève Bastien
27 */
28 public class CriticalPathParameterProvider extends TmfAbstractAnalysisParamProvider {
29
30 private static final String NAME = "Critical Path Lttng kernel parameter provider"; //$NON-NLS-1$
31
32 private HostThread fCurrentHostThread = null;
33
34 /**
35 * Constructor
36 */
37 public CriticalPathParameterProvider() {
38 super();
39 TmfSignalManager.register(this);
40 }
41
42 @Override
43 public String getName() {
44 return NAME;
45 }
46
47 @Override
48 public Object getParameter(String name) {
49 if (name.equals(CriticalPathModule.PARAM_WORKER)) {
50 final HostThread currentHostThread = fCurrentHostThread;
51 if (currentHostThread == null) {
52 return null;
53 }
54 /* Try to find the worker for the critical path */
55 IAnalysisModule mod = getModule();
56 if ((mod != null) && (mod instanceof CriticalPathModule)) {
57 LttngWorker worker = new LttngWorker(currentHostThread, "", 0); //$NON-NLS-1$
58 return worker;
59 }
60 }
61 return null;
62 }
63
64 @Override
65 public boolean appliesToTrace(ITmfTrace trace) {
66 return true;
67 }
68
69 private void setCurrentHostThread(HostThread hostThread) {
70 if (!hostThread.equals(fCurrentHostThread)) {
71 fCurrentHostThread = hostThread;
72 notifyParameterChanged(CriticalPathModule.PARAM_WORKER);
73 }
74 }
75
76 /**
77 * Signal handler to know that a thread was selected
78 *
79 * @param signal
80 * the thread was selected
81 */
82 @TmfSignalHandler
83 public void tmfThreadSelectedSignalHander(TmfThreadSelectedSignal signal) {
84 final TmfThreadSelectedSignal threadSignal = signal;
85 if (threadSignal != null) {
86 setCurrentHostThread(new HostThread(threadSignal.getTraceHost(), threadSignal.getThreadId()));
87 }
88 }
89
90 }
This page took 0.033778 seconds and 4 git commands to generate.