Search in sources :

Example 1 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class XmlDataProviderManagerTest method testOneTrace.

/**
 * Test getting the XML data provider for one trace, with an analysis that
 * applies to a trace
 */
@Test
public void testOneTrace() {
    ITmfTrace trace = null;
    try {
        // Initialize the trace and module
        trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
        TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
        ((TmfTrace) trace).traceOpened(signal);
        // The data provider manager uses opened traces from the manager
        TmfTraceManager.getInstance().traceOpened(signal);
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
        assertNotNull(viewElement);
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
        assertNotNull(timeGraphProvider);
    } finally {
        if (trace != null) {
            trace.dispose();
            TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Element(org.w3c.dom.Element) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 2 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class XmlDataProviderManagerTest method testExperimentWithTraceAnalysis.

/**
 * Test getting the XML data provider for an experiment, with an analysis that
 * applies to a trace
 */
@Test
public void testExperimentWithTraceAnalysis() {
    ITmfTrace trace = null;
    ITmfTrace trace2 = null;
    ITmfTrace experiment = null;
    try {
        // Initialize the trace and module
        trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
        trace2 = XmlUtilsTest.initializeTrace(TEST_TRACE2);
        ITmfTrace[] traces = { trace, trace2 };
        experiment = new TmfExperiment(ITmfEvent.class, "Xml Experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
        TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, experiment, null);
        ((TmfTrace) trace).traceOpened(signal);
        ((TmfTrace) trace2).traceOpened(signal);
        ((TmfTrace) experiment).traceOpened(signal);
        // The data provider manager uses opened traces from the manager
        TmfTraceManager.getInstance().traceOpened(signal);
        Iterable<@NonNull DataDrivenAnalysisModule> modules = TmfTraceUtils.getAnalysisModulesOfClass(experiment, DataDrivenAnalysisModule.class);
        modules.forEach(module -> {
            module.schedule();
            assertTrue(module.waitForCompletion());
        });
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
        assertNotNull(viewElement);
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(experiment, viewElement);
        assertNotNull(timeGraphProvider);
        assertTrue(timeGraphProvider instanceof TmfTimeGraphCompositeDataProvider);
    } finally {
        if (trace != null) {
            trace.dispose();
        }
        if (trace2 != null) {
            trace2.dispose();
        }
        if (experiment != null) {
            experiment.dispose();
            TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, experiment));
        }
    }
}
Also used : Element(org.w3c.dom.Element) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTimeGraphCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.timegraph.TmfTimeGraphCompositeDataProvider) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) Test(org.junit.Test)

Example 3 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class XmlTimeGraphDataProviderTest method testTwoLevels.

/**
 * Test getting the XML data provider for one trace, with an analysis that
 * applies to a trace
 *
 * @throws IOException
 *             Exception thrown by analyses
 */
@Test
public void testTwoLevels() throws IOException {
    ITmfTrace trace = getTrace();
    assertNotNull(trace);
    try {
        runModule(trace);
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.DATA_PROVIDER_SIMPLE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TIME_GRAPH_VIEW_ID);
        assertNotNull(viewElement);
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
        assertNotNull(timeGraphProvider);
        List<String> expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedTimeGraphTree"));
        Map<Long, String> tree = assertAndGetTree(timeGraphProvider, trace, expectedStrings);
        expectedStrings = Files.readAllLines(Paths.get("test_traces/simple_dataprovider/expectedTimeGraphRows"));
        assertRows(timeGraphProvider, tree, expectedStrings);
    } finally {
        trace.dispose();
        TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Element(org.w3c.dom.Element) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) Test(org.junit.Test)

Example 4 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class BaseDataProviderTimeGraphView method getLinkList.

@Override
protected List<@NonNull ILinkEvent> getLinkList(long zoomStartTime, long zoomEndTime, long resolution, @NonNull IProgressMonitor monitor) {
    Collection<ITimeGraphDataProvider<? extends @NonNull TimeGraphEntryModel>> providers = getProviders(getTrace());
    if (providers.isEmpty()) {
        return Collections.emptyList();
    }
    List<@NonNull ILinkEvent> linkList = new ArrayList<>();
    List<@NonNull Long> times = StateSystemUtils.getTimes(zoomStartTime, zoomEndTime, resolution);
    Map<@NonNull String, @NonNull Object> parameters = getFetchArrowsParameters(times);
    for (ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider : providers) {
        TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(parameters, monitor);
        List<ITimeGraphArrow> model = response.getModel();
        if (model != null) {
            for (ITimeGraphArrow arrow : model) {
                ITimeGraphEntry prevEntry;
                ITimeGraphEntry nextEntry;
                synchronized (fEntries) {
                    prevEntry = fEntries.get(provider, arrow.getSourceId());
                    nextEntry = fEntries.get(provider, arrow.getDestinationId());
                }
                if (prevEntry != null && nextEntry != null) {
                    linkList.add(new TimeLinkEvent(arrow, prevEntry, nextEntry));
                }
            }
        }
    }
    return linkList;
}
Also used : ITimeGraphDataProvider(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider) ArrayList(java.util.ArrayList) ITimeGraphArrow(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) TimeLinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent)

Example 5 with TimeGraphEntryModel

use of org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel in project tracecompass by tracecompass.

the class ThreadStatusDataProviderTest method assertAndGetTree.

private static Map<Long, String> assertAndGetTree(ThreadStatusDataProvider provider) throws IOException {
    TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> treeResponse = provider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), null);
    assertNotNull(treeResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
    TmfTreeModel<@NonNull TimeGraphEntryModel> treeModel = treeResponse.getModel();
    assertNotNull(treeModel);
    List<@NonNull TimeGraphEntryModel> treeEntries = treeModel.getEntries();
    List<String> expectedStrings = Files.readAllLines(Paths.get("testfiles/kernel_analysis/expectedThreadStatusTree"));
    assertEquals(expectedStrings.size(), treeEntries.size());
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        String[] split = expectedString.split(",");
        TimeGraphEntryModel threadEntry = treeEntries.get(i);
        // Assert common fields
        assertEquals(split[0], threadEntry.getName());
        assertEquals(Long.parseLong(split[1]), threadEntry.getStartTime());
        assertEquals(Long.parseLong(split[2]), threadEntry.getEndTime());
        if (threadEntry instanceof ThreadEntryModel) {
            // Verify the thread entry fields
            ThreadEntryModel threadEntryModel = (ThreadEntryModel) threadEntry;
            assertEquals(Integer.parseInt(split[3]), threadEntryModel.getThreadId());
            assertEquals(Integer.parseInt(split[4]), threadEntryModel.getProcessId());
            assertEquals(Integer.parseInt(split[5]), threadEntryModel.getParentThreadId());
        } else {
            // Make sure there is no extra expected fields
            assertEquals(3, split.length);
        }
    }
    Map<Long, String> map = new HashMap<>();
    for (TimeGraphEntryModel threadModel : treeEntries) {
        map.put(threadModel.getId(), threadModel.getName());
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ThreadEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadEntryModel) NonNull(org.eclipse.jdt.annotation.NonNull) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)

Aggregations

TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)29 NonNull (org.eclipse.jdt.annotation.NonNull)16 ArrayList (java.util.ArrayList)12 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)11 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)10 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)10 ITimeGraphDataProvider (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider)8 Element (org.w3c.dom.Element)8 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)7 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)7 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)6 List (java.util.List)6 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)6 Collection (java.util.Collection)5 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)5 TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)5 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)5 Status (org.eclipse.tracecompass.tmf.core.response.ITmfResponse.Status)4