未验证 提交 a3081e4d 编写于 作者: Z zhyee 提交者: GitHub

add shadow spring boot example and shadow spring namespace example to orchestration (#5704)

上级 0bc28040
#
# 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.
#
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.orchestration-type=config_center
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.instance-type=nacos
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.server-lists=localhost:8848
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.namespace=
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.props.overwrite=false
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.props.group=SHARDING_SPHERE_DEFAULT_GROUP
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.props.operationTimeoutMilliseconds=3000
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.orchestration-type=registry_center,metadata_center
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.instance-type=zookeeper
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.server-lists=localhost:2181
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.namespace=orchestration-spring-boot-demo
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.props.overwrite=false
#
# 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.
#
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.orchestration-type=registry_center,config_center,metadata_center
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.instance-type=zookeeper
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.server-lists=localhost:2181
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.namespace=orchestration-spring-boot-demo
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.props.overwrite=false
#
# 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.
#
spring.shardingsphere.datasource.name=shadow_ds,ds
spring.shardingsphere.datasource.shadow_ds.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.shadow_ds.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.shadow_ds.jdbc-url=jdbc:mysql://localhost:3306/shadow_demo_ds
spring.shardingsphere.datasource.shadow_ds.username=root
spring.shardingsphere.datasource.shadow_ds.password=
spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds
spring.shardingsphere.datasource.ds.username=root
spring.shardingsphere.datasource.ds.password=
spring.shardingsphere.rules.shadow.column=shadow
spring.shardingsphere.rules.shadow.shadow-mappings.ds=shadow_ds
spring.shardingsphere.props.sql.show=true
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.orchestration-type=config_center
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.instance-type=nacos
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.server-lists=localhost:8848
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.namespace=
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.props.overwrite=true
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.orchestration-type=registry_center,metadata_center
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.instance-type=zookeeper
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.server-lists=localhost:2181
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.namespace=orchestration-spring-boot-demo
spring.shardingsphere.orchestration.demo1_spring_boot_ds_shadow.props.overwrite=true
#
# 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.
#
spring.shardingsphere.datasource.name=ds,shadow_ds
spring.shardingsphere.datasource.shadow_ds.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.shadow_ds.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.shadow_ds.jdbc-url=jdbc:mysql://localhost:3306/shadow_demo_ds
spring.shardingsphere.datasource.shadow_ds.username=root
spring.shardingsphere.datasource.shadow_ds.password=
spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds
spring.shardingsphere.datasource.ds.username=root
spring.shardingsphere.datasource.ds.password=
spring.shardingsphere.rules.shadow.column=shadow
spring.shardingsphere.rules.shadow.shadow-mappings.ds=shadow_ds
spring.shardingsphere.props.sql.show=true
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.orchestration-type=registry_center,config_center,metadata_center
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.instance-type=zookeeper
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.server-lists=localhost:2181
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.namespace=orchestration-spring-boot-demo
spring.shardingsphere.orchestration.demo_spring_boot_ds_shadow.props.overwrite=true
......@@ -28,6 +28,10 @@ spring.profiles.active=local-zookeeper-sharding-databases-tables
#spring.profiles.active=local-zookeeper-encrypt
#spring.profiles.active=cloud-zookeeper-encrypt
#spring.profiles.active=local-zookeeper-shadow
#spring.profiles.active=cloud-zookeeper-shadow
#spring.profiles.active=local-nacos-sharding-databases-tables
#spring.profiles.active=local-nacos-master-slave
......@@ -36,3 +40,6 @@ spring.profiles.active=local-zookeeper-sharding-databases-tables
#spring.profiles.active=local-nacos-encrypt
#spring.profiles.active=cloud-nacos-encrypt
#spring.profiles.active=local-nacos-shadow
#spring.profiles.active=cloud-nacos-shadow
......@@ -31,6 +31,7 @@ public class ExampleMain {
private static ShardingType shardingType = ShardingType.SHARDING_DATABASES_AND_TABLES;
// private static ShardingType shardingType = ShardingType.MASTER_SLAVE;
// private static ShardingType shardingType = ShardingType.ENCRYPT;
// private static ShardingType shardingType = ShardingType.SHADOW;
private static boolean loadConfigFromRegCenter = false;
// private static boolean loadConfigFromRegCenter = true;
......@@ -52,6 +53,8 @@ public class ExampleMain {
return String.format("META-INF/%s/%s/application-master-slave.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local");
case ENCRYPT:
return String.format("META-INF/%s/%s/application-encrypt.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local");
case SHADOW:
return String.format("META-INF/%s/%s/application-shadow.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local");
default:
throw new UnsupportedOperationException(shardingType.name());
}
......
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:orchestration="http://shardingsphere.apache.org/schema/shardingsphere/orchestration"
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/orchestration
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd">
<import resource="classpath*:META-INF/nacos/registry-center.xml" />
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
<orchestration:data-source id="shadowDataSource" instance-ref="regCenter,confCenter" overwrite="false" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shadowDataSource" />
</bean>
<tx:annotation-driven />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="shadowDataSource"/>
<property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.apache.shardingsphere.example.core.mybatis.repository"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:bean="http://www.springframework.org/schema/util"
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow"
xmlns:orchestration="http://shardingsphere.apache.org/schema/shardingsphere/orchestration"
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://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://shardingsphere.apache.org/schema/shardingsphere/datasource
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
http://shardingsphere.apache.org/schema/shardingsphere/shadow
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
http://shardingsphere.apache.org/schema/shardingsphere/orchestration
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
">
<import resource="classpath*:META-INF/nacos/registry-center.xml" />
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
<bean id="shadow_demo_ds" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/shadow_demo_ds"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<bean id="demo_ds" 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_ds"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<shadow:rule id="shadowRule" column="shadow">
<shadow:mappings>
<shadow:mapping product-data-source-name="demo_ds" shadow-data-source-name="shadow_demo_ds"/>
</shadow:mappings>
</shadow:rule>
<shardingsphere:data-source id="realShadowDataSource" data-source-names="demo_ds,shadow_demo_ds" rule-refs="shadowRule" />
<orchestration:data-source id="shadowDataSource" data-source-ref="realShadowDataSource" instance-ref="regCenter,confCenter" overwrite="true" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shadowDataSource" />
</bean>
<tx:annotation-driven />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="shadowDataSource"/>
<property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.apache.shardingsphere.example.core.mybatis.repository"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:orchestration="http://shardingsphere.apache.org/schema/shardingsphere/orchestration"
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/orchestration
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd">
<import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
<orchestration:data-source id="shadowDataSource" instance-ref="regCenter" overwrite="false" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shadowDataSource" />
</bean>
<tx:annotation-driven />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="shadowDataSource"/>
<property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.apache.shardingsphere.example.core.mybatis.repository"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:bean="http://www.springframework.org/schema/util"
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow"
xmlns:orchestration="http://shardingsphere.apache.org/schema/shardingsphere/orchestration"
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://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://shardingsphere.apache.org/schema/shardingsphere/datasource
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
http://shardingsphere.apache.org/schema/shardingsphere/shadow
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
http://shardingsphere.apache.org/schema/shardingsphere/orchestration
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
">
<import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
<bean id="shadow_demo_ds" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/shadow_demo_ds"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<bean id="demo_ds" 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_ds"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<shadow:rule id="shadowRule" column="shadow">
<shadow:mappings>
<shadow:mapping product-data-source-name="demo_ds" shadow-data-source-name="shadow_demo_ds"/>
</shadow:mappings>
</shadow:rule>
<shardingsphere:data-source id="realShadowDataSource" data-source-names="demo_ds,shadow_demo_ds" rule-refs="shadowRule" />
<orchestration:data-source id="shadowDataSource" data-source-ref="realShadowDataSource" instance-ref="regCenter" overwrite="true" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shadowDataSource" />
</bean>
<tx:annotation-driven />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="shadowDataSource"/>
<property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.apache.shardingsphere.example.core.mybatis.repository"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册