use of org.eclipse.tracecompass.tmf.core.response.TmfModelResponse in project tracecompass by tracecompass.
the class TmfTreeCompositeDataProvider method fetchAnnotations.
@Override
public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
boolean isComplete = true;
AnnotationModel model = new AnnotationModel(Collections.emptyMap());
for (P dataProvider : getProviders()) {
if (dataProvider instanceof IOutputAnnotationProvider) {
TmfModelResponse<AnnotationModel> response = ((IOutputAnnotationProvider) dataProvider).fetchAnnotations(fetchParameters, monitor);
isComplete &= response.getStatus() == ITmfResponse.Status.COMPLETED;
model = AnnotationModel.of(model, response.getModel());
if (monitor != null && monitor.isCanceled()) {
return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
}
}
if (isComplete) {
return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
return new TmfModelResponse<>(model, ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
use of org.eclipse.tracecompass.tmf.core.response.TmfModelResponse in project tracecompass by tracecompass.
the class TmfTreeXYCompositeDataProvider method fetchXY.
@Override
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
/**
* <pre>
* Response status according to the provider's reponse statuses:
*
* * Cancelled -> The monitor is cancelled
* * Failed -> At least one provider has failed
* * Running -> At least one of the providers is running
* * Completed -> All providers have completed
* </pre>
*/
List<P> providers = getProviders();
// Get all the responses
Collection<TmfModelResponse<ITmfXyModel>> responses = getXyResponses(fetchParameters, monitor, providers);
if (monitor != null && monitor.isCanceled()) {
return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
}
// If one response is failed, return a failed response with a concatenation of the messages
String failedMsg = handleFailedStatus(responses);
if (failedMsg != null) {
return TmfXyResponseFactory.createFailedResponse(failedMsg);
}
boolean allCommon = Iterables.all(providers, ITmfCommonXAxisModel.class::isInstance);
// The query is considered complete if all providers are completed
boolean isComplete = Iterables.all(responses, response -> response.getStatus() == ITmfResponse.Status.COMPLETED);
if (allCommon) {
ImmutableList.Builder<IYModel> series = ImmutableList.builder();
responses.forEach(response -> {
ITmfCommonXAxisModel model = (ITmfCommonXAxisModel) response.getModel();
if (model != null) {
series.addAll(model.getYSeriesData());
}
});
TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
if (filter == null) {
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
return TmfXyResponseFactory.create(fTitle, filter.getTimesRequested(), series.build(), isComplete);
}
ImmutableList.Builder<ISeriesModel> series = ImmutableList.builder();
responses.forEach(response -> {
ITmfXyModel model = response.getModel();
if (model != null) {
series.addAll(model.getSeriesData());
}
});
return TmfXyResponseFactory.create(fTitle, series.build(), isComplete);
}
use of org.eclipse.tracecompass.tmf.core.response.TmfModelResponse in project tracecompass by tracecompass.
the class StateSystemDataProvider method fetchTooltip.
@Override
public TmfModelResponse<Map<String, String>> fetchTooltip(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
Map<Long, Pair<ITmfStateSystem, Integer>> entries = getSelectedEntries(fetchParameters);
if (entries.size() != 1) {
// Not the expected size of tooltip, just return empty
return new TmfModelResponse<>(null, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Entry<@NonNull Long, @NonNull Pair<ITmfStateSystem, Integer>> entry = entries.entrySet().iterator().next();
Map<String, String> tooltip = new HashMap<>();
Integer quark = Objects.requireNonNull(entry.getValue()).getSecond();
ITmfStateSystem ss = Objects.requireNonNull(entry.getValue()).getFirst();
tooltip.put(String.valueOf(Messages.QuarkColumnLabel), Integer.toString(quark));
tooltip.put(String.valueOf(Messages.AttributePathColumnLabel), ss.getFullAttributePath(quark));
tooltip.put(String.valueOf(Messages.ValueColumnLabel), getQuarkValue(fetchParameters, ss, quark));
return new TmfModelResponse<>(tooltip, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
use of org.eclipse.tracecompass.tmf.core.response.TmfModelResponse 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);
}
}
use of org.eclipse.tracecompass.tmf.core.response.TmfModelResponse in project tracecompass by tracecompass.
the class ResourcesStatusDataProvider method fetchTooltip.
@Override
@NonNull
public TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> fetchTooltip(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
ITmfStateSystem ss = getAnalysisModule().getStateSystem();
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
if (filter == null) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
Collection<@NonNull Integer> quarks = getSelectedEntries(filter).values();
boolean isACopy = false;
if (quarks.size() != 1) {
Map<Long, Integer> selectedEntries = new HashMap<>();
for (Long selectedItem : filter.getSelectedItems()) {
Integer quark = fTwinIdsToQuark.get(selectedItem);
if (quark != null && quark >= 0) {
selectedEntries.put(selectedItem, quark);
isACopy = true;
}
}
quarks = selectedEntries.values();
}
long start = filter.getStart();
if (ss == null || quarks.size() != 1 || !getAnalysisModule().isQueryable(start)) {
/*
* We need the ss to query, we should only be querying one attribute and the
* query times should be valid.
*/
return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
int quark = quarks.iterator().next();
// assert that it is a CPU quark
String attributeName = ss.getAttributeName(quark);
Integer cpuNumber = Ints.tryParse(attributeName);
String parent = ss.getAttributeName(ss.getParentAttributeQuark(quark));
if (cpuNumber == null && !(attributeName.equals(Attributes.CURRENT_THREAD) || attributeName.equals(Attributes.CURRENT_FREQUENCY))) {
return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
try {
Map<String, String> retMap = new LinkedHashMap<>(1);
List<ITmfStateInterval> full = ss.queryFullState(start);
Object object = full.get(quark).getValue();
if (object instanceof Integer) {
int status = (int) object;
if (isACopy) {
retMap.put(parent.equals(Attributes.IRQS) ? Messages.ResourcesStatusDataProvider_attributeIrqName : Messages.ResourcesStatusDataProvider_attributeSoftIrqName, attributeName);
} else if (parent.equals(Attributes.IRQS) || parent.equals(Attributes.SOFT_IRQS)) {
putCpus(ss, quark, retMap, full, parent, status);
} else if (status == StateValues.CPU_STATUS_IRQ) {
putIrq(ss, attributeName, retMap, full, Attributes.IRQS, status);
} else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
putIrq(ss, attributeName, retMap, full, Attributes.SOFT_IRQS, status);
} else if (status == StateValues.CPU_STATUS_RUN_USERMODE || status == StateValues.CPU_STATUS_RUN_SYSCALL) {
putCpuTooltip(ss, attributeName, retMap, full, status);
} else if (attributeName.equals(Attributes.CURRENT_THREAD)) {
putCurrentThreadTooltip(ss, retMap, full, status);
}
} else if (object instanceof Long && attributeName.equals(Attributes.CURRENT_FREQUENCY)) {
// $NON-NLS-1$
retMap.put("Frequency", FREQUENCY_FORMATTER.format(object));
}
return new TmfModelResponse<>(retMap, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
} catch (StateSystemDisposedException e) {
}
return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Aggregations