use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel 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());
}
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel 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);
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method createRows.
@NonNull
private Collection<@NonNull ITimeGraphRowModel> createRows(ITmfStateSystem ss, Map<Integer, Long> idToDisplayQuark, long[] timesRequested, @NonNull Map<@NonNull String, @NonNull Object> parameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(parameters);
if (regexesMap != null) {
predicates.putAll(computeRegexPredicate(regexesMap));
}
long currentEndTime = ss.getCurrentEndTime();
Map<Integer, ITimeGraphRowModel> quarkToRow = new HashMap<>(idToDisplayQuark.size());
for (Entry<Integer, Long> entry : idToDisplayQuark.entrySet()) {
quarkToRow.put(entry.getKey(), new TimeGraphRowModel(entry.getValue(), new ArrayList<>()));
}
for (ITmfStateInterval interval : ss.query2D(idToDisplayQuark.keySet(), getTimes(ss, timesRequested))) {
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);
applyFilterAndAddState(states, timeGraphState, row.getEntryID(), predicates, monitor);
}
}
for (ITimeGraphRowModel model : quarkToRow.values()) {
model.getStates().sort(Comparator.comparingLong(ITimeGraphState::getStartTime));
}
return quarkToRow.values();
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel 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);
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel 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);
}
Aggregations