You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/06/12 07:03:21 UTC
[shardingsphere] branch master updated: Refactor ExportableRule (#18309)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 855e717668f Refactor ExportableRule (#18309)
855e717668f is described below
commit 855e717668f8cfea2f5c1f40cc5134bd50e8ef3c
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Jun 12 15:03:17 2022 +0800
Refactor ExportableRule (#18309)
---
.../shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java | 2 +-
.../shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java | 2 +-
.../handler/fixture/DatabaseDiscoveryRuleExportableFixture.java | 2 +-
.../handler/fixture/ReadwriteSplittingRuleExportableFixture.java | 2 +-
.../readwritesplitting/rule/ReadwriteSplittingRule.java | 2 +-
.../handler/fixture/DatabaseDiscoveryRuleExportableFixture.java | 2 +-
.../handler/fixture/ReadwriteSplittingRuleExportableFixture.java | 2 +-
.../infra/rule/identifier/type/exportable/ExportableRule.java | 4 ++--
.../infra/rule/identifier/type/exportable/RuleExportEngine.java | 6 +++---
.../org/apache/shardingsphere/singletable/rule/SingleTableRule.java | 2 +-
.../backend/text/distsql/rql/SchemaRulesCountResultSetTest.java | 2 +-
11 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
index fb8dbe6e701..1b3d760460f 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
@@ -171,7 +171,7 @@ public final class DatabaseDiscoveryRule implements SchemaRule, DataSourceContai
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
return Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES, this::exportPrimaryDataSourceMap);
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
index a5873459c50..f764c9e64d1 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
@@ -77,7 +77,7 @@ public final class DatabaseDiscoveryRuleTest {
@Test
public void assertGetExportedMethods() {
DatabaseDiscoveryRule databaseDiscoveryRule = createRule();
- assertThat(databaseDiscoveryRule.getExportedMethods().get(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES).get(), is(Collections.singletonMap("test_pr", "primary")));
+ assertThat(databaseDiscoveryRule.getExportData().get(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES).get(), is(Collections.singletonMap("test_pr", "primary")));
}
private DatabaseDiscoveryRule createRule() {
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/fixture/DatabaseDiscoveryRuleExportableFixture.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/fixture/DatabaseDiscoveryR [...]
index ed0b7084144..51d6b3ae721 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/fixture/DatabaseDiscoveryRuleExportableFixture.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/fixture/DatabaseDiscoveryRuleExportableFixture.java
@@ -32,7 +32,7 @@ public final class DatabaseDiscoveryRuleExportableFixture implements ExportableR
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
return Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES, this::exportedMethod);
}
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/fixture/ReadwriteSplittingRuleExportableFixture.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/fixture/ReadwriteSplittin [...]
index cd49e79169e..f7cc3ce0a40 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/fixture/ReadwriteSplittingRuleExportableFixture.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/fixture/ReadwriteSplittingRuleExportableFixture.java
@@ -35,7 +35,7 @@ public final class ReadwriteSplittingRuleExportableFixture implements Exportable
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
Map<String, Supplier<Object>> result = new HashMap<>(4, 1);
result.put(ExportableConstants.EXPORT_DYNAMIC_READWRITE_SPLITTING_RULE, this::exportDynamicDataSources);
result.put(ExportableConstants.EXPORT_STATIC_READWRITE_SPLITTING_RULE, this::exportStaticDataSources);
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java
index 8c2306b756d..4880098c8c3 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java
@@ -119,7 +119,7 @@ public final class ReadwriteSplittingRule implements SchemaRule, DataSourceConta
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
Map<String, Supplier<Object>> result = new HashMap<>(2, 1);
result.put(ExportableConstants.EXPORT_DYNAMIC_READWRITE_SPLITTING_RULE, this::exportDynamicDataSources);
result.put(ExportableConstants.EXPORT_STATIC_READWRITE_SPLITTING_RULE, this::exportStaticDataSources);
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/fixture/DatabaseDiscoveryRuleExportableFixture.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readw [...]
index e1031831010..94d7cfc542f 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/fixture/DatabaseDiscoveryRuleExportableFixture.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/fixture/DatabaseDiscoveryRuleExportableFixture.java
@@ -32,7 +32,7 @@ public final class DatabaseDiscoveryRuleExportableFixture implements ExportableR
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
return Collections.singletonMap(ExportableConstants.EXPORT_DB_DISCOVERY_PRIMARY_DATA_SOURCES, this::exportedMethod);
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/fixture/ReadwriteSplittingRuleExportableFixture.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/read [...]
index 14a007070e3..6c3df2d075d 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/fixture/ReadwriteSplittingRuleExportableFixture.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/fixture/ReadwriteSplittingRuleExportableFixture.java
@@ -34,7 +34,7 @@ public final class ReadwriteSplittingRuleExportableFixture implements Exportable
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
Map<String, Supplier<Object>> result = new HashMap<>(4, 1);
result.put(ExportableConstants.EXPORT_DYNAMIC_READWRITE_SPLITTING_RULE, this::exportDynamicDataSources);
result.put(ExportableConstants.EXPORT_STATIC_READWRITE_SPLITTING_RULE, this::exportStaticDataSources);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/ExportableRule.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/ExportableRule.java
index 7df3f11bee0..1f51f7100db 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/ExportableRule.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/ExportableRule.java
@@ -23,7 +23,7 @@ import java.util.Map;
import java.util.function.Supplier;
/**
- * ShardingSphere rule which supports exporting data.
+ * Exportable rule.
*/
public interface ExportableRule extends ShardingSphereRule {
@@ -32,5 +32,5 @@ public interface ExportableRule extends ShardingSphereRule {
*
* @return export method supplier
*/
- Map<String, Supplier<Object>> getExportedMethods();
+ Map<String, Supplier<Object>> getExportData();
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/RuleExportEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/RuleExportEngine.java
index ca0f5de478f..1294b88c461 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/RuleExportEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/exportable/RuleExportEngine.java
@@ -40,7 +40,7 @@ public final class RuleExportEngine {
* @return data map
*/
public Map<String, Object> export(final Collection<String> keys) {
- Map<String, Supplier<Object>> exportMethods = rule.getExportedMethods();
+ Map<String, Supplier<Object>> exportMethods = rule.getExportData();
Map<String, Object> result = new HashMap<>(keys.size(), 1);
keys.forEach(each -> {
if (exportMethods.containsKey(each)) {
@@ -57,7 +57,7 @@ public final class RuleExportEngine {
* @return data
*/
public Optional<Object> export(final String key) {
- Map<String, Supplier<Object>> exportMethods = rule.getExportedMethods();
+ Map<String, Supplier<Object>> exportMethods = rule.getExportData();
if (exportMethods.containsKey(key)) {
return Optional.ofNullable(exportMethods.get(key).get());
}
@@ -71,6 +71,6 @@ public final class RuleExportEngine {
* @return contain or not
*/
public boolean containExportableKey(final Collection<String> keys) {
- return keys.stream().anyMatch(each -> rule.getExportedMethods().containsKey(each));
+ return keys.stream().anyMatch(each -> rule.getExportData().containsKey(each));
}
}
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
index 620c60ffd92..6a639b83ba5 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/rule/SingleTableRule.java
@@ -268,7 +268,7 @@ public final class SingleTableRule implements SchemaRule, DataNodeContainedRule,
}
@Override
- public Map<String, Supplier<Object>> getExportedMethods() {
+ public Map<String, Supplier<Object>> getExportData() {
return Collections.singletonMap(ExportableConstants.EXPORT_SINGLE_TABLES, tableNames::keySet);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SchemaRulesCountResultSetTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SchemaRulesCountResultSetTest.java
index 57858b6a040..1c8bf5fb919 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SchemaRulesCountResultSetTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SchemaRulesCountResultSetTest.java
@@ -74,7 +74,7 @@ public final class SchemaRulesCountResultSetTest {
private SingleTableRule mockSingleTableRule() {
SingleTableRule result = mock(SingleTableRule.class);
- when(result.getExportedMethods()).thenReturn(Collections.singletonMap(ExportableConstants.EXPORT_SINGLE_TABLES, () -> Arrays.asList("single_table_1", "single_table_2")));
+ when(result.getExportData()).thenReturn(Collections.singletonMap(ExportableConstants.EXPORT_SINGLE_TABLES, () -> Arrays.asList("single_table_1", "single_table_2")));
return result;
}