Skip to content

Commit

Permalink
Support show readwrite splitting status
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjunjie64 committed May 31, 2023
1 parent 03d8665 commit 91403e9
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,21 @@ private void buildExportableMap(final ReadwriteSplittingRule rule) {
private Collection<LocalDataQueryResultRow> buildData(final ReadwriteSplittingRule rule, final ShowReadwriteSplittingRulesStatement sqlStatement) {
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
((ReadwriteSplittingRuleConfiguration) rule.getConfiguration()).getDataSources().forEach(each -> {
LocalDataQueryResultRow dataItem = buildDataItem(each, getLoadBalancers((ReadwriteSplittingRuleConfiguration) rule.getConfiguration()));
LocalDataQueryResultRow dataItem = buildDataItem(each, getLoadBalancers((ReadwriteSplittingRuleConfiguration) rule.getConfiguration()),
rule.getDataSourceRules().get(each.getName()).isStatus());
if (null == sqlStatement.getRuleName() || sqlStatement.getRuleName().equalsIgnoreCase(each.getName())) {
result.add(dataItem);
}
});
return result;
}

private LocalDataQueryResultRow buildDataItem(final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig, final Map<String, AlgorithmConfiguration> loadBalancers) {
private LocalDataQueryResultRow buildDataItem(final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig,
final Map<String, AlgorithmConfiguration> loadBalancers, final boolean status) {
String name = dataSourceRuleConfig.getName();
Map<String, String> exportDataSources = null == dataSourceRuleConfig.getDynamicStrategy() ? exportableDataSourceMap.get(name) : exportableAutoAwareDataSource.get(name);
Optional<AlgorithmConfiguration> loadBalancer = Optional.ofNullable(loadBalancers.get(dataSourceRuleConfig.getLoadBalancerName()));
return new LocalDataQueryResultRow(name,
getAutoAwareDataSourceName(dataSourceRuleConfig),
return new LocalDataQueryResultRow(name, status,
getWriteDataSourceName(dataSourceRuleConfig, exportDataSources),
getReadDataSourceNames(dataSourceRuleConfig, exportDataSources),
loadBalancer.map(AlgorithmConfiguration::getType).orElse(""),
Expand Down Expand Up @@ -108,7 +109,7 @@ private String getReadDataSourceNames(final ReadwriteSplittingDataSourceRuleConf

@Override
public Collection<String> getColumnNames() {
return Arrays.asList("name", "auto_aware_data_source_name", "write_storage_unit_name", "read_storage_unit_names", "load_balancer_type", "load_balancer_props");
return Arrays.asList("name", "status", "write_storage_unit_name", "read_storage_unit_names", "load_balancer_type", "load_balancer_props");
}

@Override
Expand Down

0 comments on commit 91403e9

Please sign in to comment.