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/09/24 07:52:53 UTC
[shardingsphere] branch master updated: Shadow DistSQL doc (#12629)
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 d7483b2 Shadow DistSQL doc (#12629)
d7483b2 is described below
commit d7483b26e1d01436f1e8d17956277d322ec5faa7
Author: lanchengx <52...@users.noreply.github.com>
AuthorDate: Fri Sep 24 02:52:16 2021 -0500
Shadow DistSQL doc (#12629)
* doc:Shadow distSQL show statement RQL document
* doc:Shadow distSQL show statement RDL document
* doc:Shadow distSQL show statement RDL document
* Document adjustment.
* Document adjustment.
* Document adjustment.
* adjustment
* adjustment
* Document adjustment.
---
.../dist-sql/syntax/rdl/rdl-shadow-rule.cn.md | 63 ++++++++++++++
.../dist-sql/syntax/rdl/rdl-shadow-rule.en.md | 63 ++++++++++++++
.../dist-sql/syntax/rql/rql-shadow-rule.cn.md | 97 ++++++++++++++++++++++
.../dist-sql/syntax/rql/rql-shadow-rule.en.md | 97 ++++++++++++++++++++++
4 files changed, 320 insertions(+)
diff --git a/docs/document/content/features/dist-sql/syntax/rdl/rdl-shadow-rule.cn.md b/docs/document/content/features/dist-sql/syntax/rdl/rdl-shadow-rule.cn.md
new file mode 100644
index 0000000..b27f53e
--- /dev/null
+++ b/docs/document/content/features/dist-sql/syntax/rdl/rdl-shadow-rule.cn.md
@@ -0,0 +1,63 @@
++++
+title = "影子库压测"
+weight = 6
++++
+
+## 定义
+
+```sql
+CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
+
+ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
+
+ALTER SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
+
+DROP SHADOW RULE ruleName [, ruleName] ...
+
+DROP SHADOW ALGORITHM algorithmName [, algorithmName] ...
+
+shadowRuleDefinition: ruleName(resourceMapping, shadowTableRule [, shadowTableRule] ...)
+
+resourceMapping: SOURCE=resourceName, SHADOW=resourceName
+
+shadowTableRule: tableName(shadowAlgorithm [, shadowAlgorithm] ...)
+
+shadowAlgorithm: ([algorithmName, ] TYPE(NAME=shadowAlgorithmType, PROPERTIES([algorithmProperties] ...)))
+
+algorithmProperties: algorithmProperty [, algorithmProperty] ...
+
+algorithmProperty: key=value
+```
+
+- 重复的`ruleName`无法被创建
+- `resourceMapping` 指定源数据库和影子库的映射关系,需使用 RDL 管理的 `resource` ,请参考 [数据源资源](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+- `shadowAlgorithm` 可同时作用于多个 `shadowTableRule`
+- `algorithmName` 未指定时会根据 `ruleName`、`tableName` 和 `shadowAlgorithmType` 自动生成
+- `shadowAlgorithmType` 目前支持 `COLUMN_REGEX_MATCH` 和 `SIMPLE_NOTE`
+- `shadowTableRule` 能够被不同的 `shadowRuleDefinition` 复用,因此在执行 `DROP SHADOW RULE` 时,对应的 `shadowTableRule` 不会被移除
+- `shadowAlgorithm` 能够被不同的 `shadowTableRule` 复用,因此在执行 `ALTER SHADOW RULE` 时,对应的 `shadowAlgorithm` 不会被移除
+
+
+## 示例
+
+```sql
+CREATE SHADOW RULE shadow_rule(
+SOURCE=demo_ds,
+SHADOW=demo_ds_shadow,
+t_order((simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", foo="bar"))),(TYPE(NAME=COLUMN_REGEX_MATCH, PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
+t_order_item((TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", "foo"="bar")))));
+
+ALTER SHADOW RULE shadow_rule(
+SOURCE=demo_ds,
+SHADOW=demo_ds_shadow,
+t_order((simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", foo="bar"))),(TYPE(NAME=COLUMN_REGEX_MATCH, PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
+t_order_item((TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", "foo"="bar")))));
+
+ALTER SHADOW ALGORITHM
+(simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", "foo"="bar"))),
+(user_id_match_algorithm, TYPE(NAME=COLUMN_REGEX_MATCH,PROPERTIES("operation"="insert", "column"="user_id", "regex"='[1]')));
+
+DROP SHADOW RULE shadow_rule;
+
+DROP SHADOW ALGORITHM simple_note_algorithm;
+```
diff --git a/docs/document/content/features/dist-sql/syntax/rdl/rdl-shadow-rule.en.md b/docs/document/content/features/dist-sql/syntax/rdl/rdl-shadow-rule.en.md
new file mode 100644
index 0000000..65d62bc
--- /dev/null
+++ b/docs/document/content/features/dist-sql/syntax/rdl/rdl-shadow-rule.en.md
@@ -0,0 +1,63 @@
++++
+title = "Shadow"
+weight = 6
++++
+
+## Definition
+
+```sql
+CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
+
+ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
+
+ALTER SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
+
+DROP SHADOW RULE ruleName [, ruleName] ...
+
+DROP SHADOW ALGORITHM algorithmName [, algorithmName] ...
+
+shadowRuleDefinition: ruleName(resourceMapping, shadowTableRule [, shadowTableRule] ...)
+
+resourceMapping: SOURCE=resourceName, SHADOW=resourceName
+
+shadowTableRule: tableName(shadowAlgorithm [, shadowAlgorithm] ...)
+
+shadowAlgorithm: ([algorithmName, ] TYPE(NAME=shadowAlgorithmType, PROPERTIES([algorithmProperties] ...)))
+
+algorithmProperties: algorithmProperty [, algorithmProperty] ...
+
+algorithmProperty: key=value
+```
+
+- Duplicate `ruleName` cannot be created
+- `resourceMapping` specifies the mapping relationship between the source database and the shadow library. You need to use the `resource` managed by RDL, please refer to [resource](https:shardingsphere.apache.orgdocumentcurrentcnfeaturesdist-sqlsyntaxrdlrdl-resource)
+- `shadowAlgorithm` can act on multiple `shadowTableRule` at the same time
+- If `algorithmName` is not specified, it will be automatically generated according to `ruleName`, `tableName` and `shadowAlgorithmType`
+- `shadowAlgorithmType` currently supports `COLUMN_REGEX_MATCH` and `SIMPLE_NOTE`
+- `shadowTableRule` can be reused by different `shadowRuleDefinition`, so when executing `DROP SHADOW RULE`, the corresponding `shadowTableRule` will not be removed
+- `shadowAlgorithm` can be reused by different `shadowTableRule`, so when executing `ALTER SHADOW RULE`, the corresponding `shadowAlgorithm` will not be removed
+
+
+## Example
+
+```sql
+CREATE SHADOW RULE shadow_rule(
+SOURCE=demo_ds,
+SHADOW=demo_ds_shadow,
+t_order((simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", foo="bar"))),(TYPE(NAME=COLUMN_REGEX_MATCH, PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
+t_order_item((TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", "foo"="bar")))));
+
+ALTER SHADOW RULE shadow_rule(
+SOURCE=demo_ds,
+SHADOW=demo_ds_shadow,
+t_order((simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", foo="bar"))),(TYPE(NAME=COLUMN_REGEX_MATCH, PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
+t_order_item((TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", "foo"="bar")))));
+
+ALTER SHADOW ALGORITHM
+(simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES("shadow"="true", "foo"="bar"))),
+(user_id_match_algorithm, TYPE(NAME=COLUMN_REGEX_MATCH,PROPERTIES("operation"="insert", "column"="user_id", "regex"='[1]')));
+
+DROP SHADOW RULE shadow_rule;
+
+DROP SHADOW ALGORITHM simple_note_algorithm;
+```
diff --git a/docs/document/content/features/dist-sql/syntax/rql/rql-shadow-rule.cn.md b/docs/document/content/features/dist-sql/syntax/rql/rql-shadow-rule.cn.md
new file mode 100644
index 0000000..049984c
--- /dev/null
+++ b/docs/document/content/features/dist-sql/syntax/rql/rql-shadow-rule.cn.md
@@ -0,0 +1,97 @@
++++
+title = "影子库压测"
+weight = 6
++++
+
+## 定义
+
+```sql
+SHOW SHADOW shadowRule | RULES [FROM schemaName]
+
+SHOW SHADOW TABLE RULES [FROM schemaName]
+
+SHOW SHADOW ALGORITHMS [FROM schemaName]
+
+shadowRule:
+ RULE ruleName
+```
+- 支持查询所有影子规则和指定表查询
+- 支持查询所有表规则
+- 支持查询所有影子算法
+
+## 说明
+
+### Shadow Rule
+
+| 列 | 说明 |
+| ----------- | ----------- |
+| rule_name | 规则名称 |
+| source_name | 源数据库 |
+| shadow_name | 影子数据库 |
+| shadow_table | 影子表 |
+
+### Shadow Table Rule
+
+| 列 | 说明 |
+| ----------------------| ---------------|
+| shadow_table | 影子表 |
+| shadow_algorithm_name | 影子算法名称 |
+
+### Shadow Algorithms
+
+| 列 | 说明 |
+| ------------------- | ------------ |
+| shadow_algorithm_name | 影子算法名称 |
+| type | 算法类型 |
+| props | 算法参数 |
+
+## 示例
+
+*SHOW SHADOW RULES*
+
+```sql
+mysql> show shadow rules;
++--------------------+-------------+-------------+--------------+
+| rule_name | source_name | shadow_name | shadow_table |
++--------------------+-------------+-------------+--------------+
+| shadow_rule_1 | ds_1 | ds_shadow_1 | t_order |
+| shadow_rule_2 | ds_2 | ds_shadow_2 | t_order_item |
++--------------------+-------------+-------------+--------------+
+2 rows in set (0.02 sec)
+```
+*SHOW SHADOW RULE ruleName*
+
+```sql
+mysql> show shadow rule shadow_rule_1;
++------------------+-------------+-------------+--------------+
+| rule_name | source_name | shadow_name | shadow_table |
++------------------+-------------+-------------+--------------+
+| shadow_rule_1 | ds_1 | ds_shadow_1 | t_order |
++------------------+-------------+-------------+--------------+
+1 rows in set (0.01 sec)
+```
+
+*SHOW SHADOW TABLE RULES*
+
+```sql
+mysql> show shadow table rules;
++--------------+--------------------------------------------------------------------------------+
+| shadow_table | shadow_algorithm_name |
++--------------+--------------------------------------------------------------------------------+
+| t_order_1 | user_id_match_algorithm,simple_note_algorithm_1 |
++--------------+--------------------------------------------------------------------------------+
+1 rows in set (0.01 sec)
+```
+
+*SHOW SHADOW ALGORITHMS*
+
+```sql
+mysql> show shadow algorithms;
++-------------------------+--------------------+-------------------------------------------+
+| shadow_algorithm_name | type | props |
++-------------------------+--------------------+-------------------------------------------+
+| user_id_match_algorithm | COLUMN_REGEX_MATCH | operation=insert,column=user_id,regex=[1] |
+| simple_note_algorithm_1 | SIMPLE_NOTE | shadow=true,foo=bar |
++-------------------------+--------------------+-------------------------------------------+
+2 rows in set (0.01 sec)
+```
diff --git a/docs/document/content/features/dist-sql/syntax/rql/rql-shadow-rule.en.md b/docs/document/content/features/dist-sql/syntax/rql/rql-shadow-rule.en.md
new file mode 100644
index 0000000..889e7cd
--- /dev/null
+++ b/docs/document/content/features/dist-sql/syntax/rql/rql-shadow-rule.en.md
@@ -0,0 +1,97 @@
++++
+title = "Shadow"
+weight = 6
++++
+
+## Definition
+
+```sql
+SHOW SHADOW shadowRule | RULES [FROM schemaName]
+
+SHOW SHADOW TABLE RULES [FROM schemaName]
+
+SHOW SHADOW ALGORITHMS [FROM schemaName]
+
+shadowRule:
+ RULE ruleName
+```
+- Support querying all shadow rules and specified table query
+- Support querying all shadow table rules
+- Support querying all shadow algorithms
+
+## Description
+
+### Shadow Rule
+
+| Column | Description |
+| ----------- | ----------- |
+| rule_name | Rule name |
+| source_name | Source database |
+| shadow_name | Shadow database |
+| shadow_table | Shadow table |
+
+### Shadow Table Rule
+
+| Column | Description |
+| ----------------------| --------------------- |
+| shadow_table | Shadow table |
+| shadow_algorithm_name | Shadow algorithm name |
+
+### Shadow Algorithms
+
+| Column | Description |
+| ------------------- | ---------------------------- |
+| shadow_algorithm_name | Shadow algorithm name |
+| type | Shadow algorithm type |
+| properties | Shadow algorithm parameters |
+
+## Example
+
+*SHOW SHADOW RULES*
+
+```sql
+mysql> show shadow rules;
++--------------------+-------------+-------------+--------------+
+| rule_name | source_name | shadow_name | shadow_table |
++--------------------+-------------+-------------+--------------+
+| shadow_rule_1 | ds_1 | ds_shadow_1 | t_order |
+| shadow_rule_2 | ds_2 | ds_shadow_2 | t_order_item |
++--------------------+-------------+-------------+--------------+
+2 rows in set (0.02 sec)
+```
+*SHOW SHADOW RULE ruleName*
+
+```sql
+mysql> show shadow rule shadow_rule_1;
++------------------+-------------+-------------+--------------+
+| rule_name | source_name | shadow_name | shadow_table |
++------------------+-------------+-------------+--------------+
+| shadow_rule_1 | ds_1 | ds_shadow_1 | t_order |
++------------------+-------------+-------------+--------------+
+1 rows in set (0.01 sec)
+```
+
+*SHOW SHADOW TABLE RULES*
+
+```sql
+mysql> show shadow table rules;
++--------------+--------------------------------------------------------------------------------+
+| shadow_table | shadow_algorithm_name |
++--------------+--------------------------------------------------------------------------------+
+| t_order_1 | user_id_match_algorithm,simple_note_algorithm_1 |
++--------------+--------------------------------------------------------------------------------+
+1 rows in set (0.01 sec)
+```
+
+*SHOW SHADOW ALGORITHMS*
+
+```sql
+mysql> show shadow algorithms;
++-------------------------+--------------------+-------------------------------------------+
+| shadow_algorithm_name | type | properties |
++-------------------------+--------------------+-------------------------------------------+
+| user_id_match_algorithm | COLUMN_REGEX_MATCH | operation=insert,column=user_id,regex=[1] |
+| simple_note_algorithm_1 | SIMPLE_NOTE | shadow=true,foo=bar |
++-------------------------+--------------------+-------------------------------------------+
+2 rows in set (0.01 sec)
+```