ruanwenjun opened a new issue #5083:
URL: https://github.com/apache/incubator-dolphinscheduler/issues/5083
**Describe the question**
If we add a new datasource type in the future, we need to make a log of
change to the code.
For example in `DataSourceController.createDataSource()`.
We may need to add parameters like `javaSecurityKrb5Conf` and add `required
= false`, because other datasource doesn't need the parameter.(This make the
method need to receive a large number of parameters and reduce readability).
And in `DataSourceServiceImpl.buildParameter`
We may need to make the same modification. But for any type of datasource,
we do the same logic for adding operation.
`
1. check params
2. transform params
3. insert to mysql
`
We need not change the core code
**What are the current deficiencies and the benefits of improvement**
Use a target class to wrap parameters of datasource, and add subclass for
each datasource, for example:
`
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = MysqlDatasourceParams.class, name = "1"),
@JsonSubTypes.Type(value = OracleDatasourceParams.class, name = "2"),
})
public abstract class AbstractDataDourceParams {
public abstract Integer getType();
}
`
The request from the front can be automatically bound to the subclass
through jackson deserialization, and the specific data source can be known
through the type.
And add check processor or transform processor for each datasource to
transform the params to metadata stored in mysql. After that, we needn't change
any code when add a new kind of datasource, we just add a new subclass of
datasource and add a new transform processor.
**Which version of DolphinScheduler:**
-[dev]
-[1.3.6]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]