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/08/30 02:53:44 UTC
[GitHub] [shardingsphere] isHuangXin opened a new pull request, #20648: Add convert read-write-splitting distsql and test case
isHuangXin opened a new pull request, #20648:
URL: https://github.com/apache/shardingsphere/pull/20648
Fixes #17939
Changes proposed in this pull request:
- Append generateDistSQL by feature SPI
- Add convert read-write-splitting distsql and test case
Need to do:
- Append Dynamic READ-WRITTING RULES by feature SPI
--
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] TeslaCN commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958101654
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
Review Comment:
Why use format here?
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959063769
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ result.append(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE);
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, result);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder result) {
Review Comment:
fixed
--
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] TeslaCN commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958103468
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, stringBuilder);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder stringBuilder) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames((ArrayList<String>) staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ stringBuilder.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ stringBuilder.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ stringBuilder.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final ArrayList<String> readDataSourceNames) {
+ StringBuilder result = new StringBuilder();
+ Iterator<String> iterator = readDataSourceNames.iterator();
+ while (iterator.hasNext()) {
+ String readDataSourceName = iterator.next();
+ result.append(String.format(DistSQLScriptConstants.READ_RESOURCE, readDataSourceName));
+ if (iterator.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ return result.toString();
+ }
+
+ private String appendLoadBalancer(final String loadBalancerName, final Entry<String, YamlAlgorithmConfiguration> loadBalancers) {
+ StringBuilder result = new StringBuilder();
+ String loadBalancerProperties = new String();
Review Comment:
Consider replacing `new String()` with `""`.
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959060195
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ result.append(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE);
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, result);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder result) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames(staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ result.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final Collection<String> readDataSourceNames) {
+ StringBuilder result = new StringBuilder();
+ Iterator<String> iterator = readDataSourceNames.iterator();
+ while (iterator.hasNext()) {
+ String readDataSourceName = iterator.next();
+ result.append(String.format(DistSQLScriptConstants.READ_RESOURCE, readDataSourceName));
+ if (iterator.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ return result.toString();
+ }
+
+ private String appendLoadBalancer(final String loadBalancerName, final Entry<String, YamlAlgorithmConfiguration> loadBalancers) {
+ StringBuilder result = new StringBuilder();
+ String loadBalancerProperties = "";
+ if (loadBalancers.getValue().getProps().isEmpty()) {
+ result.append(String.format(DistSQLScriptConstants.TYPE, loadBalancers.getValue().getType()));
+ } else {
+ Iterator<Entry<Object, Object>> iterator = loadBalancers.getValue().getProps().entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<Object, Object> entry = iterator.next();
+ if (loadBalancerName == entry.getKey()) {
+
Review Comment:
fixed
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958105822
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, stringBuilder);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder stringBuilder) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames((ArrayList<String>) staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ stringBuilder.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ stringBuilder.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ stringBuilder.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final ArrayList<String> readDataSourceNames) {
+ StringBuilder result = new StringBuilder();
+ Iterator<String> iterator = readDataSourceNames.iterator();
+ while (iterator.hasNext()) {
+ String readDataSourceName = iterator.next();
+ result.append(String.format(DistSQLScriptConstants.READ_RESOURCE, readDataSourceName));
+ if (iterator.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ return result.toString();
+ }
+
+ private String appendLoadBalancer(final String loadBalancerName, final Entry<String, YamlAlgorithmConfiguration> loadBalancers) {
+ StringBuilder result = new StringBuilder();
+ String loadBalancerProperties = new String();
Review Comment:
fixed~
--
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] yx9o merged pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
yx9o merged PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958105635
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
Review Comment:
fixed
--
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] codecov-commenter commented on pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#issuecomment-1231107471
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/20648?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#20648](https://codecov.io/gh/apache/shardingsphere/pull/20648?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (37a3004) into [master](https://codecov.io/gh/apache/shardingsphere/commit/2112c4f00feee1481b51198911b26df05889762e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2112c4f) will **increase** coverage by `0.01%`.
> The diff coverage is `71.79%`.
```diff
@@ Coverage Diff @@
## master #20648 +/- ##
============================================
+ Coverage 61.08% 61.09% +0.01%
Complexity 2414 2414
============================================
Files 3957 3957
Lines 54881 54958 +77
Branches 9312 9328 +16
============================================
+ Hits 33522 33575 +53
- Misses 18513 18532 +19
- Partials 2846 2851 +5
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/20648?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ral/queryable/ConvertYamlConfigurationHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/20648/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL3F1ZXJ5YWJsZS9Db252ZXJ0WWFtbENvbmZpZ3VyYXRpb25IYW5kbGVyLmphdmE=) | `79.82% <69.86%> (-6.28%)` | :arrow_down: |
| [...ql/ral/common/constant/DistSQLScriptConstants.java](https://codecov.io/gh/apache/shardingsphere/pull/20648/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2NvbW1vbi9jb25zdGFudC9EaXN0U1FMU2NyaXB0Q29uc3RhbnRzLmphdmE=) | `100.00% <100.00%> (ø)` | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959061650
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
Review Comment:
fixed
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958190863
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, stringBuilder);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder stringBuilder) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames((ArrayList<String>) staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ stringBuilder.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ stringBuilder.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ stringBuilder.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final ArrayList<String> readDataSourceNames) {
Review Comment:
fixed
--
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] yx9o commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
yx9o commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959060988
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
Review Comment:
`ruleConfigs` could be better.
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959060766
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ result.append(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE);
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, result);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder result) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames(staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ result.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final Collection<String> readDataSourceNames) {
+ StringBuilder result = new StringBuilder();
+ Iterator<String> iterator = readDataSourceNames.iterator();
+ while (iterator.hasNext()) {
+ String readDataSourceName = iterator.next();
+ result.append(String.format(DistSQLScriptConstants.READ_RESOURCE, readDataSourceName));
+ if (iterator.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ return result.toString();
+ }
+
+ private String appendLoadBalancer(final String loadBalancerName, final Entry<String, YamlAlgorithmConfiguration> loadBalancers) {
+ StringBuilder result = new StringBuilder();
+ String loadBalancerProperties = "";
+ if (loadBalancers.getValue().getProps().isEmpty()) {
+ result.append(String.format(DistSQLScriptConstants.TYPE, loadBalancers.getValue().getType()));
+ } else {
+ Iterator<Entry<Object, Object>> iterator = loadBalancers.getValue().getProps().entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<Object, Object> entry = iterator.next();
+ if (loadBalancerName == entry.getKey()) {
+
Review Comment:
Are there any other errors ?
--
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] yx9o commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
yx9o commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959062642
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ result.append(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE);
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, result);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder result) {
Review Comment:
`ruleConfig` could be better.
--
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] yx9o commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
yx9o commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r959059097
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +310,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder result) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ result.append(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE);
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, result);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder result) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames(staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ result.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final Collection<String> readDataSourceNames) {
+ StringBuilder result = new StringBuilder();
+ Iterator<String> iterator = readDataSourceNames.iterator();
+ while (iterator.hasNext()) {
+ String readDataSourceName = iterator.next();
+ result.append(String.format(DistSQLScriptConstants.READ_RESOURCE, readDataSourceName));
+ if (iterator.hasNext()) {
+ result.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ return result.toString();
+ }
+
+ private String appendLoadBalancer(final String loadBalancerName, final Entry<String, YamlAlgorithmConfiguration> loadBalancers) {
+ StringBuilder result = new StringBuilder();
+ String loadBalancerProperties = "";
+ if (loadBalancers.getValue().getProps().isEmpty()) {
+ result.append(String.format(DistSQLScriptConstants.TYPE, loadBalancers.getValue().getType()));
+ } else {
+ Iterator<Entry<Object, Object>> iterator = loadBalancers.getValue().getProps().entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<Object, Object> entry = iterator.next();
+ if (loadBalancerName == entry.getKey()) {
+
Review Comment:
Please remove unnecessary blank lines.
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958233840
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -81,11 +85,44 @@ protected Collection<LocalDataQueryResultRow> getRows(final ContextManager conte
}
private String generateDistSQL(final YamlProxyDatabaseConfiguration yamlConfig) {
+ StringBuilder result = new StringBuilder();
+ String databaseType = yamlConfig.getDatabaseName();
+ switch (databaseType) {
+ case DistSQLScriptConstants.RESOURCE_DB:
+ result.append(addResourceDistSQL(yamlConfig));
Review Comment:
get it~
--
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] yx9o commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
yx9o commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958229905
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -81,11 +85,44 @@ protected Collection<LocalDataQueryResultRow> getRows(final ContextManager conte
}
private String generateDistSQL(final YamlProxyDatabaseConfiguration yamlConfig) {
+ StringBuilder result = new StringBuilder();
+ String databaseType = yamlConfig.getDatabaseName();
+ switch (databaseType) {
+ case DistSQLScriptConstants.RESOURCE_DB:
+ result.append(addResourceDistSQL(yamlConfig));
Review Comment:
Can the `result` variable be passed directly to subsequent methods.
--
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] TeslaCN commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958107896
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, stringBuilder);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder stringBuilder) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames((ArrayList<String>) staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ stringBuilder.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ stringBuilder.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ stringBuilder.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final ArrayList<String> readDataSourceNames) {
Review Comment:
Consider replacing Collection implementation with interface.
--
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] isHuangXin commented on a diff in pull request #20648: Add convert read-write-splitting distsql and test case
Posted by GitBox <gi...@apache.org>.
isHuangXin commented on code in PR #20648:
URL: https://github.com/apache/shardingsphere/pull/20648#discussion_r958123210
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java:
##########
@@ -279,4 +317,79 @@ private String getBindings(final Iterator<String> iterator) {
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
return result.toString();
}
+
+ private void appendReadWriteSplittingRules(final Collection<YamlRuleConfiguration> rules, final StringBuilder stringBuilder) {
+ if (rules.isEmpty()) {
+ return;
+ }
+ stringBuilder.append(String.format(DistSQLScriptConstants.CREATE_READWRITE_SPLITTING_RULE));
+ for (YamlRuleConfiguration rule : rules) {
+ appendStaticReadWriteSplittingRule(rule, stringBuilder);
+ // TODO Dynamic READ-WRITE-SPLITTING RULES
+ }
+ }
+
+ private void appendStaticReadWriteSplittingRule(final YamlRuleConfiguration rule, final StringBuilder stringBuilder) {
+ Iterator<Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration>> dataSources = ((YamlReadwriteSplittingRuleConfiguration) rule).getDataSources().entrySet().iterator();
+ Iterator<Entry<String, YamlAlgorithmConfiguration>> loadBalancers = ((YamlReadwriteSplittingRuleConfiguration) rule).getLoadBalancers().entrySet().iterator();
+ while (dataSources.hasNext()) {
+ Entry<String, YamlReadwriteSplittingDataSourceRuleConfiguration> entryDataSources = dataSources.next();
+ Entry<String, YamlAlgorithmConfiguration> entryLoadBalances = loadBalancers.next();
+ YamlStaticReadwriteSplittingStrategyConfiguration staticStrategy = entryDataSources.getValue().getStaticStrategy();
+ String dataSourceName = entryDataSources.getKey();
+ String writeDataSourceName = staticStrategy.getWriteDataSourceName();
+ String readDataSourceNames = appendReadDataSourceNames((ArrayList<String>) staticStrategy.getReadDataSourceNames());
+ String loadBalancerType = appendLoadBalancer(entryDataSources.getValue().getLoadBalancerName(), entryLoadBalances);
+ stringBuilder.append(String.format(DistSQLScriptConstants.STATIC_READWRITE_SPLITTING, dataSourceName, writeDataSourceName, readDataSourceNames, loadBalancerType));
+ if (dataSources.hasNext()) {
+ stringBuilder.append(DistSQLScriptConstants.COMMA);
+ }
+ }
+ stringBuilder.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
+ }
+
+ private String appendReadDataSourceNames(final ArrayList<String> readDataSourceNames) {
Review Comment:
feel confused
--
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