This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 0397f829d60 Refactor ShowMigrationSourceStorageUnitsExecutor (#30096)
0397f829d60 is described below
commit 0397f829d60b47cd57b255a4f48132d627e7b10c
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Feb 12 01:02:08 2024 +0800
Refactor ShowMigrationSourceStorageUnitsExecutor (#30096)
* Refactor ShowMigrationSourceStorageUnitsExecutor
* Update javadoc
---
.../handler/query/ShadowAlgorithmTypeAndClassMapper.java | 2 +-
.../handler/query/ShardingAlgorithmTypeAndClassMapper.java | 2 +-
.../query/ShowMigrationSourceStorageUnitsExecutor.java | 13 +++----------
3 files changed, 5 insertions(+), 12 deletions(-)
diff --git
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmTypeAndClassMapper.java
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmTypeAndClassMapper.java
index bfcf22a3164..012eeffb0fa 100644
---
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmTypeAndClassMapper.java
+++
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmTypeAndClassMapper.java
@@ -21,7 +21,7 @@ import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.PluginTypeA
import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
/**
- * Show shadow algorithm type and class mapper.
+ * Shadow algorithm type and class mapper.
*/
public final class ShadowAlgorithmTypeAndClassMapper implements
PluginTypeAndClassMapper {
diff --git
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAlgorithmTypeAndClassMapper.java
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAlgorithmTypeAndClassMapper.java
index 1c406943466..734b92d0d29 100644
---
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAlgorithmTypeAndClassMapper.java
+++
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAlgorithmTypeAndClassMapper.java
@@ -21,7 +21,7 @@ import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.PluginTypeA
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
/**
- * Show sharding algorithm type and class mapper.
+ * Sharding algorithm type and class mapper.
*/
public final class ShardingAlgorithmTypeAndClassMapper implements
PluginTypeAndClassMapper {
diff --git
a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutor.java
b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutor.java
index feebc4abc97..58f4efc134b 100644
---
a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutor.java
+++
b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutor.java
@@ -29,16 +29,13 @@ import
org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.stream.Collectors;
/**
* Show migration source storage units executor.
*/
public final class ShowMigrationSourceStorageUnitsExecutor implements
DistSQLQueryExecutor<ShowMigrationSourceStorageUnitsStatement> {
- private final MigrationJobAPI jobAPI = (MigrationJobAPI)
TypedSPILoader.getService(TransmissionJobAPI.class, "MIGRATION");
-
@Override
public Collection<String> getColumnNames(final
ShowMigrationSourceStorageUnitsStatement sqlStatement) {
return Arrays.asList("name", "type", "host", "port", "db",
"connection_timeout_milliseconds", "idle_timeout_milliseconds",
@@ -47,12 +44,8 @@ public final class ShowMigrationSourceStorageUnitsExecutor
implements DistSQLQue
@Override
public Collection<LocalDataQueryResultRow> getRows(final
ShowMigrationSourceStorageUnitsStatement sqlStatement, final ContextManager
contextManager) {
- Iterator<Collection<Object>> data =
jobAPI.listMigrationSourceResources(new
PipelineContextKey(InstanceType.PROXY)).iterator();
- Collection<LocalDataQueryResultRow> result = new LinkedList<>();
- while (data.hasNext()) {
- result.add(new LocalDataQueryResultRow(data.next().toArray()));
- }
- return result;
+ MigrationJobAPI jobAPI = (MigrationJobAPI)
TypedSPILoader.getService(TransmissionJobAPI.class, "MIGRATION");
+ return jobAPI.listMigrationSourceResources(new
PipelineContextKey(InstanceType.PROXY)).stream().map(each -> new
LocalDataQueryResultRow(each.toArray())).collect(Collectors.toList());
}
@Override