Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve Thread context from ThreadStatusDataProvider #52

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class Messages extends NLS {
public static String CriticalPathDataProvider_NetworkArrow;
/** Label for unknown arrows */
public static String CriticalPathDataProvider_UnknownArrow;
/** The data provider title text */
public static String CriticalPathDataProviderFactory_title;
/**The data provider description text */
public static String CriticalPathDataProviderFactory_descriptionText;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,30 @@

package org.eclipse.tracecompass.internal.analysis.graph.core.dataprovider;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.graph.core.criticalpath.AbstractCriticalPathModule;
import org.eclipse.tracecompass.analysis.graph.core.criticalpath.OSCriticalPathModule;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor.ProviderType;
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderFactory;
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor;
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfStartAnalysisSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;

/**
* {@link IDataProviderFactory} for the {@link CriticalPathDataProvider}
Expand All @@ -37,6 +45,14 @@ public class OSCriticalPathDataProviderFactory implements IDataProviderFactory {

private final Map<ITmfTrace, OSCriticalPathModule> map = new HashMap<>();


private static final IDataProviderDescriptor DESCRIPTOR = new DataProviderDescriptor.Builder()
.setId(CriticalPathDataProvider.ID)
.setName(Objects.requireNonNull(Messages.CriticalPathDataProviderFactory_title))
.setDescription(Objects.requireNonNull(Messages.CriticalPathDataProviderFactory_descriptionText))
.setProviderType(ProviderType.TIME_GRAPH)
.build();

/**
* Constructor, registers the module with the {@link TmfSignalManager}
*/
Expand All @@ -46,6 +62,16 @@ public OSCriticalPathDataProviderFactory() {

@Override
public @Nullable ITmfTreeDataProvider<? extends ITmfTreeDataModel> createProvider(@NonNull ITmfTrace trace) {
ITmfTrace localTrace = trace;
if (localTrace instanceof TmfExperiment) {
for(ITmfTrace tr: TmfTraceManager.getTraceSet(trace)) {
ITmfTreeDataProvider<? extends ITmfTreeDataModel> pr = createProvider(tr);
if (pr != null) {
return pr;
}
}
}

OSCriticalPathModule module = map.remove(trace);
if (module == null) {
// the DataProviderManager does not negative cache
Expand All @@ -54,6 +80,12 @@ public OSCriticalPathDataProviderFactory() {
return new OSCriticalPathDataProvider(trace, module);
}

@Override
public Collection<IDataProviderDescriptor> getDescriptors(@NonNull ITmfTrace trace) {
// Note: Currently the descriptor will be returned for all types of traces
return Collections.singletonList(DESCRIPTOR);
}

/**
* {@link TmfSignalHandler} for when {@link AbstractCriticalPathModule} is started, as
* the analysis is not registered with the trace, we use this to know to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
CriticalPathDataProvider_GroupArrows=Arrows
CriticalPathDataProvider_NetworkArrow=Network Arrow
CriticalPathDataProvider_UnknownArrow=Unknown Arrow
CriticalPathDataProviderFactory_title=Critical Path
CriticalPathDataProviderFactory_descriptionText=Shows the critical path of a selected thread
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
import org.eclipse.tracecompass.analysis.os.linux.core.model.OsStrings;
import org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus;
import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfThreadSelectedSignal;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
Expand Down Expand Up @@ -78,6 +80,7 @@
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel;
import org.eclipse.tracecompass.tmf.core.response.ITmfResponse;
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
Expand Down Expand Up @@ -177,6 +180,7 @@ public class ThreadStatusDataProvider extends AbstractTmfTraceDataProvider imple

/** Cache for entry metadata */
private final Map<Long, @NonNull Multimap<@NonNull String, @NonNull Object>> fEntryMetadata = new HashMap<>();
private final Map<Long, @NonNull TimeGraphEntryModel> fEntryModel = new HashMap<>();

private IOutputAnnotationProvider fEventAnnotationProvider;

Expand Down Expand Up @@ -274,6 +278,7 @@ public ThreadStatusDataProvider(@NonNull ITmfTrace trace, TmfStateSystemAnalysis

for (TimeGraphEntryModel model : list) {
fEntryMetadata.put(model.getId(), model.getMetadata());
fEntryModel.put(model.getId(), model);
}

if (complete) {
Expand Down Expand Up @@ -825,4 +830,40 @@ public TmfModelResponse<OutputStyleModel> fetchStyle(Map<String, Object> fetchPa
public @NonNull TmfModelResponse<@NonNull AnnotationModel> fetchAnnotations(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
return fEventAnnotationProvider.fetchAnnotations(fetchParameters, monitor);
}

@Override
public @NonNull TmfModelResponse<@NonNull Map<@NonNull String, @NonNull Object>> fetchTreeContext(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
// TODO Auto-generated method stub
fModule.waitForInitialization();
ITmfStateSystem ss = fModule.getStateSystem();
if (ss == null) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
}

/*
* As we are caching the intermediate result, we only want a single thread to
* update them.
*/
synchronized (fBuildMap) {
List<Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(fetchParameters);
if (selectedItems != null && selectedItems.size() > 0) {
Long id = selectedItems.get(0);
TimeGraphEntryModel model = fEntryModel.get(id);
if (model instanceof ThreadEntryModel) {
Map<String, Object> retMap = new HashMap<>();
ThreadEntryModel mod = (ThreadEntryModel) model;
retMap.put("name", mod.getName());
retMap.put("tid", mod.getThreadId());
retMap.put("hostId", getTrace().getHostId());

// Not restful ...
HostThread hostThread = new HostThread(getTrace().getHostId(), mod.getThreadId());
TmfThreadSelectedSignal signal = new TmfThreadSelectedSignal(this, hostThread);
TmfSignalManager.dispatchSignal(signal);
return new TmfModelResponse<>(retMap, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
}
}
return ITimeGraphDataProvider.super.fetchTreeContext(fetchParameters, monitor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 3.1.1.qualifier
Bundle-Version: 3.2.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tracecompass.lttng2.kernel.core;singleton:=true
Bundle-Activator: org.eclipse.tracecompass.internal.lttng2.kernel.core.Activator
Expand All @@ -24,6 +24,7 @@ Export-Package: org.eclipse.tracecompass.internal.lttng2.kernel.core;x-friends:=
org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
org.eclipse.tracecompass.internal.lttng2.kernel.core.criticalpath;x-internal:=true,
org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching;x-friends:="org.eclipse.tracecompass.lttng2.kernel.core.tests",
org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout;x-friends:="org.eclipse.tracecompass.lttng2.kernel.core.tests,org.eclipse.tracecompass.lttng2.kernel.ui",
org.eclipse.tracecompass.lttng2.kernel.core.trace
Expand Down
9 changes: 9 additions & 0 deletions lttng/org.eclipse.tracecompass.lttng2.kernel.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@
class="org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngGraphHandlerBuilder$HandlerBuilderExecutionGraph"
priority="10" />
</extension>
<extension
point="org.eclipse.linuxtools.tmf.core.analysis">
<parameterProvider
class="org.eclipse.tracecompass.internal.lttng2.kernel.core.criticalpath.CriticalPathParameterProvider">
<analysisId
id="org.eclipse.tracecompass.analysis.graph.core.criticalpath">
</analysisId>
</parameterProvider>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath;
package org.eclipse.tracecompass.internal.lttng2.kernel.core.criticalpath;

import org.eclipse.tracecompass.analysis.graph.core.criticalpath.AbstractCriticalPathModule;
import org.eclipse.tracecompass.analysis.graph.core.criticalpath.OSCriticalPathModule;
Expand All @@ -28,6 +28,7 @@
* traces
*
* @author Geneviève Bastien
* @since 3.2
*/
public class CriticalPathParameterProvider extends TmfAbstractAnalysisParamProvider {

Expand Down
9 changes: 0 additions & 9 deletions lttng/org.eclipse.tracecompass.lttng2.kernel.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,4 @@
</perspective>
</type>
</extension>
<extension
point="org.eclipse.linuxtools.tmf.core.analysis">
<parameterProvider
class="org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath.CriticalPathParameterProvider">
<analysisId
id="org.eclipse.tracecompass.analysis.graph.core.criticalpath">
</analysisId>
</parameterProvider>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ public class DataProviderManagerTest {
.setProviderType(ProviderType.DATA_TREE)
.setId("org.eclipse.tracecompass.internal.analysis.os.linux.core.segmentstore.PriorityStatisticsDataProvider:org.eclipse.tracecompass.analysis.os.linux.core.swslatency.sws");
EXPECTED_KERNEL_DP_DESCRIPTORS.add(builder.build());
builder = new DataProviderDescriptor.Builder();
builder.setName("Critical Path")
.setDescription("Shows the critical path of a selected thread")
.setProviderType(ProviderType.TIME_GRAPH)
.setId("org.eclipse.tracecompass.analysis.graph.core.dataprovider.CriticalPathDataProvider");
EXPECTED_KERNEL_DP_DESCRIPTORS.add(builder.build());

// UST Trace
builder = new DataProviderDescriptor.Builder();
Expand Down Expand Up @@ -319,6 +325,12 @@ public class DataProviderManagerTest {
.setProviderType(ProviderType.TREE_TIME_XY)
.setId("org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.scatter.dataprovider:org.eclipse.tracecompass.lttng2.ust.core.analysis.callstack");
EXPECTED_UST_DP_DESCRIPTORS.add(builder.build());
builder = new DataProviderDescriptor.Builder();
builder.setName("Critical Path")
.setDescription("Shows the critical path of a selected thread")
.setProviderType(ProviderType.TIME_GRAPH)
.setId("org.eclipse.tracecompass.analysis.graph.core.dataprovider.CriticalPathDataProvider");
EXPECTED_UST_DP_DESCRIPTORS.add(builder.build());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.tmf.core.model.CommonStatusMessage;
import org.eclipse.tracecompass.tmf.core.response.ITmfResponse;
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;

/**
Expand Down Expand Up @@ -43,6 +45,23 @@ public interface ITmfTreeDataProvider<T extends ITmfTreeDataModel> {
*/
TmfModelResponse<TmfTreeModel<T>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor);

/**
* This methods computes a tree model context. Then, it returns a
* {@link TmfModelResponse} that contains the model. Tree model will be used
* by tree viewer to show entries as a tree or flat hierarchy
*
* @param fetchParameters
* A query filter that contains an array of time. Times are used
* for requesting data.
* @param monitor
* A ProgressMonitor to cancel task
* @return A {@link TmfModelResponse} instance
* @since 9.3
*/
default TmfModelResponse<Map<String, Object>> fetchTreeContext(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.COMPLETED);
}

/**
* This method return the extension point ID of this provider
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,28 @@ public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fe
}
return new TmfModelResponse<>(model, ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}

@Override
public TmfModelResponse<Map<String, Object>> fetchTreeContext(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
boolean isComplete = true;
Map<String, Object> model = new HashMap<>();
for (P dataProvider : getProviders()) {
TmfModelResponse<Map<String, Object>> response = dataProvider.fetchTreeContext(fetchParameters, monitor);
isComplete &= response.getStatus() == ITmfResponse.Status.COMPLETED;
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
Map<String, Object> retModel = response.getModel();
if (retModel != null && !retModel.isEmpty()) {
model = retModel;
// only one data provider should return the context
break;
}
}
if (isComplete) {
return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
return new TmfModelResponse<>(model, ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
}

Loading