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

Refactor PipelineDataSourceCreator #29196

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class ShardingSpherePipelineDataSourceCreator implements PipelineDa
private static final AtomicInteger STANDALONE_DATABASE_ID = new AtomicInteger(1);

@Override
public DataSource createPipelineDataSource(final Object dataSourceConfig) throws SQLException {
public DataSource create(final Object dataSourceConfig) throws SQLException {
YamlRootConfiguration rootConfig = YamlEngine.unmarshal(YamlEngine.marshal(dataSourceConfig), YamlRootConfiguration.class);
removeAuthorityRule(rootConfig);
updateSingleRuleConfiguration(rootConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ public interface PipelineDataSourceCreator extends TypedSPI {
* @return pipeline data source
* @throws SQLException if create data source failed
*/
DataSource createPipelineDataSource(Object dataSourceConfig) throws SQLException;
DataSource create(Object dataSourceConfig) throws SQLException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class PipelineDataSourceFactory {
@SneakyThrows(SQLException.class)
public static PipelineDataSourceWrapper newInstance(final PipelineDataSourceConfiguration pipelineDataSourceConfig) {
DataSource dataSource = TypedSPILoader.getService(
PipelineDataSourceCreator.class, pipelineDataSourceConfig.getType()).createPipelineDataSource(pipelineDataSourceConfig.getDataSourceConfiguration());
PipelineDataSourceCreator.class, pipelineDataSourceConfig.getType()).create(pipelineDataSourceConfig.getDataSourceConfiguration());
return new PipelineDataSourceWrapper(dataSource, pipelineDataSourceConfig.getDatabaseType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public final class StandardPipelineDataSourceCreator implements PipelineDataSourceCreator {

@Override
public DataSource createPipelineDataSource(final Object dataSourceConfig) {
public DataSource create(final Object dataSourceConfig) {
return DataSourcePoolCreator.create((DataSourcePoolProperties) dataSourceConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public final class FixturePipelineDataSourceCreator implements PipelineDataSourceCreator {

@Override
public DataSource createPipelineDataSource(final Object dataSourceConfig) {
public DataSource create(final Object dataSourceConfig) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ private void initTableData(final MigrationJobConfiguration jobConfig) {
PipelineDataSourceConfiguration source = jobConfig.getSources().values().iterator().next();
PipelineDataSourceConfiguration sourceDataSourceConfig = PipelineDataSourceConfigurationFactory.newInstance(source.getType(), source.getParameter());
initTableData(TypedSPILoader.getService(
PipelineDataSourceCreator.class, sourceDataSourceConfig.getType()).createPipelineDataSource(sourceDataSourceConfig.getDataSourceConfiguration()));
PipelineDataSourceCreator.class, sourceDataSourceConfig.getType()).create(sourceDataSourceConfig.getDataSourceConfiguration()));
PipelineDataSourceConfiguration targetDataSourceConfig = PipelineDataSourceConfigurationFactory.newInstance(jobConfig.getTarget().getType(), jobConfig.getTarget().getParameter());
initTableData(TypedSPILoader.getService(
PipelineDataSourceCreator.class, targetDataSourceConfig.getType()).createPipelineDataSource(targetDataSourceConfig.getDataSourceConfiguration()));
PipelineDataSourceCreator.class, targetDataSourceConfig.getType()).create(targetDataSourceConfig.getDataSourceConfiguration()));
}

private void initTableData(final DataSource pipelineDataSource) throws SQLException {
Expand Down