Skip to content

Commit

Permalink
Refactor PipelineDataSourceCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 24, 2023
1 parent 8a18cdf commit 58252dd
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
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

0 comments on commit 58252dd

Please sign in to comment.