This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 1cd2459aa3b Refactor DataSourceCheckEngine (#29474)
1cd2459aa3b is described below
commit 1cd2459aa3bccc56194eab767d5f72ed13316417
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Dec 20 19:49:25 2023 +0800
Refactor DataSourceCheckEngine (#29474)
* Refactor DataSourceCheckEngine
* Refactor DataSourceCheckEngine
---
.../data/pipeline/core/checker/DataSourceCheckEngine.java | 9 ++++-----
.../data/pipeline/core/preparer/PipelineJobPreparer.java | 8 ++++----
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/checker/DataSourceCheckEngine.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/checker/DataSourceCheckEngine.java
index e7759414322..e424525be4d 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/checker/DataSourceCheckEngine.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/checker/DataSourceCheckEngine.java
@@ -85,16 +85,15 @@ public final class DataSourceCheckEngine {
*/
public void checkTargetDataSources(final Collection<DataSource>
dataSources, final ImporterConfiguration importerConfig) {
checkConnection(dataSources);
- checkTargetTable(dataSources,
importerConfig.getTableAndSchemaNameMapper(),
importerConfig.getLogicTableNames());
+ checkEmptyTable(dataSources,
importerConfig.getTableAndSchemaNameMapper(),
importerConfig.getLogicTableNames());
}
- // TODO rename to common usage name
// TODO Merge schemaName and tableNames
- private void checkTargetTable(final Collection<DataSource> dataSources,
final TableAndSchemaNameMapper tableAndSchemaNameMapper, final
Collection<String> logicTableNames) {
+ private void checkEmptyTable(final Collection<DataSource> dataSources,
final TableAndSchemaNameMapper tableAndSchemaNameMapper, final
Collection<String> logicTableNames) {
try {
for (DataSource each : dataSources) {
for (String tableName : logicTableNames) {
- ShardingSpherePreconditions.checkState(checkEmpty(each,
tableAndSchemaNameMapper.getSchemaName(tableName), tableName),
+
ShardingSpherePreconditions.checkState(checkEmptyTable(each,
tableAndSchemaNameMapper.getSchemaName(tableName), tableName),
() -> new
PrepareJobWithTargetTableNotEmptyException(tableName));
}
}
@@ -103,7 +102,7 @@ public final class DataSourceCheckEngine {
}
}
- private boolean checkEmpty(final DataSource dataSource, final String
schemaName, final String tableName) throws SQLException {
+ private boolean checkEmptyTable(final DataSource dataSource, final String
schemaName, final String tableName) throws SQLException {
String sql = sqlBuilder.buildCheckEmptySQL(schemaName, tableName);
try (
Connection connection = dataSource.getConnection();
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparer.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparer.java
index 792f581f092..e2cd721a675 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparer.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/PipelineJobPreparer.java
@@ -50,16 +50,16 @@ public final class PipelineJobPreparer {
/**
* Get incremental position.
*
- * @param initIncremental init incremental
+ * @param initialProgress initial iob item incremental tasks progress
* @param dumperContext incremental dumper context
* @param dataSourceManager data source manager
* @return ingest position
* @throws SQLException SQL exception
*/
- public IngestPosition getIncrementalPosition(final
JobItemIncrementalTasksProgress initIncremental, final IncrementalDumperContext
dumperContext,
+ public IngestPosition getIncrementalPosition(final
JobItemIncrementalTasksProgress initialProgress, final IncrementalDumperContext
dumperContext,
final
PipelineDataSourceManager dataSourceManager) throws SQLException {
- if (null != initIncremental) {
- Optional<IngestPosition> position =
initIncremental.getIncrementalPosition();
+ if (null != initialProgress) {
+ Optional<IngestPosition> position =
initialProgress.getIncrementalPosition();
if (position.isPresent()) {
return position.get();
}