use of org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule in project tracecompass by tracecompass.
the class PatternProvidersTest method testSegmentStore.
/**
* Test the generated segment store
*/
@Test
public void testSegmentStore() {
TmfAbstractAnalysisModule module = getModule();
if (module instanceof ITmfAnalysisModuleWithStateSystems) {
// In this test, the module will be XmlPatternAnalysis which is an instance of ITmfAnalysisModuleWithStateSystems
assertTrue(((ITmfAnalysisModuleWithStateSystems) module).waitForInitialization());
}
assertTrue(module.waitForCompletion());
ISegmentStore<@NonNull ISegment> ss = ((ISegmentStoreProvider) module).getSegmentStore();
assertNotNull(ss);
assertFalse(ss.isEmpty());
}
use of org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule in project tracecompass by tracecompass.
the class XmlPatternAnalysis method getProperties.
// ------------------------------------------------------------------------
// ITmfPropertiesProvider
// ------------------------------------------------------------------------
/**
* @since 2.0
*/
@Override
@NonNull
public Map<@NonNull String, @NonNull String> getProperties() {
Map<@NonNull String, @NonNull String> properties = super.getProperties();
// Add the sub-modules' properties
TmfAbstractAnalysisModule module = fStateSystemModule;
if (module != null) {
for (Entry<String, String> entry : module.getProperties().entrySet()) {
String value = entry.getValue();
if (value != null) {
properties.put(Objects.requireNonNull(Messages.PatternAnalysis_StateSystemPrefix + ' ' + entry.getKey()), value);
}
}
}
module = fSegmentStoreModule;
if (module != null) {
for (Entry<String, String> entry : module.getProperties().entrySet()) {
String value = entry.getValue();
if (value != null) {
properties.put(Objects.requireNonNull(Messages.PatternAnalysis_SegmentStorePrefix + ' ' + entry.getKey()), value);
}
}
}
return properties;
}
use of org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule in project tracecompass by tracecompass.
the class TmfStateSystemExplorer method handleAnalysisStarted.
/**
* Rebuild the view's entry tree to ensure that entries from a newly started
* trace are added.
*
* @param signal
* analysis started signal.
* @since 3.3
*/
@TmfSignalHandler
public void handleAnalysisStarted(TmfStartAnalysisSignal signal) {
IAnalysisModule module = signal.getAnalysisModule();
if (module instanceof ITmfAnalysisModuleWithStateSystems && !module.isAutomatic()) {
/*
* use set to wait for initialization in build entry list to avoid
* deadlocks.
*/
final ITmfTrace viewTrace = getTrace();
if (Iterables.contains(allModules(viewTrace), module)) {
/*
* Rebuild only if the started analysis module is from the
* active trace/experiment.
*/
new Thread(() -> {
/*
* DataProviderManager#getDataProvider() (see getDataProvider() below) should never be called in a signal handler.
*/
synchronized (fStartedAnalysis) {
fStartedAnalysis.add((ITmfAnalysisModuleWithStateSystems) module);
// Every children of ITmfAnalysisModuleWithStateSystems extends TmfAbstractAnalysisModule
ITmfTrace moduleTrace = module instanceof TmfAbstractAnalysisModule ? ((TmfAbstractAnalysisModule) module).getTrace() : viewTrace;
if (moduleTrace != null) {
getDataProvider(moduleTrace).startedAnalysisSignalHandler((ITmfAnalysisModuleWithStateSystems) module);
rebuild();
}
}
}).start();
} else {
/*
* Reset the View for the relevant trace, ensuring that the
* entry list will be rebuilt when the view switches back.
*/
for (ITmfTrace trace : TmfTraceManager.getInstance().getOpenedTraces()) {
if (Iterables.contains(allModules(trace), module)) {
synchronized (fStartedAnalysis) {
fStartedAnalysis.add((ITmfAnalysisModuleWithStateSystems) module);
resetView(trace);
}
break;
}
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule in project tracecompass by tracecompass.
the class AbstractSegmentsStatisticsViewer method updateElements.
@Override
@Nullable
protected ITmfTreeViewerEntry updateElements(ITmfTrace trace, long start, long end, boolean isSelection) {
ITmfTreeDataProvider<SegmentStoreStatisticsModel> provider = null;
// first try to get the data provider from the data provider manager.
String providerId = fProviderId;
if (providerId != null) {
provider = DataProviderManager.getInstance().getDataProvider(trace, fProviderId, ITmfTreeDataProvider.class);
}
// then try to get it from the legacy way
TmfAbstractAnalysisModule analysisModule = fModule;
if (provider == null && analysisModule instanceof AbstractSegmentStatisticsAnalysis && trace.equals(analysisModule.getTrace())) {
AbstractSegmentStatisticsAnalysis module = (AbstractSegmentStatisticsAnalysis) analysisModule;
provider = SegmentStoreStatisticsDataProvider.getOrCreate(trace, module);
}
if (provider == null) {
return null;
}
FilterTimeQueryFilter filter = new FilterTimeQueryFilter(start, end, 2, isSelection);
TmfModelResponse<TmfTreeModel<SegmentStoreStatisticsModel>> response = provider.fetchTree(FetchParametersUtils.filteredTimeQueryToMap(filter), null);
TmfTreeModel<SegmentStoreStatisticsModel> model = response.getModel();
if (model == null) {
return null;
}
return modelToTree(trace, model.getEntries());
}
use of org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule in project tracecompass by tracecompass.
the class TmfTestHelper method executeAnalysis.
/**
* Calls the {@link TmfAbstractAnalysisModule#executeAnalysis} method of an
* analysis module. This method does not return until the analysis is
* completed and it returns the result of the method. It allows to execute
* the analysis without requiring an Eclipse job and waiting for completion.
*
* Note that executing an analysis using this method will not automatically
* execute the dependent analyses module. The execution of those modules is
* left to the caller.
*
* @param module
* The analysis module to execute
* @return The return value of the
* {@link TmfAbstractAnalysisModule#executeAnalysis} method
*/
public static boolean executeAnalysis(IAnalysisModule module) {
if (module instanceof TmfAbstractAnalysisModule) {
try {
Class<?>[] argTypes = new Class[] { IProgressMonitor.class };
Method method = TmfAbstractAnalysisModule.class.getDeclaredMethod("executeAnalysis", argTypes);
method.setAccessible(true);
Boolean result = (Boolean) method.invoke(module, new NullProgressMonitor());
// Set the module as completed, to avoid another call creating a job
method = TmfAbstractAnalysisModule.class.getDeclaredMethod("setAnalysisCompleted", new Class[] {});
method.setAccessible(true);
method.invoke(module);
return result;
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
fail(e.toString());
}
}
throw new RuntimeException("This analysis module does not have a protected method to execute. Maybe it can be executed differently? Or it is not supported yet in this method?");
}
Aggregations