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 2021/10/09 02:27:53 UTC

[shardingsphere] branch master updated: Mixed feature example correction (#12948)

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 8f08bd9  Mixed feature example correction (#12948)
8f08bd9 is described below

commit 8f08bd91fe7c523e5e46c46624a9bb46c33f6a84
Author: Swastika Gupta <64...@users.noreply.github.com>
AuthorDate: Sat Oct 9 07:57:18 2021 +0530

    Mixed feature example correction (#12948)
---
 .../sharding-readwrite-splitting-range.yaml        | 113 --------------
 .../META-INF/sharding-readwrite-splitting.yaml     | 123 ----------------
 .../application-sharding-readwrite-splitting.xml   | 162 ---------------------
 3 files changed, 398 deletions(-)

diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-readwrite-splitting-range.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-readwrite-splitting-range.yaml
deleted file mode 100644
index cfde808..0000000
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-readwrite-splitting-range.yaml
+++ /dev/null
@@ -1,113 +0,0 @@
-#
-# 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.
-#
-
-dataSources:
-  write_ds_0:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_0_read_0:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_0_read_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_0_read_1:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_0_read_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_1:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_1_read_0:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_1_read_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_1_read_1:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_1_read_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-    
-rules:
-- !SHARDING
-  tables:
-    t_order: 
-      actualDataNodes: ds_${0..1}.t_order_${0..1}
-      tableStrategy: 
-        standard:
-          shardingColumn: order_id
-          shardingAlgorithmName: standard_test_tbl
-      keyGenerateStrategy:
-        column: order_id
-        keyGeneratorName: snowflake
-    t_order_item:
-      actualDataNodes: ds_${0..1}.t_order_item_${0..1}
-      tableStrategy:
-        standard:
-          shardingColumn: order_id
-          shardingAlgorithmName: standard_test_tbl
-      keyGenerateStrategy:
-        column: order_item_id
-        keyGeneratorName: snowflake
-  bindingTables:
-    - t_order,t_order_item
-  broadcastTables:
-    - t_address
-  defaultDatabaseStrategy:
-    standard:
-      shardingColumn: user_id
-      shardingAlgorithmName: standard_test_db
-  
-  shardingAlgorithms:
-    standard_test_db:
-      type: STANDARD_TEST_DB
-    standard_test_tbl:
-      type: STANDARD_TEST_TBL
-  
-  keyGenerators:
-    snowflake:
-      type: SNOWFLAKE
-      props:
-          worker-id: 123
-
-- !READWRITE_SPLITTING
-  dataSources:
-    ds_0:
-      writeDataSourceName: write_ds_0
-      readDataSourceNames: [write_ds_0_read_0, write_ds_0_read_1]
-      loadBalancerName: roundRobin
-    ds_1:
-      writeDataSourceName: write_ds_1
-      readDataSourceNames: [write_ds_1_read_0, write_ds_1_read_1]
-      loadBalancerName: roundRobin
-  loadBalancers:
-    roundRobin:
-      type: ROUND_ROBIN
-
-props:
-  sql-show: false
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-readwrite-splitting.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-readwrite-splitting.yaml
deleted file mode 100644
index 4617937..0000000
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-readwrite-splitting.yaml
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# 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.
-#
-
-dataSources:
-  write_ds_0:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_0_read_0:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_0_read_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_0_read_1:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_0_read_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_1:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_1_read_0:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_1_read_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-  write_ds_1_read_1:
-    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
-    driverClassName: com.mysql.jdbc.Driver
-    jdbcUrl: jdbc:mysql://localhost:3306/demo_write_ds_1_read_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-    username: root
-    password:
-    
-rules:
-- !SHARDING
-  tables:
-    t_order: 
-      actualDataNodes: ds_${0..1}.t_order_${0..1}
-      tableStrategy: 
-        standard:
-          shardingColumn: order_id
-          shardingAlgorithmName: t_order_inline
-      keyGenerateStrategy:
-        column: order_id
-        keyGeneratorName: snowflake
-    t_order_item:
-      actualDataNodes: ds_${0..1}.t_order_item_${0..1}
-      tableStrategy:
-        standard:
-          shardingColumn: order_id
-          shardingAlgorithmName: t_order_item_inline
-      keyGenerateStrategy:
-        column: order_id
-        keyGeneratorName: snowflake
-  bindingTables:
-    - t_order,t_order_item
-  broadcastTables:
-    - t_address
-  defaultDatabaseStrategy:
-    standard:
-      shardingColumn: user_id
-      shardingAlgorithmName: database_inline
-  
-  shardingAlgorithms:
-    database_inline:
-      type: INLINE
-      props:
-        algorithm-expression: ds_${user_id % 2}
-    t_order_inline:
-      type: INLINE
-      props:
-        algorithm-expression: t_order_${order_id % 2}
-    t_order_item_inline:
-      type: INLINE
-      props:
-        algorithm-expression: t_order_item_${order_id % 2}
-  
-  keyGenerators:
-    snowflake:
-      type: SNOWFLAKE
-      props:
-          worker-id: 123
-
-- !READWRITE_SPLITTING
-  dataSources:
-    ds_0:
-      writeDataSourceName: write_ds_0
-      readDataSourceNames: [write_ds_0_read_0, write_ds_0_read_1]
-      loadBalancerName: roundRobin
-      queryConsistent: true
-    ds_1:
-      writeDataSourceName: write_ds_1
-      readDataSourceNames: [write_ds_1_read_0, write_ds_1_read_1]
-      loadBalancerName: roundRobin
-      queryConsistent: false
-  loadBalancers:
-    roundRobin:
-      type: ROUND_ROBIN
-
-props:
-  sql-show: false
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml
deleted file mode 100644
index 61544c4..0000000
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:context="http://www.springframework.org/schema/context"
-       xmlns:tx="http://www.springframework.org/schema/tx"
-       xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
-       xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
-       xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-                           http://www.springframework.org/schema/beans/spring-beans.xsd
-                           http://www.springframework.org/schema/context
-                           http://www.springframework.org/schema/context/spring-context.xsd
-                           http://www.springframework.org/schema/tx
-                           http://www.springframework.org/schema/tx/spring-tx.xsd
-                           http://shardingsphere.apache.org/schema/shardingsphere/datasource
-                           http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
-                           http://shardingsphere.apache.org/schema/shardingsphere/sharding
-                           http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-                           http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting
-                           http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
-                           ">
-    <context:annotation-config />
-    <context:component-scan base-package="org.apache.shardingsphere.example.core.jpa"/>
-
-    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
-        <property name="dataSource" ref="shardingDataSource" />
-        <property name="jpaVendorAdapter">
-            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:database="MYSQL" />
-        </property>
-        <property name="packagesToScan" value="org.apache.shardingsphere.example.core.jpa.entity" />
-        <property name="jpaProperties">
-            <props>
-                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
-                <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
-                <prop key="hibernate.show_sql">false</prop>
-            </props>
-        </property>
-    </bean>
-    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" />
-    <tx:annotation-driven />
-    
-    <bean id="demo_write_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_write_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
-        <property name="username" value="root"/>
-        <property name="password" value=""/>
-        <property name="maximumPoolSize" value="16"/>
-    </bean>
-    
-    <bean id="demo_write_ds_0_read_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_write_ds_0_read_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
-        <property name="username" value="root"/>
-        <property name="password" value=""/>
-        <property name="maximumPoolSize" value="16"/>
-    </bean>
-    
-    <bean id="demo_write_ds_0_read_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_write_ds_0_read_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
-        <property name="username" value="root"/>
-        <property name="password" value=""/>
-        <property name="maximumPoolSize" value="16"/>
-    </bean>
-    
-    <bean id="demo_write_ds_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_write_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
-        <property name="username" value="root"/>
-        <property name="password" value=""/>
-        <property name="maximumPoolSize" value="16"/>
-    </bean>
-    
-    <bean id="demo_write_ds_1_read_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_write_ds_1_read_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
-        <property name="username" value="root"/>
-        <property name="password" value=""/>
-        <property name="maximumPoolSize" value="16"/>
-    </bean>
-    
-    <bean id="demo_write_ds_1_read_1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_write_ds_1_read_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
-        <property name="username" value="root"/>
-        <property name="password" value=""/>
-        <property name="maximumPoolSize" value="16"/>
-    </bean>
-    
-    <readwrite-splitting:load-balance-algorithm id="randomStrategy" type="RANDOM" />
-    
-    <sharding:sharding-algorithm id="databaseAlgorithm" type="INLINE">
-        <props>
-            <prop key="algorithm-expression">demo_pr_ds_${user_id % 2}</prop>
-        </props>
-    </sharding:sharding-algorithm>
-    <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
-    
-    <sharding:sharding-algorithm id="orderTableAlgorithm" type="INLINE">
-        <props>
-            <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
-        </props>
-    </sharding:sharding-algorithm>
-    <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
-    
-    <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="INLINE">
-        <props>
-            <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
-        </props>
-    </sharding:sharding-algorithm>
-    <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableAlgorithm" />
-    
-    <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
-        <props>
-            <prop key="worker-id">123</prop>
-        </props>
-    </sharding:key-generate-algorithm>
-    
-    <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
-    <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-    
-    <sharding:rule id="shardingRule">
-        <sharding:table-rules>
-            <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_pr_ds_${0..1}.t_order_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
-            <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_pr_ds_${0..1}.t_order_item_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
-        </sharding:table-rules>
-        <sharding:binding-table-rules>
-            <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>
-        </sharding:binding-table-rules>
-        <sharding:broadcast-table-rules>
-            <sharding:broadcast-table-rule table="t_address"/>
-        </sharding:broadcast-table-rules>
-    </sharding:rule>
-    <readwrite-splitting:rule id="readWriteSplittingRule">
-        <readwrite-splitting:data-source-rule id="demo_pr_ds_0" write-data-source-name="demo_write_ds_0" read-data-source-names="demo_write_ds_0_read_0, demo_write_ds_0_read_1" load-balance-algorithm-ref="randomStrategy" query-consistent="false" />
-        <readwrite-splitting:data-source-rule id="demo_pr_ds_1" write-data-source-name="demo_write_ds_1" read-data-source-names="demo_write_ds_1_read_0, demo_write_ds_1_read_1" load-balance-algorithm-ref="randomStrategy" query-consistent="true" />
-    </readwrite-splitting:rule>
-    
-    <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_write_ds_0,demo_write_ds_1,demo_write_ds_0_read_0, demo_write_ds_0_read_1,demo_write_ds_1_read_0, demo_write_ds_1_read_1" rule-refs="shardingRule, readWriteSplittingRule">
-        <props>
-            <prop key="sql-show">false</prop>
-        </props>
-    </shardingsphere:data-source>
-</beans>