Skip to content

Commit

Permalink
Refactor ShowMigrationSourceStorageUnitsExecutor (#30096)
Browse files Browse the repository at this point in the history
* Refactor ShowMigrationSourceStorageUnitsExecutor

* Update javadoc
  • Loading branch information
terrymanu authored Feb 11, 2024
1 parent 9e22577 commit 0397f82
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@

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",
Expand All @@ -47,12 +44,8 @@ public Collection<String> getColumnNames(final ShowMigrationSourceStorageUnitsSt

@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
Expand Down

0 comments on commit 0397f82

Please sign in to comment.