-
Notifications
You must be signed in to change notification settings - Fork 23
server: Add get report data provider endpoint #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
server: Add get report data provider endpoint #174
Conversation
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Outdated
Show resolved
Hide resolved
8bfbd39 to
e57f3bd
Compare
bhufmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comment, plus you need to update the following interface for swagger documentation: https://github.com/eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator/blob/master/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/DataProvider.java
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Outdated
Show resolved
Hide resolved
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Outdated
Show resolved
Hide resolved
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Show resolved
Hide resolved
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Outdated
Show resolved
Hide resolved
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Outdated
Show resolved
Hide resolved
e57f3bd to
367a3c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
367a3c6 to
621ec48
Compare
621ec48 to
3a6f837
Compare
...cecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java
Outdated
Show resolved
Hide resolved
| return Response.status(Status.NOT_FOUND).entity(NO_SUCH_CONFIGURATION).build(); | ||
| } | ||
|
|
||
| IDataProviderFactory factory = manager.getFactory(REPORTS_FACTORY_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint has to be independent of the reports customization. For example, if the incubator analysis.core plug-in not installed, how would one fetch the data of a data provider of type MIME?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I tried to decouple this endpoint from REPORTS_FACTORY_ID by using the given output's id in the endpoint. However, the issue is that, except for ReportsDataProviderFactory, no other report data provider classes are inheriting the IDataProviderFactory. Hence, when loading the available factories in the startup, the report-based data providers whose ID is not REPORTS_FACTORY_ID would not be recognized as a factory.
As the ReportsDataProviderFactory class is responsible for handling the entire pipeline of reports, I guess we might need to keep the structure as is. Also, the endpoint is specifically for getting report data, which makes it suitable for using the REPORTS_FACTORY_ID in it, although in some cases, the user might not have installed this plugin.
What do you think of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REPORTS_FACTORY_ID is only available if the incubator.analysis.core plug-in is installed. Otherwise there can't be any reports create by anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's fine. Since the endpoint is only for this specific DP, in case of missing (e.g., not being installed), we can tell the user that it's not installed as a plug-in. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's fine. Since the endpoint is only for this specific DP, in case of missing (e.g., not being installed), we can tell the user that it's not installed as a plug-in. wdyt?
That's not really an option. Users cannot install plug-ins. Trace server applications are pre-build.
| @GET | ||
| @Path("/report/{outputId}") | ||
| @Tag(name = RPT) | ||
| @Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In you report related code, you call Files.probeContentType which will return image/jpg (for example). Will that work?
Here is some jersey documentation for @Produces:
https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/user-guide.html#d0e2272
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the MIME type is quite diverse, I have updated the @Produces type to MediaType.WILD_CARD to improve the extendability of this endpoint.
The proper output type (i.e., provided in the response's headers) is then handled by responseModel.getContentType().
| return Response.status(Status.NOT_FOUND).entity("Report data model not found").build(); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| return Response.ok(responseModel.getContent(), responseModel.getContentType()).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For images, responseModel.getContent() returns a object of type File. The content type will be determined by Files.probeContentType() which could return image/jpg or image/svg or if it can't be determined it will be application/octet-stream. I'm clear what will happen in each case and how a FE client can handle that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the endpoint is producing MediaType.WILD_CARD to ensure any MIME data can be handled. The responseModel.getContentType would be responsible for indicating the output type (e.g., image/jpg).
The FE client should handle the output based on the response's headers that indicate the output type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How, will it work? Clients could ask for e.g. applicationt/pdf and the endpoint will allow it because of the wildcard but then the implementation won't be able to create a PDF but an image instead. I'm not clear about the procedure and header negotiation yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, basically, the client can ask only based on the report type. For instance, the client only knows that it's an image, but doesn't know if it's a JPG or PNG or SVG. The endpoint then fetches the DP data, and returns the output with a specific content type, which can be image/jpg or image/png or etc. This information is provided in the response's headers as the content type (I have checked it already).
So, it would be the responsibility of the FE to properly show the image in the output based on the response's content type.
Following the introduction of configurable reports data providers, the trace server can now face a new data provider type for image providers (i.e., "MIME"). This commit introduces the required endpoint for fetching the MIME reports from the trace server based on the given configurable output id. [Added] A new GET endpoint for MIME report data providers Signed-off-by: Kaveh Shahedi <kaveh.shahedi@ericsson.com>
3a6f837 to
8db2085
Compare
| * @author Kaveh Shahedi | ||
| */ | ||
| public class ImageReportDataProvider implements IReportDataProvider { | ||
| public class ImageReportDataProvider implements IReportDataProvider, IDataProviderFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A data provider should not be a data provider factory. Generally,, we have data provider factories that create data provider instances which provide data (tree, xy, states, reports data). In this implementation, the reports data provider is a configurator, factory and data provider. The factory's main responsibility to create data providers. It can have the capabilities of a configurator. Using the configurator the data provider factory will be able to create instances of data providers using configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right. I was working around with this IDataProiderFactory to see how we can solve the manager.getFactory() issue in the DataProviderService class, but I forgot to remove it in the end from the class. I will fix it.
| return Response.status(Status.NOT_FOUND).entity(NO_SUCH_TRACE).build(); | ||
| } | ||
|
|
||
| IDataProviderDescriptor descriptor = getDescriptor(experiment, outputId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always return null, because the DataProviderManager doesn't know about the data provider with that ID (unless it was registered). This shows some issue with the DataProviderManager because it manages ITmfTreeDataProviders. So, either the reports data provider implements ITmfTreeDataProvider which is created by the reports data provider factory (not the cleanest implementation), or in Trace Compass mainline the DataProviderManager is updated to handle other data providers than trees or a new data provider manager is created for new types of data providers. Trace Compass designers will have to be involved with this design in Trace Compass core.
We need something like this below:
provider = manager.getOrCreateDataProvider(experiment, outputId, IReportDataProvider.class)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already tested this endpoint, and I could see that this code block is not returning null in cases where the given output is a valid report DP. It also works fine for cases where the ID of the output is not valid (e.g., not present in the DP manager).
I'm not sure if I have understood your point correctly or not, but please correct me if I'm wrong.
|
|
||
| @SuppressWarnings("restriction") | ||
| @Override | ||
| public TmfModelResponse<TmfDataProviderDataModel<?>> getData(ITmfTrace trace, IDataProviderDescriptor descriptor) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The factory should be responsible create data providers (see line 121 above which needs to be implemented). Then the instance of data provider that was created there needs to be this method getData().
| return Response.status(Status.NOT_FOUND).entity(NO_SUCH_CONFIGURATION).build(); | ||
| } | ||
|
|
||
| IDataProviderFactory factory = manager.getFactory(REPORTS_FACTORY_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REPORTS_FACTORY_ID is only available if the incubator.analysis.core plug-in is installed. Otherwise there can't be any reports create by anything else.
| return Response.status(Status.NOT_FOUND).entity("Report data model not found").build(); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| return Response.ok(responseModel.getContent(), responseModel.getContentType()).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How, will it work? Clients could ask for e.g. applicationt/pdf and the endpoint will allow it because of the wildcard but then the implementation won't be able to create a PDF but an image instead. I'm not clear about the procedure and header negotiation yet.
|
@kavehshahedi, please pay attention to PR #188 where the o.e.tc.incubator.analysis.* plug-ins are move to the analysis folder, in order to remove the callstack folder after cleaning-up that folder (#185). You will have re-import the plug-ins to your development environment and apply your report related changes there.. |

What it does
Following the introduction of configurable reports data providers, the trace server can now face a new data provider type for report providers (i.e., "MIME"). This commit introduces the required endpoint for fetching the MIME reports from the trace server based on the given configurable output id.
This PR depends on:
How to test
In order to fetch a specific image output from the server, you can send a
GETrequest with the following structure:/tsp/api/experiments/EXP-ID/outputs/report/REPORT-OUTPUT-IDFollow-ups
Review checklist