This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 9ffc0f6 Minor code style and comment adjustments (#15187)
9ffc0f6 is described below
commit 9ffc0f69d672dc6be72e99a392cf3fcad905e399
Author: Guocheng Tang <[email protected]>
AuthorDate: Sun Jan 30 08:55:45 2022 +0800
Minor code style and comment adjustments (#15187)
* Minor code style and comment adjustments
* fix
* fix
---
.../AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java | 2 +-
.../builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java | 2 +-
.../handler/query/DatabaseDiscoveryRuleQueryResultSet.java | 8 ++++----
.../handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java | 2 +-
.../shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java | 2 +-
.../dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java | 4 ++--
.../dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryTypeTest.java | 4 ++--
.../spring/boot/DatabaseDiscoveryRuleSpringbootConfiguration.java | 4 ++--
.../rule/YamlDatabaseDiscoveryRuleSpringBootConfiguration.java | 2 +-
.../namespace/handler/DatabaseDiscoveryNamespaceHandler.java | 2 +-
10 files changed, 16 insertions(+), 16 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
index b13ec7c..6a4b133 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
@@ -33,7 +33,7 @@ import java.util.LinkedList;
import java.util.Map;
/**
- * Algorithm provided data base discovery rule configuration.
+ * Algorithm provided database discovery rule configuration.
*/
@NoArgsConstructor
@AllArgsConstructor
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
index 3f30309..25c1aac 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.infra.rule.builder.schema.SchemaRuleBuilder;
import java.util.Collection;
/**
- * Algorithm provided data base discovery rule builder.
+ * Algorithm provided database discovery rule builder.
*/
public final class AlgorithmProvidedDatabaseDiscoveryRuleBuilder implements
SchemaRuleBuilder<AlgorithmProvidedDatabaseDiscoveryRuleConfiguration> {
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSet.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQuer
[...]
index 6810c43..154f080 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSet.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSet.java
@@ -66,14 +66,14 @@ public final class DatabaseDiscoveryRuleQueryResultSet
implements DistSQLResultS
public void init(final ShardingSphereMetaData metaData, final SQLStatement
sqlStatement) {
Optional<DatabaseDiscoveryRuleConfiguration> ruleConfig =
metaData.getRuleMetaData().getConfigurations()
.stream().filter(each -> each instanceof
DatabaseDiscoveryRuleConfiguration).map(each ->
(DatabaseDiscoveryRuleConfiguration) each).findAny();
- data = ruleConfig.map(optional ->
optional.getDataSources().iterator()).orElse(Collections.emptyIterator());
- discoveryTypes =
ruleConfig.map(DatabaseDiscoveryRuleConfiguration::getDiscoveryTypes).orElse(Collections.emptyMap());
- discoveryHeartbeats =
ruleConfig.map(DatabaseDiscoveryRuleConfiguration::getDiscoveryHeartbeats).orElse(Collections.emptyMap());
+ data = ruleConfig.map(optional ->
optional.getDataSources().iterator()).orElseGet(Collections::emptyIterator);
+ discoveryTypes =
ruleConfig.map(DatabaseDiscoveryRuleConfiguration::getDiscoveryTypes).orElseGet(Collections::emptyMap);
+ discoveryHeartbeats =
ruleConfig.map(DatabaseDiscoveryRuleConfiguration::getDiscoveryHeartbeats).orElseGet(Collections::emptyMap);
Optional<ExportableRule> exportableRule =
metaData.getRuleMetaData().getRules()
.stream().filter(each -> each instanceof ExportableRule)
.filter(each -> ((ExportableRule)
each).containExportableKey(Collections.singleton(ExportableConstants.EXPORTABLE_KEY_PRIMARY_DATA_SOURCE)))
.map(each -> (ExportableRule) each).findAny();
- primaryDataSources = (Map<String, String>)
(exportableRule.map(optional ->
optional.export(ExportableConstants.EXPORTABLE_KEY_PRIMARY_DATA_SOURCE).orElse(Collections.emptyMap()))
+ primaryDataSources = (Map<String, String>)
(exportableRule.map(optional ->
optional.export(ExportableConstants.EXPORTABLE_KEY_PRIMARY_DATA_SOURCE).orElseGet(Collections::emptyMap))
.orElseGet(Collections::emptyMap));
}
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRule
[...]
index 2db665c..e0c75d6 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
@@ -57,7 +57,7 @@ public final class DatabaseDiscoveryRuleQueryResultSetTest {
Collection<String> columnNames = resultSet.getColumnNames();
ArrayList<Object> actual = new ArrayList<>(resultSet.getRowData());
assertThat(columnNames.size(), is(5));
- columnNames.containsAll(Arrays.asList("group_name",
"data_source_names", "primary_data_source_name", "discover_type", "heartbeat"));
+ assertThat(columnNames.containsAll(Arrays.asList("group_name",
"data_source_names", "primary_data_source_name", "discovery_type",
"discovery_heartbeat")), is(true));
assertThat(actual.size(), is(5));
assertThat(actual.get(0), is("ms_group"));
assertThat(actual.get(1), is("ds_0,ds_1"));
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
index ac813ec..f51f02b 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-mgr/src/main/java/org/apache/shardingsphere/dbdiscovery/mgr/MGRDatabaseDiscoveryType.java
@@ -40,7 +40,7 @@ import java.util.Map.Entry;
import java.util.Properties;
/**
- * MGR data base discovery type.
+ * MGR database discovery type.
*/
@Slf4j
public final class MGRDatabaseDiscoveryType implements DatabaseDiscoveryType {
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
index 44a68b0..4d03b9f 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/main/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryType.java
@@ -36,12 +36,12 @@ import java.util.Map.Entry;
import java.util.Properties;
/**
- * OpenGauss data base discovery type.
+ * OpenGauss database discovery type.
*/
@Slf4j
public final class OpenGaussDatabaseDiscoveryType implements
DatabaseDiscoveryType {
- private static final String DB_ROLE = "select local_role,db_state from
pg_stat_get_stream_replications()";
+ private static final String DB_ROLE = "SELECT local_role,db_state FROM
pg_stat_get_stream_replications()";
private String oldPrimaryDataSource;
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/test/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryTypeTest.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/test/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryTypeTest.java
index 04cd7ca..d4d8813 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/test/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryTypeTest.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-provider/shardingsphere-db-discovery-opengauss/src/test/java/org/apache/shardingsphere/dbdiscovery/opengauss/OpenGaussDatabaseDiscoveryTypeTest.java
@@ -38,9 +38,9 @@ import static org.mockito.Mockito.when;
public final class OpenGaussDatabaseDiscoveryTypeTest {
- private static final String DB_ROLE = "select local_role,db_state from
pg_stat_get_stream_replications()";
+ private static final String DB_ROLE = "SELECT local_role,db_state FROM
pg_stat_get_stream_replications()";
- private static final String STANDBYS = "select client_addr,sync_state from
pg_stat_replication";
+ private static final String STANDBYS = "SELECT client_addr,sync_state FROM
pg_stat_replication";
private final OpenGaussDatabaseDiscoveryType ogHaType = new
OpenGaussDatabaseDiscoveryType();
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/DatabaseDiscoveryRuleSpringbootConfiguration.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/DatabaseDiscoveryRuleSpringboo
[...]
index 9292cc1..bafcf11 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/DatabaseDiscoveryRuleSpringbootConfiguration.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/DatabaseDiscoveryRuleSpringbootConfiguration.java
@@ -39,7 +39,7 @@ import java.util.Map;
import java.util.Optional;
/**
- * Rule spring boot configuration for data base discovery.
+ * Rule spring boot configuration for database discovery.
*/
@Configuration
@EnableConfigurationProperties(YamlDatabaseDiscoveryRuleSpringBootConfiguration.class)
@@ -61,7 +61,7 @@ public class DatabaseDiscoveryRuleSpringbootConfiguration {
@Bean
public RuleConfiguration discoveryRuleConfiguration(final
ObjectProvider<Map<String, DatabaseDiscoveryType>> discoveryTypes) {
AlgorithmProvidedDatabaseDiscoveryRuleConfiguration result =
swapper.swapToObject(yamlConfig.getDatabaseDiscovery());
- Map<String, DatabaseDiscoveryType> discoveryTypeMap =
Optional.ofNullable(discoveryTypes.getIfAvailable()).orElse(Collections.emptyMap());
+ Map<String, DatabaseDiscoveryType> discoveryTypeMap =
Optional.ofNullable(discoveryTypes.getIfAvailable()).orElseGet(Collections::emptyMap);
result.setDiscoveryTypes(discoveryTypeMap);
return result;
}
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/rule/YamlDatabaseDiscoveryRuleSpringBootConfiguration.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/rule/YamlDatabaseDisc
[...]
index c7596a0..7b1dbab 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/rule/YamlDatabaseDiscoveryRuleSpringBootConfiguration.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-boot-starter/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/boot/rule/YamlDatabaseDiscoveryRuleSpringBootConfiguration.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.dbdiscovery.yaml.config.YamlDatabaseDiscoveryRu
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
- * YAML data base discovery rule spring boot configuration.
+ * YAML database discovery rule spring boot configuration.
*/
@ConfigurationProperties(prefix = "spring.shardingsphere.rules")
@Getter
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/handler/DatabaseDiscoveryNamespaceHandler.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/handler/DatabaseDiscoveryName
[...]
index 577b81c..4b82519 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/handler/DatabaseDiscoveryNamespaceHandler.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/handler/DatabaseDiscoveryNamespaceHandler.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.spring.namespace.parser.ShardingSphereAlgorithm
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
- * Spring namespace handler for data base discovery.
+ * Spring namespace handler for database discovery.
*/
public final class DatabaseDiscoveryNamespaceHandler extends
NamespaceHandlerSupport {