You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/07/13 23:19:35 UTC

[shardingsphere] branch master updated: Refactor standalone File type to H2 type (#19122)

This is an automated email from the ASF dual-hosted git repository.

menghaoran 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 965224497dc Refactor standalone File type to H2 type (#19122)
965224497dc is described below

commit 965224497dcb647b1937a5cb4350db63bd8893e3
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jul 14 07:19:25 2022 +0800

    Refactor standalone File type to H2 type (#19122)
---
 .../shardingsphere-jdbc/java-api/mode.cn.md         |  2 +-
 .../shardingsphere-jdbc/java-api/mode.en.md         |  2 +-
 .../shardingsphere-jdbc/spring-namespace/mode.cn.md | 17 ++++++++---------
 .../shardingsphere-jdbc/spring-namespace/mode.en.md | 21 +++++++++++----------
 examples/shardingsphere-example-generator/README.md |  2 +-
 .../shardingsphere-example-generator/README_ZH.md   |  2 +-
 .../YamlExampleConfigurationSupportedValue.java     |  2 +-
 .../src/main/resources/config.yaml                  |  4 ++--
 .../template/jdbc/java/config/Configuration.ftl     |  4 ++--
 .../{standalone-file.ftl => standalone.ftl}         |  2 +-
 .../config/{standalone-file.ftl => standalone.ftl}  |  0
 .../mode/{standalone-file.ftl => standalone.ftl}    |  0
 .../ShardingDatabasesConfigurationPrecise.java      |  2 +-
 13 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.cn.md
index a0547d48ddf..9aacd2234d0 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.cn.md
@@ -75,7 +75,7 @@ Properties props = ... // 构建属性配置
 DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(databaseName, modeConfig, dataSourceMap, ruleConfigs, props);
 
 private ModeConfiguration createModeConfiguration() {
-    return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("File", new Properties()), true);
+    return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("H2", new Properties()), true);
 }
 ```
 
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.en.md
index 6b06254edab..555ae3156f0 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/mode.en.md
@@ -75,7 +75,7 @@ Properties props = ... // Build property configuration
 DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(databaseName, modeConfig, dataSourceMap, ruleConfigs, props);
 
 private ModeConfiguration createModeConfiguration() {
-    return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("File", new Properties()), true);
+    return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("H2", new Properties()), true);
 }
 ```
 
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.cn.md
index c8e562c4e97..cd940b911ca 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.cn.md
@@ -32,11 +32,13 @@ weight = 1
 | props (?)     | 标签   | 持久化仓库所需属性    |
 
 ## 注意事项
+
 1. 生产环境建议使用集群模式部署。
-2. 集群模式部署推荐使用 `ZooKeeper` 注册中心。
+1. 集群模式部署推荐使用 `ZooKeeper` 注册中心。
 
 ## 操作步骤
-1. 引入 MAVEN 依赖
+
+引入 MAVEN 依赖
 
 ```xml
 <dependency>
@@ -64,17 +66,14 @@ weight = 1
                   http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone
                            http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone/repository.xsd">
-    <standalone:repository id="standaloneRepository" type="File">
-        <props>
-            <prop key="path">.shardingsphere</prop>
-        </props>
-    </standalone:repository>
+    <standalone:repository id="standaloneRepository" type="H2"/>
 
-    <shardingsphere:data-source id="ds" database-name="foo_db" data-source-names="..." rule-refs="..." >
-        <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" overwrite="false" />
+    <shardingsphere:data-source id="ds" database-name="foo_db" data-source-names="..." rule-refs="...">
+        <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" />
     </shardingsphere:data-source>
 </beans>
 ```
+
 ### 集群模式
 
 ```xml
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.en.md
index 0585e23ffbe..b1d8a9d51e2 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/spring-namespace/mode.en.md
@@ -33,10 +33,11 @@ Namespace:[http://shardingsphere.apache.org/schema/shardingsphere/mode-reposit
 ## Tips:
 
 1. For production environments, it is recommended to use cluster mode deployment.
-2. For cluster mode deployment, it is recommended to use `ZooKeeper` registry. 
+1. For cluster mode deployment, it is recommended to use `ZooKeeper` registry. 
 
 ## Operating Procedures
-1. Introduce MAVEN dependency
+
+Import MAVEN dependency
 
 ```xml
 <dependency>
@@ -45,11 +46,13 @@ Namespace:[http://shardingsphere.apache.org/schema/shardingsphere/mode-reposit
     <version>${latest.release.version}</version>
 </dependency>
 ```
+
 > Note: Please change `${latest.release.version}` to the actual version number.
 
 ## Configuration Example
 
 ### Standalone Mode
+
 ```xml
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
@@ -62,19 +65,16 @@ Namespace:[http://shardingsphere.apache.org/schema/shardingsphere/mode-reposit
                   http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                            http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone
                            http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone/repository.xsd">
-    <standalone:repository id="standaloneRepository" type="File">
-        <props>
-            <prop key="path">.shardingsphere</prop>
-        </props>
-    </standalone:repository>
+    <standalone:repository id="standaloneRepository" type="H2"/>
 
-    <shardingsphere:data-source id="ds" database-name="foo_db" data-source-names="..." rule-refs="..." >
-        <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" overwrite="false" />
+    <shardingsphere:data-source id="ds" database-name="foo_db" data-source-names="..." rule-refs="...">
+        <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" />
     </shardingsphere:data-source>
 </beans>
 ``` 
 
 ### Cluster Mode
+
 ```xml
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
@@ -99,7 +99,8 @@ Namespace:[http://shardingsphere.apache.org/schema/shardingsphere/mode-reposit
     </shardingsphere:data-source>
 </beans>
 ``` 
+
 ## Relevant References
 
 - [Installation and use of ZooKeeper Registry Center](https://zookeeper.apache.org/doc/r3.7.1/zookeeperStarted.html)
-- For details about persistent repository, please refer to[List of Built-in repository types](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/metadata-repository/)
+- For details about persistent repository, please refer to [List of Built-in repository types](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/metadata-repository/)
diff --git a/examples/shardingsphere-example-generator/README.md b/examples/shardingsphere-example-generator/README.md
index 8b402c00b21..db9bf3353ce 100644
--- a/examples/shardingsphere-example-generator/README.md
+++ b/examples/shardingsphere-example-generator/README.md
@@ -19,7 +19,7 @@ Generated codes: `target/generated-sources/shardingsphere-${product}-sample`
 | *Name*      | *Description*     | *Options*                                                                                                                            |
 |:----------- | ----------------- |:------------------------------------------------------------------------------------------------------------------------------------ |
 | product     | product           | jdbc, proxy                                                                                                                          |
-| mode        | operating mode    | cluster-zookeeper, cluster-etcd, standalone-file                                                                                     |
+| mode        | operating mode    | cluster-zookeeper, cluster-etcd, standalone                                                                                          |
 | transaction | transaction type  | local                                                                                                                                |
 | features    | feature set       | sharding, readwrite-splitting, db-discovery, encrypt                                                                                 |
 | frameworks  | framework set     | jdbc, spring-boot-starter-jdbc, spring-boot-starter-jpa, spring-boot-starter-mybatis, spring-namespace-jpa, spring-namespace-mybatis |
diff --git a/examples/shardingsphere-example-generator/README_ZH.md b/examples/shardingsphere-example-generator/README_ZH.md
index 36667022c46..4e899515426 100644
--- a/examples/shardingsphere-example-generator/README_ZH.md
+++ b/examples/shardingsphere-example-generator/README_ZH.md
@@ -19,7 +19,7 @@
 | *属性名称*    | *说明*      | *可选项*                                                                                                                             |
 |:----------- | ---------- |:----------------------------------------------------------------------------------------------------------------------------------- |
 | product     | 产品        | jdbc、proxy                                                                                                                         |
-| mode        | 运行模式     | cluster-zookeeper、cluster-etcd、standalone-file                                                                                    |
+| mode        | 运行模式     | cluster-zookeeper、cluster-etcd、standalone                                                                                         |
 | transaction | 事务类型     | local                                                                                                                              |
 | features    | 功能        | sharding、readwrite-splitting、db-discovery、encrypt                                                                                |
 | frameworks  | 框架        | jdbc、spring-boot-starter-jdbc、spring-boot-starter-jpa、spring-boot-starter-mybatis、spring-namespace-jpa、spring-namespace-mybatis |
diff --git a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
index 259c4bcf31e..1bf176e902f 100644
--- a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
+++ b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
@@ -33,7 +33,7 @@ public enum YamlExampleConfigurationSupportedValue {
     
     PRODUCTS("products", new HashSet<>(Arrays.asList("jdbc", "proxy"))),
     
-    MODES("modes", new HashSet<>(Arrays.asList("memory", "proxy", "cluster-zookeeper", "cluster-etcd", "standalone-file"))),
+    MODES("modes", new HashSet<>(Arrays.asList("memory", "proxy", "cluster-zookeeper", "cluster-etcd", "standalone"))),
     
     TRANSACTIONS("transactions", new HashSet<>(Arrays.asList("local", "xa-atomikos", "xa-narayana", "xa-bitronix", "base-seata"))),
     
diff --git a/examples/shardingsphere-example-generator/src/main/resources/config.yaml b/examples/shardingsphere-example-generator/src/main/resources/config.yaml
index cb4d7e09e35..0c48058858f 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/config.yaml
+++ b/examples/shardingsphere-example-generator/src/main/resources/config.yaml
@@ -19,9 +19,9 @@
 products:
   - jdbc
 
-# supported: cluster-zookeeper,cluster-etcd,standalone-file
+# supported: cluster-zookeeper,cluster-etcd,standalone
 modes: 
-  - standalone-file
+  - standalone
 
 # supported: local, xa-atomikos, xa-narayana, base-seata
 transactions: 
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl
index 59541b7007a..0007b6d55a4 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/Configuration.ftl
@@ -91,8 +91,8 @@ public final class Configuration {
     <#if mode=="cluster-etcd">
         return new ModeConfiguration("Cluster", new ClusterPersistRepositoryConfiguration("etcd", "governance-sharding-data-source", "localhost:2379", new Properties()), true);
     </#if>
-    <#if mode=="standalone-file">
-        return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("File", new Properties()), true);
+    <#if mode=="standalone">
+        return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("H2", new Properties()), true);
     </#if> 
     }
     
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone-file.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl
similarity index 95%
rename from examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone-file.ftl
rename to examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl
index a5e8f7c2b9a..68cefbc8786 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone-file.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-boot-starter/standalone.ftl
@@ -16,6 +16,6 @@
   -->
 
 spring.shardingsphere.mode.type=Standalone
-spring.shardingsphere.mode.repository.type=file
+spring.shardingsphere.mode.repository.type=H2
 spring.shardingsphere.mode.repository.props.path=demo
 spring.shardingsphere.mode.overwrite=false
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone-file.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone.ftl
similarity index 100%
rename from examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone-file.ftl
rename to examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mode/spring-namespace/config/standalone.ftl
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/proxy/mode/standalone-file.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/proxy/mode/standalone.ftl
similarity index 100%
rename from examples/shardingsphere-example-generator/src/main/resources/template/proxy/mode/standalone-file.ftl
rename to examples/shardingsphere-example-generator/src/main/resources/template/proxy/mode/standalone.ftl
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
index 50e9b594f42..6ec5001c71d 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
@@ -56,7 +56,7 @@ public final class ShardingDatabasesConfigurationPrecise implements ExampleConfi
     }
     
     private ModeConfiguration createModeConfiguration() {
-        return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("File", new Properties()), true);
+        return new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("H2", new Properties()), true);
     }
     
     private ShardingTableRuleConfiguration getOrderTableRuleConfiguration() {