You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/24 08:34:05 UTC
[GitHub] [shardingsphere] lanchengx opened a new issue #15018: [DistSQL] Add some new syntax to manage traffic rule configurations
lanchengx opened a new issue #15018:
URL: https://github.com/apache/shardingsphere/issues/15018
Hi community,
In order to facilitate users to manage the traffic rule configuration, we will add some new DistSQL syntax.
The yaml configuration of the traffic rule is as follows:
```yaml
- !TRAFFIC
trafficStrategies:
sql_match_traffic:
labels: OLTP
algorithmName: sql_match_algorithm
loadBalancerName: random_load_balancer
sql_hint_traffic:
labels: OLAP
algorithmName: sql_hint_algorithm
loadBalancerName: round_robin_load_balancer
trafficAlgorithms:
sql_match_algorithm:
type: SQL_MATCH
props:
sql: SELECT * FROM t_order WHERE order_id = ?; UPDATE t_order SET order_id = ?;
sql_hint_algorithm:
type: SQL_HINT
props:
use_traffic: true
loadBalancers:
random_load_balancer:
type: RANDOM
round_robin_load_balancer:
type: ROUND_ROBIN
```
For this configuration, we have designed the following syntax
- [ ] **Create syntax**
```sql
CREATE TRAFFIC RULE sql_match_traffic (
LABLES(OLTP),
TRAFFIC_ALGORITHM(TYPE(NAME=SQL_MATCH,PROPERTIES("sql" = "SELECT * FROM t_order WHERE order_id = ?; UPDATE t_order SET order_id = ?;"))),
LOAD_BALANCER(TYPE(NAME=RANDOM, PROPERTIES("key"="value")))
), sql_hint_traffic(
LABLES(OLAP, xxx),
TRAFFIC_ALGORITHM(TYPE(NAME= SQL_HINT,PROPERTIES("use_traffic" = "true"))),
LOAD_BALANCER(TYPE(NAME=ROUND_ROBIN, PROPERTIES("key"="value")))
);
```
- [ ] **Modify syntax**
```mysql
ALTER TRAFFIC RULE sql_match_traffic (
LABLES(OLTP),
TRAFFIC_ALGORITHM(TYPE(NAME=SQL_MATCH,PROPERTIES("sql" = "SELECT * FROM t_order WHERE order_id = ?; UPDATE t_order SET order_id = ?;"))),
LOAD_BALANCER(TYPE(NAME=RANDOM, PROPERTIES("key"="value")))
), sql_hint_traffic(
LABLES(OLAP, xxxx),
TRAFFIC_ALGORITHM(TYPE(NAME= SQL_HINT,PROPERTIES("use_traffic" = "true"))),
LOAD_BALANCER(TYPE(NAME=ROUND_ROBIN, PROPERTIES("key"="value")))
);
```
- [ ] **Delete syntax**
```mysql
DROP TRAFFIC RULE sql_match_traffic, sql_hint_traffic
```
- [ ] **Show syntax and show results**
```mysql
SHOW TRAFFIC RULES FROM schema_db;
```
```
+-------------------+------------+---------------+--------------------------------------------------------------------------------------+---------------------+-----------------------+
| rule_name | labels | algorithm_type| algorithm_props | load_balancer_type | load_balancer_props |
+-------------------+------------+---------------+--------------------------------------------------------------------------------------+---------------------+-----------------------+
| sql_match_traffic | OLTP | SQL_MATCH | "sql" = "SELECT * FROM t_order WHERE order_id = ?; UPDATE t_order SET order_id = ?;" | RANDOM | "key"="value" |
| sql_hint_traffic | OLAP | SQL_HINT | "use_traffic" = "true" | ROUND_ROBIN | "key"="value" |
+-------------------+------------+---------------+--------------------------------------------------------------------------------------+---------------------+-----------------------+
```
In addition, we also need to add syntax to support label
- [ ] **Display the label on the instance**
```mysql
SHOW INSTANCE LIST
```
```
+-----------------+------------+------+--------+---------------+
| instance_id | host | port | status | labels |
+-----------------+------------+------+--------+---------------+
| 10.7.7.136@3309 | 10.7.7.136 | 3309 | enable | OLTP,GROUP_BY |
| 10.7.7.136@3209 | 10.7.7.136 | 3209 | enable | OLAP |
| 10.7.7.136@3109 | 10.7.7.136 | 3109 | enable | |
+-----------------+------------+------+--------+---------------+
```
- [ ] **Add labels to instance**
```mysql
ALTER INSTANCE 10.7.7.136@3309 ADD LABEL olap,group_by;
```
- [ ] **Remove labels from instance**
```mysql
ALTER INSTANCE 10.7.7.136@3309 DROP LABLE olap,group_by;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu closed issue #15018: [DistSQL] Add some new syntax to manage traffic rule configurations
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #15018:
URL: https://github.com/apache/shardingsphere/issues/15018
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org