use of org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel 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.model.xy.ITmfXyModel in project tracecompass by tracecompass.
the class HistogramDataProviderTest method testHelloLost.
/**
* Test the {@link HistogramDataProvider} with the
* {@link CtfTestTrace#HELLO_LOST} trace. Ensure that the expected tree and xy
* models are returned
*
* @throws TmfAnalysisException
* if the trace is set more that once
*/
@Test
public void testHelloLost() throws TmfAnalysisException {
CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.HELLO_LOST);
TmfStatisticsModule module = new TmfStatisticsModule();
module.setName("Statistics");
assertTrue("Statistics Analysis should apply to this trace", module.setTrace(trace));
assertEquals("Statistics Analysis shouls be schedulable", Status.OK_STATUS, module.schedule());
assertTrue("Statistics Analysis should run successfully", module.waitForCompletion());
try {
HistogramDataProvider provider = new HistogramDataProvider(trace, module);
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> treeResponse = provider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(START, END, 2)), null);
assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
TmfTreeModel<@NonNull TmfTreeDataModel> treeModel = treeResponse.getModel();
assertNotNull(treeModel);
assertEquals(EXPECTED_FULL_PATHS, getFullPaths(treeModel.getEntries()));
List<Long> ids = Lists.transform(treeModel.getEntries(), TmfTreeDataModel::getId);
SelectionTimeQueryFilter selectionFilter = new SelectionTimeQueryFilter(START, END, 100, ids);
TmfModelResponse<@NonNull ITmfXyModel> xyResponse = provider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(selectionFilter), null);
assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, xyResponse.getStatus());
ITmfXyModel xyModel = xyResponse.getModel();
assertNotNull(xyModel);
assertEquals(EXPECTED_YDATA, Maps.uniqueIndex(xyModel.getSeriesData(), ISeriesModel::getId));
} finally {
module.dispose();
CtfTmfTestTraceUtils.dispose(CtfTestTrace.HELLO_LOST);
}
}
Aggregations