Search in sources :

Example 1 with TmfAbstractAnalysisModule

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());
}
Also used : ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) Test(org.junit.Test)

Example 2 with TmfAbstractAnalysisModule

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;
}
Also used : TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 3 with TmfAbstractAnalysisModule

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;
                }
            }
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 4 with TmfAbstractAnalysisModule

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());
}
Also used : AbstractSegmentStatisticsAnalysis(org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) ITmfTreeDataProvider(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider) FilterTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.FilterTimeQueryFilter) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 5 with TmfAbstractAnalysisModule

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?");
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule)

Aggregations

TmfAbstractAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule)7 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)3 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 Test (org.junit.Test)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 LinkedHashMap (java.util.LinkedHashMap)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Performance (org.eclipse.test.performance.Performance)1 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)1 ISegmentStoreProvider (org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider)1 SegmentStoreStatisticsModel (org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel)1 AbstractSegmentStatisticsAnalysis (org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis)1 ModuleEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel)1 StateSystemEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.StateSystemEntryModel)1 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)1