From bc575fd8c78421a7aa4f48c8876506e0239bd581 Mon Sep 17 00:00:00 2001 From: Hongsheng Zhong Date: Mon, 18 Sep 2023 09:55:13 +0800 Subject: [PATCH] Add "type_aliases" column in "show migration check algorithms" DistSQL result (#28453) --- .../common/pojo/DataConsistencyCheckAlgorithmInfo.java | 2 ++ .../service/impl/AbstractInventoryIncrementalJobAPIImpl.java | 4 +++- .../handler/query/ShowMigrationCheckAlgorithmsExecutor.java | 4 ++-- .../query/ShowMigrationCheckAlgorithmsExecutorTest.java | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/pojo/DataConsistencyCheckAlgorithmInfo.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/pojo/DataConsistencyCheckAlgorithmInfo.java index cf93fe1df212f..4517de99e726c 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/pojo/DataConsistencyCheckAlgorithmInfo.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/pojo/DataConsistencyCheckAlgorithmInfo.java @@ -32,6 +32,8 @@ public final class DataConsistencyCheckAlgorithmInfo { private final String type; + private final String typeAliases; + private final Collection supportedDatabaseTypes; private final String description; diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/impl/AbstractInventoryIncrementalJobAPIImpl.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/impl/AbstractInventoryIncrementalJobAPIImpl.java index 560456be74690..ecf481e03cb9a 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/impl/AbstractInventoryIncrementalJobAPIImpl.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/impl/AbstractInventoryIncrementalJobAPIImpl.java @@ -61,6 +61,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; +import java.util.stream.Collectors; import java.util.stream.IntStream; /** @@ -203,7 +204,8 @@ public Collection listDataConsistencyCheckAlg Collection result = new LinkedList<>(); for (TableDataConsistencyChecker each : ShardingSphereServiceLoader.getServiceInstances(TableDataConsistencyChecker.class)) { SPIDescription description = each.getClass().getAnnotation(SPIDescription.class); - result.add(new DataConsistencyCheckAlgorithmInfo(each.getType(), getSupportedDatabaseTypes(each.getSupportedDatabaseTypes()), null == description ? "" : description.value())); + String typeAliases = each.getTypeAliases().stream().map(Object::toString).collect(Collectors.joining(",")); + result.add(new DataConsistencyCheckAlgorithmInfo(each.getType(), typeAliases, getSupportedDatabaseTypes(each.getSupportedDatabaseTypes()), null == description ? "" : description.value())); } return result; } diff --git a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutor.java b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutor.java index 5828efe938154..6b99ab543536c 100644 --- a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutor.java +++ b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutor.java @@ -38,14 +38,14 @@ public final class ShowMigrationCheckAlgorithmsExecutor implements QueryableRALE public Collection getRows(final ShowMigrationCheckAlgorithmsStatement sqlStatement) { InventoryIncrementalJobAPI jobAPI = (InventoryIncrementalJobAPI) TypedSPILoader.getService(PipelineJobAPI.class, "MIGRATION"); return jobAPI.listDataConsistencyCheckAlgorithms().stream().map( - each -> new LocalDataQueryResultRow(each.getType(), + each -> new LocalDataQueryResultRow(each.getType(), each.getTypeAliases(), each.getSupportedDatabaseTypes().stream().map(DatabaseType::getType).collect(Collectors.joining(",")), each.getDescription())) .collect(Collectors.toList()); } @Override public Collection getColumnNames() { - return Arrays.asList("type", "supported_database_types", "description"); + return Arrays.asList("type", "type_aliases", "supported_database_types", "description"); } @Override diff --git a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java index c458446260a75..2cca2b0748650 100644 --- a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java +++ b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java @@ -31,9 +31,10 @@ class ShowMigrationCheckAlgorithmsExecutorTest { void assertGetColumnNames() { ShowMigrationCheckAlgorithmsExecutor executor = new ShowMigrationCheckAlgorithmsExecutor(); Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); + assertThat(columns.size(), is(4)); Iterator iterator = columns.iterator(); assertThat(iterator.next(), is("type")); + assertThat(iterator.next(), is("type_aliases")); assertThat(iterator.next(), is("supported_database_types")); assertThat(iterator.next(), is("description")); }