Search in sources :

Example 21 with TimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.

the class TmfEventTableDataProviderTest method fetchColumnId.

private static Map<String, Long> fetchColumnId() {
    TmfTreeModel<TmfEventTableColumnDataModel> columns = fProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, 0, 1)), null).getModel();
    if (columns == null) {
        return Collections.emptyMap();
    }
    List<TmfEventTableColumnDataModel> columnEntries = columns.getEntries();
    // Order should be timestamp, event type and contents
    assertEquals(TIMESTAMP_COLUMN_NAME, columnEntries.get(0).getName());
    assertEquals(EVENT_TYPE_COLUMN_NAME, columnEntries.get(1).getName());
    assertEquals(CONTENTS_COLUMN_NAME, columnEntries.get(2).getName());
    assertEquals(TIMESTAMP_NS_COLUMN_NAME, columnEntries.get(3).getName());
    Map<String, Long> expectedColumns = new LinkedHashMap<>();
    for (TmfEventTableColumnDataModel column : columnEntries) {
        expectedColumns.put(column.getName(), column.getId());
    }
    return expectedColumns;
}
Also used : TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) TmfEventTableColumnDataModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.events.TmfEventTableColumnDataModel) LinkedHashMap(java.util.LinkedHashMap)

Example 22 with TimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.

the class FetchParametersTest method testTimeQuery.

/**
 * Test {@link FetchParametersUtils#timeQueryToMap(TimeQueryFilter)} and
 * {@link FetchParametersUtils#createTimeQuery(Map)}
 */
@Test
public void testTimeQuery() {
    TimeQueryFilter timeQuery = FetchParametersUtils.createTimeQuery(fExpectedTimeQueryMap);
    assertNotNull(timeQuery);
    assertEquals(fExpectedTimeQuery, timeQuery);
    Map<String, Object> timeQueryMap = FetchParametersUtils.timeQueryToMap(fExpectedTimeQuery);
    assertFalse(timeQueryMap.isEmpty());
    assertEquals(fExpectedTimeQueryMap, timeQueryMap);
}
Also used : TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) Test(org.junit.Test)

Example 23 with TimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.

the class UstMemoryUsageDataProvider method getTree.

/**
 * @since 3.3
 */
@Override
protected TmfTreeModel<MemoryUsageTreeModel> getTree(ITmfStateSystem ss, Map<String, Object> parameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
    TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(parameters);
    if (filter == null) {
        return new TmfTreeModel<>(Collections.emptyList(), Collections.emptyList());
    }
    long start = filter.getStart();
    long end = filter.getEnd();
    // Let the list of active states be null if we aren't filtering
    List<ITmfStateInterval> active = null;
    Boolean isFiltered = DataProviderParameterUtils.extractIsFiltered(parameters);
    if (isFiltered != null && isFiltered) {
        if (start == end || start > ss.getCurrentEndTime() || end < ss.getStartTime()) {
            /*
                 * return an empty list if the filter is empty or does not intersect the state
                 * system
                 */
            return new TmfTreeModel<>(Collections.emptyList(), Collections.emptyList());
        }
        active = ss.queryFullState(Long.max(start, ss.getStartTime()));
    }
    List<ITmfStateInterval> nameFullState = ss.queryFullState(ss.getCurrentEndTime());
    List<Integer> tidQuarks = ss.getSubAttributes(-1, false);
    ImmutableList.Builder<MemoryUsageTreeModel> builder = ImmutableList.builder();
    long rootId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
    builder.add(new MemoryUsageTreeModel(rootId, -1L, -1, Collections.singletonList(getTrace().getName())));
    for (int quark : tidQuarks) {
        int memoryAttribute = ss.optQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE);
        int procNameQuark = ss.optQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
        String name = ss.getAttributeName(quark);
        if (procNameQuark != ITmfStateSystem.INVALID_ATTRIBUTE && procNameQuark < nameFullState.size()) {
            name = String.valueOf(nameFullState.get(procNameQuark).getValue());
        }
        if (memoryAttribute != ITmfStateSystem.INVALID_ATTRIBUTE && (active == null || (memoryAttribute < active.size() && active.get(memoryAttribute).getEndTime() < end))) {
            int tid = Integer.parseInt(ss.getAttributeName(quark));
            builder.add(new MemoryUsageTreeModel(getId(quark), rootId, tid, Collections.singletonList(name)));
        }
    }
    return new TmfTreeModel<>(Collections.emptyList(), builder.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) MemoryUsageTreeModel(org.eclipse.tracecompass.analysis.os.linux.core.memory.MemoryUsageTreeModel) 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)

