Search in sources :

Example 16 with StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.

the class DataDrivenValueStackPeek method resolveValue.

@Override
@Nullable
protected Object resolveValue(ITmfEvent event, int baseQuark, DataDrivenScenarioInfo scenarioInfo, IAnalysisDataContainer container) {
    final long ts = event.getTimestamp().toNanos();
    /* Query the state system for the value */
    Object value = null;
    ITmfStateSystem ss = container.getStateSystem();
    int quarkQuery = fPath.getQuark(event, baseQuark, scenarioInfo, container);
    /*
         * the query can fail : for example, if a value is requested but has not been
         * set yet
         */
    if (quarkQuery >= 0) {
        try {
            @Nullable ITmfStateInterval stackTopInterval = StateSystemUtils.querySingleStackTop(ss, ts, quarkQuery);
            return (stackTopInterval != null ? stackTopInterval.getStateValue().unboxValue() : null);
        } catch (AttributeNotFoundException | StateSystemDisposedException e) {
            // $NON-NLS-1$
            throw new DataDrivenException("Resolving stack peek: " + e.getMessage(), event);
        }
    }
    return value;
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) DataDrivenException(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenException) Nullable(org.eclipse.jdt.annotation.Nullable) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 17 with StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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 18 with StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.

the class XmlTimeGraphDataProvider method processEntry.

private Builder processEntry(@NonNull Element entryElement, DataDrivenStateSystemPath displayPath, @NonNull Builder parentEntry, int quark, ITmfStateSystem ss, long currentEnd) {
    /*
         * Get the start time and end time of this entry from the display attribute
         */
    int displayQuark = displayPath.getQuark(quark, parentEntry);
    long id = fBaseQuarkToId.row(ss).computeIfAbsent(quark, s -> sfAtomicId.getAndIncrement());
    if (displayQuark < 0) {
        return new Builder(id, parentEntry.getId(), Collections.singletonList(String.format("Unknown display quark for %s", ss.getAttributeName(quark))), ss.getStartTime(), ss.getCurrentEndTime(), null, ss, quark, // $NON-NLS-1$
        fCompilationData);
    }
    fIDToDisplayQuark.put(id, new Pair<>(ss, displayQuark));
    long entryStart = ss.getStartTime();
    long entryEnd = currentEnd;
    try {
        ITmfStateInterval oneInterval = ss.querySingleState(entryStart, displayQuark);
        /* The entry start is the first non-null interval */
        while (oneInterval.getStateValue().isNull()) {
            long ts = oneInterval.getEndTime() + 1;
            if (ts > currentEnd) {
                break;
            }
            oneInterval = ss.querySingleState(ts, displayQuark);
        }
        entryStart = oneInterval.getStartTime();
        /* The entry end is the last non-null interval */
        oneInterval = ss.querySingleState(entryEnd - 1, displayQuark);
        while (oneInterval.getStateValue().isNull()) {
            long ts = oneInterval.getStartTime() - 1;
            if (ts < ss.getStartTime()) {
                break;
            }
            oneInterval = ss.querySingleState(ts, displayQuark);
        }
        entryEnd = Math.min(oneInterval.getEndTime() + 1, currentEnd);
    } catch (StateSystemDisposedException e) {
    }
    return new Builder(id, parentEntry.getId(), Collections.singletonList(ss.getAttributeName(quark)), entryStart, entryEnd, entryElement, ss, quark, fCompilationData);
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) Builder(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlTimeGraphEntryModel.Builder) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)

Example 19 with StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.

the class XmlXYDataProvider method fetchXY.

@Override
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    DataDrivenStateSystemPath display = fDisplay;
    XmlXYEntry entry = fXmlEntry;
    ITmfStateSystem ss = entry.getStateSystem();
    TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
    if (filter == null) {
        return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    long[] xValues = filter.getTimesRequested();
    Map<Integer, IYModel> map = initSeries(fetchParameters);
    if (map.isEmpty()) {
        return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
    }
    long currentEnd = ss.getCurrentEndTime();
    try {
        for (int i = 0; i < xValues.length; i++) {
            if (monitor != null && monitor.isCanceled()) {
                return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
            }
            long time = xValues[i];
            if (time > currentEnd) {
                break;
            } else if (ss.getStartTime() <= time) {
                List<@NonNull ITmfStateInterval> full = ss.queryFullState(time);
                for (Entry<Integer, IYModel> series : map.entrySet()) {
                    int attributeQuark = display.getQuark(series.getKey(), entry);
                    if (attributeQuark >= 0 && attributeQuark < full.size()) {
                        Object value = full.get(attributeQuark).getValue();
                        series.getValue().getData()[i] = extractValue(value);
                    }
                }
            }
        }
        // Update the series value if delta is requested
        for (Entry<Integer, IYModel> series : map.entrySet()) {
            if (entry.getType().equals(DisplayType.DELTA)) {
                getSeriesDelta(series.getValue().getData());
            }
        }
    } catch (StateSystemDisposedException e) {
        return TmfXyResponseFactory.createFailedResponse(e.getMessage());
    }
    boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
    return TmfXyResponseFactory.create(TITLE, xValues, map.values(), complete);
}
Also used : IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) DataDrivenStateSystemPath(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) Entry(java.util.Map.Entry) NonNull(org.eclipse.jdt.annotation.NonNull) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 20 with StateSystemDisposedException

use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException 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)

Aggregations

StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)96 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)78 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)51 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)43 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)40 Test (org.junit.Test)38 NonNull (org.eclipse.jdt.annotation.NonNull)25 ArrayList (java.util.ArrayList)24 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)16 HashMap (java.util.HashMap)15 Nullable (org.eclipse.jdt.annotation.Nullable)15 IStateHistoryBackend (org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend)12 AtomicLong (java.util.concurrent.atomic.AtomicLong)11 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 StateValueTypeException (org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException)10 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)10 ImmutableList (com.google.common.collect.ImmutableList)9 List (java.util.List)9 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)9 Map (java.util.Map)7