Cobar-client implementation policy summary

Source: Internet
Author: User
1. Data Source datasource

The datasource of cobarclient is divided into three layers.

Icobardatasourceservice: encapsulates multiple performancedescriptor and ihadatasourcecreator encapsulated by HA.

Datasourcedescriptor: encapsulates identity, primary targetdatasource, and standby standbydatasource.

Datasource: actual database datasource

 

2. Router

The routing rule of cobarclient depends on ibatis. It is mainly determined by the sqlmap ID and the route field, for example

<rules>  <rule>    <namespace>com.alibaba.cobar.client.entities.Offer</namespace>    <shardingExpression>mod.apply(memberId)==1</shardingExpression>    <shards>partition1</shards>  </rule>  <rule>    <namespace>com.alibaba.cobar.client.entities.Offer</namespace>    <shardingExpression>mod.apply(memberId)==2</shardingExpression>    <shards>partition2</shards>  </rule></rules>

 

For SQL statements whose namespace is offline in sqlmap, Shard is obtained based on the memberid field of the parameter. Shard is the identity of performancedescriptor.

 

3. Ha

The HA of cobarclient is divided into active and passive modes. The active mode is enabled by default, that is, to open a thread to regularly detect whether the master data source is available. If not, switch to the standby data source, that is, the master and slave data sources of performancedescriptor are switched.

The passive mode is disabled by default. The Passive mode is to check before each query. This will reduce the efficiency. If the check fails, the active/standby mode will be switched.

 

4. Data Aggregation

Data aggregation mainly depends on manual aggregation after the client query, such

select count(*), companyId from offer group by companyId

The SQL statement is executed on multiple data sources, and multiple result sets are returned. Finally, the companyid is manually aggregated by the user.

Cobar-client implementation policy summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.