<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed 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. -->
<dble:sharding xmlns:dble="http://dble.cloud/">

    <schema name="cndb" >
        <shardingTable name="offer" shardingNode="offer_dn$0-127" function="func" shardingColumn="member_id"/>
        <shardingTable name="offer_detail" shardingNode="detail_dn0,detail_dn$1-127" function="func2" shardingColumn="offer_id" sqlRequiredSharding="false"/>
        <shardingTable name="offer_date" shardingNode="detail_dn0,detail_dn$1-127" function="by-date" shardingColumn="col_date" sqlRequiredSharding="false"/>
        <shardingTable name="independent" shardingNode="independent_dn$0-126,independent_dn127" function="by-date" shardingColumn="col_date"/>
    </schema>

    <schema name="dubbo" shardingNode="dubbo_dn"/>

    <schema name="dubbo2" shardingNode="dn1">
        <globalTable name="company"  shardingNode="dn1,dn2,dn3"/>
        <globalTable name="goods"  shardingNode="dn1,dn2,dn3"/>
    </schema>

    <schema name="ignoreSchemaTest" shardingNode="cndb_dn" />

    <schema name="config">
        <shardingTable name="offer" shardingNode="offer_dn$0-127" function="func" shardingColumn="member_id" sqlRequiredSharding="true"/>
    </schema>

    <schema name="none_node_test">
        <shardingTable name="offer" shardingNode="offer_dn$0-127" function="func" shardingColumn="member_id" sqlRequiredSharding="true"/>
    </schema>

    <schema name="solo1" shardingNode="solo1"/>

    <schema name="TESTDB" sqlMaxLimit="100">
        <shardingTable name="travelrecord" shardingNode="dn1,dn2,dn3" function="rang-long" shardingColumn="id"/>
        <!-- global table is auto cloned to all defined data nodes ,so can join
            with any table whose sharding node is in the same data node -->
        <globalTable name="company"  shardingNode="dn1,dn2,dn3"/>
        <globalTable name="goods"  shardingNode="dn1,dn2,dn3"/>
        <singleTable name="notpartionTable" shardingNode="dn1"/>
        <globalTable name="area"  shardingNode="dn1,dn2,dn3"/>
        <shardingTable name="employee" shardingNode="dn1,dn2" function="func1" shardingColumn="sharding_id"/>
        <shardingTable name="customer" shardingNode="dn1,dn2" function="rang-long2" shardingColumn="id">
            <childTable name="orders" joinColumn="customer_id" parentColumn="id">
                <childTable name="order_items" joinColumn="order_id" parentColumn="id"/>
            </childTable>
            <childTable name="customer_addr" joinColumn="customer_id" parentColumn="id"/>
        </shardingTable>
        <globalTable name="globalsn"  shardingNode="dn1"/>
    </schema>

    <schema name="mysqldb" sqlMaxLimit="100">
        <shardingTable name="offer" shardingNode="dn1,dn2" function="rang-long2" shardingColumn="id"/>
        <singleTable name="offer1" shardingNode="dn1"/>
    </schema>


    <shardingNode name="dn1" dbGroup="localhost1" database="db1"/>
    <shardingNode name="dn2" dbGroup="localhost1" database="db2"/>
    <shardingNode name="dn3" dbGroup="localhost1" database="db3"/>
    <shardingNode name="cndb_dn" dbGroup="localhost1" database="db4"/>
    <shardingNode name="offer_dn$0-127" dbGroup="localhost1" database="db1$0-127"/>
    <shardingNode name="detail_dn$0-127" dbGroup="localhost1" database="db2$0-127"/>
    <shardingNode name="test_wild1$1-3" dbGroup="localhost$1-3" database="dbwild"/>
    <shardingNode name="test_wild$1-6" dbGroup="localhost$1-3" database="dbwild1$1-2"/>
    <shardingNode name="independent_dn$0-127" dbGroup="localhost1" database="db7_$0-127"/>
    <shardingNode name="dubbo_dn" dbGroup="localhost1" database="db8"/>
    <shardingNode name="solo1" dbGroup="localhost1" database="db9"/>

    <function name="func1"
              class="com.actiontech.dble.route.function.PartitionByFileMap">
        <property name="defaultNode">0</property>
        <property name="mapFile">sharding.txt</property>
    </function>
    <function name="func"
              class="com.actiontech.dble.route.function.PartitionByString">
        <property name="partitionCount">128</property>
        <property name="partitionLength">8</property>
        <property name="hashSlice">:8</property>
    </function>
    <function name="func2" class="com.actiontech.dble.route.function.PartitionByLong">
        <property name="partitionCount">128</property>
        <property name="partitionLength">8</property>
    </function>
    <function name="rang-long"
              class="com.actiontech.dble.route.function.AutoPartitionByLong">
        <property name="mapFile">autopartition-long.txt</property>
    </function>
    <function name="rang-long2"
              class="com.actiontech.dble.route.function.AutoPartitionByLong">
        <property name="mapFile">autopartition-long2.txt</property>
    </function>
    <function name="by-date"
              class="com.actiontech.dble.route.function.PartitionByDate">
        <property name="sBeginDate">2014-01-01</property>
        <property name="sPartionDay">10</property>
        <property name="dateFormat">yyyy-MM-dd</property>
    </function>

</dble:sharding>