Example 24 with TimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.

the class XmlTimeGraphDataProviderTest method assertAndGetTree.

private static Map<Long, String> assertAndGetTree(ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider, ITmfTrace trace, List<String> expectedStrings) {
    TmfModelResponse<@NonNull TmfTreeModel<@NonNull TimeGraphEntryModel>> treeResponse = timeGraphProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), MONITOR);
    assertNotNull(treeResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
    TmfTreeModel<@NonNull TimeGraphEntryModel> treeModel = treeResponse.getModel();
    assertNotNull(treeModel);
    List<@NonNull TimeGraphEntryModel> xmlEntries = treeModel.getEntries();
    Collections.sort(xmlEntries, Comparator.comparingLong(TimeGraphEntryModel::getId));
    Map<Long, String> map = new HashMap<>();
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        assertTrue("actual entry present at " + i + ": " + expectedString, xmlEntries.size() > i);
        String[] split = expectedString.split(",");
        TimeGraphEntryModel xmlTgEntry = xmlEntries.get(i);
        assertEquals("Checking entry name at " + i, split[0], xmlTgEntry.getName());
        assertEquals("Checking entry start time at " + i, Long.parseLong(split[1]), xmlTgEntry.getStartTime());
        assertEquals("Checking entry end time at " + i, Long.parseLong(split[2]), xmlTgEntry.getEndTime());
        // Check the parent
        long parentId = xmlTgEntry.getParentId();
        if (parentId < 0) {
            assertEquals("Checking empty parent at " + i, split[3], "null");
        } else {
            String parentName = map.get(parentId);
            assertEquals("Checking parent at " + i, split[3], parentName);
        }
        map.put(xmlTgEntry.getId(), xmlTgEntry.getName());
    }
    assertEquals("Extra actual entries", expectedStrings.size(), xmlEntries.size());
    return map;
}
Also used : HashMap(java.util.HashMap) NonNull(org.eclipse.jdt.annotation.NonNull) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)

Example 25 with TimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.

the class CriticalPathView method getLinkList.

@Override
protected List<ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
    List<@NonNull TimeGraphEntry> traceEntries = getEntryList(getTrace());
    if (traceEntries == null) {
        return Collections.emptyList();
    }
    List<@NonNull ILinkEvent> linkList = new ArrayList<>();
    TimeQueryFilter queryFilter = new TimeQueryFilter(startTime, endTime, 2);
    /*
         * group entries by critical path data provider as several hosts may refer to
         * the same data provider
         */
    Table<ITimeGraphDataProvider<?>, Long, TimeGraphEntry> table = HashBasedTable.create();
    for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
        for (TimeGraphEntry entry : Utils.flatten(traceEntry)) {
            table.put(traceEntry.getProvider(), entry.getEntryModel().getId(), entry);
        }
    }
    for (Map.Entry<ITimeGraphDataProvider<?>, Map<Long, TimeGraphEntry>> entry : table.rowMap().entrySet()) {
        ITimeGraphDataProvider<?> provider = entry.getKey();
        Map<Long, TimeGraphEntry> map = entry.getValue();
        TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(FetchParametersUtils.timeQueryToMap(queryFilter), monitor);
        List<ITimeGraphArrow> model = response.getModel();
        if (monitor.isCanceled()) {
            return null;
        }
        if (model != null) {
            for (ITimeGraphArrow arrow : model) {
                ITimeGraphEntry src = map.get(arrow.getSourceId());
                ITimeGraphEntry dst = map.get(arrow.getDestinationId());
                if (src != null && dst != null) {
                    linkList.add(new TimeLinkEvent(src, dst, arrow.getStartTime(), arrow.getDuration(), arrow.getValue()));
                }
            }
        }
    }
    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) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) ArrayList(java.util.ArrayList) List(java.util.List) TimeLinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent) Map(java.util.Map)

Aggregations

TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)28 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)16 NonNull (org.eclipse.jdt.annotation.NonNull)14 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)14 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)7 Test (org.junit.Test)7 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)4 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 CpuUsageEntryModel (org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.CpuUsageEntryModel)3 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)3 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)3 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)3 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)3 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)3 ITimeGraphArrow (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow)3