Skip to content
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

Conversation

bhufmann
Copy link
Contributor

@bhufmann bhufmann commented Sep 23, 2024

It uses the new IDataProviderFactory.getAdapter() interface to get ITmfDataProviderConfigurator implementation to create data providers. It passes an ITmfConfiguration instance with default TSP parameters (name, description, typeId) and the custom parameters in a JSON converted Map<String, Object> on to the configurator which the implementer of ITmfDataProviderConfigurator 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.

@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))),
Copy link
Contributor

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)?

Copy link
Contributor Author

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))),
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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"
              }
          ]
        }
    },
}

FYI @abhinava-ericsson

Copy link
Contributor Author

@bhufmann bhufmann Oct 17, 2024

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

Copy link
Contributor Author

@bhufmann bhufmann Oct 21, 2024

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.

}

Map<String, Object> parameters = queryParameters.getParameters();
if (!(parameters.get(DataProviderParameterUtils.CONFIGURATION_TYPE_ID) instanceof String)){
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return null;
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra blank line

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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

@bhufmann bhufmann force-pushed the output-conifg-factory-impl branch from 96a343d to ea062d8 Compare October 22, 2024 19:03
@@ -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);
Copy link
Contributor

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]>
@bhufmann bhufmann force-pushed the output-conifg-factory-impl branch from ea062d8 to 81e3eb3 Compare October 22, 2024 19:30
@bhufmann bhufmann merged commit fcbdca6 into eclipse-tracecompass-incubator:master Oct 22, 2024
2 checks passed
@bhufmann bhufmann deleted the output-conifg-factory-impl branch October 22, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants