<?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.
-->
<!DOCTYPE dble:schema SYSTEM "schema.dtd">
<dble:schema xmlns:dble="http://dble.cloud/">

    <!-- schema定义 -->
    <schema name="dbtest">

        <table name="tb1" dataNode="dnTest2,dnTest1" rule="rule1"/>
        <table name="tb2" dataNode="dnTest2,dnTest3" rule="rule1"/>
        <table name="tb3" dataNode="dnTest1,dnTest2" rule="rule1"/>
    </schema>


    <schema name="dbtest2" sqlMaxLimit="100" dataNode="dnTest4"></schema>

    <schema name="ertest">
        <table name="er_parent" cacheKey="ID" dataNode="dnTest1,dnTest2" rule="rule1">
            <childTable name="er_child1" cacheKey="child1_id" joinKey="child1_id" parentKey="id">
                <childTable name="er_grandson" cacheKey="grandson_id" joinKey="grandson_id" parentKey="child1_id"/>
            </childTable>
            <childTable name="er_child2" cacheKey="child2_id" joinKey="child2_id" parentKey="id2"/>
            <childTable name="er_child3" cacheKey="child3_id" joinKey="child_char" parentKey="c_char"/>
            <childTable name="er_child4" cacheKey="child4_id" joinKey="child4_id" parentKey="id2">
                <childTable name="er_grandson2" cacheKey="grandson2_id" joinKey="grandson2_id"
                            parentKey="child4_id2"/>
            </childTable>
            <childTable name="er_child5" cacheKey="child5_id" joinKey="child5_id" parentKey="id">
                <childTable name="er_grandson3" cacheKey="grandson3_id" joinKey="grandson3_id"
                            parentKey="child5_id2"/>
            </childTable>
        </table>
    </schema>
    <!-- 数据节点定义，数据节点由数据源和其他一些参数组织而成。 -->
    <dataNode name="dnTest1" dataHost="localhost1" database="db1"/>
    <dataNode name="dnTest2" dataHost="localhost1" database="db2"/>
    <dataNode name="dnTest3" dataHost="localhost1" database="db3"/>
    <dataNode name="dnTest4" dataHost="localhost2" database="db4"/>

    <dataHost name="localhost1" maxCon="500" minCon="10" balance="0"
    >
        <heartbeat>select user()</heartbeat>
        <!-- can have multi write hosts -->
        <writeHost host="hostM1" url="localhost:3306" user="root"
                   password="123456">
            <!-- can have multi read hosts -->
            <!-- <readHost host="hostS1" url="localhost:3307" user="root" password="123456"
                /> -->
        </writeHost>
    </dataHost>


    <!-- 读权重设置 -->
    <dataHost name="localhost2" maxCon="1000" minCon="10" balance="0"
              writeType="0" switchType="1" slaveThreshold="100" tempReadHostAvailable="1">
        <heartbeat>select user()</heartbeat>
        <writeHost host="writeS" url="192.168.1.10:3306" user="root" password="123456">
            <!-- can have multi read hosts -->
            <readHost host="readS1" url="192.168.1.11:3306" user="root" password="123456" weight="1"/>
            <readHost host="readS2" url="192.168.1.12:3306" user="root" password="123456" weight="2"/>
            <readHost host="readS3" url="192.168.1.13:3306" user="root" password="123456" weight="3"/>
        </writeHost>
    </dataHost>

</dble:schema>
