Search in sources :

Example 1 with TimeGraphModel

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

the class XmlTimeGraphDataProviderTest method assertRows.

private static void assertRows(ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider, Map<Long, String> tree, List<String> expectedStrings) {
    TmfModelResponse<@NonNull TimeGraphModel> rowResponse = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(1, 20, 20, tree.keySet())), null);
    assertNotNull(rowResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, rowResponse.getStatus());
    TimeGraphModel timeGraphModel = rowResponse.getModel();
    assertNotNull(timeGraphModel);
    List<@NonNull ITimeGraphRowModel> rowModel = timeGraphModel.getRows();
    // ensure row order
    rowModel.sort(Comparator.comparingLong(ITimeGraphRowModel::getEntryID));
    assertEquals(expectedStrings.size(), rowModel.size());
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        String[] split = expectedString.split(":");
        ITimeGraphRowModel row = rowModel.get(i);
        assertEquals(split[0], tree.get(row.getEntryID()));
        assertEqualsStates(split[0], split[1], row.getStates());
    }
}
Also used : ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)

Example 2 with TimeGraphModel

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

the class XmlTimeGraphDataProvider method fetchRowModel.

@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
    // TODO server: Parameters validation should be handle separately. It
    // can be either in the data provider itself or before calling it. It
    // will avoid the creation of filters and the content of the map can be
    // use directly.
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    if (filter == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    for (Long id : filter.getSelectedItems()) {
        Pair<ITmfStateSystem, Integer> pair = fIDToDisplayQuark.get(id);
        if (pair != null) {
            table.put(pair.getFirst(), pair.getSecond(), id);
        }
    }
    List<@NonNull ITimeGraphRowModel> allRows = new ArrayList<>();
    try {
        for (Entry<ITmfStateSystem, Map<Integer, Long>> ssEntry : table.rowMap().entrySet()) {
            Collection<@NonNull ITimeGraphRowModel> rows = createRows(ssEntry.getKey(), ssEntry.getValue(), filter.getTimesRequested(), fetchParameters, monitor);
            allRows.addAll(rows);
        }
    } catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e) {
        return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
    }
    return new TmfModelResponse<>(new TimeGraphModel(allRows), Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) AtomicLong(java.util.concurrent.atomic.AtomicLong) Map(java.util.Map) HashMap(java.util.HashMap) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 3 with TimeGraphModel

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

the class DataDrivenTimeGraphDataProvider method fetchRowModel.

@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    // TODO server: Parameters validation should be handle separately. It
    // can be either in the data provider itself or before calling it. It
    // will avoid the creation of filters and the content of the map can be
    // use directly.
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    if (filter == null) {
        return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
    for (Long id : filter.getSelectedItems()) {
        Pair<ITmfStateSystem, Integer> pair = fIDToDisplayQuark.get(id);
        if (pair != null) {
            table.put(pair.getFirst(), pair.getSecond(), id);
        }
    }
    List<@NonNull ITimeGraphRowModel> allRows = new ArrayList<>();
    try {
        for (Entry<ITmfStateSystem, Map<Integer, Long>> ssEntry : table.rowMap().entrySet()) {
            Collection<@NonNull ITimeGraphRowModel> rows = createRows(ssEntry.getKey(), ssEntry.getValue(), fetchParameters, monitor);
            allRows.addAll(rows);
        }
    } catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e) {
        return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
    }
    return new TmfModelResponse<>(new TimeGraphModel(allRows), Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) AtomicLong(java.util.concurrent.atomic.AtomicLong) HashMap(java.util.HashMap) Map(java.util.Map) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 4 with TimeGraphModel

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

the class TmfTimeGraphCompositeDataProvider method fetchRowModel.

@Override
public TmfModelResponse<TimeGraphModel> fetchRowModel(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    boolean isComplete = true;
    ImmutableList.Builder<ITimeGraphRowModel> series = ImmutableList.builder();
    for (P dataProvider : getProviders()) {
        TmfModelResponse<TimeGraphModel> response = dataProvider.fetchRowModel(fetchParameters, monitor);
        isComplete &= response.getStatus() == ITmfResponse.Status.COMPLETED;
        TimeGraphModel model = response.getModel();
        if (model != null) {
            series.addAll(model.getRows());
        }
        if (monitor != null && monitor.isCanceled()) {
            return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
        }
    }
    if (isComplete) {
        return new TmfModelResponse<>(new TimeGraphModel(series.build()), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
    }
    return new TmfModelResponse<>(new TimeGraphModel(series.build()), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
Also used : ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) ImmutableList(com.google.common.collect.ImmutableList) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)

Example 5 with TimeGraphModel

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

the class StateSystemDataProvider method fetchRowModel.

@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
    // Get the quarks to display
    Collection<Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(fetchParameters);
    synchronized (fEntryBuilder) {
        if (selectedItems == null) {
            // No selected items, take them all
            selectedItems = fIDToDisplayQuark.keySet();
        }
        for (Long id : selectedItems) {
            Pair<ITmfStateSystem, Integer> pair = fIDToDisplayQuark.get(id);
            if (pair != null) {
                table.put(pair.getFirst(), pair.getSecond(), id);
            }
        }
    }
    List<@NonNull ITimeGraphRowModel> allRows = new ArrayList<>();
    try {
        List<Long> times = DataProviderParameterUtils.extractTimeRequested(fetchParameters);
        for (Entry<ITmfStateSystem, Map<Integer, Long>> ssEntry : table.rowMap().entrySet()) {
            ITmfStateSystem ss = Objects.requireNonNull(ssEntry.getKey());
            List<@NonNull ITimeGraphRowModel> rows = getRowModels(ss, ssEntry.getValue(), times, fetchParameters, monitor);
            if (monitor != null && monitor.isCanceled()) {
                return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
            }
            synchronized (fEntryBuilder) {
                // Add the SS
                Long ssId = fSsToId.get(ss);
                if (ssId != null && selectedItems.contains(ssId)) {
                    TimeGraphRowModel ssRow = new TimeGraphRowModel(ssId, new ArrayList<>());
                    List<@NonNull ITimeGraphState> states = ssRow.getStates();
                    states.add(new TimeGraphState(ss.getStartTime(), ss.getCurrentEndTime() - ss.getStartTime(), Integer.MAX_VALUE));
                    rows.add(ssRow);
                }
            }
            allRows.addAll(rows);
        }
        synchronized (fEntryBuilder) {
            for (ModuleEntryModel module : fModuleEntryModelList) {
                if (selectedItems.contains(module.getId())) {
                    allRows.add(getModuleRowModels(module));
                }
            }
        }
        if (monitor != null && monitor.isCanceled()) {
            return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
        }
        return new TmfModelResponse<>(new TimeGraphModel(allRows), Status.COMPLETED, CommonStatusMessage.COMPLETED);
    } catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e) {
        return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
    }
}
Also used : ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) TimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphRowModel) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) TimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphState) AtomicLong(java.util.concurrent.atomic.AtomicLong) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)16 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)12 ITimeGraphRowModel (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel)12 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)10 ArrayList (java.util.ArrayList)9 NonNull (org.eclipse.jdt.annotation.NonNull)9 HashMap (java.util.HashMap)7 ITimeGraphState (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState)7 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)6 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)6 Map (java.util.Map)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)5 TimeGraphRowModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphRowModel)5 List (java.util.List)4 Predicate (java.util.function.Predicate)4 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)4 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)4 LinkedHashMap (java.util.LinkedHashMap)3 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)3