-
Notifications
You must be signed in to change notification settings - Fork 14
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
server: support for customizable data providers (outputs) via data provider factories #80
server: support for customizable data providers (outputs) via data provider factories #80
Conversation
1a087fb
to
fd96cc5
Compare
...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
Show resolved
Hide resolved
@ApiResponse(responseCode = "200", description = "Returns a list of output provider descriptors", content = @Content(array = @ArraySchema(schema = @Schema(implementation = DataProvider.class)))), | ||
@ApiResponse(responseCode = "400", description = INVALID_PARAMETERS, content = @Content(schema = @Schema(implementation = String.class))), | ||
@ApiResponse(responseCode = "404", description = PROVIDER_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), | ||
@ApiResponse(responseCode = "404", description = NO_SUCH_CONFIGURATION, content = @Content(schema = @Schema(implementation = String.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.
Can this happen? Is it when the typeId inside the OutputConfigurationQueryParameters is not recognized by the data provider (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.
Yes, if configType for a typeId doesn't exists for the given output.
@Operation(summary = "Delete a configuration instance of a given configuration source type", responses = { | ||
@ApiResponse(responseCode = "200", description = "The derived data provider (and it's configuration) was successfully deleted", content = @Content(schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.Configuration.class))), | ||
@ApiResponse(responseCode = "404", description = PROVIDER_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), | ||
@ApiResponse(responseCode = "404", description = NO_SUCH_CONFIGURATION, content = @Content(schema = @Schema(implementation = String.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 assume PROVIDER_NOT_FOUND is for the outputId and NO_SUCH_CONFIGURATION is for the derivedOutputId?
Should we have a different message for that one?
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.
yes, if derived output doesn't exists then we would return NO_SUCH_CONFIGURATION.
* Contributes to the model used for TSP swagger-core annotations. | ||
*/ | ||
@Schema(allOf = ConfigurationQueryParameters.class) | ||
public interface OutputConfigurationQueryParameters extends ConfigurationQueryParameters { |
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 suggestion was made to have typeId, name, and description as explicit fields in a parameters map because these are used by the configuration feature itself, so their use can be described in the TSP, and they don't need to be included or described in the JSON Schema.
For the application-specific parameters, it was suggested to use a 'properties' field in the parameters map, where the value is an object that matches and validates against the corresponding 'properties' definition in the JSON Schema of the configuration source 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.
It's true, that name and description are valid for all configurations, so is the typeId. They could be part of the TSP definition instead of each configuration extension. The typeId would be required, the name and description can be optional.
Using properties would help us to distinguish the TSP string parameters and the custom parameters. However, if we use parameters, then the whole json would look like a serialized ITmfConfiguration (without the ID which will be assigned). I think both are ok.
So here how it would look like from the TSP point of view (for InAndOut analysis) :
{
"parameters": {
"name": "An InAndOut Analysis",
"description": "My own InAndOut analysis",
"typeId": "org.eclipse.tracecompass.incubator.internal.inandout.core.config",
"properties":
{
"specifiers" : [
{
"label":"Latency",
"inRegex":"(\\S*)_entry",
"outRegex":"(\\S*)_exit",
"contextInRegex":"(\\S*)_entry",
"contextOutRegex":"(\\S*)_exit",
"classifier":"CPU"
}
]
}
},
}
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 per discussion here #70 (comment), properties
will be replaced by parameters
to match the Configuration data structure
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 came to the realization, that having the name, description and type ID inside the Map<String, Object> and extracting the custom parameters map is not ideal. The items passed are actually the items of an ITmfConfiguration
object, where the ID is created in the back-end and doesn't need to be passed.
See eclipse-tracecompass/org.eclipse.tracecompass#167 for an update of the API.
fd96cc5
to
6a35ec9
Compare
6a35ec9
to
96a343d
Compare
} | ||
|
||
Map<String, Object> parameters = queryParameters.getParameters(); | ||
if (!(parameters.get(DataProviderParameterUtils.CONFIGURATION_TYPE_ID) instanceof String)){ |
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 should be queryParameters.getTypeId() ?
edit: But this is only introduced in the next commit.
edit 2: Then you can probably remove the "typeId" constant in DataProviderParameterUtils?
} | ||
|
||
private static @Nullable IDataProviderDescriptor getDescriptor(@NonNull ITmfTrace experiment, @NonNull String outputId) { | ||
List<IDataProviderDescriptor> list = DataProviderManager.getInstance().getAvailableProviders(experiment); |
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.
If method not static this could use 'manager' variable.
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.
Done
return null; | ||
} | ||
|
||
|
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.
extra blank line
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.
Done
|
||
IDataProviderFactory factory = manager.getFactory(outputId); | ||
if (factory == null) { | ||
return Response.status(Status.METHOD_NOT_ALLOWED).entity(NO_SUCH_PROVIDER).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.
It seems this status should only be used when the method (e.g. POST, DELETE) is not allowed for this endpoint.
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.
Makes sense. I'll update what is returned and align the API documentation
96a343d
to
ea062d8
Compare
@@ -521,6 +525,9 @@ public Response getStates( | |||
return Response.status(Status.BAD_REQUEST).entity(errorMessage).build(); | |||
} | |||
|
|||
Object value = params.get(DataProviderParameterUtils.REQUESTED_ITEMS_KEY); | |||
System.out.println(value); |
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.
remove
Update ConfigurationManagerService and corresponding tests for that. Signed-off-by: Bernd Hufmann <[email protected]>
Update skeleton endpoints in DataProviderService for that. Use ITmfDataProviderConfigurator interface for that. Signed-off-by: Bernd Hufmann <[email protected]>
ea062d8
to
81e3eb3
Compare
fcbdca6
into
eclipse-tracecompass-incubator:master
It uses the new
IDataProviderFactory.getAdapter()
interface to getITmfDataProviderConfigurator
implementation to create data providers. It passes anITmfConfiguration
instance with default TSP parameters (name, description, typeId) and the custom parameters in a JSON convertedMap<String, Object>
on to the configurator which the implementer ofITmfDataProviderConfigurator
needs to apply.It depends on
eclipse-tracecompass/org.eclipse.tracecompass#154
eclipse-tracecompass/org.eclipse.tracecompass#167
This PR includes changes of PR #71 and its dependent pull requests, and will be rebased once dependent PRs are merged.