use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class ThreadStatusDataProvider method fetchRowModel.
@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, IProgressMonitor monitor) {
ITmfStateSystem ss = fModule.getStateSystem();
if (ss == null) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
}
TreeMultimap<Integer, ITmfStateInterval> intervals = TreeMultimap.create(Comparator.naturalOrder(), Comparator.comparing(ITmfStateInterval::getStartTime));
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
Map<Long, Integer> selectedIdsToQuarks = getSelectedIdsToQuarks(filter);
Collection<Integer> stateAndSyscallQuarks = addSyscall(selectedIdsToQuarks.values(), ss);
Collection<Long> times = getTimes(ss, filter);
try {
/* Do the actual query */
for (ITmfStateInterval interval : ss.query2D(stateAndSyscallQuarks, times)) {
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
intervals.put(interval.getAttribute(), interval);
}
} catch (TimeRangeException | StateSystemDisposedException e) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, String.valueOf(e.getMessage()));
}
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(fetchParameters);
if (regexesMap != null) {
predicates.putAll(computeRegexPredicate(regexesMap));
}
@NonNull List<@NonNull ITimeGraphRowModel> rows = new ArrayList<>();
for (Entry<Long, Integer> entry : selectedIdsToQuarks.entrySet()) {
int quark = entry.getValue();
NavigableSet<ITmfStateInterval> states = intervals.get(quark);
NavigableSet<ITmfStateInterval> syscalls = intervals.get(ss.optQuarkRelative(quark, Attributes.SYSTEM_CALL));
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
List<ITimeGraphState> eventList = new ArrayList<>();
states.forEach(i -> {
ITimeGraphState timegraphState = createTimeGraphState(i, syscalls);
Long key = Objects.requireNonNull(entry.getKey());
applyFilterAndAddState(eventList, timegraphState, key, predicates, monitor);
});
rows.add(new TimeGraphRowModel(entry.getKey(), eventList));
}
return new TmfModelResponse<>(new TimeGraphModel(rows), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class ControlFlowView method synchingToTime.
@Override
protected void synchingToTime(long time) {
List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries == null) {
return;
}
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
Iterable<TimeGraphEntry> unfiltered = Utils.flatten(traceEntry);
Map<Long, TimeGraphEntry> map = Maps.uniqueIndex(unfiltered, e -> e.getEntryModel().getId());
// use time -1 as a lower bound for the end of Time events to be included.
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(time - 1, time, 2, map.keySet());
TmfModelResponse<@NonNull TimeGraphModel> response = traceEntry.getProvider().fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
TimeGraphModel model = response.getModel();
if (model == null) {
continue;
}
for (ITimeGraphRowModel row : model.getRows()) {
if (syncToRow(row, time, map)) {
return;
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class FlameChartView method synchingToTime.
/**
* @since 1.2
*/
@Override
protected void synchingToTime(final long time) {
List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries != null) {
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
Iterable<TimeGraphEntry> unfiltered = Utils.flatten(traceEntry);
Map<Long, TimeGraphEntry> map = Maps.uniqueIndex(unfiltered, e -> e.getEntryModel().getId());
// use time -1 as a lower bound for the end of Time events to be included.
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(time - 1, time, 2, map.keySet());
TmfModelResponse<@NonNull TimeGraphModel> response = traceEntry.getProvider().fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
TimeGraphModel model = response.getModel();
if (model != null) {
for (ITimeGraphRowModel row : model.getRows()) {
syncToRow(row, time, map);
}
}
}
}
fSyncSelection = false;
if (Display.getCurrent() != null) {
getTimeGraphViewer().refresh();
}
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class ExampleTimeGraphDataProvider method getDefaultRowModels.
@Nullable
private List<ITimeGraphRowModel> getDefaultRowModels(Map<String, Object> fetchParameters, ITmfStateSystem ss, @Nullable IProgressMonitor monitor) throws IndexOutOfBoundsException, TimeRangeException, StateSystemDisposedException {
Map<Integer, ITimeGraphRowModel> quarkToRow = new HashMap<>();
// Prepare the quarks to display
Collection<Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(fetchParameters);
if (selectedItems == null) {
// No selected items, take them all
selectedItems = fIDToDisplayQuark.keySet();
}
for (Long id : selectedItems) {
Integer quark = fIDToDisplayQuark.get(id);
if (quark != null) {
quarkToRow.put(quark, new TimeGraphRowModel(id, new ArrayList<>()));
}
}
// This regex map automatically filters or highlights the entry
// according to the global filter entered by the user
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(fetchParameters);
if (regexesMap != null) {
predicates.putAll(computeRegexPredicate(regexesMap));
}
// Query the state system to fill the states
long currentEndTime = ss.getCurrentEndTime();
for (ITmfStateInterval interval : ss.query2D(quarkToRow.keySet(), getTimes(ss, DataProviderParameterUtils.extractTimeRequested(fetchParameters)))) {
if (monitor != null && monitor.isCanceled()) {
return Collections.emptyList();
}
ITimeGraphRowModel row = quarkToRow.get(interval.getAttribute());
if (row != null) {
List<@NonNull ITimeGraphState> states = row.getStates();
ITimeGraphState timeGraphState = getStateFromInterval(interval, currentEndTime);
// This call will compare the state with the filter predicate
applyFilterAndAddState(states, timeGraphState, row.getEntryID(), predicates, monitor);
}
}
for (ITimeGraphRowModel model : quarkToRow.values()) {
model.getStates().sort(Comparator.comparingLong(ITimeGraphState::getStartTime));
}
return new ArrayList<>(quarkToRow.values());
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class CriticalPathDataProvider method fetchRowModel.
@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
IGraphWorker graphWorker = getCurrent();
if (graphWorker == null) {
return new TmfModelResponse<>(null, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
CriticalPathVisitor visitor = fHorizontalVisitorCache.getIfPresent(graphWorker);
if (visitor == null) {
return new TmfModelResponse<>(null, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
// 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);
}
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(fetchParameters);
if (regexesMap != null) {
predicates.putAll(computeRegexPredicate(regexesMap));
}
List<@NonNull ITimeGraphRowModel> rowModels = new ArrayList<>();
for (Long id : filter.getSelectedItems()) {
/*
* need to use asMap, so that we don't return a row for an ID that does not
* belong to this provider, else fStates.get(id) might return an empty
* collection for an id from another data provider.
*/
Collection<ITimeGraphState> states = visitor.fStates.asMap().get(id);
if (states != null) {
List<ITimeGraphState> filteredStates = new ArrayList<>();
for (ITimeGraphState state : states) {
if (overlaps(state.getStartTime(), state.getDuration(), filter.getTimesRequested())) {
// Reset the properties for this state before filtering
state.setActiveProperties(0);
applyFilterAndAddState(filteredStates, state, id, predicates, monitor);
}
}
rowModels.add(new TimeGraphRowModel(id, filteredStates));
}
}
return new TmfModelResponse<>(new TimeGraphModel(rowModels), Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Aggregations