This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 7b3a525fe46 Refactor usage of LocalDataQueryResultRow (#30113)
7b3a525fe46 is described below
commit 7b3a525fe46a54d88177aa0089c177a3be1e9b71
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Feb 13 22:58:30 2024 +0800
Refactor usage of LocalDataQueryResultRow (#30113)
* Refactor usage of LocalDataQueryResultRow
* Refactor usage of LocalDataQueryResultRow
---
.../distsql/handler/query/ShowEncryptRuleExecutor.java | 14 ++++++++------
.../query/ShowDefaultShardingStrategyExecutor.java | 2 +-
.../handler/query/ShowShardingTableRuleExecutor.java | 18 +++++++++---------
.../executor/rql/resource/ShowStorageUnitExecutor.java | 3 +--
.../result/impl/local/LocalDataQueryResultRow.java | 11 +++++++++--
.../result/impl/local/LocalDataMergedResultTest.java | 2 +-
.../handler/query/ShowStreamingListExecutor.java | 3 +--
.../handler/query/ShowMigrationJobStatusExecutor.java | 13 +++++++++----
.../handler/query/ShowSQLTranslatorRuleExecutor.java | 2 +-
.../distsql/handler/query/ShowTrafficRuleExecutor.java | 4 ++--
.../ral/queryable/ShowComputeNodeInfoExecutor.java | 2 +-
.../ral/queryable/ShowComputeNodeModeExecutor.java | 4 ++--
.../ral/queryable/ShowComputeNodesExecutor.java | 4 ++--
.../ral/queryable/ShowTableMetaDataExecutor.java | 5 ++---
.../handler/admin/executor/ShowVersionExecutor.java | 4 ++--
15 files changed, 51 insertions(+), 40 deletions(-)
diff --git
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
index fd7235ed3d0..44514d9e9ad 100644
---
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
+++
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
@@ -33,6 +33,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
import java.util.stream.Collectors;
/**
@@ -59,8 +61,8 @@ public final class ShowEncryptRuleExecutor implements
DistSQLQueryExecutor<ShowE
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
for (EncryptColumnRuleConfiguration each :
tableRuleConfig.getColumns()) {
AlgorithmConfiguration encryptorAlgorithmConfig =
encryptors.get(each.getCipher().getEncryptorName());
- AlgorithmConfiguration assistedQueryEncryptorAlgorithmConfig =
each.getAssistedQuery().isPresent() ?
encryptors.get(each.getAssistedQuery().get().getEncryptorName()) : null;
- AlgorithmConfiguration likeQueryEncryptorAlgorithmConfig =
each.getLikeQuery().isPresent() ?
encryptors.get(each.getLikeQuery().get().getEncryptorName()) : null;
+ Optional<AlgorithmConfiguration>
assistedQueryEncryptorAlgorithmConfig = each.getAssistedQuery().map(optional ->
encryptors.get(optional.getEncryptorName()));
+ Optional<AlgorithmConfiguration> likeQueryEncryptorAlgorithmConfig
= each.getLikeQuery().map(optional ->
encryptors.get(optional.getEncryptorName()));
result.add(new LocalDataQueryResultRow(
tableRuleConfig.getName(),
each.getName(),
@@ -69,10 +71,10 @@ public final class ShowEncryptRuleExecutor implements
DistSQLQueryExecutor<ShowE
each.getLikeQuery().map(EncryptColumnItemRuleConfiguration::getName).orElse(""),
encryptorAlgorithmConfig.getType(),
encryptorAlgorithmConfig.getProps(),
- null == assistedQueryEncryptorAlgorithmConfig ? "" :
assistedQueryEncryptorAlgorithmConfig.getType(),
- null == assistedQueryEncryptorAlgorithmConfig ? "" :
assistedQueryEncryptorAlgorithmConfig.getProps(),
- null == likeQueryEncryptorAlgorithmConfig ? "" :
likeQueryEncryptorAlgorithmConfig.getType(),
- null == likeQueryEncryptorAlgorithmConfig ? "" :
likeQueryEncryptorAlgorithmConfig.getProps()));
+
assistedQueryEncryptorAlgorithmConfig.map(AlgorithmConfiguration::getType).orElse(""),
+
assistedQueryEncryptorAlgorithmConfig.map(AlgorithmConfiguration::getProps).orElse(new
Properties()),
+
likeQueryEncryptorAlgorithmConfig.map(AlgorithmConfiguration::getType).orElse(""),
+
likeQueryEncryptorAlgorithmConfig.map(AlgorithmConfiguration::getProps).orElse(new
Properties())));
}
return result;
}
diff --git
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowDefaultShardingStrategyExecutor.java
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowDefaultShardingStrategyExecutor.java
index ac509ef2a58..5b1f142b4cc 100644
---
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowDefaultShardingStrategyExecutor.java
+++
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowDefaultShardingStrategyExecutor.java
@@ -67,7 +67,7 @@ public final class ShowDefaultShardingStrategyExecutor
implements DistSQLQueryEx
Iterator<String> iterator =
strategyType.getConfigurationContents(strategyConfig).iterator();
String shardingColumn = iterator.next();
String algorithmName = iterator.next();
- return new LocalDataQueryResultRow(defaultType,
strategyType.toString(), shardingColumn, algorithmName,
algorithmConfig.getType(), algorithmConfig.getProps());
+ return new LocalDataQueryResultRow(defaultType, strategyType,
shardingColumn, algorithmName, algorithmConfig.getType(),
algorithmConfig.getProps());
}
@Override
diff --git
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableRuleExecutor.java
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableRuleExecutor.java
index 976c94191f9..ee554a69048 100644
---
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableRuleExecutor.java
+++
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableRuleExecutor.java
@@ -83,12 +83,12 @@ public final class ShowShardingTableRuleExecutor implements
DistSQLQueryExecutor
Optional<ShardingStrategyConfiguration> databaseShardingStrategyConfig
= getDatabaseShardingStrategy(ruleConfig, shardingTableRuleConfig);
Optional<ShardingStrategyConfiguration> tableShardingStrategyConfig =
getTableShardingStrategy(ruleConfig,
shardingTableRuleConfig.getTableShardingStrategy());
return new
LocalDataQueryResultRow(shardingTableRuleConfig.getLogicTable(),
shardingTableRuleConfig.getActualDataNodes(), "",
-
databaseShardingStrategyConfig.map(this::getStrategyType).orElse(""),
databaseShardingStrategyConfig.map(this::getShardingColumn).orElse(""),
- databaseShardingStrategyConfig.map(optional ->
getAlgorithmType(ruleConfig, optional)).orElse(""),
- databaseShardingStrategyConfig.map(optional ->
getAlgorithmProperties(ruleConfig, optional)).orElse(new Properties()),
-
tableShardingStrategyConfig.map(this::getStrategyType).orElse(""),
tableShardingStrategyConfig.map(this::getShardingColumn).orElse(""),
- tableShardingStrategyConfig.map(optional ->
getAlgorithmType(ruleConfig, optional)).orElse(""),
- tableShardingStrategyConfig.map(optional ->
getAlgorithmProperties(ruleConfig, optional)).orElse(new Properties()),
+ databaseShardingStrategyConfig.map(this::getStrategyType),
databaseShardingStrategyConfig.map(this::getShardingColumn),
+ databaseShardingStrategyConfig.map(optional ->
getAlgorithmType(ruleConfig, optional)),
+ databaseShardingStrategyConfig.map(optional ->
getAlgorithmProperties(ruleConfig, optional)),
+
tableShardingStrategyConfig.map(this::getStrategyType).orElse(""),
tableShardingStrategyConfig.map(this::getShardingColumn),
+ tableShardingStrategyConfig.map(optional ->
getAlgorithmType(ruleConfig, optional)),
+ tableShardingStrategyConfig.map(optional ->
getAlgorithmProperties(ruleConfig, optional)),
getKeyGenerateColumn(ruleConfig,
shardingTableRuleConfig.getKeyGenerateStrategy()),
getKeyGeneratorType(ruleConfig,
shardingTableRuleConfig.getKeyGenerateStrategy()),
getKeyGeneratorProps(ruleConfig,
shardingTableRuleConfig.getKeyGenerateStrategy()), getAuditorTypes(ruleConfig,
shardingTableRuleConfig.getAuditStrategy()),
getAllowHintDisable(ruleConfig,
shardingTableRuleConfig.getAuditStrategy()));
@@ -97,9 +97,9 @@ public final class ShowShardingTableRuleExecutor implements
DistSQLQueryExecutor
private LocalDataQueryResultRow buildAutoTableRowData(final
ShardingRuleConfiguration ruleConfig, final ShardingAutoTableRuleConfiguration
shardingAutoTableRuleConfig) {
Optional<ShardingStrategyConfiguration> tableShardingStrategyConfig =
getTableShardingStrategy(ruleConfig,
shardingAutoTableRuleConfig.getShardingStrategy());
return new
LocalDataQueryResultRow(shardingAutoTableRuleConfig.getLogicTable(), "",
shardingAutoTableRuleConfig.getActualDataSources(), "", "", "", "",
-
tableShardingStrategyConfig.map(this::getStrategyType).orElse(""),
tableShardingStrategyConfig.map(this::getShardingColumn).orElse(""),
- tableShardingStrategyConfig.map(optional ->
getAlgorithmType(ruleConfig, optional)).orElse(""),
- tableShardingStrategyConfig.map(optional ->
getAlgorithmProperties(ruleConfig, optional)).orElse(new Properties()),
+ tableShardingStrategyConfig.map(this::getStrategyType),
tableShardingStrategyConfig.map(this::getShardingColumn),
+ tableShardingStrategyConfig.map(optional ->
getAlgorithmType(ruleConfig, optional)),
+ tableShardingStrategyConfig.map(optional ->
getAlgorithmProperties(ruleConfig, optional)),
getKeyGenerateColumn(ruleConfig,
shardingAutoTableRuleConfig.getKeyGenerateStrategy()),
getKeyGeneratorType(ruleConfig,
shardingAutoTableRuleConfig.getKeyGenerateStrategy()),
getKeyGeneratorProps(ruleConfig,
shardingAutoTableRuleConfig.getKeyGenerateStrategy()),
getAuditorTypes(ruleConfig, shardingAutoTableRuleConfig.getAuditStrategy()),
getAllowHintDisable(ruleConfig,
shardingAutoTableRuleConfig.getAuditStrategy()));
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rql/resource/ShowStorageUnitExecutor.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rql/resource/ShowStorageUnitExecutor.java
index df1862bf467..bb9e7f702d9 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rql/resource/ShowStorageUnitExecutor.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rql/resource/ShowStorageUnitExecutor.java
@@ -30,7 +30,6 @@ import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryRes
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.util.json.JsonUtils;
import org.apache.shardingsphere.mode.manager.ContextManager;
import javax.sql.DataSource;
@@ -76,7 +75,7 @@ public final class ShowStorageUnitExecutor implements
DistSQLQueryExecutor<ShowS
getStandardProperty(poolProps, "maxPoolSize"),
getStandardProperty(poolProps, "minPoolSize"),
getStandardProperty(poolProps, "readOnly"),
- customProps.isEmpty() ? "" :
JsonUtils.toJsonString(customProps)));
+ customProps));
}
return result;
}
diff --git
a/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataQueryResultRow.java
b/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataQueryResultRow.java
index d122a8732ec..bb23901bd00 100644
---
a/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataQueryResultRow.java
+++
b/infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataQueryResultRow.java
@@ -20,6 +20,7 @@ package
org.apache.shardingsphere.infra.merge.result.impl.local;
import com.google.common.base.Preconditions;
import org.apache.shardingsphere.infra.util.json.JsonUtils;
+import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -46,7 +47,10 @@ public final class LocalDataQueryResultRow {
if (data instanceof Optional) {
return ((Optional<?>) data).isPresent() ? convert(((Optional<?>)
data).get()) : "";
}
- if (data instanceof Boolean || data instanceof Integer || data
instanceof Long) {
+ if (data instanceof String) {
+ return data;
+ }
+ if (data instanceof Boolean || data instanceof Integer || data
instanceof Long || data instanceof LocalDateTime) {
return data.toString();
}
if (data instanceof Enum) {
@@ -55,7 +59,10 @@ public final class LocalDataQueryResultRow {
if (data instanceof Properties) {
return ((Properties) data).isEmpty() ? "" :
JsonUtils.toJsonString(convert((Properties) data));
}
- return data;
+ if (data instanceof Map) {
+ return ((Map<?, ?>) data).isEmpty() ? "" :
JsonUtils.toJsonString(data);
+ }
+ return JsonUtils.toJsonString(data);
}
private Map<Object, Object> convert(final Properties props) {
diff --git
a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataMergedResultTest.java
b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataMergedResultTest.java
index ceeb69eff61..bd8aca0b624 100644
---
a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataMergedResultTest.java
+++
b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataMergedResultTest.java
@@ -53,7 +53,7 @@ class LocalDataMergedResultTest {
LocalDataQueryResultRow row = new LocalDataQueryResultRow(new
Date(0L));
LocalDataMergedResult actual = new
LocalDataMergedResult(Collections.singletonList(row));
assertTrue(actual.next());
- assertThat(actual.getCalendarValue(1, Object.class,
Calendar.getInstance()), is(new Date(0L)));
+ assertThat(actual.getCalendarValue(1, Object.class,
Calendar.getInstance()), is("0"));
}
@Test
diff --git
a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingListExecutor.java
b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingListExecutor.java
index b128def6b6a..91e825fff62 100644
---
a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingListExecutor.java
+++
b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingListExecutor.java
@@ -28,7 +28,6 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -47,7 +46,7 @@ public final class ShowStreamingListExecutor implements
DistSQLQueryExecutor<Sho
public Collection<LocalDataQueryResultRow> getRows(final
ShowStreamingListStatement sqlStatement, final ContextManager contextManager) {
return pipelineJobManager.getJobInfos(new
PipelineContextKey(InstanceType.PROXY)).stream().map(each -> new
LocalDataQueryResultRow(each.getJobMetaData().getJobId(),
each.getDatabaseName(), each.getTableName(),
each.getJobMetaData().getJobItemCount(), each.getJobMetaData().isActive(),
- each.getJobMetaData().getCreateTime(),
Optional.ofNullable(each.getJobMetaData().getStopTime()).orElse(""))).collect(Collectors.toList());
+ each.getJobMetaData().getCreateTime(),
each.getJobMetaData().getStopTime())).collect(Collectors.toList());
}
@Override
diff --git
a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java
b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java
index 213da1d1c2c..870fcd5fa0d 100644
---
a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java
+++
b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java
@@ -28,6 +28,7 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -53,13 +54,17 @@ public final class ShowMigrationJobStatusExecutor
implements DistSQLQueryExecuto
if (null == jobItemProgress) {
return new LocalDataQueryResultRow(jobItemInfo.getShardingItem(),
"", "", "", "", "", "", "", jobItemInfo.getErrorMessage());
}
- String incrementalIdleSeconds = "";
+ return new LocalDataQueryResultRow(jobItemInfo.getShardingItem(),
jobItemProgress.getDataSourceName(), jobItemInfo.getTableNames(),
jobItemProgress.getStatus(), jobItemProgress.isActive(),
+ jobItemProgress.getProcessedRecordsCount(),
jobItemInfo.getInventoryFinishedPercentage(),
getIncrementalIdleSeconds(jobItemProgress, jobItemInfo, currentTimeMillis),
+ jobItemInfo.getErrorMessage());
+ }
+
+ private Optional<Long> getIncrementalIdleSeconds(final
TransmissionJobItemProgress jobItemProgress, final TransmissionJobItemInfo
jobItemInfo, final long currentTimeMillis) {
if
(jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis() > 0) {
long latestActiveTimeMillis =
Math.max(jobItemInfo.getStartTimeMillis(),
jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis());
- incrementalIdleSeconds =
String.valueOf(TimeUnit.MILLISECONDS.toSeconds(currentTimeMillis -
latestActiveTimeMillis));
+ return
Optional.of(TimeUnit.MILLISECONDS.toSeconds(currentTimeMillis -
latestActiveTimeMillis));
}
- return new LocalDataQueryResultRow(jobItemInfo.getShardingItem(),
jobItemProgress.getDataSourceName(), jobItemInfo.getTableNames(),
jobItemProgress.getStatus(),
- jobItemProgress.isActive(),
jobItemProgress.getProcessedRecordsCount(),
jobItemInfo.getInventoryFinishedPercentage(), incrementalIdleSeconds,
jobItemInfo.getErrorMessage());
+ return Optional.empty();
}
@Override
diff --git
a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java
b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java
index 9e2b949a40e..20423d21537 100644
---
a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java
+++
b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java
@@ -46,7 +46,7 @@ public final class ShowSQLTranslatorRuleExecutor implements
DistSQLQueryExecutor
@Override
public Collection<LocalDataQueryResultRow> getRows(final
ShowSQLTranslatorRuleStatement sqlStatement, final ContextManager
contextManager) {
SQLTranslatorRuleConfiguration ruleConfig = rule.getConfiguration();
- return Collections.singleton(new
LocalDataQueryResultRow(ruleConfig.getType(), ruleConfig.getProps(),
String.valueOf(ruleConfig.isUseOriginalSQLWhenTranslatingFailed())));
+ return Collections.singleton(new
LocalDataQueryResultRow(ruleConfig.getType(), ruleConfig.getProps(),
ruleConfig.isUseOriginalSQLWhenTranslatingFailed()));
}
@Override
diff --git
a/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java
b/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java
index b0946299c43..2a3719c12de 100644
---
a/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java
+++
b/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java
@@ -55,8 +55,8 @@ public final class ShowTrafficRuleExecutor implements
DistSQLQueryExecutor<ShowT
}
private LocalDataQueryResultRow buildRow(final
TrafficStrategyConfiguration strategy, final AlgorithmConfiguration
trafficAlgorithm, final AlgorithmConfiguration loadBalancer) {
- return new LocalDataQueryResultRow(strategy.getName(),
String.join(",", strategy.getLabels()), null != trafficAlgorithm ?
trafficAlgorithm.getType() : "",
- null == trafficAlgorithm ? null : trafficAlgorithm.getProps(),
null == loadBalancer ? "" : loadBalancer.getType(), null == loadBalancer ? "" :
loadBalancer.getProps());
+ return new LocalDataQueryResultRow(strategy.getName(),
String.join(",", strategy.getLabels()), null == trafficAlgorithm ? null :
trafficAlgorithm.getType(),
+ null == trafficAlgorithm ? null : trafficAlgorithm.getProps(),
null == loadBalancer ? null : loadBalancer.getType(), null == loadBalancer ?
null : loadBalancer.getProps());
}
@Override
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java
index ebc3a2a6cda..408f75c1f56 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeInfoExecutor.java
@@ -46,7 +46,7 @@ public final class ShowComputeNodeInfoExecutor implements
DistSQLQueryExecutor<S
String modeType =
contextManager.getInstanceContext().getModeConfiguration().getType();
return Collections.singletonList(new
LocalDataQueryResultRow(instanceMetaData.getId(), instanceMetaData.getIp(),
instanceMetaData instanceof ProxyInstanceMetaData ?
((ProxyInstanceMetaData) instanceMetaData).getPort() : -1,
- instance.getState().getCurrentState().name(), modeType,
instance.getWorkerId(), String.join(",", instance.getLabels()),
+ instance.getState().getCurrentState(), modeType,
instance.getWorkerId(), String.join(",", instance.getLabels()),
instanceMetaData.getVersion()));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java
index 8628d921dc6..e1880ee7d1c 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutor.java
@@ -42,8 +42,8 @@ public final class ShowComputeNodeModeExecutor implements
DistSQLQueryExecutor<S
public Collection<LocalDataQueryResultRow> getRows(final
ShowComputeNodeModeStatement sqlStatement, final ContextManager contextManager)
{
PersistRepositoryConfiguration repositoryConfig =
contextManager.getInstanceContext().getModeConfiguration().getRepository();
String modeType =
contextManager.getInstanceContext().getModeConfiguration().getType();
- String repositoryType = null == repositoryConfig ? "" :
repositoryConfig.getType();
- Properties props = null == repositoryConfig ? new Properties() :
repositoryConfig.getProps();
+ String repositoryType = null == repositoryConfig ? null :
repositoryConfig.getType();
+ Properties props = null == repositoryConfig ? null :
repositoryConfig.getProps();
return Collections.singleton(new LocalDataQueryResultRow(modeType,
repositoryType, props));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
index 4e176a6eb82..80ba0529a2e 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodesExecutor.java
@@ -53,9 +53,9 @@ public final class ShowComputeNodesExecutor implements
DistSQLQueryExecutor<Show
private LocalDataQueryResultRow buildRow(final ComputeNodeInstance
instance, final String modeType) {
String labels = String.join(",", instance.getLabels());
InstanceMetaData instanceMetaData = instance.getMetaData();
- return new LocalDataQueryResultRow(instanceMetaData.getId(),
instanceMetaData.getType().name(), instanceMetaData.getIp(),
+ return new LocalDataQueryResultRow(instanceMetaData.getId(),
instanceMetaData.getType(), instanceMetaData.getIp(),
instanceMetaData instanceof ProxyInstanceMetaData ?
((ProxyInstanceMetaData) instanceMetaData).getPort() : -1,
- instance.getState().getCurrentState().name(), modeType,
instance.getWorkerId(), labels, instanceMetaData.getVersion());
+ instance.getState().getCurrentState(), modeType,
instance.getWorkerId(), labels, instanceMetaData.getVersion());
}
@Override
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java
index d9ea9342efd..fcf55c1a054 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java
@@ -28,7 +28,6 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.infra.util.json.JsonUtils;
import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Arrays;
@@ -66,11 +65,11 @@ public final class ShowTableMetaDataExecutor implements
DistSQLQueryExecutor<Sho
}
private LocalDataQueryResultRow buildColumnRow(final String databaseName,
final String tableName, final ShardingSphereColumn column) {
- return new LocalDataQueryResultRow(databaseName, tableName, "COLUMN",
column.getName(), JsonUtils.toJsonString(column));
+ return new LocalDataQueryResultRow(databaseName, tableName, "COLUMN",
column.getName(), column);
}
private LocalDataQueryResultRow buildIndexRow(final String databaseName,
final String tableName, final ShardingSphereIndex index) {
- return new LocalDataQueryResultRow(databaseName, tableName, "INDEX",
index.getName(), JsonUtils.toJsonString(index));
+ return new LocalDataQueryResultRow(databaseName, tableName, "INDEX",
index.getName(), index);
}
@Override
diff --git
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/ShowVersionExecutor.java
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/ShowVersionExecutor.java
index 0c6d481f975..e56b9aa34da 100644
---
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/ShowVersionExecutor.java
+++
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/ShowVersionExecutor.java
@@ -51,8 +51,8 @@ public final class ShowVersionExecutor implements
DatabaseAdminQueryExecutor {
@Override
public void execute(final ConnectionSession connectionSession) {
- mergedResult = new LocalDataMergedResult(Collections.singleton(new
LocalDataQueryResultRow(DatabaseProtocolServerInfo.getProtocolVersion(connectionSession.getDatabaseName(),
- TypedSPILoader.getService(DatabaseType.class, "MySQL")))));
+ mergedResult = new LocalDataMergedResult(Collections.singleton(new
LocalDataQueryResultRow(
+
DatabaseProtocolServerInfo.getProtocolVersion(connectionSession.getDatabaseName(),
TypedSPILoader.getService(DatabaseType.class, "MySQL")))));
}
@Override