This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 3297b2e Add readwrite-splitting jdbc example and update generator
(#13561)
3297b2e is described below
commit 3297b2e797893f0761e90dbbf7ca42c41c894d8d
Author: Guocheng Tang <[email protected]>
AuthorDate: Fri Nov 12 10:18:24 2021 +0800
Add readwrite-splitting jdbc example and update generator (#13561)
---
.../example/engine/ExampleGenerateEngine.java | 29 +++++----
.../main/resources/dataModel/jdbc/data-model.yaml | 2 +-
.../src/main/resources/template/Example.ftl | 16 +++--
.../src/main/resources/template/entity/Order.ftl | 2 +-
.../main/resources/template/entity/OrderItem.ftl | 2 +-
.../main/resources/template/jdbc/Configuration.ftl | 73 ++++++---------------
.../resources/template/jdbc/ExampleService.ftl | 12 ++--
.../jdbc/readwritesplittingConfiguration.ftl | 40 ++++++++++++
...Configuration.ftl => shardingConfiguration.ftl} | 71 +++++---------------
.../pom.xml | 1 +
.../pom.xml | 7 +-
.../pom.xml | 15 +++--
...ryLocalReadwriteSplittingJdbcConfiguration.java | 75 ++++++++++++++++++++++
.../MemoryLocalReadwriteSplittingJdbcExample.java | 32 +++++++++
...LocalReadwriteSplittingJdbcExampleService.java} | 18 ++----
.../readwrite/splitting/jdbc/entity/Order.java} | 28 +-------
.../splitting/jdbc/entity/OrderItem.java} | 28 +-------
.../src/main/resources/logback.xml} | 32 ++++-----
18 files changed, 256 insertions(+), 227 deletions(-)
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
index 24f9531..de4a247 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/ExampleGenerateEngine.java
@@ -29,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
+import java.io.Writer;
import java.util.Map;
/**
@@ -43,15 +44,19 @@ public abstract class ExampleGenerateEngine {
+
"/shardingsphere-jdbc-${mode}-${transaction}-example/shardingsphere-jdbc-${mode}-${transaction}-${feature}-example"
+
"/shardingsphere-jdbc-${mode}-${transaction}-${feature}-${framework}-example/src/main/";
- private static final String JAVA_CLASS_PATH =
"java/org/apache/shardingsphere/example/${feature}/${framework?replace('-',
'/')}";
+ private static final String JAVA_CLASS_PATH =
"java/org/apache/shardingsphere/example/${feature?replace('-',
'/')}/${framework?replace('-', '/')}";
private static final String RESOURCES_PATH = "resources";
- private static final String FILE_NAME_PREFIX =
"${mode?cap_first}${transaction?cap_first}${feature?cap_first}" +
- "<#assign frameworkName=\"\">" +
- "<#list framework?split(\"-\") as framework1>" +
- "<#assign frameworkName=frameworkName + framework1?cap_first>" +
- "</#list>${frameworkName}";
+ private static final String FILE_NAME_PREFIX =
"${mode?cap_first}${transaction?cap_first}"
+ + "<#assign featureName=\"\">"
+ + "<#list feature?split(\"-\") as feature1>"
+ + "<#assign featureName=featureName + feature1?cap_first>"
+ + "</#list>${featureName}"
+ + "<#assign frameworkName=\"\">"
+ + "<#list framework?split(\"-\") as framework1>"
+ + "<#assign frameworkName=frameworkName + framework1?cap_first>"
+ + "</#list>${frameworkName}";
private static final String FRAMEWORK_PATH =
"/dataModel/%s/data-model.yaml";
@@ -77,10 +82,10 @@ public abstract class ExampleGenerateEngine {
* @param outputFile Output directory and file name.
*/
public static void processFile(final Object model, final String
templateFile, final String outputFile) {
- try {
+ try (Writer writer = new FileWriter(outputFile)) {
Template template = CONFIGURATION.getTemplate(templateFile);
- template.process(model, new FileWriter(outputFile));
- } catch (IOException | TemplateException e) {
+ template.process(model, writer);
+ } catch (TemplateException | IOException e) {
e.printStackTrace();
}
}
@@ -92,9 +97,9 @@ public abstract class ExampleGenerateEngine {
* @return Replace the placeholder string
*/
public static String processString(final Object model, final String
templateString) {
- try {
- StringWriter result = new StringWriter();
- Template t = new Template("string", new
StringReader(templateString), CONFIGURATION);
+ try (StringWriter result = new StringWriter();
+ StringReader reader = new StringReader(templateString)) {
+ Template t = new Template("string", reader, CONFIGURATION);
t.process(model, result);
return result.toString();
} catch (IOException | TemplateException e) {
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/jdbc/data-model.yaml
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/jdbc/data-model.yaml
index 66fe5f1..792c10b 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/jdbc/data-model.yaml
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/jdbc/data-model.yaml
@@ -17,7 +17,7 @@
mode: memory
transaction: local
-feature: sharding
+feature: readwrite-splitting
framework: jdbc
host: localhost
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
index 53d91c9..e6eb6ec 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')};
+package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')};
<#if framework?contains("springboot")>
<#if framework=="springboot-starter-mybatis">
@@ -39,6 +39,10 @@ import java.sql.SQLException;
<#list framework?split("-") as framework1>
<#assign frameworkName=frameworkName + framework1?cap_first>
</#list>
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+ <#assign featureName=featureName + feature1?cap_first>
+</#list>
<#if framework=="springboot-starter-mybatis">
@MapperScan("org.apache.shardingsphere.example.${feature}.springboot.starter.mybatis.repository")
</#if>
@@ -48,21 +52,21 @@ import java.sql.SQLException;
<#if framework?contains("springboot")>
@SpringBootApplication
</#if>
-public class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Example
{
+public class
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Example {
public static void main(final String[] args) throws SQLException {
<#if framework=="jdbc">
-
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}Configuration
shardingConfiguration = new
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}Configuration();
+
${mode?cap_first}${transaction?cap_first}${featureName}${framework?cap_first}Configuration
shardingConfiguration = new
${mode?cap_first}${transaction?cap_first}${featureName}${framework?cap_first}Configuration();
DataSource dataSource = shardingConfiguration.getDataSource();
-
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}ExampleService
exampleService = new
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}ExampleService(dataSource);
+
${mode?cap_first}${transaction?cap_first}${featureName}${framework?cap_first}ExampleService
exampleService = new
${mode?cap_first}${transaction?cap_first}${featureName}${framework?cap_first}ExampleService(dataSource);
exampleService.run();
<#else>
<#if framework?contains("spring-namespace")>
try (ConfigurableApplicationContext applicationContext = new
ClassPathXmlApplicationContext("application.xml")) {
<#else>
- try (ConfigurableApplicationContext applicationContext =
SpringApplication.run(${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}Example.class,
args)) {
+ try (ConfigurableApplicationContext applicationContext =
SpringApplication.run(${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Example.class,
args)) {
</#if>
-
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService
exampleService =
applicationContext.getBean(${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService.class);
+
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
exampleService =
applicationContext.getBean(${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService.class);
exampleService.run();
}
</#if>
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
index 3bf5d32..8915499 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity;
+package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity;
<#if framework?contains("jpa")>
import javax.persistence.Column;
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
index 30a27fc..6b74f98 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity;
+package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity;
<#if framework?contains("jpa")>
import javax.persistence.Column;
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
index 25f2047..69eb142 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
@@ -15,10 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework};
+package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework};
import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
+<#if feature=="sharding">
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import
org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepositoryConfiguration;
@@ -26,15 +27,25 @@ import
org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
+</#if>
+<#if feature=="readwrite-splitting">
+import
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+</#if>
import javax.sql.DataSource;
import java.sql.SQLException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-public final class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}Configuration
{
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+ <#assign featureName=featureName + feature1?cap_first>
+</#list>
+public final class
${mode?cap_first}${transaction?cap_first}${featureName}${framework?cap_first}Configuration
{
private static final String HOST = "${host}";
@@ -43,58 +54,12 @@ public final class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}
private static final String USER_NAME = "${username}";
private static final String PASSWORD = "${(password)?c}";
-
- /**
- * Create a DataSource object, which is an object rewritten by
ShardingSphere itself
- * and contains various rules for rewriting the original data storage.
When in use, you only need to use this object.
- * @return
- * @throws SQLException
- */
- public DataSource getDataSource() throws SQLException {
- return
ShardingSphereDataSourceFactory.createDataSource(createModeConfiguration(),
createDataSourceMap(),
Collections.singleton(createShardingRuleConfiguration()), new Properties());
- }
-
- private ShardingRuleConfiguration createShardingRuleConfiguration() {
- ShardingRuleConfiguration result = new ShardingRuleConfiguration();
- result.getTables().add(getOrderTableRuleConfiguration());
- result.getTables().add(getOrderItemTableRuleConfiguration());
- result.getBroadcastTables().add("t_address");
- result.setDefaultDatabaseShardingStrategy(new
StandardShardingStrategyConfiguration("user_id", "inline"));
- Properties props = new Properties();
- props.setProperty("algorithm-expression", "${r"demo_ds_${user_id %
2}"}");
- result.getShardingAlgorithms() .put("inline", new
ShardingSphereAlgorithmConfiguration("INLINE", props));
- result.getKeyGenerators().put("snowflake", new
ShardingSphereAlgorithmConfiguration("SNOWFLAKE", getProperties()));
- return result;
- }
-
- private static ModeConfiguration createModeConfiguration() {
- return new ModeConfiguration("Standalone", new
StandalonePersistRepositoryConfiguration("File", new Properties()), true);
- }
-
- private static ShardingTableRuleConfiguration
getOrderTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new
ShardingTableRuleConfiguration("t_order");
- result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("order_id", "snowflake"));
- return result;
- }
-
- private static ShardingTableRuleConfiguration
getOrderItemTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new
ShardingTableRuleConfiguration("t_order_item");
- result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("order_item_id", "snowflake"));
- return result;
- }
-
- private Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>(2, 1);
- result.put("demo_ds_0", createDataSource("demo_ds_0"));
- result.put("demo_ds_1", createDataSource("demo_ds_1"));
- return result;
- }
-
- private static Properties getProperties() {
- Properties result = new Properties();
- result.setProperty("worker-id", "123");
- return result;
- }
+<#if feature=="sharding">
+ <#include "shardingConfiguration.ftl">
+</#if>
+<#if feature=="readwrite-splitting">
+ <#include "readwritesplittingConfiguration.ftl">
+</#if>
private DataSource createDataSource(final String dataSourceName) {
HikariDataSource result = new HikariDataSource();
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
index 6cffe99..eaa0d76 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')};
+package org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')};
import lombok.AllArgsConstructor;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity.OrderItem;
+import org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity.Order;
+import org.apache.shardingsphere.example.${feature?replace('-',
'.')}.${framework?replace('-', '.')}.entity.OrderItem;
<#if framework?contains("spring")>
import org.springframework.stereotype.Service;
</#if>
@@ -38,11 +38,15 @@ import java.util.List;
<#list framework?split("-") as framework1>
<#assign frameworkName=frameworkName + framework1?cap_first>
</#list>
+<#assign featureName="">
+<#list feature?split("-") as feature1>
+ <#assign featureName=featureName + feature1?cap_first>
+</#list>
<#if framework?contains("spring")>
@Service
</#if>
@AllArgsConstructor
-public final class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService
{
+public final class
${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}ExampleService
{
private final DataSource dataSource;
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/readwritesplittingConfiguration.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/readwritesplittingConfiguration.ftl
new file mode 100644
index 0000000..71dfe21
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/readwritesplittingConfiguration.ftl
@@ -0,0 +1,40 @@
+<#--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+ /**
+ * Create a DataSource object, which is an object rewritten by
ShardingSphere itself
+ * and contains various rules for rewriting the original data storage.
When in use, you only need to use this object.
+ * @return
+ * @throws SQLException
+ */
+ public DataSource getDataSource() throws SQLException {
+ return
ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(),
Collections.singleton(createReadwriteSplittingRuleConfiguration()), new
Properties());
+ }
+
+ private ReadwriteSplittingRuleConfiguration
createReadwriteSplittingRuleConfiguration() {
+ ReadwriteSplittingDataSourceRuleConfiguration dataSourceConfig = new
ReadwriteSplittingDataSourceRuleConfiguration(
+ "demo_read_query_ds", "", "demo_write_ds",
Arrays.asList("demo_read_ds_0", "demo_read_ds_1"), null);
+ return new
ReadwriteSplittingRuleConfiguration(Collections.singleton(dataSourceConfig),
Collections.emptyMap());
+ }
+
+ private Map<String, DataSource> createDataSourceMap() {
+ Map<String, DataSource> result = new HashMap<>(3, 1);
+ result.put("demo_write_ds", createDataSource("demo_write_ds"));
+ result.put("demo_read_ds_0", createDataSource("demo_read_ds_0"));
+ result.put("demo_read_ds_1", createDataSource("demo_read_ds_1"));
+ return result;
+ }
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/shardingConfiguration.ftl
similarity index 50%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
copy to
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/shardingConfiguration.ftl
index 25f2047..57f42c3 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/Configuration.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/shardingConfiguration.ftl
@@ -1,48 +1,19 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.example.${feature}.${framework};
-
-import com.zaxxer.hikari.HikariDataSource;
-import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import
org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepositoryConfiguration;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public final class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${framework?cap_first}Configuration
{
-
- private static final String HOST = "${host}";
-
- private static final int PORT = ${(port)?c};
-
- private static final String USER_NAME = "${username}";
-
- private static final String PASSWORD = "${(password)?c}";
+<#--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
/**
* Create a DataSource object, which is an object rewritten by
ShardingSphere itself
@@ -95,13 +66,3 @@ public final class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}
result.setProperty("worker-id", "123");
return result;
}
-
- private DataSource createDataSource(final String dataSourceName) {
- HikariDataSource result = new HikariDataSource();
- result.setDriverClassName("com.mysql.jdbc.Driver");
-
result.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8",
HOST, PORT, dataSourceName));
- result.setUsername(USER_NAME);
- result.setPassword(PASSWORD);
- return result;
- }
-}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
index f19784a..83f067a 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
@@ -30,5 +30,6 @@
<name>${project.artifactId}</name>
<modules>
<module>shardingsphere-jdbc-memory-local-sharding-example</module>
+
<module>shardingsphere-jdbc-memory-local-readwrite-splitting-example</module>
</modules>
</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
similarity index 83%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
index f19784a..ca1ca8d 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/pom.xml
@@ -20,15 +20,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>shardingsphere-jdbc-memory-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
<groupId>org.apache.shardingsphere.example</groupId>
<version>5.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
- <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-example</artifactId>
<name>${project.artifactId}</name>
+
<modules>
- <module>shardingsphere-jdbc-memory-local-sharding-example</module>
+
<module>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</module>
</modules>
</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/pom.xml
similarity index 76%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/pom.xml
index f19784a..725057e 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/pom.xml
@@ -20,15 +20,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>shardingsphere-jdbc-memory-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-example</artifactId>
<groupId>org.apache.shardingsphere.example</groupId>
<version>5.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+
<artifactId>shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-jdbc-memory-local-sharding-example</module>
- </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJdbcConfiguration.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example
[...]
new file mode 100644
index 0000000..c727549
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJdbcConfiguration.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.jdbc;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
+import
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public final class MemoryLocalReadwriteSplittingJdbcConfiguration {
+
+ private static final String HOST = "localhost";
+
+ private static final int PORT = 3306;
+
+ private static final String USER_NAME = "root";
+
+ private static final String PASSWORD = "123456";
+
+ /**
+ * Create a DataSource object, which is an object rewritten by
ShardingSphere itself
+ * and contains various rules for rewriting the original data storage.
When in use, you only need to use this object.
+ * @return
+ * @throws SQLException
+ */
+ public DataSource getDataSource() throws SQLException {
+ return
ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(),
Collections.singleton(createReadwriteSplittingRuleConfiguration()), new
Properties());
+ }
+
+ private ReadwriteSplittingRuleConfiguration
createReadwriteSplittingRuleConfiguration() {
+ ReadwriteSplittingDataSourceRuleConfiguration dataSourceConfig = new
ReadwriteSplittingDataSourceRuleConfiguration(
+ "demo_read_query_ds", "", "demo_write_ds",
Arrays.asList("demo_read_ds_0", "demo_read_ds_1"), null);
+ return new
ReadwriteSplittingRuleConfiguration(Collections.singleton(dataSourceConfig),
Collections.emptyMap());
+ }
+
+ private Map<String, DataSource> createDataSourceMap() {
+ Map<String, DataSource> result = new HashMap<>(3, 1);
+ result.put("demo_write_ds", createDataSource("demo_write_ds"));
+ result.put("demo_read_ds_0", createDataSource("demo_read_ds_0"));
+ result.put("demo_read_ds_1", createDataSource("demo_read_ds_1"));
+ return result;
+ }
+
+ private DataSource createDataSource(final String dataSourceName) {
+ HikariDataSource result = new HikariDataSource();
+ result.setDriverClassName("com.mysql.jdbc.Driver");
+
result.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8",
HOST, PORT, dataSourceName));
+ result.setUsername(USER_NAME);
+ result.setPassword(PASSWORD);
+ return result;
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJdbcExample.java
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shard
[...]
new file mode 100644
index 0000000..14ae473
--- /dev/null
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJdbcExample.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.readwrite.splitting.jdbc;
+
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+public class MemoryLocalReadwriteSplittingJdbcExample {
+
+ public static void main(final String[] args) throws SQLException {
+ MemoryLocalReadwriteSplittingJdbcConfiguration shardingConfiguration =
new MemoryLocalReadwriteSplittingJdbcConfiguration();
+ DataSource dataSource = shardingConfiguration.getDataSource();
+ MemoryLocalReadwriteSplittingJdbcExampleService exampleService = new
MemoryLocalReadwriteSplittingJdbcExampleService(dataSource);
+ exampleService.run();
+ }
+}
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJd
[...]
similarity index 93%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJdbcExampleService.java
index 6cffe99..77f1ef3 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/jdbc/ExampleService.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/MemoryLocalReadwriteSplittingJdbcExampleService.java
@@ -15,14 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')};
+package org.apache.shardingsphere.example.readwrite.splitting.jdbc;
import lombok.AllArgsConstructor;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity.Order;
-import org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity.OrderItem;
-<#if framework?contains("spring")>
-import org.springframework.stereotype.Service;
-</#if>
+import org.apache.shardingsphere.example.readwrite.splitting.jdbc.entity.Order;
+import
org.apache.shardingsphere.example.readwrite.splitting.jdbc.entity.OrderItem;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -34,15 +31,8 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-<#assign frameworkName="">
-<#list framework?split("-") as framework1>
- <#assign frameworkName=frameworkName + framework1?cap_first>
-</#list>
-<#if framework?contains("spring")>
-@Service
-</#if>
@AllArgsConstructor
-public final class
${mode?cap_first}${transaction?cap_first}${feature?cap_first}${frameworkName}ExampleService
{
+public final class MemoryLocalReadwriteSplittingJdbcExampleService {
private final DataSource dataSource;
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/entity/Order.java
similarity index 70%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/entity/Order.java
index 3bf5d32..ef77180 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/Order.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/entity/Order.java
@@ -15,46 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity;
+package org.apache.shardingsphere.example.readwrite.splitting.jdbc.entity;
-<#if framework?contains("jpa")>
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-</#if>
import java.io.Serializable;
-<#if framework?contains("jpa")>
-@Entity
-@Table(name = "t_order")
-</#if>
public class Order implements Serializable {
private static final long serialVersionUID = 8306802022239174861L;
- <#if framework?contains("jpa")>
- @Id
- @Column(name = "order_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- </#if>
private long orderId;
- <#if framework?contains("jpa")>
- @Column(name = "user_id")
- </#if>
private int userId;
- <#if framework?contains("jpa")>
- @Column(name = "address_id")
- </#if>
private long addressId;
- <#if framework?contains("jpa")>
- @Column(name = "status")
- </#if>
private String status;
public long getOrderId() {
diff --git
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/entity/OrderItem.java
similarity index 70%
copy from
examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/entity/OrderItem.java
index 30a27fc..a501ce7 100644
---
a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/entity/OrderItem.ftl
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/jdbc/entity/OrderItem.java
@@ -15,46 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.${feature}.${framework?replace('-',
'.')}.entity;
+package org.apache.shardingsphere.example.readwrite.splitting.jdbc.entity;
-<#if framework?contains("jpa")>
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-</#if>
import java.io.Serializable;
-<#if framework?contains("jpa")>
-@Entity
-@Table(name = "t_order_item")
-</#if>
public class OrderItem implements Serializable {
private static final long serialVersionUID = 1332162822494069342L;
- <#if framework?contains("jpa")>
- @Id
- @Column(name = "order_item_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- </#if>
private long orderItemId;
- <#if framework?contains("jpa")>
- @Column(name = "order_id")
- </#if>
private long orderId;
- <#if framework?contains("jpa")>
- @Column(name = "user_id")
- </#if>
private int userId;
- <#if framework?contains("jpa")>
- @Column(name = "status")
- </#if>
private String status;
public long getOrderItemId() {
diff --git
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/resources/logback.xml
similarity index 54%
copy from
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
copy to
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/resources/logback.xml
index f19784a..8c81a7f 100644
---
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/pom.xml
+++
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-readwrite-splitting-example/shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example/src/main/resources/logback.xml
@@ -16,19 +16,19 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>shardingsphere-jdbc-memory-example</artifactId>
- <groupId>org.apache.shardingsphere.example</groupId>
- <version>5.0.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
- <name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-jdbc-memory-local-sharding-example</module>
- </modules>
-</project>
+<configuration>
+ <property name="log.context.name"
value="shardingsphere-jdbc-memory-local-readwrite-splitting-jdbc-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger]
%msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder charset="${log.charset}">
+ <pattern>${log.pattern}</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <level value="INFO" />
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>