You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/29 05:20:21 UTC
[shardingsphere] branch master updated: Update doc (#17200)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 989455b2eb4 Update doc (#17200)
989455b2eb4 is described below
commit 989455b2eb4923376eda7a25585acfac5e8dccfa
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Apr 29 13:20:16 2022 +0800
Update doc (#17200)
---
docs/document/content/dev-manual/kernel.cn.md | 54 +++++++++++++---------
docs/document/content/dev-manual/kernel.en.md | 10 ++++
...atabaseDiscoveryDynamicDataSourceStrategy.java} | 6 +--
.../dbdiscovery/rule/DatabaseDiscoveryRule.java | 4 +-
...ngsphere.infra.aware.DynamicDataSourceStrategy} | 2 +-
.../ReadwriteSplittingStrategyFactory.java | 10 ++--
.../type/DynamicReadwriteSplittingStrategy.java | 12 ++---
...meAware.java => DynamicDataSourceStrategy.java} | 4 +-
....java => DynamicDataSourceStrategyFactory.java} | 10 ++--
...a => DynamicDataSourceStrategyFactoryTest.java} | 4 +-
10 files changed, 68 insertions(+), 48 deletions(-)
diff --git a/docs/document/content/dev-manual/kernel.cn.md b/docs/document/content/dev-manual/kernel.cn.md
index 96c04561ae9..943b57877c5 100644
--- a/docs/document/content/dev-manual/kernel.cn.md
+++ b/docs/document/content/dev-manual/kernel.cn.md
@@ -7,37 +7,37 @@ chapter = true
## SQLRouter
-| *SPI 名称* | *详细说明* |
-| ----------------------------------- | ------------------------- |
-| SQLRouter | 用于处理路由结果 |
-
-| *已知实现类* | *详细说明* |
-| ----------------------------------- | ------------------------- |
-| ReadwriteSplittingSQLRouter | 用于处理读写分离路由结果 |
-| DatabaseDiscoverySQLRouter | 用于处理数据库发现路由结果 |
-| SingleTableSQLRouter | 用于处理单表路由结果 |
-| ShardingSQLRouter | 用于处理分片路由结果 |
-| ShadowSQLRouter | 用于处理影子库路由结果 |
+| *SPI 名称* | *详细说明* |
+| ----------------------------------- | --------------------- |
+| SQLRouter | 用于处理路由结果 |
+
+| *已知实现类* | *详细说明* |
+| ----------------------------------- | --------------------- |
+| ReadwriteSplittingSQLRouter | 用于处理读写分离路由结果 |
+| DatabaseDiscoverySQLRouter | 用于处理数据库发现路由结果 |
+| SingleTableSQLRouter | 用于处理单表路由结果 |
+| ShardingSQLRouter | 用于处理分片路由结果 |
+| ShadowSQLRouter | 用于处理影子库路由结果 |
## SQLRewriteContextDecorator
-| *SPI 名称* | *详细说明* |
-| ---------------------------------- | ------------------------- |
-| SQLRewriteContextDecorator | 用于处理 SQL 改写结果 |
+| *SPI 名称* | *详细说明* |
+| ---------------------------------- | ------------------ |
+| SQLRewriteContextDecorator | 用于处理 SQL 改写结果 |
-| *已知实现类* | *详细说明* |
-| ---------------------------------- | ------------------------ |
-| ShardingSQLRewriteContextDecorator | 用于处理分片 SQL 改写结果 |
-| EncryptSQLRewriteContextDecorator | 用于处理加密 SQL 改写结果 |
+| *已知实现类* | *详细说明* |
+| ---------------------------------- | --------------------- |
+| ShardingSQLRewriteContextDecorator | 用于处理分片 SQL 改写结果 |
+| EncryptSQLRewriteContextDecorator | 用于处理加密 SQL 改写结果 |
## SQLExecutionHook
-| *SPI 名称* | *详细说明* |
-| ----------------------------- | ------------- |
+| *SPI 名称* | *详细说明* |
+| ----------------------------- | --------------- |
| SQLExecutionHook | SQL 执行过程监听器 |
-| *已知实现类* | *详细说明* |
-| ----------------------------- | ------------------- |
+| *已知实现类* | *详细说明* |
+| ----------------------------- | ------------------------- |
| TransactionalSQLExecutionHook | 基于事务的 SQL 执行过程监听器 |
## ResultProcessEngine
@@ -63,3 +63,13 @@ chapter = true
| SQLServerPrivilegeHandler | 使用 SQLServer 方言处理权限信息 |
| OraclePrivilegeHandler | 使用 Oracle 方言处理权限信息 |
| MySQLPrivilegeHandler | 使用 MySQL 方言处理权限信息 |
+
+## DynamicDataSourceStrategy
+
+| *SPI 名称* | *详细说明* |
+| ------------------------------------------ | ------------------------------ |
+| DynamicDataSourceStrategy | 动态数据源获取策略 |
+
+| *已知实现类* | *详细说明* |
+| ------------------------------------------ | ------------------------------- |
+| DatabaseDiscoveryDynamicDataSourceStrategy | 使用数据库自动发现的功能获取动态数据源 |
diff --git a/docs/document/content/dev-manual/kernel.en.md b/docs/document/content/dev-manual/kernel.en.md
index 8d8ba1c22f4..a40a649230c 100644
--- a/docs/document/content/dev-manual/kernel.en.md
+++ b/docs/document/content/dev-manual/kernel.en.md
@@ -63,3 +63,13 @@ chapter = true
| SQLServerPrivilegeHandler | Use SQLServer dialect to process privilege metadata |
| OraclePrivilegeHandler | Use Oracle dialect to process privilege metadata |
| MySQLPrivilegeHandler | Use MySQL dialect to process privilege metadata |
+
+## DynamicDataSourceStrategy
+
+| *SPI Name* | *Description* |
+| ------------------------------------------ | --------------------------------------------------- |
+| DynamicDataSourceStrategy | Dynamic data source fetch strategy |
+
+| *Implementation Class* | *Description* |
+| ------------------------------------------ | --------------------------------------------------- |
+| DatabaseDiscoveryDynamicDataSourceStrategy | Use database discovery to dynamic fetch data source |
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/aware/DatabaseDiscoveryDataSourceNameAware.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/aware/DatabaseDiscoveryDynamicDataSourceStrategy.java
similarity index 88%
rename from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/aware/DatabaseDiscoveryDataSourceNameAware.java
rename to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/aware/DatabaseDiscoveryDynamicDataSourceStrategy.java
index eaf66b380c0..8c53556c18f 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/aware/DatabaseDiscoveryDataSourceNameAware.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/aware/DatabaseDiscoveryDynamicDataSourceStrategy.java
@@ -18,16 +18,16 @@
package org.apache.shardingsphere.dbdiscovery.aware;
import org.apache.shardingsphere.dbdiscovery.rule.DatabaseDiscoveryRule;
-import org.apache.shardingsphere.infra.aware.DataSourceNameAware;
+import org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategy;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import java.util.Collection;
import java.util.Optional;
/**
- * Database discovery data source name aware.
+ * Database discovery dynamic data source strategy.
*/
-public final class DatabaseDiscoveryDataSourceNameAware implements DataSourceNameAware {
+public final class DatabaseDiscoveryDynamicDataSourceStrategy implements DynamicDataSourceStrategy {
private DatabaseDiscoveryRule rule;
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 2148d25e951..5dd23ae6aee 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
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHe
import org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
import org.apache.shardingsphere.dbdiscovery.heartbeat.HeartbeatJob;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
-import org.apache.shardingsphere.infra.aware.DataSourceNameAwareFactory;
+import org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategyFactory;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
@@ -116,7 +116,7 @@ public final class DatabaseDiscoveryRule implements SchemaRule, DataSourceContai
}
private void initAware() {
- DataSourceNameAwareFactory.newInstance().ifPresent(optional -> optional.setRule(this));
+ DynamicDataSourceStrategyFactory.newInstance().ifPresent(optional -> optional.setRule(this));
}
/**
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.aware.DataSourceNameAware b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategy
similarity index 90%
rename from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.aware.DataSourceNameAware
rename to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategy
index 422e226fc30..ba114fef898 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.aware.DataSourceNameAware
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategy
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.dbdiscovery.aware.DatabaseDiscoveryDataSourceNameAware
+org.apache.shardingsphere.dbdiscovery.aware.DatabaseDiscoveryDynamicDataSourceStrategy
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/ReadwriteSplittingStrategyFactory.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/ReadwriteSplittingStrategyFactory.java
index ca6c76cc0c2..ec00c3a0b09 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/ReadwriteSplittingStrategyFactory.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/ReadwriteSplittingStrategyFactory.java
@@ -22,8 +22,8 @@ import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.aware.DataSourceNameAware;
-import org.apache.shardingsphere.infra.aware.DataSourceNameAwareFactory;
+import org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategy;
+import org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategyFactory;
import org.apache.shardingsphere.readwritesplitting.strategy.type.DynamicReadwriteSplittingStrategy;
import org.apache.shardingsphere.readwritesplitting.strategy.type.StaticReadwriteSplittingStrategy;
@@ -59,8 +59,8 @@ public final class ReadwriteSplittingStrategyFactory {
private static DynamicReadwriteSplittingStrategy createDynamicDataSourceProcessor(final Properties props) {
String autoAwareDataSourceName = props.getProperty("auto-aware-data-source-name");
Preconditions.checkArgument(!Strings.isNullOrEmpty(autoAwareDataSourceName), "Auto aware data source name is required.");
- Optional<DataSourceNameAware> dataSourceNameAware = DataSourceNameAwareFactory.newInstance();
- Preconditions.checkArgument(dataSourceNameAware.isPresent(), "Data source name aware is required.");
- return new DynamicReadwriteSplittingStrategy(autoAwareDataSourceName, dataSourceNameAware.get());
+ Optional<DynamicDataSourceStrategy> dynamicDataSourceStrategy = DynamicDataSourceStrategyFactory.newInstance();
+ Preconditions.checkArgument(dynamicDataSourceStrategy.isPresent(), "Dynamic data source strategy is required.");
+ return new DynamicReadwriteSplittingStrategy(autoAwareDataSourceName, dynamicDataSourceStrategy.get());
}
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/type/DynamicReadwriteSplittingStrategy.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/type/DynamicReadwriteSplittingStrategy.java
index bebce9010aa..0d9a7ce1819 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/type/DynamicReadwriteSplittingStrategy.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/strategy/type/DynamicReadwriteSplittingStrategy.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.readwritesplitting.strategy.type;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.aware.DataSourceNameAware;
+import org.apache.shardingsphere.infra.aware.DynamicDataSourceStrategy;
import org.apache.shardingsphere.readwritesplitting.strategy.ReadwriteSplittingStrategy;
import java.util.ArrayList;
@@ -37,23 +37,23 @@ public final class DynamicReadwriteSplittingStrategy implements ReadwriteSplitti
private final String autoAwareDataSourceName;
- private final DataSourceNameAware dataSourceNameAware;
+ private final DynamicDataSourceStrategy dynamicDataSourceStrategy;
@Override
public String getWriteDataSource() {
- return dataSourceNameAware.getPrimaryDataSourceName(autoAwareDataSourceName);
+ return dynamicDataSourceStrategy.getPrimaryDataSourceName(autoAwareDataSourceName);
}
@Override
public List<String> getReadDataSources() {
- return dataSourceNameAware.getRule().isPresent() ? new ArrayList<>(dataSourceNameAware.getReplicaDataSourceNames(autoAwareDataSourceName)) : Collections.emptyList();
+ return dynamicDataSourceStrategy.getRule().isPresent() ? new ArrayList<>(dynamicDataSourceStrategy.getReplicaDataSourceNames(autoAwareDataSourceName)) : Collections.emptyList();
}
@Override
public Collection<String> getAllDataSources() {
Collection<String> result = new LinkedList<>();
- result.add(dataSourceNameAware.getPrimaryDataSourceName(autoAwareDataSourceName));
- result.addAll(dataSourceNameAware.getReplicaDataSourceNames(autoAwareDataSourceName));
+ result.add(dynamicDataSourceStrategy.getPrimaryDataSourceName(autoAwareDataSourceName));
+ result.addAll(dynamicDataSourceStrategy.getReplicaDataSourceNames(autoAwareDataSourceName));
return result;
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DataSourceNameAware.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategy.java
similarity index 94%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DataSourceNameAware.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategy.java
index aea82de6b34..02e6a62a14c 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DataSourceNameAware.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategy.java
@@ -25,10 +25,10 @@ import java.util.Collection;
import java.util.Optional;
/**
- * Data source name aware.
+ * Dynamic data source strategy.
*/
@SingletonSPI
-public interface DataSourceNameAware extends OptionalSPI {
+public interface DynamicDataSourceStrategy extends OptionalSPI {
/**
* Get rule.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DataSourceNameAwareFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategyFactory.java
similarity index 79%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DataSourceNameAwareFactory.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategyFactory.java
index 2e31cf9542f..f9ed6bb9fc2 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DataSourceNameAwareFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategyFactory.java
@@ -25,13 +25,13 @@ import org.apache.shardingsphere.spi.type.optional.OptionalSPIRegistry;
import java.util.Optional;
/**
- * Data source name aware factory.
+ * Dynamic data source strategy factory.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DataSourceNameAwareFactory {
+public final class DynamicDataSourceStrategyFactory {
static {
- ShardingSphereServiceLoader.register(DataSourceNameAware.class);
+ ShardingSphereServiceLoader.register(DynamicDataSourceStrategy.class);
}
/**
@@ -39,7 +39,7 @@ public final class DataSourceNameAwareFactory {
*
* @return new instance of data source name aware
*/
- public static Optional<DataSourceNameAware> newInstance() {
- return OptionalSPIRegistry.findRegisteredService(DataSourceNameAware.class);
+ public static Optional<DynamicDataSourceStrategy> newInstance() {
+ return OptionalSPIRegistry.findRegisteredService(DynamicDataSourceStrategy.class);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/aware/DataSourceNameAwareFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategyFactoryTest.java
similarity index 87%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/aware/DataSourceNameAwareFactoryTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategyFactoryTest.java
index 3bdb1608345..7d827f3fa36 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/aware/DataSourceNameAwareFactoryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/aware/DynamicDataSourceStrategyFactoryTest.java
@@ -21,10 +21,10 @@ import org.junit.Test;
import static org.junit.Assert.assertFalse;
-public final class DataSourceNameAwareFactoryTest {
+public final class DynamicDataSourceStrategyFactoryTest {
@Test
public void assertGetInstance() {
- assertFalse(DataSourceNameAwareFactory.newInstance().isPresent());
+ assertFalse(DynamicDataSourceStrategyFactory.newInstance().isPresent());
}
}